final locking API cleanup

This commit is contained in:
skodak
2007-08-09 12:44:10 +00:00
parent 6c9f672529
commit ddc2098247
2 changed files with 2 additions and 46 deletions
+2 -24
View File
@@ -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
-22
View File
@@ -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.
*