Merge branch 'MDL-63968-master' of git://github.com/andrewnicols/moodle
[moodle.git] / grade / tests / behat / grade_scales.feature
blob258217dace178168e31d68b168a2a0274599660b
1 @core @core_grades @javascript
2 Feature: View gradebook when scales are used
3   In order to use scales to grade activities
4   As an teacher
5   I need to be able to view gradebook with scales
7   Background:
8     Given I log in as "admin"
9     And the "multilang" filter is "on"
10     And the "multilang" filter applies to "content and headings"
11     And I set the following administration settings values:
12       | grade_report_showranges    | 1 |
13       | 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 |
14     And I navigate to "Grades > Scales" in site administration
15     And I press "Add a new scale"
16     And I set the following fields to these values:
17       | Name  | <span lang="en" class="multilang">EN</span><span lang="fr" class="multilang">FR</span> Letterscale |
18       | Scale | F,D,C,B,A                                                                                          |
19     And I press "Save changes"
20     And I log out
21     And the following "courses" exist:
22       | fullname | shortname |
23       | Course 1 | C1        |
24     And the following "users" exist:
25       | username | firstname | lastname | email            | idnumber |
26       | teacher1 | Teacher   | 1        | teacher1@example.com | t1       |
27       | student1 | Student   | 1        | student1@example.com | s1       |
28       | student2 | Student   | 2        | student2@example.com | s2       |
29       | student3 | Student   | 3        | student3@example.com | s3       |
30       | student4 | Student   | 4        | student4@example.com | s4       |
31       | student5 | Student   | 5        | student5@example.com | s5       |
32     And the following "course enrolments" exist:
33       | user     | course | role           |
34       | teacher1 | C1     | editingteacher |
35       | student1 | C1     | student        |
36       | student2 | C1     | student        |
37       | student3 | C1     | student        |
38       | student4 | C1     | student        |
39       | student5 | C1     | student        |
40     And the following "grade categories" exist:
41       | fullname       | course |
42       | Sub category 1 | C1     |
43     And the following "activities" exist:
44       | activity | course | idnumber | name                | intro             | gradecategory  |
45       | assign   | C1     | a1       | Test assignment one | Submit something! | Sub category 1 |
46     And I log in as "teacher1"
47     And I am on "Course 1" course homepage
48     And I follow "Test assignment one"
49     And I navigate to "Edit settings" in current page administration
50     And I expand all fieldsets
51     And I set the field "grade[modgrade_type]" to "Scale"
52     And I set the field "grade[modgrade_scale]" to "EN Letterscale"
53     And I press "Save and display"
54     And I navigate to "View all submissions" in current page administration
55     And I click on "Grade" "link" in the "Student 1" "table_row"
56     And I set the field "Grade" to "A"
57     And I press "Save changes"
58     And I press "Ok"
59     And I click on "[data-action=next-user]" "css_element"
60     And I set the field "Grade" to "B"
61     And I press "Save changes"
62     And I press "Ok"
63     And I click on "[data-action=next-user]" "css_element"
64     And I set the field "Grade" to "C"
65     And I press "Save changes"
66     And I press "Ok"
67     And I click on "[data-action=next-user]" "css_element"
68     And I set the field "Grade" to "D"
69     And I press "Save changes"
70     And I press "Ok"
71     And I click on "[data-action=next-user]" "css_element"
72     And I set the field "Grade" to "F"
73     And I press "Save changes"
74     And I press "Ok"
75     And I am on "Course 1" course homepage
76     And I navigate to "Setup > Course grade settings" in the course gradebook
77     And I set the field "Show weightings" to "Show"
78     And I set the field "Show contribution to course total" to "Show"
79     And I press "Save changes"
80     And I navigate to "View > Grader report" in the course gradebook
81     And I turn editing mode on
83   Scenario: Test displaying scales in gradebook in aggregation method Natural
84     When I turn editing mode off
85     Then the following should exist in the "user-grades" table:
86       | -1-                | -4-      | -5-            | -6-          |
87       | Student 1          | A        | 5.00           | 5.00         |
88       | Student 2          | B        | 4.00           | 4.00         |
89       | Student 3          | C        | 3.00           | 3.00         |
90       | Student 4          | D        | 2.00           | 2.00         |
91       | Student 5          | F        | 1.00           | 1.00         |
92     And the following should exist in the "user-grades" table:
93       | -1-                | -2-      | -3-            | -4-          |
94       | Range              | F–A      | 0.00–5.00      | 0.00–5.00    |
95       | Overall average    | C        | 3.00           | 3.00         |
96     And I navigate to "View > User report" in the course gradebook
97     And I select "Student 3" from the "Select all or one user" singleselect
98     And the following should exist in the "user-grade" table:
99       | Grade item          | Grade | Range | Percentage | Contribution to course total |
100       | Test assignment one | C     | F–A   | 50.00 %    | 60.00 %                      |
101       | Sub category 1 total      | 3.00  | 0–5   | 60.00 %    | -                            |
102       | Course total        | 3.00  | 0–5   | 60.00 %    | -                            |
103     And I navigate to "Setup > Gradebook setup" in the course gradebook
104     And the following should exist in the "grade_edit_tree_table" table:
105       | Name                | Max grade |
106       | Test assignment one | 5.00      |
107       | Sub category 1 total      | 5.00      |
108       | Course total        | 5.00      |
109     And I log out
110     And I log in as "student2"
111     And I follow "Grades" in the user menu
112     And I click on "Course 1" "link" in the "region-main" "region"
113     And the following should exist in the "user-grade" table:
114       | Grade item          | Grade | Range | Percentage | Contribution to course total |
115       | Test assignment one | B     | F–A   | 75.00 %    | 80.00 %                      |
116       | Sub category 1 total      | 4.00  | 0–5   | 80.00 %    | -                            |
117       | Course total        | 4.00  | 0–5   | 80.00 %    | -                            |
119   Scenario Outline: Test displaying scales in gradebook in all other aggregation methods
120     When I follow "Edit   Course 1"
121     And I set the field "Aggregation" to "<aggregation>"
122     And I press "Save changes"
123     And I follow "Edit   Sub category 1"
124     And I expand all fieldsets
125     And I set the field "Aggregation" to "<aggregation>"
126     And I set the field "Category name" to "Sub category (<aggregation>)"
127     And I set the field "Maximum grade" to "5"
128     And I set the field "Minimum grade" to "1"
129     And I press "Save changes"
130     And I turn editing mode off
131     Then the following should exist in the "user-grades" table:
132       | -1-                | -4-      | -5-            | -6-            |
133       | Student 1          | A        | 5.00           | <coursetotal1> |
134       | Student 2          | B        | 4.00           | <coursetotal2> |
135       | Student 3          | C        | 3.00           | <coursetotal3> |
136       | Student 4          | D        | 2.00           | <coursetotal4> |
137       | Student 5          | F        | 1.00           | <coursetotal5> |
138     And the following should exist in the "user-grades" table:
139       | -1-                | -2-      | -3-            | -4-            |
140       | Range              | F–A      | 1.00–5.00      | 0.00–100.00    |
141       | Overall average    | C        | 3.00           | <overallavg>   |
142     And I navigate to "View > User report" in the course gradebook
143     And I select "Student 3" from the "Select all or one user" singleselect
144     And the following should exist in the "user-grade" table:
145       | Grade item                   | Grade          | Range | Percentage    | Contribution to course total |
146       | Test assignment one          | C              | F–A   | 50.00 %       | <contrib3>                   |
147       | Sub category (<aggregation>) total<aggregation>. | 3.00           | 1–5   | 50.00 %       | -                            |
148       | Course total<aggregation>.   | <coursetotal3> | 0–100 | <courseperc3> | -                            |
149     And I navigate to "Setup > Gradebook setup" in the course gradebook
150     And the following should exist in the "grade_edit_tree_table" table:
151       | Name                | Max grade |
152       | Test assignment one | A (5)     |
153       | Sub category (<aggregation>) total<aggregation>. |           |
154       | Course total<aggregation>.   |           |
155     And I log out
156     And I log in as "student2"
157     And I follow "Grades" in the user menu
158     And I click on "Course 1" "link" in the "region-main" "region"
159     And the following should exist in the "user-grade" table:
160       | Grade item                   | Grade          | Range | Percentage    | Contribution to course total |
161       | Test assignment one          | B              | F–A   | 75.00 %       | <contrib2>                   |
162       | Sub category (<aggregation>) total<aggregation>. | 4.00           | 1–5   | 75.00 %       | -                            |
163       | Course total<aggregation>.   | <coursetotal2> | 0–100 | <courseperc2> | -                            |
165     Examples:
166       | aggregation                         | coursetotal1 | coursetotal2 | coursetotal3 | coursetotal4 | coursetotal5 |overallavg | courseperc2 | courseperc3 | contrib2 | contrib3 |
167       | Mean of grades                      | 100.00       | 75.00        | 50.00        | 25.00        | 0.00         | 50.00     | 75.00 %     | 50.00 %     | 75.00 %  | 50.00 %  |
168       | Weighted mean of grades             | 100.00       | 75.00        | 50.00        | 25.00        | 0.00         | 50.00     | 75.00 %     | 50.00 %     | 75.00 %  | 50.00 %  |
169       | Simple weighted mean of grades      | 100.00       | 75.00        | 50.00        | 25.00        | 0.00         | 50.00     | 75.00 %     | 50.00 %     | 75.00 %  | 50.00 %  |
170       | Mean of grades (with extra credits) | 100.00       | 75.00        | 50.00        | 25.00        | 0.00         | 50.00     | 75.00 %     | 50.00 %     | 75.00 %  | 50.00 %  |
171       | Median of grades                    | 100.00       | 75.00        | 50.00        | 25.00        | 0.00         | 50.00     | 75.00 %     | 50.00 %     | 75.00 %  | 50.00 %  |
172       | Lowest grade                        | 100.00       | 75.00        | 50.00        | 25.00        | 0.00         | 50.00     | 75.00 %     | 50.00 %     | 75.00 %  | 50.00 %  |
173       | Highest grade                       | 100.00       | 75.00        | 50.00        | 25.00        | 0.00         | 50.00     | 75.00 %     | 50.00 %     | 75.00 %  | 50.00 %  |
174       | Mode of grades                      | 100.00       | 75.00        | 50.00        | 25.00        | 0.00         | 50.00     | 75.00 %     | 50.00 %     | 75.00 %  | 50.00 %  |