1
0
mirror of https://github.com/moodle/moodle.git synced 2025-04-17 22:45:54 +02:00

MDL-47763 Grades: Handle the case when a grade category is hidden.

This was breaking the contribution column, which needs to know the
weights of all the categories up the tree, whether they are visible or
not.
This commit is contained in:
Damyon Wiese 2014-10-23 11:22:10 +08:00 committed by Eloy Lafuente (stronk7)
parent 7a811fb63a
commit edffadfd1c
2 changed files with 40 additions and 34 deletions
grade/report/user
lib/grade

@ -446,6 +446,32 @@ class grade_report_user extends grade_report {
}
}
// Actual Grade - We need to calculate this whether the row is hidden or not.
$gradeval = $grade_grade->finalgrade;
$hint = $grade_grade->get_aggregation_hint();
if (!$this->canviewhidden) {
/// Virtual Grade (may be calculated excluding hidden items etc).
$adjustedgrade = $this->blank_hidden_total_and_adjust_bounds($this->courseid,
$grade_grade->grade_item,
$gradeval);
$gradeval = $adjustedgrade['grade'];
// We temporarily adjust the view of this grade item - because the min and
// max are affected by the hidden values in the aggregation.
$grade_grade->grade_item->grademax = $adjustedgrade['grademax'];
$grade_grade->grade_item->grademin = $adjustedgrade['grademin'];
$hint['status'] = $adjustedgrade['aggregationstatus'];
$hint['weight'] = $adjustedgrade['aggregationweight'];
} else {
// The max and min for an aggregation may be different to the grade_item.
if (!is_null($gradeval)) {
$grade_grade->grade_item->grademax = $grade_grade->rawgrademax;
$grade_grade->grade_item->grademin = $grade_grade->rawgrademin;
}
}
if (!$hide) {
/// Excluded Item
/**
@ -473,31 +499,6 @@ class grade_report_user extends grade_report {
$data['itemname']['celltype'] = 'th';
$data['itemname']['id'] = $header_row;
/// Actual Grade
$gradeval = $grade_grade->finalgrade;
$hint = $grade_grade->get_aggregation_hint();
if (!$this->canviewhidden) {
/// Virtual Grade (may be calculated excluding hidden items etc).
$adjustedgrade = $this->blank_hidden_total_and_adjust_bounds($this->courseid,
$grade_grade->grade_item,
$gradeval);
$gradeval = $adjustedgrade['grade'];
// We temporarily adjust the view of this grade item - because the min and
// max are affected by the hidden values in the aggregation.
$grade_grade->grade_item->grademax = $adjustedgrade['grademax'];
$grade_grade->grade_item->grademin = $adjustedgrade['grademin'];
$hint['status'] = $adjustedgrade['aggregationstatus'];
$hint['weight'] = $adjustedgrade['aggregationweight'];
} else {
// The max and min for an aggregation may be different to the grade_item.
if (!is_null($gradeval)) {
$grade_grade->grade_item->grademax = $grade_grade->rawgrademax;
$grade_grade->grade_item->grademin = $grade_grade->rawgrademin;
}
}
if ($this->showfeedback) {
// Copy $class before appending itemcenter as feedback should not be centered
$classfeedback = $class;
@ -649,17 +650,20 @@ class grade_report_user extends grade_report {
$data['contributiontocoursetotal']['content'] = '-';
$data['contributiontocoursetotal']['headers'] = "$header_cat $header_row contributiontocoursetotal";
$hint['grademax'] = $grade_grade->grade_item->grademax;
$hint['grademin'] = $grade_grade->grade_item->grademin;
$hint['grade'] = $gradeval;
$parent = $grade_object->load_parent_category();
if ($grade_object->is_category_item()) {
$parent = $parent->load_parent_category();
}
$hint['parent'] = $parent->load_grade_item()->id;
$this->aggregationhints[$grade_grade->itemid] = $hint;
}
}
// We collect the aggregation hints whether they are hidden or not.
if ($this->showcontributiontocoursetotal) {
$hint['grademax'] = $grade_grade->grade_item->grademax;
$hint['grademin'] = $grade_grade->grade_item->grademin;
$hint['grade'] = $gradeval;
$parent = $grade_object->load_parent_category();
if ($grade_object->is_category_item()) {
$parent = $parent->load_parent_category();
}
$hint['parent'] = $parent->load_grade_item()->id;
$this->aggregationhints[$grade_grade->itemid] = $hint;
}
}
/// Category

@ -703,6 +703,8 @@ class grade_grade extends grade_object {
} else if ($grade_grade->is_hidden()) {
$hiddenfound = true;
$altered[$grade_grade->itemid] = null;
$alteredaggregationstatus[$grade_grade->itemid] = 'dropped';
$alteredaggregationweight[$grade_grade->itemid] = 0;
} else if ($grade_grade->is_locked() or $grade_grade->is_overridden()) {
// no need to recalculate locked or overridden grades
} else {