1@core @core_grades
2Feature: Control the aggregation of the scales
3  In order to use control the aggregation of the scales
4  As an admin
5  I can change use administration setting
6
7  Background:
8    Given the following "courses" exist:
9      | fullname | shortname |
10      | Course 1 | C1        |
11    And the following "users" exist:
12      | username | firstname | lastname | email            | idnumber |
13      | teacher1 | Teacher   | 1        | teacher1@example.com | t1       |
14      | student1 | Student   | 1        | student1@example.com | s1       |
15    And the following "course enrolments" exist:
16      | user     | course | role           |
17      | teacher1 | C1     | editingteacher |
18      | student1 | C1     | student        |
19    And I log in as "admin"
20    And I set the following administration settings values:
21      | 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 |
22      | grade_report_user_showcontributiontocoursetotal | 1 |
23    And I navigate to "Grades > Scales" in site administration
24    And I press "Add a new scale"
25    And I set the following fields to these values:
26      | Name  | Letterscale |
27      | Scale | F,D,C,B,A   |
28    And I press "Save changes"
29    And the following "grade items" exist:
30      | itemname | course |
31      | Grade me | C1     |
32    And the following "grade items" exist:
33      | itemname | course | scale       |
34      | Scale me | C1     | Letterscale |
35    And the following config values are set as admin:
36      | grade_includescalesinaggregation | 0 |
37    And I log out
38
39  Scenario Outline: Scales can be excluded from aggregation
40    Given I log in as "teacher1"
41    And I am on "Course 1" course homepage
42    And I navigate to "View > Grader report" in the course gradebook
43    And I turn editing mode on
44    When I give the grade "10" to the user "Student 1" for the grade item "Grade me"
45    And I give the grade "B" to the user "Student 1" for the grade item "Scale me"
46    And I press "Save changes"
47    And I set the following settings for grade item "Course 1":
48      | Aggregation | <aggregation> |
49    And I navigate to "View > User report" in the course gradebook
50    And I select "Student 1" from the "Select all or one user" singleselect
51    Then the following should exist in the "user-grade" table:
52      | Grade item             | Grade          | Percentage  | Contribution to course total |
53      | Grade me               | 10.00          | 10.00 %     | <gradecontrib>               |
54      | Scale me               | B              | 75.00 %     | <scalecontrib>               |
55      | Course total<totalstr> | <coursetotal>  | <coursepc>  | -                            |
56    And I log out
57    And I log in as "admin"
58    And I set the following administration settings values:
59      | grade_includescalesinaggregation | 1 |
60    And I log out
61    And I log in as "teacher1"
62    And I am on "Course 1" course homepage
63    And I navigate to "View > User report" in the course gradebook
64    And I select "Student 1" from the "Select all or one user" singleselect
65    And the following should exist in the "user-grade" table:
66      | Grade item             | Grade          | Percentage  | Contribution to course total |
67      | Grade me               | 10.00          | 10.00 %     | <gradecontrib2>              |
68      | Scale me               | B              | 75.00 %     | <scalecontrib2>              |
69      | Course total<totalstr> | <coursetotal2> | <coursepc2> | -                            |
70
71    Examples:
72      | aggregation                         | totalstr                             | coursetotal | coursepc | gradecontrib | scalecontrib | coursetotal2 | coursepc2 | gradecontrib2 | scalecontrib2 |
73      | Natural                             |                                      | 10.00       | 10.00 %  | 10.00        | 0.00         | 14.00        | 13.33 %   | 9.52 %        | 3.81 %        |
74      | Mean of grades                      | Mean of grades.                      | 10.00       | 10.00 %  | 10.00        | 0.00         | 42.50        | 42.50 %   | 5.00 %        | 37.50 %       |
75      | Weighted mean of grades             | Weighted mean of grades.             | 10.00       | 10.00 %  | 10.00        | 0.00         | 42.50        | 42.50 %   | 5.00 %        | 37.50 %       |
76      | Simple weighted mean of grades      | Simple weighted mean of grades.      | 10.00       | 10.00 %  | 10.00        | 0.00         | 12.50        | 12.50 %   | 9.62 %        | 2.88 %        |
77      | Mean of grades (with extra credits) | Mean of grades (with extra credits). | 10.00       | 10.00 %  | 10.00        | 0.00         | 42.50        | 42.50 %   | 5.00 %        | 37.50 %       |
78      | Median of grades                    | Median of grades.                    | 10.00       | 10.00 %  | 10.00        | 0.00         | 42.50        | 42.50 %   | 5.00 %        | 37.50 %       |
79      | Lowest grade                        | Lowest grade.                        | 10.00       | 10.00 %  | 10.00        | 0.00         | 10.00        | 10.00 %   | 10.00 %       | 0.00 %        |
80      | Highest grade                       | Highest grade.                       | 10.00       | 10.00 %  | 10.00        | 0.00         | 75.00        | 75.00 %   | 0.00 %        | 75.00 %       |
81      | Mode of grades                      | Mode of grades.                      | 10.00       | 10.00 %  | 10.00        | 0.00         | 75.00        | 75.00 %   | 0.00 %        | 75.00 %       |
82
83  @javascript
84  Scenario: Weights of scales cannot be edited when they are not aggregated
85    Given I log in as "teacher1"
86    And I am on "Course 1" course homepage
87    And I navigate to "View > Grader report" in the course gradebook
88    And I turn editing mode on
89    When I set the following settings for grade item "Course 1":
90      | Aggregation | Natural |
91    And I navigate to "Setup > Gradebook setup" in the course gradebook
92    And I set the field "Override weight of Grade me" to "1"
93    Then the field "Override weight of Grade me" matches value "100.00"
94    And I open the action menu in "Scale me" "table_row"
95    And I click on "Edit settings" "link" in the "Scale me" "table_row"
96    And I follow "Show more..."
97    And I should not see "Weight adjusted"
98    And I should not see "Weight"
99    And the following config values are set as admin:
100      | grade_includescalesinaggregation | 1 |
101    And I am on "Course 1" course homepage
102    And I navigate to "Setup > Gradebook setup" in the course gradebook
103    And I set the field "Override weight of Grade me" to "1"
104    And the field "Override weight of Grade me" matches value "95.238"
105    And I set the field "Override weight of Scale me" to "1"
106    And the field "Override weight of Scale me" matches value "4.8"
107    And I open the action menu in "Scale me" "table_row"
108    And I click on "Edit settings" "link" in the "Scale me" "table_row"
109    And I follow "Show more..."
110    And I should see "Weight adjusted"
111    And I should see "Weight"
112