From: skodak Date: Tue, 30 Oct 2007 21:25:50 +0000 (+0000) Subject: MDL-11973 Improved showing of hidden items in ouuser and user report X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=597f50e616ada456157156e2c11e04da4f068d59;p=moodle.git MDL-11973 Improved showing of hidden items in ouuser and user report --- diff --git a/grade/report/user/lib.php b/grade/report/user/lib.php index 794bc0dd91..245063861a 100644 --- a/grade/report/user/lib.php +++ b/grade/report/user/lib.php @@ -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]); diff --git a/grade/report/user/settings.php b/grade/report/user/settings.php index 773bbae61c..5eb9949721 100644 --- a/grade/report/user/settings.php +++ b/grade/report/user/settings.php @@ -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)); ?> diff --git a/lang/en_utf8/grades.php b/lang/en_utf8/grades.php index 6afe116cb7..d7a43e48bf 100644 --- a/lang/en_utf8/grades.php +++ b/lang/en_utf8/grades.php @@ -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'; diff --git a/lib/grade/grade_category.php b/lib/grade/grade_category.php index c5c2824be8..05a603b838 100644 --- a/lib/grade/grade_category.php +++ b/lib/grade/grade_category.php @@ -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(). diff --git a/lib/grade/grade_grade.php b/lib/grade/grade_grade.php index 3cfa614457..60fa5d3772 100644 --- a/lib/grade/grade_grade.php +++ b/lib/grade/grade_grade.php @@ -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 diff --git a/lib/grade/grade_item.php b/lib/grade/grade_item.php index 163c001605..18a4ae6fd8 100644 --- a/lib/grade/grade_item.php +++ b/lib/grade/grade_item.php @@ -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