Skip to content

Commit

Permalink
MDL-36255 grades: allow multilang filters in grades
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaboesch committed Aug 20, 2018
1 parent a9428fa commit 8ad225b
Show file tree
Hide file tree
Showing 14 changed files with 226 additions and 182 deletions.
3 changes: 2 additions & 1 deletion grade/edit/tree/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ 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, true);
$object->name = format_string($this->gtree->get_element_header($element, true, true, true, true, true),
false, array("context" => context_course::instance($COURSE->id)));
$object->stripped_name = $this->gtree->get_element_header($element, false, false, false);

$is_category_item = false;
Expand Down
3 changes: 3 additions & 0 deletions grade/report/history/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@

$select = "itemtype <> 'course' AND courseid = :courseid AND " . $DB->sql_isnotempty('grade_items', 'itemname', true, true);
$itemids = $DB->get_records_select_menu('grade_items', $select, array('courseid' => $course->id), 'itemname ASC', 'id, itemname');
foreach ($itemids as $itemid => $itemname) {
$itemids[$itemid] = format_string($itemname, false, array("context" => $context));
}
$itemids = array(0 => get_string('allgradeitems', 'gradereport_history')) + $itemids;

$output = $PAGE->get_renderer('gradereport_history');
Expand Down
178 changes: 90 additions & 88 deletions grade/tests/behat/grade_calculated_weights.feature

Large diffs are not rendered by default.

56 changes: 29 additions & 27 deletions grade/tests/behat/grade_category_validation.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,18 @@ Feature: Editing a grade item
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And I log in as "admin"
And the "multilang" filter is "on"
And the "multilang" filter applies to "content and headings"
And I navigate to "Scales" node in "Site administration > Grades"
And I press "Add a new scale"
And I set the following fields to these values:
| Name | ABCDEF |
| Scale | F,E,D,C,B,A |
| Name | <span lang="en" class="multilang">EN</span><span lang="fr" class="multilang">FR</span> ABCDEF |
| Scale | F,E,D,C,B,A |
And I press "Save changes"
And I press "Add a new scale"
And I set the following fields to these values:
| Name | Letter scale |
| Scale | Disappointing, Good, Very good, Excellent |
| Name | <span lang="en" class="multilang">EN</span><span lang="fr" class="multilang">FR</span> Letter scale |
| Scale | Disappointing, Good, Very good, Excellent |
And I press "Save changes"
And I set the following administration settings values:
| grade_aggregations_visible | Mean of grades,Weighted mean of grades,Simple weighted mean of grades,Mean of grades (with extra credits),Median of grades,Lowest grade,Highest grade,Mode of grades,Natural |
Expand All @@ -36,72 +38,72 @@ Feature: Editing a grade item
And I navigate to "Setup > Gradebook setup" in the course gradebook
And I press "Add category"
And I set the following fields to these values:
| Category name | Cat 1 |
| Aggregation | Highest grade |
| Category name | <span lang="en" class="multilang">EN</span><span lang="fr" class="multilang">FR</span> Cat 1 |
| Aggregation | Highest grade |
And I press "Save changes"
And I press "Add grade item"
And I set the following fields to these values:
| Item name | Item 1 |
| Grade category | Cat 1 |
| Item name | <span lang="en" class="multilang">EN</span><span lang="fr" class="multilang">FR</span> Item 1 |
| Grade category | EN Cat 1 |
And I press "Save changes"
And I press "Add grade item"
And I set the following fields to these values:
| Item name | Item 2 |
| Grade category | Cat 1 |
| Item name | <span lang="en" class="multilang">EN</span><span lang="fr" class="multilang">FR</span> Item 2 |
| Grade category | EN Cat 1 |
And I press "Save changes"

