on-demand release 4.2dev+
[moodle.git] / grade / report / singleview / tests / behat / singleview.feature
1 @core @core_grades @gradereport_singleview @javascript
2 Feature: We can use Single view
3   As a teacher
4   In order to view and edit grades
5   For users and activities for a course.
7   Background:
8     Given the following "courses" exist:
9       | fullname | shortname | category |
10       | Course 1 | C1 | 0 |
11     And the following "users" exist:
12       | username | firstname | lastname    | email                | idnumber | middlename | alternatename | firstnamephonetic | lastnamephonetic |
13       | teacher1 | Teacher   | 1           | teacher1@example.com | t1       |            | fred          |                   |                  |
14       | teacher2 | No edit   | 1           | teacher2@example.com | t2       |            | nick          |                   |                  |
15       | student1 | Grainne   | Beauchamp   | student1@example.com | s1       | Ann        | Jill          | Gronya            | Beecham          |
16       | student2 | Niamh     | Cholmondely | student2@example.com | s2       | Jane       | Nina          | Nee               | Chumlee          |
17       | student3 | Siobhan   | Desforges   | student3@example.com | s3       | Sarah      | Sev           | Shevon            | De-forjay        |
18       | student4 | Student   | 4           | student4@example.com | s4       |            | zac           |                   |                  |
19     And the following "scales" exist:
20       | name | scale |
21       | Test Scale | Disappointing, Good, Very good, Excellent |
22     And the following "grade items" exist:
23       | itemname | course | gradetype | scale |
24       | new grade item 1 | C1 | Scale | Test Scale |
25     And the following "scales" exist:
26       | name       | scale                                     |
27       | Test Scale | Disappointing, Good, Very good, Excellent |
28     And the following "course enrolments" exist:
29       | user | course | role |
30       | teacher1 | C1 | editingteacher |
31       | teacher2 | C1 | teacher |
32       | student1 | C1 | student |
33       | student2 | C1 | student |
34       | student3 | C1 | student |
35       | student4 | C1 | student |
36     And the following "grade categories" exist:
37       | fullname | course |
38       | Sub category 1 | C1|
39       | Sub category 2 | C1|
40     And the following "activities" exist:
41       | activity | course | idnumber | name | intro | grade |
42       | assign | C1 | a1 | Test assignment one | Submit something! | 300 |
43       | assign | C1 | a2 | Test assignment two | Submit something! | 100 |
44       | assign | C1 | a3 | Test assignment three | Submit something! | 150 |
45       | assign | C1 | a4 | Test assignment four | Submit nothing! | 150 |
46     And the following "grade items" exist:
47       | itemname | course | gradetype |
48       | Test grade item | C1 | Scale |
49     And the following "permission overrides" exist:
50       | capability                  | permission | role     | contextlevel  | reference |
51       | moodle/grade:edit           | Allow      | teacher  | Course        | C1        |
52       | gradereport/singleview:view | Allow      | teacher  | Course        | C1        |
53     And the following config values are set as admin:
54       | fullnamedisplay | firstnamephonetic,lastnamephonetic |
55       | alternativefullnameformat | middlename, alternatename, firstname, lastname |
56     And I log in as "teacher1"
57     And I am on "Course 1" course homepage
58     Given I navigate to "View > Grader report" in the course gradebook
60   Scenario: I can update grades, add feedback and exclude grades.
61     Given I navigate to "View > Single view" in the course gradebook
62     And I click on "Users" "link" in the ".page-toggler" "css_element"
63     And I click on "Student" in the "user" search widget
64     And I turn editing mode on
65     And I set the field "Override for Test assignment one" to "1"
66     When I set the following fields to these values:
67         | Grade for Test assignment one | 10.00 |
68         | Feedback for Test assignment one | test data |
69     And I set the field "Exclude for Test assignment four" to "1"
70     And I press "Save"
71     Then I should see "Grades were set for 2 items"
72     And the field "Exclude for Test assignment four" matches value "1"
73     And the field "Grade for Test assignment one" matches value "10.00"
74     And I set the following fields to these values:
75         | Test grade item | 45 |
76     And I press "Save"
77     Then I should see "Grades were set for 1 items"
78     And the field "Grade for Test grade item" matches value "45.00"
79     And the field "Grade for Course total" matches value "55.00"
80     And I open the action menu in "Test assignment three" "table_row"
81     And I choose "Show all grades" in the open action menu
82     And I click on "Override for Ann, Jill, Grainne, Beauchamp" "checkbox"
83     And I set the following fields to these values:
84         | Grade for Ann, Jill, Grainne, Beauchamp | 12.05 |
85         | Feedback for Ann, Jill, Grainne, Beauchamp | test data2 |
86     And I set the field "Exclude for Jane, Nina, Niamh, Cholmondely" to "1"
87     And I press "Save"
88     Then I should see "Grades were set for 2 items"
89     And the field "Grade for Ann, Jill, Grainne, Beauchamp" matches value "12.05"
90     And the field "Exclude for Jane, Nina, Niamh, Cholmondely" matches value "1"
91     And I click on "new grade item 1" in the "grade" search widget
92     And I set the field "Grade for Ann, Jill, Grainne, Beauchamp" to "Very good"
93     And I press "Save"
94     Then I should see "Grades were set for 1 items"
95     And the following should exist in the "generaltable" table:
96         | First name (Alternate name) Last name | Grade |
97         | Ann, Jill, Grainne, Beauchamp | Very good |
98     And I log out
99     And I log in as "teacher2"
100     And I am on "Course 1" course homepage
101     Given I navigate to "View > Single view" in the course gradebook
102     And I click on "Users" "link" in the ".page-toggler" "css_element"
103     And I click on "Student" in the "user" search widget
104     And I turn editing mode on
105     And the "Exclude for Test assignment one" "checkbox" should be disabled
106     And the "Override for Test assignment one" "checkbox" should be enabled
108   Scenario: Single view links work on grade report.
109     Given I click on grade item menu "Test assignment one" of type "gradeitem" on "grader" page
110     And I choose "Single view for this item" in the open action menu
111     And I should see "Test assignment one"
112     When I navigate to "View > Grader report" in the course gradebook
113     And I click on user menu "Grainne Beauchamp"
114     And I choose "Single view for this user" in the open action menu
115     Then I should see "Gronya,Beecham"
117   Scenario: I can bulk update grades.
118     Given I click on user menu "Grainne Beauchamp"
119     And I choose "Single view for this user" in the open action menu
120     And I should see "Gronya,Beecham"
121     When I turn editing mode on
122     And I click on "Actions" "link"
123     And I click on "Bulk insert" "link"
124     And I click on "I understand that my unsaved changes will be lost." "checkbox"
125     And I click on "All grades" "radio"
126     And I set the field "Insert new grade" to "1.0"
127     And I click on "Save" "button" in the ".modal-dialog" "css_element"
128     Then I should see "Grades were set for 6 items"
130   Scenario: I can bulk update grades with custom decimal separator
131     Given the following "language customisations" exist:
132       | component       | stringid | value |
133       | core_langconfig | decsep   | #     |
134     And I click on user menu "Grainne Beauchamp"
135     And I choose "Single view for this user" in the open action menu
136     And I should see "Gronya,Beecham"
137     When I turn editing mode on
138     And I click on "Actions" "link"
139     And I click on "Bulk insert" "link"
140     And I click on "I understand that my unsaved changes will be lost." "checkbox"
141     And I click on "All grades" "radio"
142     And I set the field "Insert new grade" to "1#25"
143     And I click on "Save" "button" in the ".modal-dialog" "css_element"
144     Then I should see "Grades were set for 6 items"
145     # Custom scale, cast to int
146     And the field "Grade for new grade item 1" matches value "Disappointing"
147     # Value grade, float with custom decsep.
148     And the field "Grade for Test assignment one" matches value "1#25"
149     # Numerical scale, cast to int, showing as float with custom decsep.
150     And the field "Grade for Test grade item" matches value "1#00"
152   Scenario: Navigation works in the Single view.
153     Given I click on user menu "Grainne Beauchamp"
154     And I choose "Single view for this user" in the open action menu
155     Then I should see "Gronya,Beecham"
156     And I follow "Nee,Chumlee"
157     Then I should see "Nee,Chumlee"
158     And I follow "Gronya,Beecham"
159     Then I should see "Gronya,Beecham"
160     And I open the action menu in "Test assignment four" "table_row"
161     And I choose "Show all grades" in the open action menu
162     Then I should see "Test assignment four"
163     And I follow "Test assignment three"
164     Then I should see "Test assignment three"
165     And I follow "Test assignment four"
166     Then I should see "Test assignment four"
168   Scenario: Activities are clickable only when it has a valid activity page.
169     Given I click on user menu "Grainne Beauchamp"
170     And I choose "Single view for this user" in the open action menu
171     And "new grade item 1" "link" should not exist in the "//tbody//tr[position()=1]//td[position()=2]" "xpath_element"
172     Then "Category total" "link" should not exist in the "//tbody//tr[position()=2]//td[position()=2]" "xpath_element"
173     And "Course total" "link" should not exist in the "//tbody//tr[position()=last()]//td[position()=2]" "xpath_element"