Merge branch 'MDL-36255-master' of https://github.com/lucaboesch/moodle

This commit is contained in:
Jake Dallimore 2018-08-21 16:04:17 +08:00
commit 805ce3de79
14 changed files with 226 additions and 182 deletions

View File

@ -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;

View File

@ -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');

View File

@ -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 | <span lang="en" class="multilang">EN</span><span lang="fr" class="multilang">FR</span> Test assignment one | Submit something! |
| assign | C1 | a2 | <span lang="en" class="multilang">EN</span><span lang="fr" class="multilang">FR</span> Test assignment two | Submit something! |
| assign | C1 | a3 | <span lang="en" class="multilang">EN</span><span lang="fr" class="multilang">FR</span> Test assignment three | Submit something! |
| assign | C1 | a4 | <span lang="en" class="multilang">EN</span><span lang="fr" class="multilang">FR</span> Test assignment four | Submit something! |
| assign | C1 | a5 | <span lang="en" class="multilang">EN</span><span lang="fr" class="multilang">FR</span> Test assignment five | Submit something! |
| assign | C1 | a6 | <span lang="en" class="multilang">EN</span><span lang="fr" class="multilang">FR</span> 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 "<span lang=\"en\" class=\"multilang\">EN</span><span lang=\"fr\" class=\"multilang\">FR</span> 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 | - |

View File

@ -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 "Grades > Scales" in site administration
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 |
@ -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."

View File

@ -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 |
| <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"
@ -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 "Grades > Report settings > Overview report" in site administration
And I set the field "s__grade_report_overview_showtotalsifcontainhidden" to "Show totals excluding hidden items"
And I navigate to "Grades > Report settings > User report" in site administration

View File

@ -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 "Grades > Scales" in site administration
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."

View File

@ -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 |
| <span lang="en" class="multilang">EN</span><span lang="fr" class="multilang">FR</span> 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! | <span lang="en" class="multilang">EN</span><span lang="fr" class="multilang">FR</span> Sub category 1 | 20 |
| assign | C1 | a6 | Test assignment six | Submit something! | <span lang="en" class="multilang">EN</span><span lang="fr" class="multilang">FR</span> Sub category 1 | 10 |
| assign | C1 | a7 | Test assignment seven | Submit nothing! | <span lang="en" class="multilang">EN</span><span lang="fr" class="multilang">FR</span> 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"

View File

@ -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 "Grades > Scales" in site administration
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 | <span lang="en" class="multilang">EN</span><span lang="fr" class="multilang">FR</span> 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"

View File

@ -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 "Grades > Scales" in site administration
And I press "Add a new scale"
And I set the following fields to these values:
| Name | Singleitem |
| Scale | Ace! |
| Name | <span lang="en" class="multilang">EN</span><span lang="fr" class="multilang">FR</span> 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 |
| <span lang="en" class="multilang">EN</span><span lang="fr" class="multilang">FR</span> 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! | <span lang="en" class="multilang">EN</span><span lang="fr" class="multilang">FR</span> 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 | 01 | - |
| Course total | 1.00 | 01 | - |
| Grade item | Grade | Range | Contribution to course total |
| Test assignment one | Ace! | Ace!Ace! | 100.00 % |
| EN Sub category 1 total| 1.00 | 01 | - |
| Course total | 1.00 | 01 | - |
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| - | 01 | - |
| Course total | - | 01 | - |
| Grade item | Grade | Range | Contribution to course total |
| Test assignment one | - | Ace!Ace! | - |
| EN Sub category 1 total| - | 01 | - |
| Course total | - | 01 | - |
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 "<aggregation>"
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 | <aggregation> |
| Category name | Sub category (<aggregation>) |

View File

@ -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;
}
/**

View File

@ -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)));
}
}

View File

@ -231,7 +231,6 @@ abstract class grade_object {
$result[$instance->id] = $instance;
}
$rs->close();
return $result;
}

View File

@ -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)));
}
/**

View File

@ -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_name>(?:[^"]|\\")*)" 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);
}
}
}