From 4bcf7d3e746c2b03bbdfb9e48f819cc8de33dfbb Mon Sep 17 00:00:00 2001 From: Andrew Robert Nicols Date: Tue, 12 Feb 2013 00:18:59 +0000 Subject: [PATCH] MDL-37939 Course: Ensure that the cm->section is set when moving modules --- course/lib.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/course/lib.php b/course/lib.php index 097d61b4b14..cc424fd0611 100644 --- a/course/lib.php +++ b/course/lib.php @@ -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; } }