mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 16:32:18 +02:00
MDL-11003 adding of first activity on frontpage does not work - incorrect section
This commit is contained in:
parent
b571c6b37b
commit
97928ddf00
@ -2007,6 +2007,25 @@ function add_course_module($mod) {
|
||||
return insert_record("course_modules", $mod);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns course section - creates new if does not exist yet.
|
||||
* @param int $relative section number
|
||||
* @param int $courseid
|
||||
* @return object $course_section object
|
||||
*/
|
||||
function get_course_section($section, $courseid) {
|
||||
if ($cw = get_record("course_sections", "section", $section, "course", $courseid)) {
|
||||
return $cw;
|
||||
}
|
||||
$cw = new object();
|
||||
$cw->course = $courseid;
|
||||
$cw->section = $section;
|
||||
$cw->summary = "";
|
||||
$cw->sequence = "";
|
||||
$id = insert_record("course_sections", $cw);
|
||||
return get_record("course_sections", "id", $id);
|
||||
}
|
||||
|
||||
function add_mod_to_section($mod, $beforemod=NULL) {
|
||||
/// Given a full mod object with section and course already defined
|
||||
/// If $before is specified, then this is an existing ID which we
|
||||
|
@ -29,9 +29,7 @@
|
||||
error("This module type doesn't exist");
|
||||
}
|
||||
|
||||
if (! $cw = get_record("course_sections", "section", $section, "course", $course->id)) {
|
||||
error("This course section doesn't exist");
|
||||
}
|
||||
$cw = get_course_section($section, $course->id);
|
||||
|
||||
if (!course_allowed_module($course, $module->id)) {
|
||||
error("This module has been disabled for this particular course");
|
||||
|
Loading…
x
Reference in New Issue
Block a user