*/
var $userselect;
-//// GROUP VARIABLES (including SQL)
-
- /**
- * The current group being displayed.
- * @var int $currentgroup
- */
- var $currentgroup;
-
- /**
- * A HTML select element used to select the current group.
- * @var string $group_selector
- */
- var $group_selector;
-
- /**
- * An SQL fragment used to add linking information to the group tables.
- * @var string $groupsql
- */
- var $groupsql;
-
- /**
- * An SQL constraint to append to the queries used by this object to build the report.
- * @var string $groupwheresql
- */
- var $groupwheresql;
-
-
/**
* Constructor. Sets local copies of user preferences and initialises grade_tree.
* @param int $courseid
$this->pbarurl = 'report.php?id='.$this->courseid.'&perpage='.$this->get_pref('studentsperpage')
.'&report=grader&';
+ // Setup groups if requested
if ($this->get_pref('showgroups')) {
$this->setup_groups();
}
return true;
}
- /**
- * Sets up this object's group variables, mainly to restrict the selection of users to display.
- */
- function setup_groups() {
- global $CFG;
-
- /// find out current groups mode
- $course = get_record('course', 'id', $this->courseid);
- $groupmode = $course->groupmode;
- ob_start();
- $this->currentgroup = setup_and_print_groups($course, $groupmode, $this->pbarurl);
- $this->group_selector = ob_get_clean();
-
- // update paging after group
- $this->baseurl .= 'group='.$this->currentgroup.'&';
- $this->pbarurl .= 'group='.$this->currentgroup.'&';
-
- if ($this->currentgroup) {
- $this->groupsql = " LEFT JOIN {$CFG->prefix}groups_members gm ON gm.userid = u.id ";
- $this->groupwheresql = " AND gm.groupid = $this->currentgroup ";
- }
- }
/**
* Setting the sort order, this depends on last state
}
/**
- * Fetches and returns a count of all the users that will be shows on this page.
+ * Fetches and returns a count of all the users that will be shown on this page.
* @return int Count of users
*/
function get_numusers() {
*/
var $lang_strings = array();
+//// GROUP VARIABLES (including SQL)
+
+ /**
+ * The current group being displayed.
+ * @var int $currentgroup
+ */
+ var $currentgroup;
+
+ /**
+ * A HTML select element used to select the current group.
+ * @var string $group_selector
+ */
+ var $group_selector;
+
+ /**
+ * An SQL fragment used to add linking information to the group tables.
+ * @var string $groupsql
+ */
+ var $groupsql;
+
+ /**
+ * An SQL constraint to append to the queries used by this object to build the report.
+ * @var string $groupwheresql
+ */
+ var $groupwheresql;
+
+
/**
* Constructor. Sets local copies of user preferences and initialises grade_tree.
* @param int $courseid
// Grab the grade_tree for this course
$this->gtree = new grade_tree($this->courseid, true, $this->get_pref('aggregationposition'));
+
}
/**
}
return $letters;
}
+
+ /**
+ * Fetches and returns a count of all the users that will be shown on this page.
+ * @return int Count of users
+ */
+ function get_numusers() {
+ global $CFG;
+
+ $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
+ WHERE ra.roleid in ($this->gradebookroles)
+ $this->groupwheresql
+ AND ra.contextid ".get_related_contexts_string($this->context);
+ return count_records_sql($countsql);
+ }
+
+ /**
+ * Sets up this object's group variables, mainly to restrict the selection of users to display.
+ */
+ function setup_groups() {
+ global $CFG;
+
+ /// find out current groups mode
+ $course = get_record('course', 'id', $this->courseid);
+ $groupmode = $course->groupmode;
+ ob_start();
+ $this->currentgroup = setup_and_print_groups($course, $groupmode, $this->pbarurl);
+ $this->group_selector = ob_get_clean();
+
+ // update paging after group
+ $this->baseurl .= 'group='.$this->currentgroup.'&';
+ $this->pbarurl .= 'group='.$this->currentgroup.'&';
+
+ if ($this->currentgroup) {
+ $this->groupsql = " LEFT JOIN {$CFG->prefix}groups_members gm ON gm.userid = u.id ";
+ $this->groupwheresql = " AND gm.groupid = $this->currentgroup ";
+ }
+ }
}
?>
// base url for sorting by first/last name
$this->baseurl = $CFG->wwwroot.'/grade/report?id='.$courseid.'&userid='.$userid;
+ $this->pbarurl = $this->baseurl;
- $this->setup_table();
+ // Setup groups if requested
+ if ($this->get_pref('showgroups')) {
+ $this->setup_groups();
+ }
+ $this->setup_table();
}
/**
function fill_table() {
global $CFG;
+ $numusers = $this->get_numusers();
if ($all_grade_items = grade_item::fetch_all(array('courseid'=>$this->courseid))) {
$grade_items = array();
function process_data($data) {
}
- /**
- * Fetches and returns a count of all the users that will be shows on this page.
- * @return int Count of users
- */
- function get_numusers() {
- global $CFG;
- return count(get_role_users(@implode(',', $CFG->gradebookroles), $this->context));
- }
-
}
?>