]> git.mjollnir.org Git - moodle.git/commitdiff
locktime cron support - not much efficient though :-(
authorskodak <skodak>
Thu, 9 Aug 2007 09:38:14 +0000 (09:38 +0000)
committerskodak <skodak>
Thu, 9 Aug 2007 09:38:14 +0000 (09:38 +0000)
admin/cron.php
lib/gradelib.php

index edef75348e32afbc838118d766a04b2223819a27..249e4f978bf1d346b3a249d23a78c9f5e0282aeb 100644 (file)
@@ -32,6 +32,7 @@
 
     require_once(dirname(__FILE__) . '/../config.php');
     require_once($CFG->libdir.'/adminlib.php');
+    require_once($CFG->libdir.'/gradelib.php');
 
 /// extra safety
     @session_write_close();
     }
 
 
+    mtrace('Starting grade job ...', '');
+    grade_cron();
+    mtrace('Done ...', '');
+    
+
+
 /// Run all core cron jobs, but not every time since they aren't too important.
 /// These don't have a timer to reduce load, so we'll use a random number 
 /// to randomly choose the percentage of times we should run these jobs.
index ad73350f6857b6955de80fa1d8560254c43b962f..09aeeed5748fc2ec2018e498d0a4a61a864a4dc9 100644 (file)
@@ -798,7 +798,6 @@ function remove_course_grades($courseid, $showfeedback) {
     if ($showfeedback) {
         notify($strdeleted.' - '.get_string('scales'));
     }
-
 }
 
 /**
@@ -812,4 +811,22 @@ function build_percentages_array($steps=1, $order='desc', $lowest=0, $highest=10
     // TODO reject or implement
 }
 
+/**
+ * Grading cron job
+ */
+function grade_cron() {
+    // go through all courses that have proper final grades and lock them if needed
+    if ($rs = get_recordset_select('grade_items', "itemtype='course' AND needsupdate=0", '', 'courseid')) {
+        if ($rs->RecordCount() > 0) {
+            while ($courseitem = rs_fetch_next_record($rs)) {
+                $courseid = $courseitem->courseid;
+                grade_grade::check_locktime_all($courseid);
+                grade_item::check_locktime_all($courseid);
+            }
+        }
+        rs_close($rs);
+    }
+    
+}
+
 ?>