From 41e62a9093ab59f55e0c6818ec6cde65f31ca561 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Wed, 15 Oct 2014 09:33:52 +0800 Subject: [PATCH] MDL-47349 gradereport: Use category title on report --- grade/edit/tree/lib.php | 2 +- grade/lib.php | 7 +++++-- grade/report/grader/lib.php | 2 +- .../report/singleview/classes/local/screen/user.php | 2 +- grade/report/user/lib.php | 2 +- grade/tests/behat/grade_calculated_weights.feature | 4 ++-- grade/tests/behat/grade_scales.feature | 12 ++++++------ grade/tests/behat/grade_single_item_scales.feature | 10 +++++----- 8 files changed, 22 insertions(+), 19 deletions(-) diff --git a/grade/edit/tree/lib.php b/grade/edit/tree/lib.php index d36add45d7512..fe90e41ccf58c 100644 --- a/grade/edit/tree/lib.php +++ b/grade/edit/tree/lib.php @@ -113,7 +113,7 @@ public function build_html_tree($element, $totals, $parents, $level, &$row_count $object = $element['object']; $eid = $element['eid']; - $object->name = $this->gtree->get_element_header($element, true, true, true, true); + $object->name = $this->gtree->get_element_header($element, true, true, true, true, true); $object->stripped_name = $this->gtree->get_element_header($element, false, false, false); $is_category_item = false; diff --git a/grade/lib.php b/grade/lib.php index 40aa1c56ad46e..529f32cb84379 100644 --- a/grade/lib.php +++ b/grade/lib.php @@ -1334,17 +1334,20 @@ public function get_element_icon(&$element, $spacerifnone=false) { * @param bool $icon Whether or not to display an icon with this header * @param bool $spacerifnone return spacer if no icon found * @param bool $withdescription Show description if defined by this item. + * @param bool $fulltotal If the item is a category total, returns $categoryname."total" + * instead of "Category total" or "Course total" * * @return string header */ - public function get_element_header(&$element, $withlink=false, $icon=true, $spacerifnone=false, $withdescription=false) { + public function get_element_header(&$element, $withlink = false, $icon = true, $spacerifnone = false, + $withdescription = false, $fulltotal = false) { $header = ''; if ($icon) { $header .= $this->get_element_icon($element, $spacerifnone); } - $header .= $element['object']->get_name(); + $header .= $element['object']->get_name($fulltotal); if ($element['type'] != 'item' and $element['type'] != 'categoryitem' and $element['type'] != 'courseitem') { diff --git a/grade/report/grader/lib.php b/grade/report/grader/lib.php index 26b49332124ee..bdd772719e843 100644 --- a/grade/report/grader/lib.php +++ b/grade/report/grader/lib.php @@ -816,7 +816,7 @@ public function get_right_rows($displayaverages) { $arrow = $this->get_sort_arrow('move', $sortlink); } - $headerlink = $this->gtree->get_element_header($element, true, $showactivityicons, false); + $headerlink = $this->gtree->get_element_header($element, true, $showactivityicons, false, false, true); $itemcell = new html_table_cell(); $itemcell->attributes['class'] = $type . ' ' . $catlevel . ' highlightable'. ' i'. $element['object']->id; diff --git a/grade/report/singleview/classes/local/screen/user.php b/grade/report/singleview/classes/local/screen/user.php index c588d6e957c15..e016b28a487fd 100644 --- a/grade/report/singleview/classes/local/screen/user.php +++ b/grade/report/singleview/classes/local/screen/user.php @@ -192,7 +192,7 @@ public function format_line($item) { $gradetreeitem['object'] = $item; $gradetreeitem['userid'] = $this->item->id; - $itemlabel = $this->structure->get_element_header($gradetreeitem, true, false); + $itemlabel = $this->structure->get_element_header($gradetreeitem, true, false, false, false, true); $grade->label = $item->get_name(); $line = array( diff --git a/grade/report/user/lib.php b/grade/report/user/lib.php index e02c99fcff298..a7f86338b50e9 100644 --- a/grade/report/user/lib.php +++ b/grade/report/user/lib.php @@ -385,7 +385,7 @@ private function fill_table_recursive(&$element) { $grade_object = $element['object']; $eid = $grade_object->id; $element['userid'] = $this->user->id; - $fullname = $this->gtree->get_element_header($element, true, true, true, true); + $fullname = $this->gtree->get_element_header($element, true, true, true, true, true); $data = array(); $hidden = ''; $excluded = ''; diff --git a/grade/tests/behat/grade_calculated_weights.feature b/grade/tests/behat/grade_calculated_weights.feature index 13d1177f50a00..2b5dde9435940 100644 --- a/grade/tests/behat/grade_calculated_weights.feature +++ b/grade/tests/behat/grade_calculated_weights.feature @@ -225,7 +225,7 @@ Feature: We can understand the gradebook user report | Test assignment four | 33.33 % | 10.00 | 1.11 % | | Test assignment five | 33.33 % | 70.00 | 7.78 % | | Test assignment six | 33.33 % | 30.00 | 3.33 % | - | Category totalWeighted mean of grades. | 33.33 % | 36.67 | - | + | Sub category totalWeighted mean of grades. | 33.33 % | 36.67 | - | | Course total | - | 156.67 | - | @javascript @@ -244,5 +244,5 @@ Feature: We can understand the gradebook user report | Test assignment four | 33.33 % | 10.00 | 2.00 % | | Test assignment five | 33.33 % | 70.00 | 14.00 % | | Test assignment six | 33.33 % | 30.00 | 6.00 % | - | Category total | 60.00 % | 110.00 | - | + | Sub category total | 60.00 % | 110.00 | - | | Course total | - | 230.00 | - | diff --git a/grade/tests/behat/grade_scales.feature b/grade/tests/behat/grade_scales.feature index c04f0f8f5a911..67e98f4134f5b 100644 --- a/grade/tests/behat/grade_scales.feature +++ b/grade/tests/behat/grade_scales.feature @@ -90,13 +90,13 @@ Feature: View gradebook when scales are used And the following should exist in the "user-grade" table: | Grade item | Grade | Range | Percentage | Contribution to course total | | Test assignment one | C | F–A | 50.00 % | 60.00 % | - | Category total | 3.00 | 0–5 | 60.00 % | - | + | Sub category 1 total | 3.00 | 0–5 | 60.00 % | - | | Course total | 3.00 | 0–5 | 60.00 % | - | And I set the field "jump" to "Categories and items" And the following should exist in the "grade_edit_tree_table" table: | Name | Max grade | | Test assignment one | 5.00 | - | Category total | 5.00 | + | Sub category 1 total | 5.00 | | Course total | 5.00 | And I log out And I log in as "student2" @@ -105,7 +105,7 @@ Feature: View gradebook when scales are used And the following should exist in the "user-grade" table: | Grade item | Grade | Range | Percentage | Contribution to course total | | Test assignment one | B | F–A | 75.00 % | 80.00 % | - | Category total | 4.00 | 0–5 | 80.00 % | - | + | Sub category 1 total | 4.00 | 0–5 | 80.00 % | - | | Course total | 4.00 | 0–5 | 80.00 % | - | @javascript @@ -138,13 +138,13 @@ Feature: View gradebook when scales are used And the following should exist in the "user-grade" table: | Grade item | Grade | Range | Percentage | Contribution to course total | | Test assignment one | C | F–A | 50.00 % | | - | Category total. | 3.00 | 1–5 | 50.00 % | - | + | Sub category () total. | 3.00 | 1–5 | 50.00 % | - | | Course total. | | 0–100 | | - | And I set the field "jump" to "Categories and items" And the following should exist in the "grade_edit_tree_table" table: | Name | Max grade | | Test assignment one | A (5) | - | Category total. | | + | Sub category () total. | | | Course total. | | And I log out And I log in as "student2" @@ -153,7 +153,7 @@ Feature: View gradebook when scales are used And the following should exist in the "user-grade" table: | Grade item | Grade | Range | Percentage | Contribution to course total | | Test assignment one | B | F–A | 75.00 % | | - | Category total. | 4.00 | 1–5 | 75.00 % | - | + | Sub category () total. | 4.00 | 1–5 | 75.00 % | - | | Course total. | | 0–100 | | - | Examples: diff --git a/grade/tests/behat/grade_single_item_scales.feature b/grade/tests/behat/grade_single_item_scales.feature index 5a83d48565e01..200b2098ba2f9 100644 --- a/grade/tests/behat/grade_single_item_scales.feature +++ b/grade/tests/behat/grade_single_item_scales.feature @@ -71,19 +71,19 @@ Feature: View gradebook when single item scales are used And the following should exist in the "user-grade" table: | Grade item | Grade | Range | Contribution to course total | | Test assignment one | Ace! | Ace!–Ace! | 100.00 % | - | Category total | 1.00 | 0–1 | - | + | Sub category 1 total | 1.00 | 0–1 | - | | Course total | 1.00 | 0–1 | - | And I set the field "Select all or one user" to "Student 2" And the following should exist in the "user-grade" table: | Grade item | Grade | Range | Contribution to course total | | Test assignment one | - | Ace!–Ace! | - | - | Category total | - | 0–1 | - | + | Sub category 1 total | - | 0–1 | - | | Course total | - | 0–1 | - | And I set the field "jump" to "Categories and items" And the following should exist in the "grade_edit_tree_table" table: | Name | Max grade | | Test assignment one | 1.00 | - | Category total | 1.00 | + | Sub category 1 total | 1.00 | | Course total | 1.00 | @javascript @@ -113,13 +113,13 @@ Feature: View gradebook when single item scales are used And the following should exist in the "user-grade" table: | Grade item | Grade | Range | Contribution to course total | | Test assignment one | Ace! | Ace!–Ace! | | - | Category total. | | 0–100 | - | + | Sub category () total. | | 0–100 | - | | Course total. | | 0–100 | - | And I set the field "jump" to "Categories and items" And the following should exist in the "grade_edit_tree_table" table: | Name | Max grade | | Test assignment one | Ace! (1) | - | Category total. | 100.00 | + | Sub category () total. | 100.00 | | Course total. | 100.00 | Examples: