Commit 35079f53 authored by skodak's avatar skodak
Browse files

MDL-18951 standardised group support in grader report (not complete yet)

parent d0d1293d
......@@ -144,10 +144,7 @@ class grade_report_grader extends grade_report {
$this->pbarurl = 'index.php?id='.$this->courseid.$perpage.'&';
// Setup groups if requested
if ($this->get_pref('showgroups')) {
$this->setup_groups();
}
$this->setup_groups();
$this->setup_sortitemid();
}
......@@ -430,12 +427,6 @@ class grade_report_grader extends grade_report {
$html .= $this->print_toggle('averages', true);
}
if (has_capability('moodle/grade:viewall', $this->context)
and has_capability('moodle/site:accessallgroups', $this->context)
and ($course_has_groups = true)) { // TODO replace that last condition with proper check
$html .= $this->print_toggle('groups', true);
}
$html .= $this->print_toggle('ranges', true);
if (!empty($CFG->enableoutcomes)) {
$html .= $this->print_toggle('nooutcomes', true);
......@@ -1024,10 +1015,10 @@ class grade_report_grader extends grade_report {
// Averages heading
$straverage_group = get_string('groupavg', 'grades');
$showaverages_group = $this->currentgroup && $this->get_pref('showgroups');
$straverage = get_string('overallaverage', 'grades');
$showaverages = $this->get_pref('showaverages');
$showaverages_group = $this->currentgroup && $showaverages;
if ($showaverages_group) {
$studentshtml .= '<tr class="groupavg r'.$this->rowcount++.'"><th class="header c0" '.$colspan.'scope="row">'.$straverage_group.'</th></tr>';
}
......@@ -1075,7 +1066,7 @@ class grade_report_grader extends grade_report {
if ($grouponly) {
$straverage = get_string('groupavg', 'grades');
$showaverages = $this->currentgroup && $this->get_pref('showgroups');
$showaverages = $this->currentgroup && $this->get_pref('showaverages');
$groupsql = $this->groupsql;
$groupwheresql = $this->groupwheresql;
$groupwheresql_params = $this->groupwheresql_params;
......
......@@ -72,7 +72,6 @@ class grader_report_preferences_form extends moodleform {
if ($canviewhidden) {
$preferences['prefshow']['showaverages'] = $checkbox_default;
}
$preferences['prefshow']['showgroups'] = $checkbox_default;
$preferences['prefshow']['showlocks'] = $checkbox_default;
$preferences['prefrows'] = array(
......
......@@ -65,9 +65,6 @@ $settings->add(new admin_setting_configcheckbox('grade_report_showeyecons', get_
$settings->add(new admin_setting_configcheckbox('grade_report_showaverages', get_string('showaverages', 'grades'),
get_string('configshowaverages', 'grades'), 1));
$settings->add(new admin_setting_configcheckbox('grade_report_showgroups', get_string('showgroups', 'grades'),
get_string('configshowgroups', 'grades'), 0));
$settings->add(new admin_setting_configcheckbox('grade_report_showlocks', get_string('showlocks', 'grades'),
get_string('configshowlocks', 'grades'), 0));
......
......@@ -108,6 +108,12 @@ abstract class grade_report {
*/
public $currentgroup;
/**
* Current course group mode
* @var int $groupmode
*/
var $groupmode;
/**
* A HTML select element used to select the current group.
* @var string $group_selector
......@@ -298,13 +304,15 @@ abstract class grade_report {
*/
protected function setup_groups() {
/// find out current groups mode
$this->group_selector = groups_print_course_menu($this->course, $this->pbarurl, true);
$this->currentgroup = groups_get_course_group($this->course);
if ($this->currentgroup) {
$this->groupsql = " JOIN {groups_members} gm ON gm.userid = u.id ";
$this->groupwheresql = " AND gm.groupid = :gr_grpid ";
$this->groupwheresql_params = array('gr_grpid'=>$this->currentgroup);
if ($this->groupmode = groups_get_course_groupmode($this->course)) {
$this->group_selector = groups_print_course_menu($this->course, $this->pbarurl, true);
$this->currentgroup = groups_get_course_group($this->course);
if ($this->currentgroup) {
$this->groupsql = " JOIN {groups_members} gm ON gm.userid = u.id ";
$this->groupwheresql = " AND gm.groupid = :gr_grpid ";
$this->groupwheresql_params = array('gr_grpid'=>$this->currentgroup);
}
}
}
......
......@@ -1703,6 +1703,11 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
upgrade_main_savepoint($result, 2009042700);
}
if ($result && $oldversion < 2009043000) {
unset_config('grade_report_showgroups');
upgrade_main_savepoint($result, 2009043000);
}
return $result;
}
......
......@@ -6,7 +6,7 @@
// This is compared against the values stored in the database to determine
// whether upgrades should be performed (see lib/db/*.php)
$version = 2009042700; // YYYYMMDD = date of the last version bump
$version = 2009043000; // YYYYMMDD = date of the last version bump
// XX = daily increments
$release = '2.0 dev (Build: 20090430)'; // Human-friendly version name
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment