Skip to content

Commit

Permalink
MDL-9506 Resolved a small bug in grade_category that failed the set_a…
Browse files Browse the repository at this point in the history
…s_parent method.
  • Loading branch information
nicolasconnault committed May 21, 2007
1 parent 83bc64d commit 750b055
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/grade/grade_category.php
Expand Up @@ -743,10 +743,11 @@ function set_as_parent($children) {
debugging("Could not update this category's sortorder in DB.");
return false;
}

$query = "UPDATE {$CFG->prefix}grade_items SET sortorder = sortorder + 1 WHERE sortorder >= $this->grade_item->sortorder";
$query = "UPDATE {$CFG->prefix}grade_items SET sortorder = sortorder + 1 WHERE sortorder >= {$this->grade_item->sortorder}";
if (!execute_sql($query)) {
debugging("Could not update the sortorder of grade_items listed after this category.");
return false;
} else {
return true;
}
Expand Down
3 changes: 3 additions & 0 deletions lib/simpletest/grade/simpletest/testgradecategory.php
Expand Up @@ -223,6 +223,7 @@ function test_grade_category_set_as_parent() {
$grade_category = new grade_category();
$grade_category->fullname = 'new topcategory';
$grade_category->courseid = $this->courseid;
$grade_category->insert();

// 1. mixed types of children
$child1 = new grade_item();
Expand Down Expand Up @@ -254,6 +255,8 @@ function test_grade_category_set_as_parent() {
$child2->itemname = 'new grade_item';
$child1->sortorder = 1;
$child2->sortorder = 2;
$child1->insert();
$child2->insert();
$this->assertTrue($grade_category->set_as_parent(array($child1, $child2)));
}
}
Expand Down

0 comments on commit 750b055

Please sign in to comment.