}
}
- /**
- * 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
}
}
- /**
- * 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.
*