diff --git a/grade/edit/tree/lib.php b/grade/edit/tree/lib.php index bd4a0c82f82..fe7c1323a88 100644 --- a/grade/edit/tree/lib.php +++ b/grade/edit/tree/lib.php @@ -113,7 +113,8 @@ class grade_edit_tree { $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; diff --git a/grade/report/history/index.php b/grade/report/history/index.php index 9c62a713b2e..127e106aadf 100644 --- a/grade/report/history/index.php +++ b/grade/report/history/index.php @@ -51,6 +51,9 @@ $USER->grade_last_report[$course->id] = 'history'; $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'); diff --git a/grade/tests/behat/grade_calculated_weights.feature b/grade/tests/behat/grade_calculated_weights.feature index 88b20c35f96..6d5826819d5 100644 --- a/grade/tests/behat/grade_calculated_weights.feature +++ b/grade/tests/behat/grade_calculated_weights.feature @@ -18,12 +18,14 @@ Feature: We can understand the gradebook user report | student1 | C1 | student | And the following "activities" exist: | activity | course | idnumber | name | intro | - | assign | C1 | a1 | Test assignment one | Submit something! | - | assign | C1 | a2 | Test assignment two | Submit something! | - | assign | C1 | a3 | Test assignment three | Submit something! | - | assign | C1 | a4 | Test assignment four | Submit something! | - | assign | C1 | a5 | Test assignment five | Submit something! | - | assign | C1 | a6 | Test assignment six | Submit something! | + | assign | C1 | a1 | ENFR Test assignment one | Submit something! | + | assign | C1 | a2 | ENFR Test assignment two | Submit something! | + | assign | C1 | a3 | ENFR Test assignment three | Submit something! | + | assign | C1 | a4 | ENFR Test assignment four | Submit something! | + | assign | C1 | a5 | ENFR Test assignment five | Submit something! | + | assign | C1 | a6 | ENFR Test assignment six | Submit something! | + And the "multilang" filter is "on" + And the "multilang" filter applies to "content and headings" And I log in as "admin" 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 | @@ -32,12 +34,12 @@ Feature: We can understand the gradebook user report And I am on "Course 1" course homepage And I navigate to "View > Grader report" in the course gradebook And I turn editing mode on - And I give the grade "60.00" to the user "Student 1" for the grade item "Test assignment one" - And I give the grade "20.00" to the user "Student 1" for the grade item "Test assignment two" - And I give the grade "40.00" to the user "Student 1" for the grade item "Test assignment three" - And I give the grade "10.00" to the user "Student 1" for the grade item "Test assignment four" - And I give the grade "70.00" to the user "Student 1" for the grade item "Test assignment five" - And I give the grade "30.00" to the user "Student 1" for the grade item "Test assignment six" + And I give the grade "60.00" to the user "Student 1" for the grade item "EN Test assignment one" + And I give the grade "20.00" to the user "Student 1" for the grade item "EN Test assignment two" + And I give the grade "40.00" to the user "Student 1" for the grade item "EN Test assignment three" + And I give the grade "10.00" to the user "Student 1" for the grade item "EN Test assignment four" + And I give the grade "70.00" to the user "Student 1" for the grade item "EN Test assignment five" + And I give the grade "30.00" to the user "Student 1" for the grade item "EN Test assignment six" And I press "Save changes" And I navigate to "Setup > Course grade settings" in the course gradebook And I set the field "Show weightings" to "Show" @@ -45,14 +47,14 @@ Feature: We can understand the gradebook user report And I press "Save changes" And I navigate to "Setup > Gradebook setup" in the course gradebook And I press "Add category" - And I set the field "Category name" to "Sub category" + And I set the field "Category name" to "ENFR Sub category" And I press "Save changes" - And I click on "Move" "link" in the "Test assignment six" "table_row" + And I click on "Move" "link" in the "EN Test assignment six" "table_row" # This xpath finds the forth last row in the table. And I click on "Move to here" "link" in the "//tbody//tr[position()=last()-3]" "xpath_element" - And I click on "Move" "link" in the "Test assignment five" "table_row" + And I click on "Move" "link" in the "EN Test assignment five" "table_row" And I click on "Move to here" "link" in the "//tbody//tr[position()=last()-3]" "xpath_element" - And I click on "Move" "link" in the "Test assignment four" "table_row" + And I click on "Move" "link" in the "EN Test assignment four" "table_row" And I click on "Move to here" "link" in the "//tbody//tr[position()=last()-3]" "xpath_element" @javascript @@ -65,24 +67,24 @@ Feature: We can understand the gradebook user report # Check the values in the weights column. Then the following should exist in the "user-grade" table: | Grade item | Calculated weight | Grade | Contribution to course total | - | Test assignment one | 25.00 % | 60.00 | 15.00 % | - | Test assignment two | 25.00 % | 20.00 | 5.00 % | - | Test assignment three | 25.00 % | 40.00 | 10.00 % | - | Test assignment four | 33.33 % | 10.00 | 0.83 % | - | Test assignment five | 33.33 % | 70.00 | 5.83 % | - | Test assignment six | 33.33 % | 30.00 | 2.50 % | + | EN Test assignment one | 25.00 % | 60.00 | 15.00 % | + | EN Test assignment two | 25.00 % | 20.00 | 5.00 % | + | EN Test assignment three | 25.00 % | 40.00 | 10.00 % | + | EN Test assignment four | 33.33 % | 10.00 | 0.83 % | + | EN Test assignment five | 33.33 % | 70.00 | 5.83 % | + | EN Test assignment six | 33.33 % | 30.00 | 2.50 % | @javascript Scenario: Weighted mean of grades aggregation And I set the following settings for grade item "Course 1": | Aggregation | Weighted mean of grades | - And I set the following settings for grade item "Test assignment one": + And I set the following settings for grade item "EN Test assignment one": | Item weight | 2.0 | - And I set the following settings for grade item "Test assignment two": + And I set the following settings for grade item "EN Test assignment two": | Item weight | 1.0 | - And I set the following settings for grade item "Test assignment three": + And I set the following settings for grade item "EN Test assignment three": | Item weight | 1.0 | - And I set the following settings for grade item "Sub category": + And I set the following settings for grade item "EN Sub category": | Item weight | 1.0 | And I navigate to "View > User report" in the course gradebook And I set the field "Select all or one user" to "Student 1" @@ -90,20 +92,20 @@ Feature: We can understand the gradebook user report # Check the values in the weights column. Then the following should exist in the "user-grade" table: | Grade item | Calculated weight | Grade | Contribution to course total | - | Test assignment one | 40.00 % | 60.00 | 24.00 % | - | Test assignment two | 20.00 % | 20.00 | 4.00 % | - | Test assignment three | 20.00 % | 40.00 | 8.00 % | - | Test assignment four | 33.33 % | 10.00 | 0.67 % | - | Test assignment five | 33.33 % | 70.00 | 4.67 % | - | Test assignment six | 33.33 % | 30.00 | 2.00 % | + | EN Test assignment one | 40.00 % | 60.00 | 24.00 % | + | EN Test assignment two | 20.00 % | 20.00 | 4.00 % | + | EN Test assignment three | 20.00 % | 40.00 | 8.00 % | + | EN Test assignment four | 33.33 % | 10.00 | 0.67 % | + | EN Test assignment five | 33.33 % | 70.00 | 4.67 % | + | EN Test assignment six | 33.33 % | 30.00 | 2.00 % | @javascript Scenario: Simple weighted mean of grades aggregation And I set the following settings for grade item "Course 1": | Aggregation | Simple weighted mean of grades | - And I set the following settings for grade item "Sub category": + And I set the following settings for grade item "EN Sub category": | Aggregation | Simple weighted mean of grades | - And I set the following settings for grade item "Test assignment three": + And I set the following settings for grade item "EN Test assignment three": | Extra credit | 1 | And I navigate to "View > User report" in the course gradebook And I set the field "Select all or one user" to "Student 1" @@ -111,18 +113,18 @@ Feature: We can understand the gradebook user report # Check the values in the weights column. Then the following should exist in the "user-grade" table: | Grade item | Calculated weight | Grade | Contribution to course total | - | Test assignment one | 33.33 % | 60.00 | 20.00 % | - | Test assignment two | 33.33 % | 20.00 | 6.67 % | - | Test assignment three | 33.33 %( Extra credit ) | 40.00 | 13.33 % | - | 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 % | + | EN Test assignment one | 33.33 % | 60.00 | 20.00 % | + | EN Test assignment two | 33.33 % | 20.00 | 6.67 % | + | EN Test assignment three | 33.33 %( Extra credit ) | 40.00 | 13.33 % | + | EN Test assignment four | 33.33 % | 10.00 | 1.11 % | + | EN Test assignment five | 33.33 % | 70.00 | 7.78 % | + | EN Test assignment six | 33.33 % | 30.00 | 3.33 % | @javascript Scenario: Mean of grades (with extra credits) aggregation And I set the following settings for grade item "Course 1": | Aggregation | Mean of grades (with extra credits) | - And I set the following settings for grade item "Test assignment three": + And I set the following settings for grade item "EN Test assignment three": | Extra credit weight | 1.0 | And I navigate to "View > User report" in the course gradebook And I set the field "Select all or one user" to "Student 1" @@ -130,12 +132,12 @@ Feature: We can understand the gradebook user report # Check the values in the weights column. Then the following should exist in the "user-grade" table: | Grade item | Calculated weight | Grade | Contribution to course total | - | Test assignment one | 33.33 % | 60.00 | 20.00 % | - | Test assignment two | 33.33 % | 20.00 | 6.67 % | - | Test assignment three | 33.33 %( Extra credit ) | 40.00 | 13.33 % | - | 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 % | + | EN Test assignment one | 33.33 % | 60.00 | 20.00 % | + | EN Test assignment two | 33.33 % | 20.00 | 6.67 % | + | EN Test assignment three | 33.33 %( Extra credit ) | 40.00 | 13.33 % | + | EN Test assignment four | 33.33 % | 10.00 | 1.11 % | + | EN Test assignment five | 33.33 % | 70.00 | 7.78 % | + | EN Test assignment six | 33.33 % | 30.00 | 3.33 % | @javascript Scenario: Median of grades aggregation @@ -147,12 +149,12 @@ Feature: We can understand the gradebook user report # Check the values in the weights column. Then the following should exist in the "user-grade" table: | Grade item | Calculated weight | Grade | Contribution to course total | - | Test assignment one | 0.00 % | 60.00 | 0.00 % | - | Test assignment two | 0.00 % | 20.00 | 0.00 % | - | Test assignment three | 50.00 % | 40.00 | 20.00 % | - | Test assignment four | 33.33 % | 10.00 | 1.67 % | - | Test assignment five | 33.33 % | 70.00 | 11.67 % | - | Test assignment six | 33.33 % | 30.00 | 5.00 % | + | EN Test assignment one | 0.00 % | 60.00 | 0.00 % | + | EN Test assignment two | 0.00 % | 20.00 | 0.00 % | + | EN Test assignment three | 50.00 % | 40.00 | 20.00 % | + | EN Test assignment four | 33.33 % | 10.00 | 1.67 % | + | EN Test assignment five | 33.33 % | 70.00 | 11.67 % | + | EN Test assignment six | 33.33 % | 30.00 | 5.00 % | @javascript Scenario: Lowest grade aggregation @@ -164,12 +166,12 @@ Feature: We can understand the gradebook user report # Check the values in the weights column. Then the following should exist in the "user-grade" table: | Grade item | Calculated weight | Grade | Contribution to course total | - | Test assignment one | 0.00 % | 60.00 | 0.00 % | - | Test assignment two | 100.00 % | 20.00 | 20.00 % | - | Test assignment three | 0.00 % | 40.00 | 0.00 % | - | Test assignment four | 33.33 % | 10.00 | 0.00 % | - | Test assignment five | 33.33 % | 70.00 | 0.00 % | - | Test assignment six | 33.33 % | 30.00 | 0.00 % | + | EN Test assignment one | 0.00 % | 60.00 | 0.00 % | + | EN Test assignment two | 100.00 % | 20.00 | 20.00 % | + | EN Test assignment three | 0.00 % | 40.00 | 0.00 % | + | EN Test assignment four | 33.33 % | 10.00 | 0.00 % | + | EN Test assignment five | 33.33 % | 70.00 | 0.00 % | + | EN Test assignment six | 33.33 % | 30.00 | 0.00 % | @javascript Scenario: Highest grade aggregation @@ -181,12 +183,12 @@ Feature: We can understand the gradebook user report # Check the values in the weights column. Then the following should exist in the "user-grade" table: | Grade item | Calculated weight | Grade | Contribution to course total | - | Test assignment one | 100.00 % | 60.00 | 60.00 % | - | Test assignment two | 0.00 % | 20.00 | 0.00 % | - | Test assignment three | 0.00 % | 40.00 | 0.00 % | - | Test assignment four | 33.33 % | 10.00 | 0.00 % | - | Test assignment five | 33.33 % | 70.00 | 0.00 % | - | Test assignment six | 33.33 % | 30.00 | 0.00 % | + | EN Test assignment one | 100.00 % | 60.00 | 60.00 % | + | EN Test assignment two | 0.00 % | 20.00 | 0.00 % | + | EN Test assignment three | 0.00 % | 40.00 | 0.00 % | + | EN Test assignment four | 33.33 % | 10.00 | 0.00 % | + | EN Test assignment five | 33.33 % | 70.00 | 0.00 % | + | EN Test assignment six | 33.33 % | 30.00 | 0.00 % | @javascript Scenario: Mode of grades aggregation @@ -198,20 +200,20 @@ Feature: We can understand the gradebook user report # Check the values in the weights column. Then the following should exist in the "user-grade" table: | Grade item | Calculated weight | Grade | Contribution to course total | - | Test assignment one | 100.00 % | 60.00 | 60.00 % | - | Test assignment two | 0.00 % | 20.00 | 0.00 % | - | Test assignment three | 0.00 % | 40.00 | 0.00 % | - | Test assignment four | 33.33 % | 10.00 | 0.00 % | - | Test assignment five | 33.33 % | 70.00 | 0.00 % | - | Test assignment six | 33.33 % | 30.00 | 0.00 % | + | EN Test assignment one | 100.00 % | 60.00 | 60.00 % | + | EN Test assignment two | 0.00 % | 20.00 | 0.00 % | + | EN Test assignment three | 0.00 % | 40.00 | 0.00 % | + | EN Test assignment four | 33.33 % | 10.00 | 0.00 % | + | EN Test assignment five | 33.33 % | 70.00 | 0.00 % | + | EN Test assignment six | 33.33 % | 30.00 | 0.00 % | @javascript Scenario: View user report with mixed aggregation methods And I set the following settings for grade item "Course 1": | Aggregation | Natural | - And I set the following settings for grade item "Sub category": + And I set the following settings for grade item "EN Sub category": | Aggregation | Weighted mean of grades | - And I set the following settings for grade item "Test assignment three": + And I set the following settings for grade item "EN Test assignment three": | Extra credit | 1 | And I navigate to "View > User report" in the course gradebook And I set the field "Select all or one user" to "Student 1" @@ -219,18 +221,18 @@ Feature: We can understand the gradebook user report # Check the values in the weights column. Then the following should exist in the "user-grade" table: | Grade item | Calculated weight | Grade | Contribution to course total | - | Test assignment one | 33.33 % | 60.00 | 20.00 % | - | Test assignment two | 33.33 % | 20.00 | 6.67 % | - | Test assignment three | 33.33 %( Extra credit ) | 40.00 | 13.33 % | - | 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 % | - | Sub category totalWeighted mean of grades. | 33.33 % | 36.67 | - | + | EN Test assignment one | 33.33 % | 60.00 | 20.00 % | + | EN Test assignment two | 33.33 % | 20.00 | 6.67 % | + | EN Test assignment three | 33.33 %( Extra credit ) | 40.00 | 13.33 % | + | EN Test assignment four | 33.33 % | 10.00 | 1.11 % | + | EN Test assignment five | 33.33 % | 70.00 | 7.78 % | + | EN Test assignment six | 33.33 % | 30.00 | 3.33 % | + | EN Sub category totalWeighted mean of grades. | 33.33 % | 36.67 | - | | Course total | - | 156.67 | - | @javascript Scenario: View user report with natural aggregation - And I set the following settings for grade item "Test assignment three": + And I set the following settings for grade item "EN Test assignment three": | Extra credit | 1 | And I navigate to "View > User report" in the course gradebook And I set the field "Select all or one user" to "Student 1" @@ -238,11 +240,11 @@ Feature: We can understand the gradebook user report # Check the values in the weights column. Then the following should exist in the "user-grade" table: | Grade item | Calculated weight | Grade | Contribution to course total | - | Test assignment one | 20.00 % | 60.00 | 12.00 % | - | Test assignment two | 20.00 % | 20.00 | 4.00 % | - | Test assignment three | 20.00 %( Extra credit ) | 40.00 | 8.00 % | - | 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 % | - | Sub category total | 60.00 % | 110.00 | - | + | EN Test assignment one | 20.00 % | 60.00 | 12.00 % | + | EN Test assignment two | 20.00 % | 20.00 | 4.00 % | + | EN Test assignment three | 20.00 %( Extra credit ) | 40.00 | 8.00 % | + | EN Test assignment four | 33.33 % | 10.00 | 2.00 % | + | EN Test assignment five | 33.33 % | 70.00 | 14.00 % | + | EN Test assignment six | 33.33 % | 30.00 | 6.00 % | + | EN Sub category total | 60.00 % | 110.00 | - | | Course total | - | 230.00 | - | diff --git a/grade/tests/behat/grade_category_validation.feature b/grade/tests/behat/grade_category_validation.feature index ad270465406..12f5e3f56b6 100644 --- a/grade/tests/behat/grade_category_validation.feature +++ b/grade/tests/behat/grade_category_validation.feature @@ -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 | ENFR 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 | ENFR 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 | @@ -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 | ENFR 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 | ENFR 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 | ENFR 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." diff --git a/grade/tests/behat/grade_hidden_items.feature b/grade/tests/behat/grade_hidden_items.feature index e7616710eac..7df2f656624 100644 --- a/grade/tests/behat/grade_hidden_items.feature +++ b/grade/tests/behat/grade_hidden_items.feature @@ -18,15 +18,17 @@ 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 | + | ENFR Sub category 1 | C1 | + | ENFR 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! | ENFR Sub category 1 | 100 | + | assign | C1 | a2 | Test assignment two | Submit something! | ENFR Sub category 1 | 100 | + | assign | C1 | a3 | Test assignment three | Submit something! | ENFR Sub category 2 | 100 | + | assign | C1 | a4 | Test assignment four | Submit something! | ENFR 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" @@ -34,7 +36,7 @@ Feature: Student and teacher's view of aggregated grade items is consistent when | 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" diff --git a/grade/tests/behat/grade_item_validation.feature b/grade/tests/behat/grade_item_validation.feature index 4f3d6cb3663..67a63bc80b0 100644 --- a/grade/tests/behat/grade_item_validation.feature +++ b/grade/tests/behat/grade_item_validation.feature @@ -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 | ENFR 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 | ENFR 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 | ENFR 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." diff --git a/grade/tests/behat/grade_natural_normalisation.feature b/grade/tests/behat/grade_natural_normalisation.feature index 4706e101d1e..e45982bfc16 100644 --- a/grade/tests/behat/grade_natural_normalisation.feature +++ b/grade/tests/behat/grade_natural_normalisation.feature @@ -18,7 +18,7 @@ Feature: We can use natural aggregation and weights will be normalised to a tota | student1 | C1 | student | And the following "grade categories" exist: | fullname | course | - | Sub category 1 | C1 | + | ENFR Sub category 1 | C1 | And the following "activities" exist: | activity | course | idnumber | name | intro | grade | | assign | C1 | a1 | Test assignment one | Submit something! | 300 | @@ -27,9 +27,11 @@ Feature: We can use natural aggregation and weights will be normalised to a tota | assign | C1 | a4 | Test assignment four | Submit nothing! | 150 | And the following "activities" exist: | activity | course | idnumber | name | intro | gradecategory | grade | - | assign | C1 | a5 | Test assignment five | Submit something! | Sub category 1 | 20 | - | assign | C1 | a6 | Test assignment six | Submit something! | Sub category 1 | 10 | - | assign | C1 | a7 | Test assignment seven | Submit nothing! | Sub category 1 | 15 | + | assign | C1 | a5 | Test assignment five | Submit something! | ENFR Sub category 1 | 20 | + | assign | C1 | a6 | Test assignment six | Submit something! | ENFR Sub category 1 | 10 | + | assign | C1 | a7 | Test assignment seven | Submit nothing! | ENFR Sub category 1 | 15 | + And the "multilang" filter is "on" + And the "multilang" filter applies to "content and headings" And I log in as "teacher1" And I am on "Course 1" course homepage And I navigate to "Setup > Gradebook setup" in the course gradebook @@ -113,7 +115,7 @@ Feature: We can use natural aggregation and weights will be normalised to a tota And the field "Weight of Test assignment five" matches value "60.000" And the field "Weight of Test assignment six" matches value "40.000" And the field "Weight of Test assignment seven" matches value "50.0" - And I reset weights for grade category "Sub category 1" + And I reset weights for grade category "EN Sub category 1" And the field "Weight of Test assignment five" matches value "66.667" And the field "Weight of Test assignment six" matches value "33.333" And the field "Weight of Test assignment seven" matches value "50.0" @@ -133,7 +135,7 @@ Feature: We can use natural aggregation and weights will be normalised to a tota And the field "Weight of Test assignment five" matches value "54.545" And the field "Weight of Test assignment six" matches value "45.455" And the field "Weight of Test assignment seven" matches value "50.0" - And I reset weights for grade category "Sub category 1" + And I reset weights for grade category "EN Sub category 1" And the field "Weight of Test assignment five" matches value "66.667" And the field "Weight of Test assignment six" matches value "33.333" And the field "Weight of Test assignment seven" matches value "50.0" @@ -153,7 +155,7 @@ Feature: We can use natural aggregation and weights will be normalised to a tota And the field "Weight of Test assignment five" matches value "57.143" And the field "Weight of Test assignment six" matches value "42.857" And the field "Weight of Test assignment seven" matches value "50.0" - And I reset weights for grade category "Sub category 1" + And I reset weights for grade category "EN Sub category 1" And the field "Weight of Test assignment five" matches value "66.667" And the field "Weight of Test assignment six" matches value "33.333" And the field "Weight of Test assignment seven" matches value "50.0" @@ -171,7 +173,7 @@ Feature: We can use natural aggregation and weights will be normalised to a tota And the field "Weight of Test assignment five" matches value "40.00" And the field "Weight of Test assignment six" matches value "60.000" And the field "Weight of Test assignment seven" matches value "50.0" - And I reset weights for grade category "Sub category 1" + And I reset weights for grade category "EN Sub category 1" And the field "Weight of Test assignment five" matches value "66.667" And the field "Weight of Test assignment six" matches value "33.333" And the field "Weight of Test assignment seven" matches value "50.0" @@ -207,7 +209,7 @@ Feature: We can use natural aggregation and weights will be normalised to a tota And I set the field "Weight of Test assignment seven" to "105" And I press "Save changes" - And I reset weights for grade category "Sub category 1" + And I reset weights for grade category "EN Sub category 1" And the field "Weight of Test assignment five" matches value "66.667" And the field "Weight of Test assignment six" matches value "33.333" And the field "Weight of Test assignment seven" matches value "50.0" @@ -236,7 +238,7 @@ Feature: We can use natural aggregation and weights will be normalised to a tota And I set the field "Weight of Test assignment six" to "55" And I set the field "Weight of Test assignment seven" to "40" And I press "Save changes" - And I reset weights for grade category "Sub category 1" + And I reset weights for grade category "EN Sub category 1" Then the field "Weight of Test assignment five" matches value "80.0" And the field "Weight of Test assignment six" matches value "40.0" And the field "Weight of Test assignment seven" matches value "60.0" @@ -254,7 +256,7 @@ Feature: We can use natural aggregation and weights will be normalised to a tota And I press "Save changes" And the field "Weight of Test assignment six" matches value "0.0" And the field "Weight of Test assignment seven" matches value "100.0" - And I reset weights for grade category "Sub category 1" + And I reset weights for grade category "EN Sub category 1" And I set the field "Override weight of Test assignment five" to "1" And I set the field "Override weight of Test assignment six" to "1" And I set the field "Weight of Test assignment five" to "-10" diff --git a/grade/tests/behat/grade_scales.feature b/grade/tests/behat/grade_scales.feature index d673eabf7cb..6ff6027bacb 100644 --- a/grade/tests/behat/grade_scales.feature +++ b/grade/tests/behat/grade_scales.feature @@ -6,14 +6,16 @@ Feature: View gradebook when scales are used Background: Given I log in as "admin" + And the "multilang" filter is "on" + And the "multilang" filter applies to "content and headings" And I set the following administration settings values: | grade_report_showranges | 1 | | 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 | 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 | Letterscale | - | Scale | F,D,C,B,A | + | Name | ENFR Letterscale | + | Scale | F,D,C,B,A | And I press "Save changes" And I log out And the following "courses" exist: @@ -47,7 +49,7 @@ Feature: View gradebook when scales are used And I navigate to "Edit settings" in current page administration And I expand all fieldsets And I set the field "grade[modgrade_type]" to "Scale" - And I set the field "grade[modgrade_scale]" to "Letterscale" + And I set the field "grade[modgrade_scale]" to "EN Letterscale" And I press "Save and display" And I navigate to "View all submissions" in current page administration And I click on "Grade" "link" in the "Student 1" "table_row" diff --git a/grade/tests/behat/grade_single_item_scales.feature b/grade/tests/behat/grade_single_item_scales.feature index 1b319e328d0..87943c48f94 100644 --- a/grade/tests/behat/grade_single_item_scales.feature +++ b/grade/tests/behat/grade_single_item_scales.feature @@ -6,14 +6,16 @@ Feature: View gradebook when single item scales are used Background: Given I log in as "admin" + And the "multilang" filter is "on" + And the "multilang" filter applies to "content and headings" And I set the following administration settings values: | grade_report_showranges | 1 | | 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 | 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 | Singleitem | - | Scale | Ace! | + | Name | ENFR Singleitem | + | Scale | Ace! | And I press "Save changes" And I log out And the following "courses" exist: @@ -31,17 +33,19 @@ Feature: View gradebook when single item scales are used | student2 | C1 | student | And the following "grade categories" exist: | fullname | course | - | Sub category 1 | C1 | + | ENFR Sub category 1 | C1 | And the following "activities" exist: | activity | course | idnumber | name | intro | gradecategory | - | assign | C1 | a1 | Test assignment one | Submit something! | Sub category 1 | + | assign | C1 | a1 | Test assignment one | Submit something! | ENFR Sub category 1 | + And the "multilang" filter is "on" + And the "multilang" filter applies to "content and headings" And I log in as "teacher1" And I am on "Course 1" course homepage And I follow "Test assignment one" And I navigate to "Edit settings" in current page administration And I expand all fieldsets And I set the field "grade[modgrade_type]" to "Scale" - And I set the field "grade[modgrade_scale]" to "Singleitem" + And I set the field "grade[modgrade_scale]" to "EN Singleitem" And I press "Save and display" And I navigate to "View all submissions" in current page administration And I click on "Grade" "link" in the "Student 1" "table_row" @@ -68,28 +72,28 @@ Feature: View gradebook when single item scales are used And I navigate to "View > User report" in the course gradebook And I select "Student 1" from the "Select all or one user" singleselect 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 % | - | Sub category 1 total| 1.00 | 0–1 | - | - | Course total | 1.00 | 0–1 | - | + | Grade item | Grade | Range | Contribution to course total | + | Test assignment one | Ace! | Ace!–Ace! | 100.00 % | + | EN Sub category 1 total| 1.00 | 0–1 | - | + | Course total | 1.00 | 0–1 | - | And I select "Student 2" from the "Select all or one user" singleselect And the following should exist in the "user-grade" table: - | Grade item | Grade | Range | Contribution to course total | - | Test assignment one | - | Ace!–Ace! | - | - | Sub category 1 total| - | 0–1 | - | - | Course total | - | 0–1 | - | + | Grade item | Grade | Range | Contribution to course total | + | Test assignment one | - | Ace!–Ace! | - | + | EN Sub category 1 total| - | 0–1 | - | + | Course total | - | 0–1 | - | And I navigate to "Setup > Gradebook setup" in the course gradebook And the following should exist in the "grade_edit_tree_table" table: - | Name | Max grade | - | Test assignment one | 1.00 | - | Sub category 1 total| 1.00 | - | Course total | 1.00 | + | Name | Max grade | + | Test assignment one | 1.00 | + | EN Sub category 1 total| 1.00 | + | Course total | 1.00 | Scenario Outline: Test displaying single item scales in gradebook in all other aggregation methods When I follow "Edit Course 1" And I set the field "Aggregation" to "" And I press "Save changes" - And I follow "Edit Sub category 1" + And I follow "Edit EN Sub category 1" And I set the following fields to these values: | Aggregation | | | Category name | Sub category () | diff --git a/lib/datalib.php b/lib/datalib.php index 96b4dcd4e4a..8d8bfae9704 100644 --- a/lib/datalib.php +++ b/lib/datalib.php @@ -1177,8 +1177,12 @@ function get_scales_menu($courseid=0) { WHERE courseid = 0 or courseid = ? ORDER BY courseid ASC, name ASC"; $params = array($courseid); - - return $scales = $DB->get_records_sql_menu($sql, $params); + $scales = array(); + $results = $DB->get_records_sql_menu($sql, $params); + foreach ($results as $i => $scalename) { + $scales[$i] = format_string($scalename, false, array("context" => context_course::instance($courseid))); + } + return $scales; } /** diff --git a/lib/grade/grade_category.php b/lib/grade/grade_category.php index 768d834f351..9fc1abd7eb6 100644 --- a/lib/grade/grade_category.php +++ b/lib/grade/grade_category.php @@ -2309,10 +2309,10 @@ class grade_category extends grade_object { // For a course category, we return the course name if the fullname is set to '?' in the DB (empty in the category edit form) if (empty($this->parent) && $this->fullname == '?') { $course = $DB->get_record('course', array('id'=> $this->courseid)); - return format_string($course->fullname); + return format_string($course->fullname, false, array("context" => context_course::instance($this->courseid))); } else { - return $this->fullname; + return format_string($this->fullname, false, array("context" => context_course::instance($this->courseid))); } } diff --git a/lib/grade/grade_object.php b/lib/grade/grade_object.php index ca6b87b2abb..654228e622c 100644 --- a/lib/grade/grade_object.php +++ b/lib/grade/grade_object.php @@ -231,7 +231,6 @@ abstract class grade_object { $result[$instance->id] = $instance; } $rs->close(); - return $result; } diff --git a/lib/grade/grade_outcome.php b/lib/grade/grade_outcome.php index ffb47de5dd6..3ba3fab5342 100644 --- a/lib/grade/grade_outcome.php +++ b/lib/grade/grade_outcome.php @@ -276,7 +276,7 @@ class grade_outcome extends grade_object { * @return string name */ public function get_name() { - return format_string($this->fullname); + return format_string($this->fullname, false, array("context" => context_course::instance($this->courseid))); } /** diff --git a/lib/tests/behat/behat_filters.php b/lib/tests/behat/behat_filters.php index 2b066623468..dfc360b5ee3 100644 --- a/lib/tests/behat/behat_filters.php +++ b/lib/tests/behat/behat_filters.php @@ -64,4 +64,25 @@ class behat_filters extends behat_base { } filter_set_global_state($filtername, $state); } + + /** + * Set the global filter target. + * + * @Given /^the "(?P(?:[^"]|\\")*)" filter applies to "(content|content and headings)"$/ + * + * @param string $filtername the name of a filter, e.g. 'glossary'. + * @param string $filtertarget 'content' or 'content and headings'. + */ + public function the_filter_applies_to($filtername, $filtertarget) { + switch ($filtertarget) { + case 'content and headings': + filter_set_applies_to_strings($filtername, 1); + break; + case 'content': + filter_set_applies_to_strings($filtername, 0); + break; + default: + throw new coding_exception('Unknown filter target: ' . $filtertarget); + } + } }