]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-11859 student rank and showing of hidden grade items are now configurable + fixed...
authorskodak <skodak>
Sun, 21 Oct 2007 12:56:19 +0000 (12:56 +0000)
committerskodak <skodak>
Sun, 21 Oct 2007 12:56:19 +0000 (12:56 +0000)
admin/settings/grades.php
grade/report/grader/settings.php
grade/report/user/lib.php
grade/report/user/settings.php [new file with mode: 0644]
lang/en_utf8/grades.php

index a3f8282d7cce89b962269aa26072761836ad9a6e..6aef71dba4550e5645ef8a633d319332e515f4c0 100644 (file)
@@ -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);
     }
 }
index 211a82741e07b7033031270390dfb5cc26ab7280..0bce862d171aa9cedb262bc2460d9a47a815281e 100644 (file)
@@ -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');
index da4c6b1afad5b89354ed1503f794b4c2ca3dd7b9..e850af906443f69526dbc62dabc64d17a764e5a1 100644 (file)
@@ -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[] = '<span class="gradingerror">'.get_string('error').'</span>';
-
-            } 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[] = '<span class="gradingerror">'.get_string('error').'</span>';
+    
+                } 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 (file)
index 0000000..ce62456
--- /dev/null
@@ -0,0 +1,32 @@
+<?php // $Id$
+
+///////////////////////////////////////////////////////////////////////////
+//                                                                       //
+// NOTICE OF COPYRIGHT                                                   //
+//                                                                       //
+// Moodle - Modular Object-Oriented Dynamic Learning Environment         //
+//          http://moodle.com                                            //
+//                                                                       //
+// Copyright (C) 1999 onwards Martin Dougiamas  http://dougiamas.com     //
+//                                                                       //
+// This program is free software; you can redistribute it and/or modify  //
+// it under the terms of the GNU General Public License as published by  //
+// the Free Software Foundation; either version 2 of the License, or     //
+// (at your option) any later version.                                   //
+//                                                                       //
+// This program is distributed in the hope that it will be useful,       //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of        //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         //
+// GNU General Public License for more details:                          //
+//                                                                       //
+//          http://www.gnu.org/copyleft/gpl.html                         //
+//                                                                       //
+///////////////////////////////////////////////////////////////////////////
+
+/// Add settings for this module to the $settings object (it's already defined)
+
+$settings->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));
+
+?>
index 8217f91cbc633dbf7396850141197ce8598686bf..b0c0e853a20eeb019bd5ec1d24077a900ef47961 100644 (file)
@@ -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';