]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-11576 Added the groupsql clause to has_hidden_grades
authornicolasconnault <nicolasconnault>
Thu, 4 Oct 2007 08:16:13 +0000 (08:16 +0000)
committernicolasconnault <nicolasconnault>
Thu, 4 Oct 2007 08:16:13 +0000 (08:16 +0000)
grade/report/grader/lib.php
lib/grade/grade_item.php

index 21bb72a64d0546eb7e90bac2e7b163a0af56a987..0ea6cf737b87dcf6a0ce12ac9f31e05719d2021e 100644 (file)
@@ -863,7 +863,7 @@ class grade_report_grader extends grade_report {
             foreach ($this->items as $item) {
                 // If the user shouldn't see this grade_item, hide the average as well
                 // 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) {
+                if (($item->is_hidden() || $item->has_hidden_grades($groupsql, $groupwheresql)) && !$canviewhidden) {
                     $avghtml .= '<td class="cell c' . $columncount++.'"> - </td>';
                     continue;
                 }
index a6387b29bd2682f07229b2bfb2fb37cdc6b552cc..7dcea7a033ffd8c019e4865a6698be65531e911d 100644 (file)
@@ -569,8 +569,10 @@ 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);
+    function has_hidden_grades($groupsql = null, $groupwheresql = null) {
+        global $CFG;
+        return get_field_sql("SELECT COUNT(*) FROM {$CFG->prefix}grade_grades g LEFT JOIN "
+                            ."{$CFG->prefix}user u ON g.userid = u.id$groupsql WHERE itemid = $this->id AND hidden = 1 $groupwheresql");
     }
 
     /**