added groups param to get_numusers() - to be used in oureport; might be handy elsewhe...
authorskodak <skodak>
Sat, 27 Oct 2007 22:05:58 +0000 (22:05 +0000)
committerskodak <skodak>
Sat, 27 Oct 2007 22:05:58 +0000 (22:05 +0000)
grade/report/lib.php

index a6db267b7a70d6153968909a4f5bc7cf89dffb9b..1db95fee9101bf661420bc04c699f963c7ade497 100755 (executable)
@@ -284,18 +284,26 @@ class grade_report {
 
     /**
      * Fetches and returns a count of all the users that will be shown on this page.
+     * @param boolean $groups include groups limit
      * @return int Count of users
      */
-    function get_numusers() {
+    function get_numusers($groups=true) {
         global $CFG;
 
+        $groupsql      = "";
+        $groupwheresql = "";
+        if ($groups) {
+            $groupsql      = $this->groupsql;
+            $groupwheresql = $this->groupsqlwhere;
+        }
+
         $countsql = "SELECT COUNT(DISTINCT u.id)
                     FROM {$CFG->prefix}grade_grades g RIGHT OUTER JOIN
                          {$CFG->prefix}user u ON u.id = g.userid
                          LEFT JOIN {$CFG->prefix}role_assignments ra ON u.id = ra.userid
-                         $this->groupsql
+                         $groupsql
                     WHERE ra.roleid in ($this->gradebookroles)
-                         $this->groupwheresql
+                         $groupwheresql
                     AND ra.contextid ".get_related_contexts_string($this->context);
         return count_records_sql($countsql);
     }