Skip to content

Commit

Permalink
MDL-43306 restore: fix grade item sortorder restoration
Browse files Browse the repository at this point in the history
Previously, restore was blindly inserting the old sort order into the
database, causing duplicate sortorders which lead to unpredicatble
sorting results.

Now we will use the api function to add it after the original sortorder,
this means if a duplicate exists in the original location, this item
will appear after it.
  • Loading branch information
danpoltawski committed Dec 10, 2013
1 parent cf0e970 commit 32df282
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions backup/moodle2/restore_stepslib.php
Expand Up @@ -2769,9 +2769,9 @@ protected function process_grade_item($data) {
$gradeitem = new grade_item($data, false); $gradeitem = new grade_item($data, false);
$gradeitem->insert('restore'); $gradeitem->insert('restore');


//sortorder is automatically assigned when inserting. Re-instate the previous sortorder // Reinstate the grade item close to its original sortorder, if something already exists
$gradeitem->sortorder = $data->sortorder; // in the original sortorer then it will be first.
$gradeitem->update('restore'); $gradeitem->move_after_sortorder($data->sortorder);


// Set mapping, saving the original category id into parentitemid // Set mapping, saving the original category id into parentitemid
// gradebook restore (final task) will need it to reorganise items // gradebook restore (final task) will need it to reorganise items
Expand Down

0 comments on commit 32df282

Please sign in to comment.