mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-25708 recordsets - fix lib/grade/xxx stuff
This commit is contained in:
parent
be981316f4
commit
1b42e67747
@ -481,7 +481,8 @@ class grade_category extends grade_object {
|
|||||||
ORDER BY g.userid";
|
ORDER BY g.userid";
|
||||||
|
|
||||||
// group the results by userid and aggregate the grades for this user
|
// group the results by userid and aggregate the grades for this user
|
||||||
if ($rs = $DB->get_recordset_sql($sql, $params)) {
|
$rs = $DB->get_recordset_sql($sql, $params);
|
||||||
|
if ($rs->valid()) {
|
||||||
$prevuser = 0;
|
$prevuser = 0;
|
||||||
$grade_values = array();
|
$grade_values = array();
|
||||||
$excluded = array();
|
$excluded = array();
|
||||||
@ -506,9 +507,9 @@ class grade_category extends grade_object {
|
|||||||
$oldgrade = $used;
|
$oldgrade = $used;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$rs->close();
|
|
||||||
$this->aggregate_grades($prevuser, $items, $grade_values, $oldgrade, $excluded);//the last one
|
$this->aggregate_grades($prevuser, $items, $grade_values, $oldgrade, $excluded);//the last one
|
||||||
}
|
}
|
||||||
|
$rs->close();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -390,14 +390,13 @@ class grade_grade extends grade_object {
|
|||||||
$now = time(); // no rounding needed, this is not supposed to be called every 10 seconds
|
$now = time(); // no rounding needed, this is not supposed to be called every 10 seconds
|
||||||
list($usql, $params) = $DB->get_in_or_equal($items);
|
list($usql, $params) = $DB->get_in_or_equal($items);
|
||||||
$params[] = $now;
|
$params[] = $now;
|
||||||
if ($rs = $DB->get_recordset_select('grade_grades', "itemid $usql AND locked = 0 AND locktime > 0 AND locktime < ?", $params)) {
|
$rs = $DB->get_recordset_select('grade_grades', "itemid $usql AND locked = 0 AND locktime > 0 AND locktime < ?", $params);
|
||||||
foreach ($rs as $grade) {
|
foreach ($rs as $grade) {
|
||||||
$grade_grade = new grade_grade($grade, false);
|
$grade_grade = new grade_grade($grade, false);
|
||||||
$grade_grade->locked = time();
|
$grade_grade->locked = time();
|
||||||
$grade_grade->update('locktime');
|
$grade_grade->update('locktime');
|
||||||
}
|
|
||||||
$rs->close();
|
|
||||||
}
|
}
|
||||||
|
$rs->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1722,7 +1722,8 @@ class grade_item extends grade_object {
|
|||||||
$return = true;
|
$return = true;
|
||||||
|
|
||||||
// group the grades by userid and use formula on the group
|
// group the grades by userid and use formula on the group
|
||||||
if ($rs = $DB->get_recordset_sql($sql, $params)) {
|
$rs = $DB->get_recordset_sql($sql, $params);
|
||||||
|
if ($rs->valid()) {
|
||||||
$prevuser = 0;
|
$prevuser = 0;
|
||||||
$grade_records = array();
|
$grade_records = array();
|
||||||
$oldgrade = null;
|
$oldgrade = null;
|
||||||
@ -1740,11 +1741,11 @@ class grade_item extends grade_object {
|
|||||||
}
|
}
|
||||||
$grade_records['gi'.$used->itemid] = $used->finalgrade;
|
$grade_records['gi'.$used->itemid] = $used->finalgrade;
|
||||||
}
|
}
|
||||||
$rs->close();
|
|
||||||
if (!$this->use_formula($prevuser, $grade_records, $useditems, $oldgrade)) {
|
if (!$this->use_formula($prevuser, $grade_records, $useditems, $oldgrade)) {
|
||||||
$return = false;
|
$return = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$rs->close();
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user