MDL-41174 course: Update calendar events.

Updates calendar events when the activity name is changed.
This commit is contained in:
Adrian Greeve
2016-09-07 14:17:05 +08:00
parent f9c8cef1a4
commit 8b61a6a338
2 changed files with 40 additions and 0 deletions
+34
View File
@@ -263,6 +263,40 @@ function workshop_delete_instance($id) {
return true;
}
/**
* This standard function will check all instances of this module
* and make sure there are up-to-date events created for each of them.
* If courseid = 0, then every workshop event in the site is checked, else
* only workshop events belonging to the course specified are checked.
*
* @param integer $courseid The Course ID.
* @return bool Returns true if the calendar events were successfully updated.
*/
function workshop_refresh_events($courseid = 0) {
global $DB;
if ($courseid) {
// Make sure that the course id is numeric.
if (!is_numeric($courseid)) {
return false;
}
if (!$workshops = $DB->get_records('workshop', array('course' => $courseid))) {
return false;
}
} else {
if (!$workshops = $DB->get_records('workshop')) {
return false;
}
}
foreach ($workshops as $workshop) {
if (!$cm = get_coursemodule_from_instance('workshop', $workshop->id, $courseid, false)) {
continue;
}
workshop_calendar_update($workshop, $cm->id);
}
return true;
}
/**
* List the actions that correspond to a view of this module.
* This is used by the participation report.