mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 08:22:07 +02:00
gradebook MDL-23181 committing grade item patch
This commit is contained in:
parent
c791bb4dfa
commit
e40eabb5d9
@ -1760,11 +1760,15 @@ class grade_item extends grade_object {
|
||||
|
||||
// add missing final grade values
|
||||
// not graded (null) is counted as 0 - the spreadsheet way
|
||||
$allinputsnull = true;
|
||||
foreach($useditems as $gi) {
|
||||
if (!array_key_exists('gi'.$gi, $params)) {
|
||||
if (!array_key_exists('gi'.$gi, $params) || is_null($params['gi'.$gi])) {
|
||||
$params['gi'.$gi] = 0;
|
||||
} else {
|
||||
$params['gi'.$gi] = (float)$params['gi'.$gi];
|
||||
if ($gi != $this->id) {
|
||||
$allinputsnull = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1789,16 +1793,24 @@ class grade_item extends grade_object {
|
||||
return true;
|
||||
}
|
||||
|
||||
// do the calculation
|
||||
$this->formula->set_params($params);
|
||||
$result = $this->formula->evaluate();
|
||||
|
||||
if ($result === false) {
|
||||
if ($allinputsnull) {
|
||||
$grade->finalgrade = null;
|
||||
$result = true;
|
||||
|
||||
} else {
|
||||
// normalize
|
||||
$grade->finalgrade = $this->bounded_grade($result);
|
||||
|
||||
// do the calculation
|
||||
$this->formula->set_params($params);
|
||||
$result = $this->formula->evaluate();
|
||||
|
||||
if ($result === false) {
|
||||
$grade->finalgrade = null;
|
||||
|
||||
} else {
|
||||
// normalize
|
||||
$grade->finalgrade = $this->bounded_grade($result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// update in db if changed
|
||||
|
Loading…
x
Reference in New Issue
Block a user