]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-11973 Improved showing of hidden items in ouuser and user report
authorskodak <skodak>
Tue, 30 Oct 2007 21:25:50 +0000 (21:25 +0000)
committerskodak <skodak>
Tue, 30 Oct 2007 21:25:50 +0000 (21:25 +0000)
grade/report/user/lib.php
grade/report/user/settings.php
lang/en_utf8/grades.php
lib/grade/grade_category.php
lib/grade/grade_grade.php
lib/grade/grade_item.php

index 794bc0dd91ad0b0020b07c9276698c2158b38639..245063861aa90e3212f8e2ac650d6daadcefcdee 100644 (file)
@@ -75,8 +75,8 @@ class grade_report_user extends grade_report {
         global $CFG;
         parent::grade_report($courseid, $gpr, $context);
 
-        $this->showrank        = grade_get_setting($this->courseid, 'report_user_showrank', !empty($CFG->grade_report_user_showrank));
-        $this->showhiddenitems = grade_get_setting($this->courseid, 'report_user_showhiddenitems', !empty($CFG->grade_report_user_showhiddenitems));
+        $this->showrank        = grade_get_setting($this->courseid, 'report_user_showrank', $CFG->grade_report_user_showrank);
+        $this->showhiddenitems = grade_get_setting($this->courseid, 'report_user_showhiddenitems', $CFG->grade_report_user_showhiddenitems);
 
         $switch = grade_get_setting($this->courseid, 'aggregationposition', $CFG->grade_aggregationposition);
 
@@ -173,8 +173,14 @@ class grade_report_user extends grade_report {
             $grade_item  =& $items[$itemid];
             $grade_grade =& $grades[$itemid];
 
-            if (!$this->showhiddenitems and !$canviewhidden and $grade_item->is_hidden()) {
-                continue;
+            if (!$canviewhidden and $grade_item->is_hidden()) {
+                if ($this->showhiddenitems == 0) {
+                    // no hidden items at all
+                    continue;
+                } else if ($this->showhiddenitems == 1 and !$grade_item->is_hiddenuntil()) {
+                    // hidden until that are still hidden are visible
+                    continue;
+                }
             }
 
             $class = 'gradeitem';
@@ -313,7 +319,8 @@ function grade_report_user_settings_definition(&$mform) {
 
     $options = array(-1 => get_string('default', 'grades'),
                       0 => get_string('hide'),
-                      1 => get_string('show'));
+                      1 => get_string('showhiddenuntilonly', 'grades'),
+                      2 => get_string('show'));
 
     if (empty($CFG->grade_report_user_showhiddenitems)) {
         $options[-1] = get_string('defaultprev', 'grades', $options[0]);
index 773bbae61cbafaf4b0a9e0d8158443a86ec30628..5eb9949721eccc321787b3f788a47fe758177e96 100644 (file)
@@ -27,6 +27,9 @@
 
 $settings->add(new admin_setting_configcheckbox('grade_report_user_showrank', get_string('showrank', 'grades'), get_string('configshowrank', 'grades'), 0, PARAM_INT));
 
-$settings->add(new admin_setting_configcheckbox('grade_report_user_showhiddenitems', get_string('showhiddenitems', 'grades'), get_string('configshowhiddenitems', 'grades'), 0, PARAM_INT));
+$options = array(0 => get_string('shownohidden', 'grades'),
+                 1 => get_string('showhiddenuntilonly', 'grades'),
+                 2 => get_string('showallhidden', 'grades'));
+$settings->add(new admin_setting_configselect('grade_report_user_showhiddenitems', get_string('showhiddenitems', 'grades'), get_string('configshowhiddenitems', 'grades'), 1, $options));
 
 ?>
index 6afe116cb79ee2b3c9bc60927b22dcd22d8eee80..d7a43e48bfa39dee4987d47580d4010a7f46ae17 100644 (file)
@@ -386,6 +386,7 @@ $string['setpreferences'] = 'Set Preferences';
 $string['setting'] = 'Setting';
 $string['settings'] = 'Settings';
 $string['setweights'] = 'Set Weights';
+$string['showallhidden'] = 'All hidden';
 $string['showallstudents'] = 'Show All Students';
 $string['showactivityicons'] = 'Show activity icons';
 $string['showaverages'] = 'Show column averages';
@@ -394,7 +395,9 @@ $string['showeyecons'] = 'Show show/hide icons';
 $string['showfeedback'] = 'Show feedback';
 $string['showgroups'] = 'Show groups';
 $string['showhiddenitems'] = 'Show hidden items';
+$string['showhiddenuntilonly'] = 'Only hidden until';
 $string['showlocks'] = 'Show locks';
+$string['shownohidden'] = 'No hidden';
 $string['shownooutcomes'] = 'Hide outcomes';
 $string['shownumberofgrades'] = 'Show number of grades in averages';
 $string['showranges'] = 'Show ranges';
index c5c2824be80e410a074dd89e0aee7cb53df6a5a5..05a603b8382614ef2201674eb05f4bae28824bc3 100644 (file)
@@ -1092,6 +1092,15 @@ class grade_category extends grade_object {
         return $this->grade_item->is_hidden();
     }
 
+    /**
+     * Check grade hidden status. Uses data from both grade item and grade.
+     * @return boolean true if hiddenuntil, false if not
+     */
+    function is_hiddenuntil() {
+        $this->load_grade_item();
+        return $this->grade_item->is_hiddenuntil();
+    }
+
     /**
      * Sets the grade_item's hidden variable and updates the grade_item.
      * Method named after grade_item::set_hidden().
index 3cfa6144578797bfc3237acd43c626b84fcdf1a5..60fa5d37723367bcb926ed647d9ff49731f7031a 100644 (file)
@@ -395,6 +395,24 @@ class grade_grade extends grade_object {
         return $this->hidden == 1 or ($this->hidden != 0 and $this->hidden > time()) or $this->grade_item->is_hidden();
     }
 
+    /**
+     * Check grade hidden status. Uses data from both grade item and grade.
+     * @return boolean true if hiddenuntil, false if not
+     */
+    function is_hiddenuntil() {
+        $this->load_grade_item();
+
+        if ($this->hidden == 1 or $this->grade_item->hidden == 1) {
+            return false; //always hidden
+        }
+
+        if ($this->hidden > 1 or $this->grade_item->hidden > 1) {
+            return true;
+        }
+
+        return false;
+    }
+
     /**
      * Check grade hidden status. Uses data from both grade item and grade.
      * @return int 0 means visible, 1 hidden always, timestamp hidden until
index 163c00160587c0297ccd208652c45ff9d69f725c..18a4ae6fd889b6d420e6ae0371f1bca98a7c6c6d 100644 (file)
@@ -545,6 +545,14 @@ class grade_item extends grade_object {
         return ($this->hidden == 1 or ($this->hidden != 0 and $this->hidden > time()));
     }
 
+    /**
+     * Check grade hidden status. Uses data from both grade item and grade.
+     * @return boolean true if hiddenuntil, false if not
+     */
+    function is_hiddenuntil() {
+        return $this->hidden > 1;
+    }
+
     /**
      * Check grade item hidden status.
      * @return int 0 means visible, 1 hidden always, timestamp hidden until