From 2650c51ef45bf0fd339965e576ac291f1b869ad0 Mon Sep 17 00:00:00 2001 From: skodak Date: Thu, 9 Aug 2007 09:38:14 +0000 Subject: [PATCH] locktime cron support - not much efficient though :-( --- admin/cron.php | 7 +++++++ lib/gradelib.php | 19 ++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/admin/cron.php b/admin/cron.php index edef75348e..249e4f978b 100644 --- a/admin/cron.php +++ b/admin/cron.php @@ -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(); @@ -162,6 +163,12 @@ } + 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. diff --git a/lib/gradelib.php b/lib/gradelib.php index ad73350f68..09aeeed574 100644 --- a/lib/gradelib.php +++ b/lib/gradelib.php @@ -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); + } + +} + ?> -- 2.39.5