Permalink
Browse files

MDL-38173 Course: Use the correct module id's when adding to a section

When course completion is on, $mod->id is the instance, not the
course_module id.  In add_to_section $mod->coursemodule must be used.
  • Loading branch information...
1 parent 8a7bc6c commit 14c2bada3360e03ee0bc54c9ea924d2682ec9537 Russell Smith committed with damyon Feb 23, 2013
Showing with 2 additions and 2 deletions.
  1. +2 −2 course/lib.php
View
@@ -2848,7 +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));
+ $DB->set_field("course_modules", "section", $section->id, array("id" => $mod->coursemodule));
return $section->id; // Return course_sections ID that was used.
} else { // Insert a new record
@@ -2859,7 +2859,7 @@ function add_mod_to_section($mod, $beforemod=NULL) {
$section->summaryformat = FORMAT_HTML;
$section->sequence = $mod->coursemodule;
$section->id = $DB->insert_record("course_sections", $section);
- $DB->set_field("course_modules", "section", $section->id, array("id" => $mod->id));
+ $DB->set_field("course_modules", "section", $section->id, array("id" => $mod->coursemodule));
return $section->id;
}
}

0 comments on commit 14c2bad

Please sign in to comment.