diff --git a/grade/lib.php b/grade/lib.php index 7712f6cde9f..9ecbbddbb11 100644 --- a/grade/lib.php +++ b/grade/lib.php @@ -470,7 +470,7 @@ class grade_tree { * @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; @@ -486,6 +486,11 @@ class grade_tree { 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); @@ -527,6 +532,27 @@ class grade_tree { } } + /** + * 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 diff --git a/grade/report/grader/lib.php b/grade/report/grader/lib.php index fee2b93df26..710d0f53cfc 100644 --- a/grade/report/grader/lib.php +++ b/grade/report/grader/lib.php @@ -80,8 +80,14 @@ class grade_report_grader extends grade_report { } 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; @@ -306,7 +312,8 @@ class grade_report_grader extends grade_report { * @return string HTML code */ function get_toggles_html() { - global $USER; + global $CFG, $USER; + $html = '