Skip to content

Commit

Permalink
MDL-41174 mod_workshop: Added workshop_refresh_events
Browse files Browse the repository at this point in the history
This function was missing from this activity.
  • Loading branch information
abgreeve committed Sep 7, 2016
1 parent 7ceab0d commit 80753d3
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions mod/workshop/lib.php
Expand Up @@ -279,6 +279,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.
Expand Down

0 comments on commit 80753d3

Please sign in to comment.