Scenario: Being able to change the grade type, scale and maximum grade for a grade category when there are no overridden grades
Given I click on "Edit" "link" in the "Cat 1" "table_row"
When I click on "Edit settings" "link" in the "Cat 1" "table_row"
And I click on "Edit" "link" in the "EN Cat 1" "table_row"
When I click on "Edit settings" "link" in the "EN Cat 1" "table_row"
Then I should not see "This category has associated grade items which have been overridden. Therefore some grades have already been awarded"
And I set the field "Grade type" to "Scale"
And I press "Save changes"
And I should see "Scale must be selected"
And I set the field "Scale" to "ABCDEF"
And I set the field "Scale" to "EN ABCDEF"
And I press "Save changes"
And I should not see "You cannot change the type, as grades already exist for this item"
And I click on "Edit" "link" in the "Cat 1" "table_row"
And I click on "Edit settings" "link" in the "Cat 1" "table_row"
And I click on "Edit" "link" in the "EN Cat 1" "table_row"
And I click on "Edit settings" "link" in the "EN Cat 1" "table_row"
And I should not see "This category has associated grade items which have been overridden. Therefore some grades have already been awarded"
And I set the field "Scale" to "Letter scale"
And I set the field "Scale" to "EN Letter scale"
And I press "Save changes"
And I should not see "You cannot change the scale, as grades already exist for this item"

Scenario: Attempting to change a category item's grade type when overridden grades already exist
Given I navigate to "View > Grader report" in the course gradebook
And I turn editing mode on
And I give the grade "20.00" to the user "Student 1" for the grade item "Cat 1 total"
And I give the grade "20.00" to the user "Student 1" for the grade item "EN Cat 1 total"
And I press "Save changes"
And I navigate to "Setup > Gradebook setup" in the course gradebook
And I click on "Edit" "link" in the "Cat 1" "table_row"
When I click on "Edit settings" "link" in the "Cat 1" "table_row"
And I click on "Edit" "link" in the "EN Cat 1" "table_row"
When I click on "Edit settings" "link" in the "EN Cat 1" "table_row"
Then I should see "This category has associated grade items which have been overridden. Therefore some grades have already been awarded, so the grade type cannot be changed. If you wish to change the maximum grade, you must first choose whether or not to rescale existing grades."
And "//div[contains(concat(' ', normalize-space(@class), ' '), 'felement') and contains(text(), 'Value')]" "xpath_element" should exist

Scenario: Attempting to change a category item's scale when overridden grades already exist
Given I click on "Edit" "link" in the "Cat 1" "table_row"
And I click on "Edit settings" "link" in the "Cat 1" "table_row"
Given I click on "Edit" "link" in the "EN Cat 1" "table_row"
And I click on "Edit settings" "link" in the "EN Cat 1" "table_row"
And I set the field "Grade type" to "Scale"
And I set the field "Scale" to "ABCDEF"
And I press "Save changes"
And I navigate to "View > Grader report" in the course gradebook
And I turn editing mode on
And I give the grade "C" to the user "Student 1" for the grade item "Cat 1 total"
And I give the grade "C" to the user "Student 1" for the grade item "EN Cat 1 total"
And I press "Save changes"
And I navigate to "Setup > Gradebook setup" in the course gradebook
And I click on "Edit" "link" in the "Cat 1" "table_row"
When I click on "Edit settings" "link" in the "Cat 1" "table_row"
And I click on "Edit" "link" in the "EN Cat 1" "table_row"
When I click on "Edit settings" "link" in the "EN Cat 1" "table_row"
Then I should see "This category has associated grade items which have been overridden. Therefore some grades have already been awarded, so the grade type and scale cannot be changed."
And "//div[contains(concat(' ', normalize-space(@class), ' '), 'felement') and contains(text(), 'ABCDEF')]" "xpath_element" should exist

