]> git.mjollnir.org Git - moodle.git/commitdiff
Modified the function. Now it accepts a courseid to restrict the check
authorstronk7 <stronk7>
Fri, 9 Apr 2004 23:55:02 +0000 (23:55 +0000)
committerstronk7 <stronk7>
Fri, 9 Apr 2004 23:55:02 +0000 (23:55 +0000)
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 :-)

mod/assignment/lib.php

index a59aadc04b0bda6a66ad9c533551ea1c22393bee..15f7fb7dcc4e4ddf2688285aeef1c38c0fddfc50 100644 (file)
@@ -96,12 +96,21 @@ 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 (! $assignments = get_records("assignment")) {
-        return true;
+    if ($courseid == 0) {
+        if (! $assignments = get_records("assignment")) {
+            return true;
+        }
+    } else {
+        if (! $assignments = get_records("assignment", "course", $courseid)) {
+            return true;
+        }
     }
 
     foreach ($assignments as $assignment) {