MDL-66178 user: filter course participants for users with no roles.
[moodle.git] / user / tests / behat / filter_participants.feature
CommitLineData
9651e491
JP
1@core @core_user
2Feature: Course participants can be filtered
3 In order to filter the list of course participants
4 As a user
5 I need to visit the course participants page and apply the appropriate filters
6
7 Background:
8 Given the following "courses" exist:
9 | fullname | shortname | groupmode |
10 | Course 1 | C1 | 1 |
11 | Course 2 | C2 | 0 |
5290d060 12 | Course 3 | C3 | 0 |
9651e491 13 And the following "users" exist:
e52856bc
JP
14 | username | firstname | lastname | email | idnumber | country | city | maildisplay |
15 | student1 | Student | 1 | student1@example.com | SID1 | | SCITY1 | 0 |
16 | student2 | Student | 2 | student2@example.com | SID2 | GB | SCITY2 | 1 |
17 | student3 | Student | 3 | student3@example.com | SID3 | AU | SCITY3 | 0 |
18 | student4 | Student | 4 | student4@example.com | SID4 | AT | SCITY4 | 0 |
19 | teacher1 | Teacher | 1 | teacher1@example.com | TID1 | US | TCITY1 | 0 |
9651e491
JP
20 And the following "course enrolments" exist:
21 | user | course | role | status | timeend |
22 | student1 | C1 | student | 0 | |
23 | student2 | C1 | student | 1 | |
24 | student3 | C1 | student | 0 | |
25 | student4 | C1 | student | 0 | ##yesterday## |
26 | student1 | C2 | student | 0 | |
27 | student2 | C2 | student | 0 | |
28 | student3 | C2 | student | 0 | |
5290d060
SA
29 | student1 | C3 | student | 0 | |
30 | student2 | C3 | student | 0 | |
31 | student3 | C3 | student | 0 | |
9651e491
JP
32 | teacher1 | C1 | editingteacher | 0 | |
33 | teacher1 | C2 | editingteacher | 0 | |
5290d060 34 | teacher1 | C3 | editingteacher | 0 | |
9651e491
JP
35 And the following "groups" exist:
36 | name | course | idnumber |
37 | Group 1 | C1 | G1 |
38 | Group 2 | C1 | G2 |
5290d060
SA
39 | Group A | C3 | GA |
40 | Group B | C3 | GB |
9651e491
JP
41 And the following "group members" exist:
42 | user | group |
43 | student2 | G1 |
44 | student2 | G2 |
45 | student3 | G2 |
5290d060
SA
46 | student1 | GA |
47 | student2 | GA |
48 | student2 | GB |
9651e491
JP
49
50 @javascript
51 Scenario: No filters applied
52 Given I log in as "teacher1"
53 And I am on "Course 1" course homepage
54 And I navigate to course participants
9651e491
JP
55 Then I should see "Student 1" in the "participants" "table"
56 And I should see "Student 2" in the "participants" "table"
57 And I should see "Student 3" in the "participants" "table"
58 And I should see "Teacher 1" in the "participants" "table"
59
60 @javascript
61 Scenario Outline: Filter users for a course
62 Given I log in as "teacher1"
63 And I am on "Course 1" course homepage
64 And I navigate to course participants
65 When I open the autocomplete suggestions list
66 And I click on "<filter1>" item in the autocomplete list
9651e491
JP
67 Then I should see "<expected1>" in the "participants" "table"
68 And I should see "<expected2>" in the "participants" "table"
69 And I should see "<expected3>" in the "participants" "table"
70 And I should not see "<notexpected1>" in the "participants" "table"
71 And I should not see "<notexpected2>" in the "participants" "table"
72 # Note the 'XX-IGNORE-XX' elements are for when there is less than 2 'not expected' items.
73 Examples:
74 | filter1 | expected1 | expected2 | expected3 | notexpected1 | notexpected2 |
5290d060 75 | Group: No group | Student 1 | Student 4 | Teacher 1 | Student 2 | Student 3 |
9651e491
JP
76 | Group: Group 1 | Student 2 | | | Student 1 | Student 3 |
77 | Group: Group 2 | Student 2 | Student 3 | | Student 1 | XX-IGNORE-XX |
78 | Role: Teacher | Teacher 1 | | | Student 1 | Student 2 |
79 | Status: Active | Teacher 1 | Student 1 | Student 3 | Student 2 | Student 4 |
80 | Status: Inactive | Student 2 | Student 4 | | Teacher 1 | Student 1 |
81
5290d060
SA
82 @javascript
83 Scenario Outline: Filter users which are group members in several courses
84 Given I log in as "teacher1"
85 And I am on "Course 3" course homepage
86 And I navigate to course participants
87 When I open the autocomplete suggestions list
88 And I click on "<filter1>" item in the autocomplete list
89 Then I should see "<expected1>" in the "participants" "table"
90 And I should see "<expected2>" in the "participants" "table"
91 And I should see "<expected3>" in the "participants" "table"
92 And I should not see "<notexpected1>" in the "participants" "table"
93 And I should not see "<notexpected2>" in the "participants" "table"
94 # Note the 'XX-IGNORE-XX' elements are for when there is less than 2 'not expected' items.
95 Examples:
96 | filter1 | expected1 | expected2 | expected3 | notexpected1 | notexpected2 |
97 | Group: No group | Student 3 | | | Student 1 | Student 2 |
98 | Group: Group A | Student 1 | Student 2 | | Student 3 | XX-IGNORE-XX |
99 | Group: Group B | Student 2 | | | Student 1 | Student 3 |
100
90ce66a9
PH
101 @javascript
102 Scenario: Filter users who have no role in a course
103 Given I log in as "teacher1"
104 And I am on "Course 1" course homepage
105 And I navigate to course participants
106 And I click on "Student 1's role assignments" "link"
107 And I click on ".form-autocomplete-selection [aria-selected=true]" "css_element"
108 And I press key "27" in the field "Student 1's role assignments"
109 And I click on "Save changes" "link"
110 When I open the autocomplete suggestions list
111 And I click on "Role: No roles" item in the autocomplete list
112 Then I should see "Student 1" in the "participants" "table"
113 And I should not see "Student 2" in the "participants" "table"
114 And I should not see "Student 3" in the "participants" "table"
115 And I should not see "Student 4" in the "participants" "table"
116 And I should not see "Teacher 1" in the "participants" "table"
117
9651e491
JP
118 @javascript
119 Scenario: Multiple filters applied
120 Given I log in as "teacher1"
121 And I am on "Course 1" course homepage
122 And I navigate to course participants
123 When I open the autocomplete suggestions list
124 And I click on "Role: Student" item in the autocomplete list
125 And I open the autocomplete suggestions list
126 And I click on "Status: Active" item in the autocomplete list
9651e491
JP
127 Then I should see "Student 1" in the "participants" "table"
128 And I should see "Student 3" in the "participants" "table"
129 And I should not see "Student 2" in the "participants" "table"
130 And I should not see "Student 4" in the "participants" "table"
131 And I should not see "Teacher 1" in the "participants" "table"
a3bfb41c
JP
132 # Add more filters.
133 And I open the autocomplete suggestions list
134 And I click on "Enrolment methods: Manual enrolments" item in the autocomplete list
135 And I open the autocomplete suggestions list
136 And I click on "Group: Group 2" item in the autocomplete list
137 And I should see "Student 3" in the "participants" "table"
138 But I should not see "Teacher 1" in the "participants" "table"
139 And I should not see "Student 1" in the "participants" "table"
140 And I should not see "Student 2" in the "participants" "table"
141 And I should not see "Student 4" in the "participants" "table"
142 # Deselect the active status filter.
143 And I click on "Status: Active" "text" in the ".form-autocomplete-selection" "css_element"
144 # Apply Status: Inactive filter.
145 And I open the autocomplete suggestions list
146 And I click on "Status: Inactive" item in the autocomplete list
147 Then I should see "Student 2" in the "participants" "table"
148 But I should not see "Student 4" in the "participants" "table"
149 And I should not see "Student 1" in the "participants" "table"
150 And I should not see "Student 3" in the "participants" "table"
151 And I should not see "Teacher 1" in the "participants" "table"
9651e491
JP
152
153 @javascript
154 Scenario: Filter by keyword
155 Given I log in as "teacher1"
156 And I am on "Course 1" course homepage
157 And I navigate to course participants
446b21b5 158 # Note: This is the literal string "student", not the Role student.
9651e491
JP
159 When I set the field "Filters" to "student"
160 And I press key "13" in the field "Filters"
9651e491
JP
161 Then I should see "Student 1" in the "participants" "table"
162 And I should see "Student 2" in the "participants" "table"
163 And I should see "Student 3" in the "participants" "table"
164 And I should see "Student 4" in the "participants" "table"
165 And I should not see "Teacher 1" in the "participants" "table"
166
7fde8358 167 @javascript
168 Scenario: Reorder users without losing filter
169 Given I log in as "teacher1"
170 And I am on "Course 1" course homepage
171 And I navigate to course participants
172 And I open the autocomplete suggestions list
173 And I click on "Role: Student" item in the autocomplete list
174 When I click on "Surname" "link"
175 Then I should see "Role: Student"
176 And I should see "Student 1" in the "participants" "table"
177 And I should see "Student 2" in the "participants" "table"
178 And I should see "Student 3" in the "participants" "table"
179 And I should see "Student 4" in the "participants" "table"
180 And I should not see "Teacher 1" in the "participants" "table"
181
9651e491
JP
182 @javascript
183 Scenario: Rendering filter options for teachers in a course that don't support groups
184 Given I log in as "teacher1"
185 And I am on "Course 2" course homepage
186 And I navigate to course participants
187 When I open the autocomplete suggestions list
188 Then I should see "Role:" in the ".form-autocomplete-suggestions" "css_element"
189 And I should see "Enrolment methods:" in the ".form-autocomplete-suggestions" "css_element"
190 But I should not see "Group:" in the ".form-autocomplete-suggestions" "css_element"
191
192 @javascript
193 Scenario: Rendering filter options for students who have limited privileges
194 Given I log in as "student1"
195 And I am on "Course 2" course homepage
196 And I navigate to course participants
197 When I open the autocomplete suggestions list
198 Then I should see "Role:" in the ".form-autocomplete-suggestions" "css_element"
199 But I should not see "Status:" in the ".form-autocomplete-suggestions" "css_element"
200 And I should not see "Enrolment methods:" in the ".form-autocomplete-suggestions" "css_element"
e52856bc
JP
201
202 @javascript
203 Scenario: Filter by user identity fields
204 Given I log in as "teacher1"
205 And the following config values are set as admin:
206 | showuseridentity | idnumber,email,city,country |
207 And I am on "Course 1" course homepage
208 And I navigate to course participants
209 # Search by email (only).
210 When I set the field "Filters" to "student1@example.com"
211 And I press key "13" in the field "Filters"
212 Then I should see "Student 1" in the "participants" "table"
213 And I should not see "Student 2" in the "participants" "table"
214 And I should not see "Teacher 1" in the "participants" "table"
215 # Search by idnumber (only).
8420b61c
JP
216 And I click on "student1@example.com" "text" in the ".form-autocomplete-selection" "css_element"
217 And I set the field "Filters" to "SID"
e52856bc 218 And I press key "13" in the field "Filters"
8420b61c 219 And I should see "Student 1" in the "participants" "table"
e52856bc
JP
220 And I should see "Student 2" in the "participants" "table"
221 And I should see "Student 3" in the "participants" "table"
222 And I should see "Student 4" in the "participants" "table"
223 And I should not see "Teacher 1" in the "participants" "table"
224 # Search by city (only).
8420b61c
JP
225 And I click on "SID" "text" in the ".form-autocomplete-selection" "css_element"
226 And I set the field "Filters" to "SCITY"
e52856bc 227 And I press key "13" in the field "Filters"
8420b61c 228 And I should see "Student 1" in the "participants" "table"
e52856bc
JP
229 And I should see "Student 2" in the "participants" "table"
230 And I should see "Student 3" in the "participants" "table"
231 And I should see "Student 4" in the "participants" "table"
232 And I should not see "Teacher 1" in the "participants" "table"
233 # Search by country text (only) - should not match.
8420b61c
JP
234 And I click on "SCITY" "text" in the ".form-autocomplete-selection" "css_element"
235 And I set the field "Filters" to "GB"
e52856bc 236 And I press key "13" in the field "Filters"
8420b61c 237 And I should see "Nothing to display"
e52856bc 238 # Check no match.
8420b61c
JP
239 And I click on "GB" "text" in the ".form-autocomplete-selection" "css_element"
240 And I set the field "Filters" to "NOTHING"
241 And I press key "13" in the field "Filters"
242 And I should see "Nothing to display"
e52856bc
JP
243
244 @javascript
245 Scenario: Filter by user identity fields when cannot see the field data
246 Given I log in as "admin"
247 And I set the following system permissions of "Teacher" role:
248 | moodle/site:viewuseridentity | Prevent |
249 And the following config values are set as admin:
250 | showuseridentity | idnumber,email,city,country |
251 And I log out
252 And I log in as "teacher1"
253 And I am on "Course 1" course homepage
254 And I navigate to course participants
255 # Search by email (only) - should only see visible email + own.
256 When I set the field "Filters" to "@example.com"
257 And I press key "13" in the field "Filters"
258 Then I should not see "Student 1" in the "participants" "table"
259 And I should see "Student 2" in the "participants" "table"
260 And I should not see "Student 3" in the "participants" "table"
261 And I should not see "Student 4" in the "participants" "table"
262 And I should see "Teacher 1" in the "participants" "table"
263 # Search for other fields - should only see own results.
8420b61c
JP
264 And I click on "@example.com" "text" in the ".form-autocomplete-selection" "css_element"
265 And I set the field "Filters" to "SID"
e52856bc 266 And I press key "13" in the field "Filters"
8420b61c
JP
267 And I should see "Nothing to display"
268 And I click on "SID" "text" in the ".form-autocomplete-selection" "css_element"
269 And I set the field "Filters" to "TID"
e52856bc 270 And I press key "13" in the field "Filters"
8420b61c
JP
271 And I should see "Teacher 1" in the "participants" "table"
272 And I set the field "Filters" to "CITY"
273 And I press key "13" in the field "Filters"
274 And I should see "Teacher 1" in the "participants" "table"
e52856bc
JP
275 And I should not see "Student 1" in the "participants" "table"
276 # Check no match.
8420b61c
JP
277 And I set the field "Filters" to "NOTHING"
278 And I press key "13" in the field "Filters"
279 And I should see "Nothing to display"