mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 04:22:07 +02:00
Merge branch 'wip-MDL-59311-master' of git://github.com/marinaglancy/moodle
This commit is contained in:
commit
f82e86e9f7
@ -3479,31 +3479,33 @@ function duplicate_module($course, $cm) {
|
||||
}
|
||||
}
|
||||
|
||||
$rc->destroy();
|
||||
|
||||
if (empty($CFG->keeptempdirectoriesonbackup)) {
|
||||
fulldelete($backupbasepath);
|
||||
}
|
||||
|
||||
// If we know the cmid of the new course module, let us move it
|
||||
// right below the original one. otherwise it will stay at the
|
||||
// end of the section.
|
||||
if ($newcmid) {
|
||||
$info = get_fast_modinfo($course);
|
||||
$newcm = $info->get_cm($newcmid);
|
||||
$section = $DB->get_record('course_sections', array('id' => $cm->section, 'course' => $cm->course));
|
||||
moveto_module($newcm, $section, $cm);
|
||||
moveto_module($cm, $section, $newcm);
|
||||
$modarray = explode(",", trim($section->sequence));
|
||||
$cmindex = array_search($cm->id, $modarray);
|
||||
if ($cmindex !== false && $cmindex < count($modarray) - 1) {
|
||||
$newcm = get_coursemodule_from_id($cm->modname, $newcmid, $cm->course);
|
||||
moveto_module($newcm, $section, $modarray[$cmindex + 1]);
|
||||
}
|
||||
|
||||
// Update calendar events with the duplicated module.
|
||||
// The following line is to be removed in MDL-58906.
|
||||
course_module_update_calendar_events($newcm->modname, null, $newcm);
|
||||
|
||||
// Trigger course module created event. We can trigger the event only if we know the newcmid.
|
||||
$newcm = get_fast_modinfo($cm->course)->get_cm($newcmid);
|
||||
$event = \core\event\course_module_created::create_from_cm($newcm);
|
||||
$event->trigger();
|
||||
}
|
||||
rebuild_course_cache($cm->course);
|
||||
|
||||
$rc->destroy();
|
||||
|
||||
if (empty($CFG->keeptempdirectoriesonbackup)) {
|
||||
fulldelete($backupbasepath);
|
||||
}
|
||||
|
||||
return isset($newcm) ? $newcm : null;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user