Skip to content

Commit

Permalink
MDL-52078 gradebook: Stop totals including hidden items.
Browse files Browse the repository at this point in the history
This patch fixes a problem where the course and user reports, when viewed by
a student, were incorrectly including hidden grade items in the course totals,
making the percentages lower than they should be.
  • Loading branch information
Peter Miller authored and cameorn1730 committed Jan 5, 2016
1 parent 2a416b3 commit 374639d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/grade/grade_grade.php
Original file line number Diff line number Diff line change
Expand Up @@ -805,8 +805,18 @@ public static function get_hiding_affected(&$grade_grades, &$grade_items) {

} else if (!array_intersect($dependson[$do], $todo)) {
$hidden_precursors = array_intersect($dependson[$do], array_keys($altered));
if (!$hidden_precursors) {
// hiding does not affect this grade
// If the dependency is a sum aggregation, we need to process it as if it had hidden items.
// The reason for this, is that the code will recalculate the maxgrade by removing ungraded
// items and accounting for 'drop x grades' and then stored back in our virtual grade_items.
// This recalculation is necessary because there will be a call to:
// $grade_category->aggregate_values_and_adjust_bounds
// for the top level grade that will depend on knowing what that caclulated grademax is
// and it finds that value by checking the virtual grade_items.
$issumaggregate = false;
if ($grade_items[$do]->itemtype == 'category') {
$issumaggregate = $grade_items[$do]->load_item_category()->aggregation == GRADE_AGGREGATE_SUM;
}
if (!$hidden_precursors && !$issumaggregate) {
unset($todo[$key]);
$found = true;
continue;
Expand Down

0 comments on commit 374639d

Please sign in to comment.