1@core @core_course @javascript
2Feature: Viewing participants page in different group modes
3  In order to view my students
4  As a user
5  I need to be able to browse participants who are grouped
6
7  Background:
8    Given the following "courses" exist:
9      | fullname     | shortname | summary | groupmode | category |
10      | C1 nogroups  | C1        |         | 0         | 0        |
11      | C2 visgroups | C2        |         | 2         | 0        |
12      | C3 sepgroups | C3        |         | 1         | 0        |
13    And the following "users" exist:
14      | username | firstname | lastname | email                |
15      | teacher1 | Teacher   | 1        | teacher1@example.com |
16      | teacher2 | Teacher   | 2        | teacher2@example.com |
17      | student1 | Student   | 1        | student1@example.com |
18      | student2 | Student   | 2        | student2@example.com |
19      | student3 | Student   | 3        | student3@example.com |
20    And the following "course enrolments" exist:
21      | user     | course | role    |
22      | teacher1 | C1     | editingteacher |
23      | teacher1 | C2     | editingteacher |
24      | teacher1 | C3     | editingteacher |
25      | teacher2 | C1     | teacher |
26      | teacher2 | C2     | teacher |
27      | teacher2 | C3     | teacher |
28      | student1 | C1     | student |
29      | student1 | C2     | student |
30      | student1 | C3     | student |
31      | student2 | C1     | student |
32      | student2 | C2     | student |
33      | student2 | C3     | student |
34      | student3 | C1     | student |
35      | student3 | C2     | student |
36      | student3 | C3     | student |
37    And the following "groups" exist:
38      | name | course | idnumber |
39      | G1   | C2     | C2G1      |
40      | G2   | C2     | C2G2      |
41      | G1   | C3     | C3G1      |
42      | G2   | C3     | C3G2      |
43    And the following "group members" exist:
44      | user     | group |
45      | student1 | C2G1   |
46      | student1 | C3G1   |
47      | student2 | C2G2   |
48      | student2 | C3G2   |
49      | teacher2 | C2G1   |
50      | teacher2 | C3G1   |
51
52  Scenario: Viewing participants page as an editing teacher in a course without group mode
53    When I log in as "teacher1"
54    And I am on "C1 nogroups" course homepage
55    And I navigate to course participants
56    Then "Student 1" row "Groups" column of "participants" table should contain "No groups"
57    And "Student 2" row "Groups" column of "participants" table should contain "No groups"
58    And "Student 3" row "Groups" column of "participants" table should contain "No groups"
59    And "Teacher 1" row "Groups" column of "participants" table should contain "No groups"
60    And "Teacher 2" row "Groups" column of "participants" table should contain "No groups"
61
62  Scenario: Viewing participants page as an editing teacher in a course in visible groups mode
63    When I log in as "teacher1"
64    And I am on "C2 visgroups" course homepage
65    And I navigate to course participants
66    Then "Student 1" row "Groups" column of "participants" table should contain "G1"
67    And "Student 2" row "Groups" column of "participants" table should contain "G2"
68    And "Student 3" row "Groups" column of "participants" table should contain "No groups"
69    And "Teacher 1" row "Groups" column of "participants" table should contain "No groups"
70    And "Teacher 2" row "Groups" column of "participants" table should contain "G1"
71
72  Scenario: Viewing participants page as an editing teacher in a course in separate groups mode
73    When I log in as "teacher1"
74    And I am on "C3 sepgroups" course homepage
75    And I navigate to course participants
76    Then "Student 1" row "Groups" column of "participants" table should contain "G1"
77    And "Student 2" row "Groups" column of "participants" table should contain "G2"
78    And "Student 3" row "Groups" column of "participants" table should contain "No groups"
79    And "Teacher 1" row "Groups" column of "participants" table should contain "No groups"
80    And "Teacher 2" row "Groups" column of "participants" table should contain "G1"
81
82  Scenario: Viewing participants page as a non-editing teacher in a course without group mode
83    When I log in as "teacher2"
84    And I am on "C1 nogroups" course homepage
85    And I navigate to course participants
86    Then "Student 1" row "Groups" column of "participants" table should contain "No groups"
87    And "Student 2" row "Groups" column of "participants" table should contain "No groups"
88    And "Student 3" row "Groups" column of "participants" table should contain "No groups"
89    And "Teacher 1" row "Groups" column of "participants" table should contain "No groups"
90    And "Teacher 2" row "Groups" column of "participants" table should contain "No groups"
91
92  Scenario: Viewing participants page as a non-editing teacher in a course in visible groups mode
93    When I log in as "teacher2"
94    And I am on "C2 visgroups" course homepage
95    And I navigate to course participants
96    Then "Student 1" row "Groups" column of "participants" table should contain "G1"
97    And "Teacher 2" row "Groups" column of "participants" table should contain "G1"
98    And I should not see "Teacher 1"
99    And I should not see "Student 2"
100    And I should not see "Student 3"
101
102    When I click on "Clear filters" "button"
103    Then "Student 1" row "Groups" column of "participants" table should contain "G1"
104    And "Student 2" row "Groups" column of "participants" table should contain "G2"
105    And "Student 3" row "Groups" column of "participants" table should contain "No groups"
106    And "Teacher 1" row "Groups" column of "participants" table should contain "No groups"
107    And "Teacher 2" row "Groups" column of "participants" table should contain "G1"
108
109  Scenario: Viewing participants page as a non-editing teacher in a course in separate groups mode
110    When I log in as "teacher2"
111    And I am on "C3 sepgroups" course homepage
112    And I navigate to course participants
113    Then "Student 1" row "Groups" column of "participants" table should contain "G1"
114    And "Teacher 2" row "Groups" column of "participants" table should contain "G1"
115    And I should not see "Teacher 1"
116    And I should not see "Student 2"
117    And I should not see "Student 3"
118
119    When I click on "Clear filters" "button"
120    Then "Student 1" row "Groups" column of "participants" table should contain "G1"
121    And "Teacher 2" row "Groups" column of "participants" table should contain "G1"
122    And I should not see "Teacher 1"
123    And I should not see "Student 2"
124    And I should not see "Student 3"
125
126  Scenario: Viewing participants page as a student in a course without group mode
127    When I log in as "student1"
128    And I am on "C1 nogroups" course homepage
129    And I navigate to course participants
130    Then "Student 1" row "Groups" column of "participants" table should contain "No groups"
131    And "Student 2" row "Groups" column of "participants" table should contain "No groups"
132    And "Student 3" row "Groups" column of "participants" table should contain "No groups"
133
134  Scenario: Viewing participants page as a student in a group in a course in visible groups mode
135    When I log in as "student1"
136    And I am on "C2 visgroups" course homepage
137    And I navigate to course participants
138    Then "Student 1" row "Groups" column of "participants" table should contain "G1"
139    And "Teacher 2" row "Groups" column of "participants" table should contain "G1"
140    And I should not see "Student 2"
141    And I should not see "Student 3"
142    And I should not see "Teacher 1"
143    When I click on "Clear filters" "button"
144    Then "Student 1" row "Groups" column of "participants" table should contain "G1"
145    And "Student 2" row "Groups" column of "participants" table should contain "G2"
146    And "Student 3" row "Groups" column of "participants" table should contain "No groups"
147    And "Teacher 1" row "Groups" column of "participants" table should contain "No groups"
148    And "Teacher 2" row "Groups" column of "participants" table should contain "G1"
149
150  Scenario: Viewing participants page as a student in a group in a course in separate groups mode
151    When I log in as "student1"
152    And I am on "C3 sepgroups" course homepage
153    And I navigate to course participants
154    Then "Student 1" row "Groups" column of "participants" table should contain "G1"
155    And "Teacher 2" row "Groups" column of "participants" table should contain "G1"
156    And I should not see "Student 2"
157    And I should not see "Student 3"
158    And I should not see "Teacher 1"
159    When I click on "Clear filters" "button"
160    Then "Student 1" row "Groups" column of "participants" table should contain "G1"
161    And "Teacher 2" row "Groups" column of "participants" table should contain "G1"
162    And I should not see "Student 2"
163    And I should not see "Student 3"
164    And I should not see "Teacher 1"
165
166  Scenario: Viewing participants page as a student not in a group in a course in visible groups mode
167    When I log in as "student3"
168    And I am on "C2 visgroups" course homepage
169    And I navigate to course participants
170    Then "Student 1" row "Groups" column of "participants" table should contain "G1"
171    And "Teacher 2" row "Groups" column of "participants" table should contain "G1"
172    And I should not see "Student 2"
173    And I should not see "Student 3" in the "participants" "table"
174    And I should not see "Teacher 1"
175    When I click on "Clear filters" "button"
176    Then "Student 1" row "Groups" column of "participants" table should contain "G1"
177    And "Student 2" row "Groups" column of "participants" table should contain "G2"
178    And "Student 3" row "Groups" column of "participants" table should contain "No groups"
179    And "Teacher 1" row "Groups" column of "participants" table should contain "No groups"
180    And "Teacher 2" row "Groups" column of "participants" table should contain "G1"
181
182  Scenario: Viewing participants page as a student not in a group in a course in separate groups mode
183    When I log in as "student3"
184    And I am on "C3 sepgroups" course homepage
185    And I navigate to course participants
186    Then I should see "Sorry, but you need to be part of a group to see this page."
187