Merge branch 'MDL-37161-moodle23' of https://github.com/StudiUM/moodle into MOODLE_23...
authorSam Hemelryk <sam@moodle.com>
Mon, 7 Jan 2013 01:14:28 +0000 (14:14 +1300)
committerSam Hemelryk <sam@moodle.com>
Mon, 7 Jan 2013 01:14:28 +0000 (14:14 +1300)
backup/moodle2/restore_stepslib.php

index 3247a82..740c202 100644 (file)
@@ -297,8 +297,13 @@ class restore_gradebook_structure_step extends restore_structure_step {
 
         $data->courseid = $this->get_courseid();
 
-        $newitemid = $DB->insert_record('grade_settings', $data);
-        //$this->set_mapping('grade_setting', $oldid, $newitemid);
+        if (!$DB->record_exists('grade_settings', array('courseid' => $data->courseid, 'name' => $data->name))) {
+            $newitemid = $DB->insert_record('grade_settings', $data);
+        } else {
+            $newitemid = $data->id;
+        }
+
+        $this->set_mapping('grade_setting', $oldid, $newitemid);
     }
 
     /**