Scenario: Attempting to change a category item's maximum grade when no rescaling option has been chosen
Given I navigate to "View > Grader report" in the course gradebook
And I turn editing mode on
And I give the grade "20.00" to the user "Student 1" for the grade item "Cat 1 total"
And I give the grade "20.00" to the user "Student 1" for the grade item "EN Cat 1 total"
And I press "Save changes"
And I navigate to "Setup > Gradebook setup" in the course gradebook
And I click on "Edit" "link" in the "Cat 1" "table_row"
And I click on "Edit settings" "link" in the "Cat 1" "table_row"
And I click on "Edit" "link" in the "EN Cat 1" "table_row"
And I click on "Edit settings" "link" in the "EN Cat 1" "table_row"
And I set the field "Maximum grade" to "50"
When I press "Save changes"
Then I should see "You must choose whether to rescale existing grades or not."
16 changes: 9 additions & 7 deletions grade/tests/behat/grade_hidden_items.feature
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,25 @@ Feature: Student and teacher's view of aggregated grade items is consistent when
| student1 | C1 | student |
And the following "grade categories" exist:
| fullname | course |
| Sub category 1 | C1 |
| Sub category 2 | C1 |
| <span lang="en" class="multilang">EN</span><span lang="fr" class="multilang">FR</span> Sub category 1 | C1 |
| <span lang="en" class="multilang">EN</span><span lang="fr" class="multilang">FR</span> Sub category 2 | C1 |
And the following "activities" exist:
| activity | course | idnumber | name | intro | gradecategory| grade |
| assign | C1 | a1 | Test assignment one | Submit something! | Sub category 1 | 100 |
| assign | C1 | a2 | Test assignment two | Submit something! | Sub category 1 | 100 |
| assign | C1 | a3 | Test assignment three | Submit something! | Sub category 2 | 100 |
| assign | C1 | a4 | Test assignment four | Submit something! | Sub category 2 | 100 |
| assign | C1 | a1 | Test assignment one | Submit something! | <span lang="en" class="multilang">EN</span><span lang="fr" class="multilang">FR</span> Sub category 1 | 100 |
| assign | C1 | a2 | Test assignment two | Submit something! | <span lang="en" class="multilang">EN</span><span lang="fr" class="multilang">FR</span> Sub category 1 | 100 |
| assign | C1 | a3 | Test assignment three | Submit something! | <span lang="en" class="multilang">EN</span><span lang="fr" class="multilang">FR</span> Sub category 2 | 100 |
| assign | C1 | a4 | Test assignment four | Submit something! | <span lang="en" class="multilang">EN</span><span lang="fr" class="multilang">FR</span> Sub category 2 | 100 |
And I log in as "admin"
And the "multilang" filter is "on"
And the "multilang" filter applies to "content and headings"
And I am on "Course 1" course homepage
And I navigate to "Setup > Gradebook setup" in the course gradebook
And I press "Add grade item"
And I set the following fields to these values:
| Item name | calculated |
And I press "Save changes"
And I set "=[[a4]]/2" calculation for grade item "calculated" with idnumbers:
| Sub category 1 | sub1 |
| EN Sub category 1 | sub1 |
And I navigate to "Overview report" node in "Site administration > Grades > Report settings"
And I set the field "s__grade_report_overview_showtotalsifcontainhidden" to "Show totals excluding hidden items"
And I navigate to "User report" node in "Site administration > Grades > Report settings"
Expand Down
44 changes: 23 additions & 21 deletions grade/tests/behat/grade_item_validation.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,76 +17,78 @@ Feature: Grade item validation
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And I log in as "admin"
And the "multilang" filter is "on"
And the "multilang" filter applies to "content and headings"
And I navigate to "Scales" node in "Site administration > Grades"
And I press "Add a new scale"
And I set the following fields to these values:
| Name | ABCDEF |
| Scale | F,E,D,C,B,A |
| Name | <span lang="en" class="multilang">EN</span><span lang="fr" class="multilang">FR</span> ABCDEF |
| Scale | F,E,D,C,B,A |
And I press "Save changes"
And I press "Add a new scale"
And I set the following fields to these values:
| Name | Letter scale |
| Scale | Disappointing, Good, Very good, Excellent |
| Name | <span lang="en" class="multilang">EN</span><span lang="fr" class="multilang">FR</span> Letter scale |
| Scale | Disappointing, Good, Very good, Excellent |
And I press "Save changes"
And I am on "Course 1" course homepage
And I navigate to "Setup > Gradebook setup" in the course gradebook
And I press "Add grade item"
And I set the following fields to these values:
| Item name | MI 1 |
| Item name | <span lang="en" class="multilang">EN</span><span lang="fr" class="multilang">FR</span> MI 1 |
And I press "Save changes"

