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.
if ($showfeedback) {
notify($strdeleted.' - '.get_string('scales'));
}
-
}
/**
// 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);
+ }
+
+}
+
?>