mirror of
https://github.com/moodle/moodle.git
synced 2025-01-31 12:45:04 +01:00
MDL-50894 lib/conditionlib: Occasional cron error
Inhibit division by zero error warnings when rawgrademax and rawgrademin are equal. The change does not affect existing functional behavior.
This commit is contained in:
parent
e1d4e288ac
commit
c28eb52862
@ -228,7 +228,9 @@ class condition extends \core_availability\condition {
|
||||
WHERE
|
||||
gi.courseid = ?', array($userid, $courseid));
|
||||
foreach ($rs as $record) {
|
||||
if (is_null($record->finalgrade)) {
|
||||
// This function produces division by zero error warnings when rawgrademax and rawgrademin
|
||||
// are equal. Below change does not affect function behavior, just avoids the warning.
|
||||
if (is_null($record->finalgrade) || $record->rawgrademax == $record->rawgrademin) {
|
||||
// No grade = false.
|
||||
$cachedgrades[$record->id] = false;
|
||||
} else {
|
||||
@ -249,7 +251,9 @@ class condition extends \core_availability\condition {
|
||||
// Just get current grade.
|
||||
$record = $DB->get_record('grade_grades', array(
|
||||
'userid' => $userid, 'itemid' => $gradeitemid));
|
||||
if ($record && !is_null($record->finalgrade)) {
|
||||
// This function produces division by zero error warnings when rawgrademax and rawgrademin
|
||||
// are equal. Below change does not affect function behavior, just avoids the warning.
|
||||
if ($record && !is_null($record->finalgrade) && $record->rawgrademax != $record->rawgrademin) {
|
||||
$score = (($record->finalgrade - $record->rawgrademin) * 100) /
|
||||
($record->rawgrademax - $record->rawgrademin);
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user