Permalink
Browse files

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

…MOODLE_23_STABLE
  • Loading branch information...
2 parents 5e143a2 + b7da14f commit f3d5fb4dec6d8ad84de56dfdb289b6cd94f4b17f @stronk7 stronk7 committed Aug 28, 2012
Showing with 16 additions and 5 deletions.
  1. +16 −5 backup/moodle2/restore_stepslib.php
@@ -270,7 +270,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) {
@@ -2401,17 +2408,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 f3d5fb4

Please sign in to comment.