Skip to content

Commit

Permalink
MDL-28180 backup - on restore always prevent completion_aggr_methd dupes
Browse files Browse the repository at this point in the history
This covers the last case where dupes could be happening in the
completion_aggr_methd table: Restoring one complete course into
an existing one, adding information. Now we always check if the
aggr_method exists before inserting it.
  • Loading branch information
stronk7 committed Dec 11, 2011
1 parent 43cf316 commit 4d85633
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions backup/moodle2/restore_stepslib.php
Expand Up @@ -1805,15 +1805,20 @@ public function process_course_completion_aggr_methd($data) {

$data->course = $this->get_courseid();

$params = array(
'course' => $data->course,
'criteriatype' => $data->criteriatype,
'method' => $data->method,
'value' => $data->value,
);
$DB->insert_record('course_completion_aggr_methd', $params);
// Only create the course_completion_aggr_methd records if
// the target course has not them defined. MDL-28180
if (!$DB->record_exists('course_completion_aggr_methd', array(
'course' => $data->course,
'criteriatype' => $data->criteriatype))) {
$params = array(
'course' => $data->course,
'criteriatype' => $data->criteriatype,
'method' => $data->method,
'value' => $data->value,
);
$DB->insert_record('course_completion_aggr_methd', $params);
}
}

}


Expand Down

0 comments on commit 4d85633

Please sign in to comment.