Permalink
Browse files

MDL-37939 Course: Ensure that the cm->section is set when moving modules

  • Loading branch information...
1 parent bbcf8da commit 4bcf7d3e746c2b03bbdfb9e48f819cc8de33dfbb @andrewnicols andrewnicols committed Feb 12, 2013
Showing with 4 additions and 1 deletion.
  1. +4 −1 course/lib.php
View
@@ -2848,6 +2848,7 @@ function add_mod_to_section($mod, $beforemod=NULL) {
}
$DB->set_field("course_sections", "sequence", $newsequence, array("id"=>$section->id));
+ $DB->set_field("course_modules", "section", $section->id, array("id" => $mod->id));
return $section->id; // Return course_sections ID that was used.
} else { // Insert a new record
@@ -2857,7 +2858,9 @@ function add_mod_to_section($mod, $beforemod=NULL) {
$section->summary = "";
$section->summaryformat = FORMAT_HTML;
$section->sequence = $mod->coursemodule;
- return $DB->insert_record("course_sections", $section);
+ $section->id = $DB->insert_record("course_sections", $section);
+ $DB->set_field("course_modules", "section", $section->id, array("id" => $mod->id));
+ return $section->id;
}
}

0 comments on commit 4bcf7d3

Please sign in to comment.