Permalink
Browse files

MDL-36130: mod_assign: migrate logs when migrating from mod_assignment

  • Loading branch information...
1 parent 881d1d8 commit 93efeb53529ce5797db81e92bcde5f86e81e33ab @aolley aolley committed with nebgor Oct 19, 2012
Showing with 9 additions and 0 deletions.
  1. +9 −0 mod/assign/upgradelib.php
@@ -162,6 +162,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));
@@ -260,6 +265,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) {

0 comments on commit 93efeb5

Please sign in to comment.