Permalink
Browse files

Merge branch 'MDL-31314_22' of git://github.com/timhunt/moodle into M…

…OODLE_22_STABLE
  • Loading branch information...
2 parents cfbde86 + a3b0c94 commit 5a1e6f2a6c4545a46de66dfb4d69a9d08bea55df @stronk7 stronk7 committed Jan 31, 2012
Showing with 16 additions and 21 deletions.
  1. +16 −21 backup/moodle2/restore_stepslib.php
@@ -371,40 +371,35 @@ protected function after_execute() {
}
$rs->close();
- //need to correct the grade category path and parent
+ // Need to correct the grade category path and parent
$conditions = array(
'courseid' => $this->get_courseid()
);
- $grade_category = new stdclass();
$rs = $DB->get_recordset('grade_categories', $conditions);
- if (!empty($rs)) {
- //get all the parents correct first as grade_category::build_path() loads category parents from the DB
- foreach($rs as $gc) {
- if (!empty($gc->parent)) {
- $grade_category->id = $gc->id;
- $grade_category->parent = $this->get_mappingid('grade_category', $gc->parent);
- $DB->update_record('grade_categories', $grade_category);
- }
+ // Get all the parents correct first as grade_category::build_path() loads category parents from the DB
+ foreach ($rs as $gc) {
+ if (!empty($gc->parent)) {
+ $grade_category = new stdClass();
+ $grade_category->id = $gc->id;
+ $grade_category->parent = $this->get_mappingid('grade_category', $gc->parent);
+ $DB->update_record('grade_categories', $grade_category);
}
}
- if (isset($grade_category->parent)) {
- unset($grade_category->parent);
- }
$rs->close();
+ // Now we can rebuild all the paths
$rs = $DB->get_recordset('grade_categories', $conditions);
- if (!empty($rs)) {
- //now we can rebuild all the paths
- foreach($rs as $gc) {
- $grade_category->id = $gc->id;
- $grade_category->path = grade_category::build_path($gc);
- $DB->update_record('grade_categories', $grade_category);
- }
+ foreach ($rs as $gc) {
+ $grade_category = new stdClass();
+ $grade_category->id = $gc->id;
+ $grade_category->path = grade_category::build_path($gc);
+ $grade_category->depth = substr_count($grade_category->path, '/') - 1;
+ $DB->update_record('grade_categories', $grade_category);
}
$rs->close();
- //Restore marks items as needing update. Update everything now.
+ // Restore marks items as needing update. Update everything now.
grade_regrade_final_grades($this->get_courseid());
}
}

0 comments on commit 5a1e6f2

Please sign in to comment.