Skip to content

Commit

Permalink
MDL-37939 Course: Ensure that the cm->section is set when moving modules
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Robert Nicols committed Feb 15, 2013
1 parent bbcf8da commit 4bcf7d3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion course/lib.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -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_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. return $section->id; // Return course_sections ID that was used.


} else { // Insert a new record } else { // Insert a new record
Expand All @@ -2857,7 +2858,9 @@ function add_mod_to_section($mod, $beforemod=NULL) {
$section->summary = ""; $section->summary = "";
$section->summaryformat = FORMAT_HTML; $section->summaryformat = FORMAT_HTML;
$section->sequence = $mod->coursemodule; $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;
} }
} }


Expand Down

0 comments on commit 4bcf7d3

Please sign in to comment.