* @param boolean $category_grade_last category grade item is the last child
* @param array $collapsed array of collapsed categories
*/
- function grade_tree($courseid, $fillers=true, $category_grade_last=false, $collapsed=null) {
+ function grade_tree($courseid, $fillers=true, $category_grade_last=false, $collapsed=null, $nooutcomes=false) {
global $USER, $CFG;
$this->courseid = $courseid;
grade_tree::category_collapse($this->top_element, $collapsed);
}
+ // no otucomes if requested
+ if (!empty($nooutcomes)) {
+ grade_tree::no_outcomes($this->top_element);
+ }
+
// move category item to last position in category
if ($category_grade_last) {
grade_tree::category_grade_last($this->top_element);
}
}
+ /**
+ * Static recursive helper - removes all outcomes
+ * @static
+ * @param array $element The seed of the recursion
+ * @return void
+ */
+ function no_outcomes(&$element) {
+ if ($element['type'] != 'category') {
+ return;
+ }
+ foreach ($element['children'] as $sortorder=>$child) {
+ if ($element['children'][$sortorder]['type'] == 'item'
+ and $element['children'][$sortorder]['object']->is_outcome_item()) {
+ unset($element['children'][$sortorder]);
+
+ } else if ($element['children'][$sortorder]['type'] == 'category') {
+ grade_tree::no_outcomes($element['children'][$sortorder]);
+ }
+ }
+ }
+
/**
* Static recursive helper - makes the grade_item for category the last children
* @static
} else {
$this->collapsed = array();
}
+ if (empty($CFG->enableoutcomes)) {
+ $nooutcomes = false;
+ } else {
+ $nooutcomes = get_user_preferences('grade_report_shownooutcomes');
+ }
+
// Grab the grade_tree for this course
- $this->gtree = new grade_tree($this->courseid, true, $this->get_pref('aggregationposition'), $this->collapsed);
+ $this->gtree = new grade_tree($this->courseid, true, $this->get_pref('aggregationposition'), $this->collapsed, $nooutcomes);
$this->sortitemid = $sortitemid;
* @return string HTML code
*/
function get_toggles_html() {
- global $USER;
+ global $CFG, $USER;
+
$html = '<div id="grade-report-toggles">';
if ($USER->gradeediting[$this->courseid]) {
if (has_capability('moodle/grade:manage', $this->context) or has_capability('moodle/grade:hide', $this->context)) {
$html .= $this->print_toggle('averages', true);
$html .= $this->print_toggle('groups', true);
$html .= $this->print_toggle('ranges', true);
+ if (!empty($CFG->enableoutcomes)) {
+ $html .= $this->print_toggle('nooutcomes', true);
+ }
$html .= '</div>';
return $html;
}
function print_toggle($type, $return=false) {
global $CFG;
- $icons = array('eyecons' => 'hide',
- 'calculations' => 'calc',
- 'locks' => 'lock',
- 'averages' => 'sigma');
+ $icons = array('eyecons' => 't/hide.gif',
+ 'calculations' => 't/calc.gif',
+ 'locks' => 't/lock.gif',
+ 'averages' => 't/sigma.gif',
+ 'nooutcomes' => 'i/outcomes.gif');
$pref_name = 'grade_report_show' . $type;
- $show_pref = get_user_preferences($pref_name, $CFG->$pref_name);
+
+ if (array_key_exists($pref_name, $CFG)) {
+ $show_pref = get_user_preferences($pref_name, $CFG->$pref_name);
+ } else {
+ $show_pref = get_user_preferences($pref_name);
+ }
$strshow = $this->get_lang_string('show' . $type, 'grades');
$strhide = $this->get_lang_string('hide' . $type, 'grades');
if (array_key_exists($type, $icons)) {
$image_name = $icons[$type];
} else {
- $image_name = $type;
+ $image_name = "t/$type.gif";
}
$string = ${'str' . $show_hide};
- $img = '<img src="'.$CFG->pixpath.'/t/'.$image_name.'.gif" class="iconsmall" alt="'
+ $img = '<img src="'.$CFG->pixpath.'/'.$image_name.'" class="iconsmall" alt="'
.$string.'" title="'.$string.'" />'. "\n";
$retval = '<div class="gradertoggle">' . $img . '<a href="' . $this->baseurl . "&toggle=$toggle_action&toggle_type=$type\">"
$string['hideaverages'] = 'Hide averages';
$string['hidegroups'] = 'Hide groups';
$string['hidelocks'] = 'Hide locks';
+$string['hidenooutcomes'] = 'Show outcomes';
$string['hidefeedback'] = 'Hide feedback';
$string['hideranges'] = 'Hide ranges';
$string['highgradeascending'] = 'Sort by high grade ascending';
$string['showgroups'] = 'Show groups';
$string['showhiddenitems'] = 'Show Hidden Items';
$string['showlocks'] = 'Show locks';
+$string['shownooutcomes'] = 'Hide outcomes';
$string['showranges'] = 'Show ranges';
$string['showuserimage'] = 'Show user profile images';
$string['sitedefault'] = 'Site default ($a)';