Scenario: Being able to change the grade type, scale and maximum grade for a manual grade item when there are no grades
Given I click on "Edit" "link" in the "MI 1" "table_row"
When I click on "Edit settings" "link" in the "MI 1" "table_row"
Given I click on "Edit" "link" in the "EN MI 1" "table_row"
When I click on "Edit settings" "link" in the "EN MI 1" "table_row"
Then I should not see "Some grades have already been awarded, so the grade type"
And I set the field "Grade type" to "Scale"
And I press "Save changes"
And I should see "Scale must be selected"
And I set the field "Scale" to "ABCDEF"
And I set the field "Scale" to "EN ABCDEF"
And I press "Save changes"
And I should not see "You cannot change the type, as grades already exist for this item"
And I click on "Edit" "link" in the "MI 1" "table_row"
And I click on "Edit settings" "link" in the "MI 1" "table_row"
And I click on "Edit settings" "link" in the "EN MI 1" "table_row"
And I should not see "Some grades have already been awarded, so the grade type"
And I set the field "Scale" to "Letter scale"
And I set the field "Scale" to "EN Letter scale"
And I press "Save changes"
And I should not see "You cannot change the scale, as grades already exist for this item"

Scenario: Attempting to change a manual item's grade type when grades already exist
Given I navigate to "View > Grader report" in the course gradebook
And I turn editing mode on
And I give the grade "20.00" to the user "Student 1" for the grade item "MI 1"
And I give the grade "20.00" to the user "Student 1" for the grade item "EN MI 1"
And I press "Save changes"
And I navigate to "Setup > Gradebook setup" in the course gradebook
And I click on "Edit" "link" in the "MI 1" "table_row"
When I click on "Edit settings" "link" in the "MI 1" "table_row"
And I click on "Edit" "link" in the "EN MI 1" "table_row"
When I click on "Edit settings" "link" in the "EN MI 1" "table_row"
Then I should see "Some grades have already been awarded, so the grade type cannot be changed. If you wish to change the maximum grade, you must first choose whether or not to rescale existing grades."
And "//div[contains(concat(' ', normalize-space(@class), ' '), 'felement') and contains(text(), 'Value')]" "xpath_element" should exist

Scenario: Attempting to change a manual item's scale when grades already exist
Given I click on "Edit" "link" in the "MI 1" "table_row"
And I click on "Edit settings" "link" in the "MI 1" "table_row"
Given I click on "Edit" "link" in the "EN MI 1" "table_row"
And I click on "Edit settings" "link" in the "EN MI 1" "table_row"
And I set the field "Grade type" to "Scale"
And I set the field "Scale" to "ABCDEF"
And I set the field "Scale" to "EN ABCDEF"
And I press "Save changes"
And I navigate to "View > Grader report" in the course gradebook
And I turn editing mode on
And I give the grade "C" to the user "Student 1" for the grade item "MI 1"
And I give the grade "C" to the user "Student 1" for the grade item "EN MI 1"
And I press "Save changes"
And I navigate to "Setup > Gradebook setup" in the course gradebook
And I click on "Edit" "link" in the "MI 1" "table_row"
When I click on "Edit settings" "link" in the "MI 1" "table_row"
And I click on "Edit" "link" in the "EN MI 1" "table_row"
When I click on "Edit settings" "link" in the "EN MI 1" "table_row"
Then I should see "Some grades have already been awarded, so the grade type and scale cannot be changed."
And "//div[contains(concat(' ', normalize-space(@class), ' '), 'felement') and contains(text(), 'ABCDEF')]" "xpath_element" should exist

Scenario: Attempting to change a manual item's maximum grade when no rescaling option has been chosen
Given I navigate to "View > Grader report" in the course gradebook
And I turn editing mode on
And I give the grade "20.00" to the user "Student 1" for the grade item "MI 1"
And I give the grade "20.00" to the user "Student 1" for the grade item "EN MI 1"
And I press "Save changes"
And I navigate to "Setup > Gradebook setup" in the course gradebook
And I click on "Edit" "link" in the "MI 1" "table_row"
And I click on "Edit settings" "link" in the "MI 1" "table_row"
And I click on "Edit settings" "link" in the "EN MI 1" "table_row"
And I set the field "Maximum grade" to "50"
When I press "Save changes"
Then I should see "You must choose whether to rescale existing grades or not."
Loading

0 comments on commit 8ad225b

Please sign in to comment.