diff --git a/mod/assignment/type/online/db/mysql.php b/mod/assignment/type/online/db/mysql.php index 8cb5f2c7e5c..daa07589615 100644 --- a/mod/assignment/type/online/db/mysql.php +++ b/mod/assignment/type/online/db/mysql.php @@ -42,7 +42,6 @@ function assignment_online_upgrade($oldversion) { $assignment->id = insert_record('assignment', $assignment); - /// Now create a new course module record $oldcm = get_coursemodule_from_instance('journal', $journal->id, $journal->course); @@ -58,7 +57,13 @@ function assignment_online_upgrade($oldversion) { /// And locate it above the old one + if (!$section = get_record('course_sections', 'id', $oldcm->section)) { + $section->section = 0; // So it goes somewhere! + } + $newcm->coursemodule = $newcm->id; + $newcm->section = $section->section; // need relative reference + if (! $sectionid = add_mod_to_section($newcm, $oldcm) ) { // Add it before Journal error("Could not add the new course module to that section"); } @@ -109,4 +114,6 @@ function assignment_online_upgrade($oldversion) { } } + return true; + } diff --git a/mod/assignment/type/online/db/postgres7.php b/mod/assignment/type/online/db/postgres7.php index 8cb5f2c7e5c..daa07589615 100644 --- a/mod/assignment/type/online/db/postgres7.php +++ b/mod/assignment/type/online/db/postgres7.php @@ -42,7 +42,6 @@ function assignment_online_upgrade($oldversion) { $assignment->id = insert_record('assignment', $assignment); - /// Now create a new course module record $oldcm = get_coursemodule_from_instance('journal', $journal->id, $journal->course); @@ -58,7 +57,13 @@ function assignment_online_upgrade($oldversion) { /// And locate it above the old one + if (!$section = get_record('course_sections', 'id', $oldcm->section)) { + $section->section = 0; // So it goes somewhere! + } + $newcm->coursemodule = $newcm->id; + $newcm->section = $section->section; // need relative reference + if (! $sectionid = add_mod_to_section($newcm, $oldcm) ) { // Add it before Journal error("Could not add the new course module to that section"); } @@ -109,4 +114,6 @@ function assignment_online_upgrade($oldversion) { } } + return true; + }