Corrected the journal -> Assignment upgrade!!! :-(
This commit is contained in:
@@ -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;
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user