gradebook MDL-22841 fixed a bug where the user report when viewing multiple students...
authorAndrew Davis <andrew@affinitysoftware.net>
Tue, 14 Sep 2010 08:43:50 +0000 (08:43 +0000)
committerAndrew Davis <andrew@affinitysoftware.net>
Tue, 14 Sep 2010 08:43:50 +0000 (08:43 +0000)
grade/report/lib.php

index d34d037..ebfd1c3 100755 (executable)
@@ -339,10 +339,19 @@ abstract class grade_report {
         global $CFG, $DB;
         static $hiding_affected = null;//array of items in this course affected by hiding
 
         global $CFG, $DB;
         static $hiding_affected = null;//array of items in this course affected by hiding
 
+        //if we're dealing with multiple users we need to know when we've moved on to a new user
+        static $previous_userid = null;
+
         if( $this->showtotalsifcontainhidden==GRADE_REPORT_SHOW_REAL_TOTAL_IF_CONTAINS_HIDDEN ) {
             return $finalgrade;
         }
 
         if( $this->showtotalsifcontainhidden==GRADE_REPORT_SHOW_REAL_TOTAL_IF_CONTAINS_HIDDEN ) {
             return $finalgrade;
         }
 
+        //if we've moved on to another user don't return the previous user's affected grades
+        if ($previous_userid!=$this->user->id) {
+            $hiding_affected = null;
+            $previous_userid = $this->user->id;
+        }
+
         if( !$hiding_affected ) {
             $items = grade_item::fetch_all(array('courseid'=>$courseid));
             $grades = array();
         if( !$hiding_affected ) {
             $items = grade_item::fetch_all(array('courseid'=>$courseid));
             $grades = array();