Permalink
Browse files

Merge branch 'wip-MDL-59055-master' of git://github.com/marinaglancy/…

…moodle
  • Loading branch information...
dmonllao committed Aug 7, 2017
2 parents 53ce3e4 + fe9965e commit 037093107689cf32424470f308dd888f47b0b024
Showing with 21 additions and 10 deletions.
  1. +2 −2 grade/report/grader/lib.php
  2. +2 −2 grade/report/lib.php
  3. +8 −0 grade/tests/behat/grade_hidden_items.feature
  4. +9 −6 lib/grade/grade_grade.php
@@ -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);
}
@@ -996,7 +996,7 @@ public function get_right_rows($displayaverages) {
// Get the decimal points preference for this item
$decimalpoints = $item->get_decimals();
if (in_array($itemid, $unknown)) {
if (array_key_exists($itemid, $unknown)) {
$gradeval = null;
} else if (array_key_exists($itemid, $altered)) {
$gradeval = $altered[$itemid];
@@ -525,14 +525,14 @@ protected function blank_hidden_total_and_adjust_bounds($courseid, $course_item,
$aggregationweight = null;
}
}
} else if (!empty($hiding_affected['unknown'][$course_item->id])) {
} 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];
@@ -27,6 +27,14 @@ Feature: Student and teacher's view of aggregated grade items is consistent when
| assign | C1 | a3 | Test assignment three | Submit something! | Sub category 2 | 100 |
| assign | C1 | a4 | Test assignment four | Submit something! | Sub category 2 | 100 |
And I log in as "admin"
And I am on "Course 1" course homepage
And I navigate to "Setup > Gradebook setup" in the course gradebook
And I press "Add grade item"
And I set the following fields to these values:
| Item name | calculated |
And I press "Save changes"
And I set "=[[a4]]/2" calculation for grade item "calculated" with idnumbers:
| Sub category 1 | sub1 |
And I navigate to "Overview report" node in "Site administration > Grades > Report settings"
And I set the field "s__grade_report_overview_showtotalsifcontainhidden" to "Show totals excluding hidden items"
And I navigate to "User report" node in "Site administration > Grades > Report settings"
@@ -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
@@ -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(),
@@ -795,10 +797,10 @@ public static function get_hiding_affected(&$grade_grades, &$grade_items) {
for($i=0; $i<$max; $i++) {
$found = false;
foreach($todo as $key=>$do) {
$hidden_precursors = array_intersect($dependson[$do], $unknown);
$hidden_precursors = array_intersect($dependson[$do], array_keys($unknown));
if ($hidden_precursors) {
// this item depends on hidden grade indirectly
$unknown[$do] = $do;
$unknown[$do] = $grade_grades[$do]->finalgrade;
unset($todo[$key]);
$found = true;
continue;
@@ -828,7 +830,7 @@ public static function get_hiding_affected(&$grade_grades, &$grade_items) {
) {
// This is a grade item that is not a category or course and has been affected by grade hiding.
// I guess this means it is a calculation that needs to be recalculated.
$unknown[$do] = $do;
$unknown[$do] = $grade_grades[$do]->finalgrade;
unset($todo[$key]);
$found = true;
continue;
@@ -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,

0 comments on commit 0370931

Please sign in to comment.