From: skodak Date: Thu, 9 Aug 2007 12:44:10 +0000 (+0000) Subject: final locking API cleanup X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=ddc209824724d5b0cd62ecec7a15f4b7715eacf5;p=moodle.git final locking API cleanup --- diff --git a/lib/grade/grade_grade.php b/lib/grade/grade_grade.php index ff2e4ebad9..4c60b2c8fc 100644 --- a/lib/grade/grade_grade.php +++ b/lib/grade/grade_grade.php @@ -302,37 +302,15 @@ class grade_grade extends grade_object { } } - /** - * Lock the grade if needed - make sure this is called only when final grade is valid - */ - function check_locktime() { - if (!empty($this->locked)) { - return; // already locked - do not use is_locked() because we do not want the locking status of grade_item here - } - - if ($this->locktime and $this->locktime < time()) { - $this->locked = time(); - $this->update('locktime'); - } - } - - /** * Lock the grade if needed - make sure this is called only when final grades are valid * @param int $courseid - * @param array $items array of all grade item ids (speedup only) + * @param array $items array of all grade item ids * @return void */ - function check_locktime_all($courseid, $items=null) { + function check_locktime_all($courseid, $items) { global $CFG; - if (!$items) { - if (!$items = get_records('grade_items', 'courseid', $courseid, '', 'id')) { - return; // no items? - } - $items = array_keys($items); - } - $items_sql = implode(',', $items); $now = time(); // no rounding needed, this is not supposed to be called every 10 seconds diff --git a/lib/grade/grade_item.php b/lib/grade/grade_item.php index 1c8aaa804b..1dcf587b9a 100644 --- a/lib/grade/grade_item.php +++ b/lib/grade/grade_item.php @@ -493,28 +493,6 @@ class grade_item extends grade_object { } } - /** - * Lock all grade items if needed - make sure this is called only when final grades are valid - * @static - * @param int $courseid - * @return void - */ - function check_locktime_all($courseid) { - global $CFG; - - $now = time(); // no need to round it here, executed from cron only - $sql = "SELECT * FROM {$CFG->prefix}grade_items - WHERE courseid=$courseid AND locked = 0 AND locktime > 0 AND locktime < $now"; - - if ($items = get_records_sql($sql)) { - foreach ($items as $item) { - $grade_item = new grade_grade($item, false); - $grade_item->locked = time(); - $grade_item->update('locktime'); - } - } - } - /** * Set the locktime for this grade item. *