Skip to content

Commit

Permalink
MDL-59055 grades: provide backward-compatibility of changes
Browse files Browse the repository at this point in the history
  • Loading branch information
marinaglancy committed Aug 7, 2017
1 parent be85f0c commit 20060b3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion grade/report/grader/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,7 @@ public function get_right_rows($displayaverages) {
$usergrades = $this->allgrades[$userid];
$hidingaffected = grade_grade::get_hiding_affected($usergrades, $allgradeitems);
$altered = $hidingaffected['altered'];
$unknown = $hidingaffected['unknown'];
$unknown = $hidingaffected['unknowngrades'];
unset($hidingaffected);
}

Expand Down
4 changes: 2 additions & 2 deletions grade/report/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -525,14 +525,14 @@ protected function blank_hidden_total_and_adjust_bounds($courseid, $course_item,
$aggregationweight = null;
}
}
} else if (array_key_exists($course_item->id, $hiding_affected['unknown'])) {
} else if (array_key_exists($course_item->id, $hiding_affected['unknowngrades'])) {
//not sure whether or not this item depends on a hidden item
if (!$this->showtotalsifcontainhidden[$courseid]) {
//hide the grade
$finalgrade = null;
} else {
//use reprocessed marks that exclude hidden items
$finalgrade = $hiding_affected['unknown'][$course_item->id];
$finalgrade = $hiding_affected['unknowngrades'][$course_item->id];

if (array_key_exists($course_item->id, $hiding_affected['alteredgrademin'])) {
$grademin = $hiding_affected['alteredgrademin'][$course_item->id];
Expand Down
9 changes: 6 additions & 3 deletions lib/grade/grade_grade.php
Original file line number Diff line number Diff line change
Expand Up @@ -727,8 +727,9 @@ protected static function flatten_dependencies_array(&$dependson, &$dependencyde
*
* @param array $grade_grades all course grades of one user, & used for better internal caching
* @param array $grade_items array of grade items, & used for better internal caching
* @return array This is an array of 3 arrays:
* unknown => list of item ids that may be affected by hiding (with the calculated grade as the value)
* @return array This is an array of following arrays:
* unknown => list of item ids that may be affected by hiding (with the ITEM ID as both the key and the value) - for BC with old gradereport plugins
* unknowngrades => list of item ids that may be affected by hiding (with the calculated grade as the value)
* altered => list of item ids that are definitely affected by hiding (with the calculated grade as the value)
* alteredgrademax => for each item in altered or unknown, the new value of the grademax
* alteredgrademin => for each item in altered or unknown, the new value of the grademin
Expand Down Expand Up @@ -779,6 +780,7 @@ public static function get_hiding_affected(&$grade_grades, &$grade_items) {

if (!$hiddenfound) {
return array('unknown' => array(),
'unknowngrades' => array(),
'altered' => array(),
'alteredgrademax' => array(),
'alteredgrademin' => array(),
Expand Down Expand Up @@ -953,7 +955,8 @@ public static function get_hiding_affected(&$grade_grades, &$grade_items) {
}
}

return array('unknown' => $unknown,
return array('unknown' => array_combine(array_keys($unknown), array_keys($unknown)), // Left for BC in case some gradereport plugins expect it.
'unknowngrades' => $unknown,
'altered' => $altered,
'alteredgrademax' => $alteredgrademax,
'alteredgrademin' => $alteredgrademin,
Expand Down

0 comments on commit 20060b3

Please sign in to comment.