Permalink
Browse files

Merge branch 'MDL-29598_22' of git://github.com/dmonllao/moodle into …

…MOODLE_22_STABLE
  • Loading branch information...
2 parents 6e8d3ac + c52a364 commit 90241eaaf86b715341b62c05c4da69c72cefd8e9 @stronk7 stronk7 committed Aug 28, 2012
Showing with 16 additions and 5 deletions.
  1. +16 −5 backup/moodle2/restore_stepslib.php
@@ -269,7 +269,14 @@ protected function process_grade_letter($data) {
$data->contextid = get_context_instance(CONTEXT_COURSE, $this->get_courseid())->id;
- $newitemid = $DB->insert_record('grade_letters', $data);
+ $gradeletter = (array)$data;
+ unset($gradeletter['id']);
+ if (!$DB->record_exists('grade_letters', $gradeletter)) {
+ $newitemid = $DB->insert_record('grade_letters', $data);
+ } else {
+ $newitemid = $data->id;
+ }
+
$this->set_mapping('grade_letter', $oldid, $newitemid);
}
protected function process_grade_setting($data) {
@@ -2265,17 +2272,21 @@ protected function process_grade_grade($data) {
/**
* process activity grade_letters. Note that, while these are possible,
- * because grade_letters are contextid based, in proctice, only course
+ * because grade_letters are contextid based, in practice, only course
* context letters can be defined. So we keep here this method knowing
* it won't be executed ever. gradebook restore will restore course letters.
*/
protected function process_grade_letter($data) {
global $DB;
- $data = (object)$data;
+ $data['contextid'] = $this->task->get_contextid();
+ $gradeletter = (object)$data;
- $data->contextid = $this->task->get_contextid();
- $newitemid = $DB->insert_record('grade_letters', $data);
+ // Check if it exists before adding it
+ unset($data['id']);
+ if (!$DB->record_exists('grade_letters', $data)) {
+ $newitemid = $DB->insert_record('grade_letters', $gradeletter);
+ }
// no need to save any grade_letter mapping
}
}

0 comments on commit 90241ea

Please sign in to comment.