From: skodak Date: Sun, 21 Oct 2007 12:56:19 +0000 (+0000) Subject: MDL-11859 student rank and showing of hidden grade items are now configurable + fixed... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=029735054a01b35bdbf5cc25d97a6e01a7663791;p=moodle.git MDL-11859 student rank and showing of hidden grade items are now configurable + fixed some incorrect include_once --- diff --git a/admin/settings/grades.php b/admin/settings/grades.php index a3f8282d7c..6aef71dba4 100644 --- a/admin/settings/grades.php +++ b/admin/settings/grades.php @@ -116,7 +116,7 @@ foreach (get_list_of_plugins('grade/report') as $plugin) { if (file_exists($CFG->dirroot.'/grade/report/'.$plugin.'/settings.php')) { $settings = new admin_settingpage('gradereport'.$plugin, get_string('modulename', 'gradereport_'.$plugin)); - include_once($CFG->dirroot.'/grade/report/'.$plugin.'/settings.php'); + include($CFG->dirroot.'/grade/report/'.$plugin.'/settings.php'); $ADMIN->add('gradereports', $settings); } } @@ -134,7 +134,7 @@ foreach (get_list_of_plugins('grade/import') as $plugin) { } $settings = new admin_settingpage('gradeimport'.$plugin, get_string('modulename', 'gradeimport_'.$plugin)); - include_once($CFG->dirroot.'/grade/import/'.$plugin.'/settings.php'); + include($CFG->dirroot.'/grade/import/'.$plugin.'/settings.php'); $ADMIN->add('gradeimports', $settings); } } @@ -152,7 +152,7 @@ foreach (get_list_of_plugins('grade/export') as $plugin) { } $settings = new admin_settingpage('gradeexport'.$plugin, get_string('modulename', 'gradeexport_'.$plugin)); - include_once($CFG->dirroot.'/grade/export/'.$plugin.'/settings.php'); + include($CFG->dirroot.'/grade/export/'.$plugin.'/settings.php'); $ADMIN->add('gradeexports', $settings); } } diff --git a/grade/report/grader/settings.php b/grade/report/grader/settings.php index 211a82741e..0bce862d17 100644 --- a/grade/report/grader/settings.php +++ b/grade/report/grader/settings.php @@ -22,7 +22,6 @@ // http://www.gnu.org/copyleft/gpl.html // // // /////////////////////////////////////////////////////////////////////////// -require_once($CFG->libdir.'/grade/constants.php'); $strinherit = get_string('inherit', 'grades'); $strpercentage = get_string('percentage', 'grades'); diff --git a/grade/report/user/lib.php b/grade/report/user/lib.php index da4c6b1afa..e850af9064 100644 --- a/grade/report/user/lib.php +++ b/grade/report/user/lib.php @@ -87,16 +87,24 @@ class grade_report_user extends grade_report { * Prepares the headers and attributes of the flexitable. */ function setup_table() { + global $CFG; /* - * Table has 6 columns - *| pic | itemname/description | grade (grade_final) | percentage | rank | feedback | + * Table has 5-6 columns + *| pic | itemname/description | grade (grade_final) | percentage | rank (optional) | feedback | */ // setting up table headers - $tablecolumns = array('itemname', 'category', 'grade', 'percentage', 'rank', 'feedback'); - $tableheaders = array($this->get_lang_string('gradeitem', 'grades'), $this->get_lang_string('category'), $this->get_lang_string('grade'), - $this->get_lang_string('percent', 'grades'), $this->get_lang_string('rank', 'grades'), - $this->get_lang_string('feedback')); + if (!empty($CFG->grade_userreport_showrank)) { + // TODO: this is broken if hidden grades present!! + $tablecolumns = array('itemname', 'category', 'grade', 'percentage', 'rank', 'feedback'); + $tableheaders = array($this->get_lang_string('gradeitem', 'grades'), $this->get_lang_string('category'), $this->get_lang_string('grade'), + $this->get_lang_string('percent', 'grades'), $this->get_lang_string('rank', 'grades'), + $this->get_lang_string('feedback')); + } else { + $tablecolumns = array('itemname', 'category', 'grade', 'percentage', 'feedback'); + $tableheaders = array($this->get_lang_string('gradeitem', 'grades'), $this->get_lang_string('category'), $this->get_lang_string('grade'), + $this->get_lang_string('percent', 'grades'), $this->get_lang_string('feedback')); + } $this->table = new flexible_table('grade-report-user-'.$this->courseid); @@ -150,6 +158,10 @@ class grade_report_user extends grade_report { $grade_item =& $items[$itemid]; $grade_grade =& $grades[$itemid]; + if (empty($CFG->grade_userreport_showhiddenitems) and !$canviewhidden and $grade_item->is_hidden()) { + continue; + } + if (in_array($itemid, $unknown)) { $gradeval = null; } else if (array_key_exists($itemid, $altered)) { @@ -199,22 +211,25 @@ class grade_report_user extends grade_report { } /// prints rank - if ($grade_item->needsupdate) { - $data[] = ''.get_string('error').''; - - } else if (is_null($gradeval)) { - // no grade, no rank - $data[] = '-'; - - } else { - /// find the number of users with a higher grade - $sql = "SELECT COUNT(DISTINCT(userid)) - FROM {$CFG->prefix}grade_grades - WHERE finalgrade > {$grade_grade->finalgrade} - AND itemid = {$grade_item->id}"; - $rank = count_records_sql($sql) + 1; - - $data[] = "$rank/$numusers"; + if (!empty($CFG->grade_userreport_showrank)) { + // TODO: this is broken if hidden grades present!! + if ($grade_item->needsupdate) { + $data[] = ''.get_string('error').''; + + } else if (is_null($gradeval)) { + // no grade, no rank + $data[] = '-'; + + } else { + /// find the number of users with a higher grade + $sql = "SELECT COUNT(DISTINCT(userid)) + FROM {$CFG->prefix}grade_grades + WHERE finalgrade > {$grade_grade->finalgrade} + AND itemid = {$grade_item->id}"; + $rank = count_records_sql($sql) + 1; + + $data[] = "$rank/$numusers"; + } } /// prints notes diff --git a/grade/report/user/settings.php b/grade/report/user/settings.php new file mode 100644 index 0000000000..ce62456c31 --- /dev/null +++ b/grade/report/user/settings.php @@ -0,0 +1,32 @@ +add(new admin_setting_configcheckbox('grade_userreport_showrank', get_string('showrank', 'grades'), get_string('configshowrank', 'grades'), 0, PARAM_INT)); + +$settings->add(new admin_setting_configcheckbox('grade_userreport_showhiddenitems', get_string('showhiddenitems', 'grades'), get_string('configshowhiddenitems', 'grades'), 0, PARAM_INT)); + +?> diff --git a/lang/en_utf8/grades.php b/lang/en_utf8/grades.php index 8217f91cbc..b0c0e853a2 100644 --- a/lang/en_utf8/grades.php +++ b/lang/en_utf8/grades.php @@ -89,10 +89,12 @@ $string['configshoweyecons'] = 'Whether to show a show/hide icon near each grade $string['configshowactivityicons'] = 'Show an activity icon next to each grade item linked to an activity, in the grader report.'; $string['configshowaverages'] = 'Show column averages in the grader report.'; $string['configshowgroups'] = 'Show group averages and means in the grader report.'; +$string['configshowhiddenitems'] = 'Show hidden items in report even when user does not have moodle/grade:viewhidden capability. Visibility of hidden grades is not affected by this setting.'; $string['configshowlocks'] = 'Whether to show a lock/unlock icon near each grade.'; $string['configshowfeedback'] = 'Whether to show a feedback icon (for adding/editing) near each grade.'; $string['configshownumberofgrades'] = 'Shows the number of grades being aggregated next to each average, between brackets. Example: 45 (34).'; $string['configshowranges'] = 'Display a row showing the range of possible for each grading item in the grader report.'; +$string['configshowrank'] = 'Show rank for each item.'; $string['configshowuserimage'] = 'Whether to show the user\'s profile image next to the name in the grader report.'; $string['configstudentsperpage'] = 'The number of students to display per page in the grader report.'; $string['configstudentsperpagedefault'] = 'The number of students to display per page in the grader report. Leave this field empty to use the site default (currently $a).'; @@ -388,11 +390,12 @@ $string['showcalculations'] = 'Show calculations'; $string['showeyecons'] = 'Show show/hide icons'; $string['showfeedback'] = 'Show feedback'; $string['showgroups'] = 'Show groups'; -$string['showhiddenitems'] = 'Show Hidden Items'; +$string['showhiddenitems'] = 'Show hidden items'; $string['showlocks'] = 'Show locks'; $string['shownooutcomes'] = 'Hide outcomes'; $string['shownumberofgrades'] = 'Show number of grades in averages'; $string['showranges'] = 'Show ranges'; +$string['showrank'] = 'Show rank'; $string['showuserimage'] = 'Show user profile images'; $string['sitewide'] = 'Site-wide'; $string['sort'] = 'sort';