MDL-47430 core_grades: Handle negative grademin with natural weighting

Part of: MDL-46576
This commit is contained in:
Frederic Massart 2014-09-26 17:32:08 +08:00 committed by Adrian Greeve
parent 11c93e286b
commit 0b2e8ae07b
2 changed files with 34 additions and 8 deletions

View file

@ -706,8 +706,15 @@ class grade_report_user extends grade_report {
if (isset($this->aggregationhints[$itemid])) {
// Normalise the gradeval.
$graderange = $this->aggregationhints[$itemid]['grademax'] - $this->aggregationhints[$itemid]['grademin'];
$gradeval = ($this->aggregationhints[$itemid]['grade'] - $this->aggregationhints[$itemid]['grademin']) / $graderange;
$gradecat = $grade_object->load_parent_category();
if ($gradecat->aggregation == GRADE_AGGREGATE_SUM) {
// Natural aggregation/Sum of grades does not consider the mingrade.
$graderange = $this->aggregationhints[$itemid]['grademax'];
$gradeval = $this->aggregationhints[$itemid]['grade'] / $graderange;
} else {
$graderange = $this->aggregationhints[$itemid]['grademax'] - $this->aggregationhints[$itemid]['grademin'];
$gradeval = ($this->aggregationhints[$itemid]['grade'] - $this->aggregationhints[$itemid]['grademin']) / $graderange;
}
// Multiply the normalised value by the weight
// of all the categories higher in the tree.