From: nicolasconnault Date: Thu, 9 Aug 2007 16:41:39 +0000 (+0000) Subject: MDL-9628 Simplified and improved the expanding/collapsing of categories. There are... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=384960dd68901cbf52f72a47942d280add9873cb;p=moodle.git MDL-9628 Simplified and improved the expanding/collapsing of categories. There are now three view types: full, aggregates only and grades only. --- diff --git a/grade/edit/tree/category_form.php b/grade/edit/tree/category_form.php index 2ef411d768..37a100f35c 100644 --- a/grade/edit/tree/category_form.php +++ b/grade/edit/tree/category_form.php @@ -54,8 +54,9 @@ class edit_category_form extends moodleform { // user preferences $mform->addElement('header', 'general', get_string('userpreferences', 'grades')); $options = array(GRADE_REPORT_PREFERENCE_DEFAULT => get_string('default', 'grades'), - GRADE_REPORT_AGGREGATION_VIEW_FULL => get_string('full', 'grades'), - GRADE_REPORT_AGGREGATION_VIEW_COMPACT => get_string('compact', 'grades')); + GRADE_REPORT_AGGREGATION_VIEW_FULL => get_string('fullmode', 'grades'), + GRADE_REPORT_AGGREGATION_VIEW_AGGREGATES_ONLY => get_string('aggregatesonly', 'grades'), + GRADE_REPORT_AGGREGATION_VIEW_GRADES_ONLY => get_string('gradesonly', 'grades')); $label = get_string('aggregationview', 'grades') . ' (' . get_string('default', 'grades') . ': ' . $options[$CFG->grade_report_aggregationview] . ')'; $mform->addElement('select', 'pref_aggregationview', $label, $options); diff --git a/grade/lib.php b/grade/lib.php index c7dd0d19df..a1983df503 100644 --- a/grade/lib.php +++ b/grade/lib.php @@ -521,12 +521,17 @@ class grade_tree { return; } - if (in_array($element['object']->id, $collapsed)) { + if (in_array($element['object']->id, $collapsed['aggregatesonly'])) { $category_item = reset($element['children']); //keep only category item $element['children'] = array(key($element['children'])=>$category_item); } else { - foreach ($element['children'] as $sortorder=>$child) { + if (in_array($element['object']->id, $collapsed['gradesonly'])) { // Remove category item + reset($element['children']); + $first_key = key($element['children']); + unset($element['children'][$first_key]); + } + foreach ($element['children'] as $sortorder=>$child) { // Recurse through the element's children grade_tree::category_collapse($element['children'][$sortorder], $collapsed); } } diff --git a/grade/report/grader/lib.php b/grade/report/grader/lib.php index 8b17e22f95..f770b20d49 100644 --- a/grade/report/grader/lib.php +++ b/grade/report/grader/lib.php @@ -52,7 +52,7 @@ class grade_report_grader extends grade_report { var $userselect; /** - * List of collapsed captegories from user perference + * List of collapsed categories from user preference * @var array $collapsed */ var $collapsed; @@ -72,14 +72,10 @@ class grade_report_grader extends grade_report { // load collapsed settings for this report if ($collapsed = get_user_preferences('grade_report_grader_collapsed_categories')) { $this->collapsed = unserialize($collapsed); - foreach ($this->collapsed as $key=>$id) { - if ($this->get_pref('aggregationview', $id) == GRADE_REPORT_AGGREGATION_VIEW_FULL) { - unset($this->collapsed[$key]); // full view categories can not be collapsed - } - } } else { - $this->collapsed = array(); + $this->collapsed = array('aggregatesonly' => array(), 'gradesonly' => array()); } + if (empty($CFG->enableoutcomes)) { $nooutcomes = false; } else { @@ -977,14 +973,19 @@ class grade_report_grader extends grade_report { $contract_expand_icon = ''; // If object is a category, display expand/contract icon - if ($element['type'] == 'category' && $this->get_pref('aggregationview', $element['object']->id) == GRADE_REPORT_AGGREGATION_VIEW_COMPACT) { + if ($element['type'] == 'category') { // Load language strings - $strswitch_minus = $this->get_lang_string('contract', 'grades'); - $strswitch_plus = $this->get_lang_string('expand', 'grades'); + $strswitch_minus = $this->get_lang_string('aggregatesonly', 'grades'); + $strswitch_plus = $this->get_lang_string('gradesonly', 'grades'); + $strswitch_whole = $this->get_lang_string('fullmode', 'grades'); + $expand_contract = 'switch_minus'; // Default: expanded + // $this->get_pref('aggregationview', $element['object']->id) == GRADE_REPORT_AGGREGATION_VIEW_COMPACT - if (in_array($element['object']->id, $this->collapsed)) { + if (in_array($element['object']->id, $this->collapsed['aggregatesonly'])) { $expand_contract = 'switch_plus'; + } elseif (in_array($element['object']->id, $this->collapsed['gradesonly'])) { + $expand_contract = 'switch_whole'; } $url = $this->gpr->get_return_url(null, array('target'=>$element['eid'], 'action'=>$expand_contract, 'sesskey'=>sesskey())); $contract_expand_icon = '