]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-11576 New grade_item method has_hidden_grades(), which returns a simple count...
authornicolasconnault <nicolasconnault>
Thu, 4 Oct 2007 08:02:00 +0000 (08:02 +0000)
committernicolasconnault <nicolasconnault>
Thu, 4 Oct 2007 08:02:00 +0000 (08:02 +0000)
grade/report/grader/lib.php
lib/grade/grade_item.php

index a68bc33cf6c2d8ec253b799759c101e20bc30849..21bb72a64d0546eb7e90bac2e7b163a0af56a987 100644 (file)
@@ -859,9 +859,11 @@ class grade_report_grader extends grade_report {
             $avghtml = '<tr class="' . $avgcssclass . ' r'.$this->rowcount++.'"><th class="header c0" scope="row">'.$straverage.'</th>';
 
             $columncount=1;
+
             foreach ($this->items as $item) {
                 // If the user shouldn't see this grade_item, hide the average as well
-                if ($item->is_hidden() && !$canviewhidden) {
+                // MDL-11576 If any of the grades are hidden and the user doesn't have permission to view them, hide average as well
+                if (($item->is_hidden() || $item->has_hidden_grades()) && !$canviewhidden) {
                     $avghtml .= '<td class="cell c' . $columncount++.'"> - </td>';
                     continue;
                 }
index c3e4b464314738765551bd96e34c3b4d1498d484..a6387b29bd2682f07229b2bfb2fb37cdc6b552cc 100644 (file)
@@ -564,6 +564,14 @@ class grade_item extends grade_object {
             }
         }
     }
+    
+    /**
+     * Returns the number of grades that are hidden.
+     * @param return int Number of hidden grades
+     */
+    function has_hidden_grades() {
+        return count_records('grade_grades', 'itemid', $this->id, 'hidden', 1);
+    }
 
     /**
      * Mark regrading as finished successfully.