Modified the function. Now it accepts a courseid to restrict the check

to assignments belonging to one exact course. if not specified all
assignments in site are checked (old approach).
This function in used by restore_refresh_events() to recalculate module events.
Perhaps it should become a standard function in NEWMODULE to allow new modules
implement it.
Ciao :-)
This commit is contained in:
stronk7 2004-04-09 23:55:02 +00:00
parent df9a165ecc
commit 9c48354deb

View file

@ -96,13 +96,22 @@ function assignment_delete_instance($id) {
return $result;
}
function assignment_refresh_events() {
function assignment_refresh_events($courseid = 0) {
// 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 assignment event in the site is checked, else
// only assignment events belonging to the course specified are checked.
// This function is used, in its new format, by restore_refresh_events()
if ($courseid == 0) {
if (! $assignments = get_records("assignment")) {
return true;
}
} else {
if (! $assignments = get_records("assignment", "course", $courseid)) {
return true;
}
}
foreach ($assignments as $assignment) {
$event = NULL;