Skip to content

Commit

Permalink
MDL-36130: mod_assign: migrate logs when migrating from mod_assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
aolley committed Oct 19, 2012
1 parent 7e8ae12 commit ac9ac1f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions mod/assign/upgradelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ public function upgrade_assignment($oldassignmentid, & $log) {
}
$completiondone = true;

// Migrate log entries so we don't lose them.
$logparams = array('cmid' => $oldcoursemodule->id, 'course' => $oldcoursemodule->course);
$DB->set_field('log', 'module', 'assign', $logparams);
$DB->set_field('log', 'cmid', $newcoursemodule->id, $logparams);


// copy all the submission data (and get plugins to do their bit)
$oldsubmissions = $DB->get_records('assignment_submissions', array('assignment'=>$oldassignmentid));
Expand Down Expand Up @@ -269,6 +274,10 @@ public function upgrade_assignment($oldassignmentid, & $log) {
$DB->update_record('course_completion_criteria', $criteria);
}
}
// Roll back the log changes
$logparams = array('cmid' => $newcoursemodule->id, 'course' => $newcoursemodule->course);
$DB->set_field('log', 'module', 'assignment', $logparams);
$DB->set_field('log', 'cmid', $oldcoursemodule->id, $logparams);
// roll back the advanced grading update
if ($gradingarea) {
foreach ($gradeidmap as $newgradeid => $oldsubmissionid) {
Expand Down

0 comments on commit ac9ac1f

Please sign in to comment.