MFC: MDL-11973 Improved showing of hidden items in ouuser and user report

This commit is contained in:
skodak
2007-10-30 21:41:41 +00:00
parent 29cf643cad
commit aa4847c757
6 changed files with 62 additions and 7 deletions
+12 -5
View 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]);
+4 -1
View 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));
?>
+3
View 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';
+17 -1
View File
@@ -364,7 +364,7 @@ class grade_category extends grade_object {
/**
* Generates and saves raw_grades in associated category grade item.
* These immediate children must alrady have their own final grades.
* These immediate children must already have their own final grades.
* The category's aggregation method is used to generate raw grades.
*
* Please note that category grade is either calculated or aggregated - not both at the same time.
@@ -446,6 +446,13 @@ class grade_category extends grade_object {
/**
* internal function for category grades aggregation
*
* @param int $userid
* @param array $items
* @param array $grade_values
* @param float $oldgrade
* @param bool $excluded
* @return boolean (just plain return;)
*/
function aggregate_grades($userid, $items, $grade_values, $oldgrade, $excluded) {
global $CFG;
@@ -1085,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().
+18
View 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
+8
View 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