1@mod @mod_feedback
2Feature: Feedbacks in courses with groups
3  In order to collect feedbacks per group
4  As an teacher
5  I need to be able to filter feedback replies by groups
6
7  Background:
8    Given the following "users" exist:
9      | username | firstname | lastname |
10      | user1    | Username  | 1        |
11      | user2    | Username  | 2        |
12      | user3    | Username  | 3        |
13      | user4    | Username  | 4        |
14      | user5    | Username  | 5        |
15      | user6    | Username  | 6        |
16      | user7    | Username  | 7        |
17      | teacher  | Teacher   | T        |
18      | manager  | Manager   | M        |
19    And the following "courses" exist:
20      | fullname | shortname | groupmode |
21      | Course 1 | C1        | 1 |
22    And the following "course enrolments" exist:
23      | user  | course | role    |
24      | user1 | C1     | student |
25      | user2 | C1     | student |
26      | user3 | C1     | student |
27      | user4 | C1     | student |
28      | user5 | C1     | student |
29      | user6 | C1     | student |
30      | user7 | C1     | student |
31      | teacher | C1   | editingteacher |
32    And the following "groups" exist:
33      | name | course | idnumber |
34      | Group 1 | C1 | G1 |
35      | Group 2 | C1 | G2 |
36    And the following "group members" exist:
37      | user | group |
38      | user1 | G1 |
39      | user2 | G1 |
40      | user2 | G2 |
41      | user3 | G2 |
42      | user4 | G1 |
43      | user5 | G1 |
44      | user6 | G2 |
45    And the following "system role assigns" exist:
46      | user    | course               | role    |
47      | manager | Acceptance test site | manager |
48    And the following "activities" exist:
49      | activity   | name            | course               | idnumber  | anonymous | publish_stats | groupmode | section |
50      | feedback   | Site feedback   | Acceptance test site | feedback0 | 2         | 1             | 1         | 1       |
51      | feedback   | Course feedback | C1                   | feedback1 | 2         | 1             | 1         | 0       |
52      | feedback   | Course anon feedback | C1              | feedback2 | 1         | 1             | 1         | 0       |
53    And I am on the "Site feedback" "feedback activity" page logged in as manager
54    And I click on "Edit questions" "link" in the "[role=main]" "css_element"
55    And I add a "Multiple choice" question to the feedback with:
56      | Question                       | Do you like our site?              |
57      | Label                          | multichoice2                       |
58      | Multiple choice type           | Multiple choice - single answer    |
59      | Hide the "Not selected" option | Yes                                |
60      | Multiple choice values         | Yes of course\nNot at all\nI don't know |
61    And I log out
62
63  @javascript
64  Scenario: Non anonymous feedback with groups in a course
65    Given I am on the "Course feedback" "feedback activity" page logged in as teacher
66    And I click on "Edit questions" "link" in the "[role=main]" "css_element"
67    And I add a "Multiple choice" question to the feedback with:
68      | Question                       | Do you like this course?           |
69      | Label                          | multichoice1                       |
70      | Multiple choice type           | Multiple choice - single answer    |
71      | Hide the "Not selected" option | Yes                                |
72      | Multiple choice values         | Yes of course\nNot at all\nI don't know |
73    And I log out
74    And I log in as "user1" and complete feedback "Course feedback" in course "Course 1" with:
75      | Not at all | 1 |
76    And I log in as "user2" and complete feedback "Course feedback" in course "Course 1" with:
77      | I don't know | 1 |
78    And I log in as "user3" and complete feedback "Course feedback" in course "Course 1" with:
79      | Not at all | 1 |
80    And I log in as "user4" and complete feedback "Course feedback" in course "Course 1" with:
81      | Yes of course | 1 |
82    And I log in as "user5" and complete feedback "Course feedback" in course "Course 1" with:
83      | Yes of course | 1 |
84    And I log in as "user6" and complete feedback "Course feedback" in course "Course 1" with:
85      | Not at all | 1 |
86    And I log in as "user7" and complete feedback "Course feedback" in course "Course 1" with:
87      | I don't know | 1 |
88    # View analysis, user1 should only see one group - group 1
89    And I am on the "Course feedback" "feedback activity" page logged in as user1
90    And I follow "Submitted answers"
91    And I should see "Separate groups: Group 1"
92    And I show chart data for the "multichoice1" feedback
93    And I should see "2 (50.00 %)" in the "Yes of course" "table_row"
94    And I should see "1 (25.00 %)" in the "Not at all" "table_row"
95    And I log out
96    # View analysis, user3 should only see one group - group 2
97    And I am on the "Course feedback" "feedback activity" page logged in as user3
98    And I follow "Submitted answers"
99    And I should see "Separate groups: Group 2"
100    And I show chart data for the "multichoice1" feedback
101    And I should see "0" in the "Yes of course" "table_row"
102    And I should see "2 (66.67 %)" in the "Not at all" "table_row"
103    And I log out
104    # View analysis, user2 should see a group selector and be able to change the group but not view all.
105    And I am on the "Course feedback" "feedback activity" page logged in as user2
106    And I follow "Submitted answers"
107    And the field "Separate groups" matches value "Group 1"
108    And I show chart data for the "multichoice1" feedback
109    And I should see "2 (50.00 %)" in the "Yes of course" "table_row"
110    And I should see "1 (25.00 %)" in the "Not at all" "table_row"
111    And I select "Group 2" from the "Separate groups" singleselect
112    And I show chart data for the "multichoice1" feedback
113    And I should see "0" in the "Yes of course" "table_row"
114    And I should see "2 (66.67 %)" in the "Not at all" "table_row"
115    And the "Separate groups" select box should not contain "All participants"
116    And I log out
117    # User without group can see all participants only
118    And I am on the "Course feedback" "feedback activity" page logged in as user7
119    And I follow "Submitted answers"
120    And I should see "Separate groups: All participants"
121    And I show chart data for the "multichoice1" feedback
122    And I should see "2 (28.57 %)" in the "Yes of course" "table_row"
123    And I should see "3 (42.86 %)" in the "Not at all" "table_row"
124    And I should see "2 (28.57 %)" in the "I don't know" "table_row"
125    And I log out
126    # Teacher can browse everybody
127    And I am on the "Course feedback" "feedback activity" page logged in as teacher
128    And I navigate to "Analysis" in current page administration
129    And the field "Separate groups" matches value "All participants"
130    And I show chart data for the "multichoice1" feedback
131    And I should see "2 (28.57 %)" in the "Yes of course" "table_row"
132    And I should see "3 (42.86 %)" in the "Not at all" "table_row"
133    And I should see "2 (28.57 %)" in the "I don't know" "table_row"
134    And I select "Group 1" from the "Separate groups" singleselect
135    And I show chart data for the "multichoice1" feedback
136    And I should see "2 (50.00 %)" in the "Yes of course" "table_row"
137    And I should see "1 (25.00 %)" in the "Not at all" "table_row"
138    And I select "Group 2" from the "Separate groups" singleselect
139    And I show chart data for the "multichoice1" feedback
140    And I should see "0" in the "Yes of course" "table_row"
141    And I should see "2 (66.67 %)" in the "Not at all" "table_row"
142    And I follow "Show responses"
143    And the field "Separate groups" matches value "Group 2"
144    And I should not see "Username 1"
145    And I should see "Username 3"
146    And I select "Group 1" from the "Separate groups" singleselect
147    And I should see "Username 1"
148    And I should not see "Username 3"
149    And I select "All participants" from the "Separate groups" singleselect
150    And I should see "Username 1"
151    And I should see "Username 3"
152
153  @javascript
154  Scenario: Anonymous feedback with groups in a course
155    Given I am on the "Course anon feedback" "feedback activity" page logged in as teacher
156    And I click on "Edit questions" "link" in the "[role=main]" "css_element"
157    And I add a "Multiple choice" question to the feedback with:
158      | Question                       | Do you like this course?           |
159      | Label                          | multichoice1                       |
160      | Multiple choice type           | Multiple choice - single answer    |
161      | Hide the "Not selected" option | Yes                                |
162      | Multiple choice values         | Yes of course\nNot at all\nI don't know |
163    And I log out
164    And I log in as "user1" and complete feedback "Course anon feedback" in course "Course 1" with:
165      | Not at all | 1 |
166    And I am on the "Course anon feedback" "feedback activity" page logged in as user1
167    And I follow "Submitted answers"
168    And I should see "There are insufficient responses for this group"
169    And I should not see "Yes of course"
170    And I log out
171    And I log in as "user2" and complete feedback "Course anon feedback" in course "Course 1" with:
172      | I don't know | 1 |
173    And I log in as "user3" and complete feedback "Course anon feedback" in course "Course 1" with:
174      | Not at all | 1 |
175    And I log in as "user4" and complete feedback "Course anon feedback" in course "Course 1" with:
176      | Yes of course | 1 |
177    And I log in as "user5" and complete feedback "Course anon feedback" in course "Course 1" with:
178      | Yes of course | 1 |
179    And I log in as "user6" and complete feedback "Course anon feedback" in course "Course 1" with:
180      | Not at all | 1 |
181    And I log in as "user7" and complete feedback "Course anon feedback" in course "Course 1" with:
182      | I don't know | 1 |
183    # View analysis, user1 should only see one group - group 1
184    And I am on the "Course anon feedback" "feedback activity" page logged in as user1
185    And I follow "Submitted answers"
186    And I should see "Separate groups: Group 1"
187    And I show chart data for the "multichoice1" feedback
188    And I should see "2 (50.00 %)" in the "Yes of course" "table_row"
189    And I should see "1 (25.00 %)" in the "Not at all" "table_row"
190    And I log out
191    # View analysis, user3 should only see one group - group 2
192    And I am on the "Course anon feedback" "feedback activity" page logged in as user3
193    And I follow "Submitted answers"
194    And I should see "Separate groups: Group 2"
195    And I show chart data for the "multichoice1" feedback
196    And I should see "0" in the "Yes of course" "table_row"
197    And I should see "2 (66.67 %)" in the "Not at all" "table_row"
198    And I log out
199    # View analysis, user2 should see a group selector and be able to change the group but not view all.
200    And I am on the "Course anon feedback" "feedback activity" page logged in as user2
201    And I follow "Submitted answers"
202    And the field "Separate groups" matches value "Group 1"
203    And I show chart data for the "multichoice1" feedback
204    And I should see "2 (50.00 %)" in the "Yes of course" "table_row"
205    And I should see "1 (25.00 %)" in the "Not at all" "table_row"
206    And I select "Group 2" from the "Separate groups" singleselect
207    And I show chart data for the "multichoice1" feedback
208    And I should see "0" in the "Yes of course" "table_row"
209    And I should see "2 (66.67 %)" in the "Not at all" "table_row"
210    And the "Separate groups" select box should not contain "All participants"
211    And I log out
212    # User without group can see all participants only
213    And I am on the "Course anon feedback" "feedback activity" page logged in as user7
214    And I follow "Submitted answers"
215    And I should see "Separate groups: All participants"
216    And I show chart data for the "multichoice1" feedback
217    And I should see "2 (28.57 %)" in the "Yes of course" "table_row"
218    And I should see "3 (42.86 %)" in the "Not at all" "table_row"
219    And I should see "2 (28.57 %)" in the "I don't know" "table_row"
220    And I log out
221    # Teacher can browse everybody
222    And I am on the "Course anon feedback" "feedback activity" page logged in as teacher
223    And I navigate to "Analysis" in current page administration
224    And the field "Separate groups" matches value "All participants"
225    And I show chart data for the "multichoice1" feedback
226    And I should see "2 (28.57 %)" in the "Yes of course" "table_row"
227    And I should see "3 (42.86 %)" in the "Not at all" "table_row"
228    And I should see "2 (28.57 %)" in the "I don't know" "table_row"
229    And I select "Group 1" from the "Separate groups" singleselect
230    And I show chart data for the "multichoice1" feedback
231    And I should see "2 (50.00 %)" in the "Yes of course" "table_row"
232    And I should see "1 (25.00 %)" in the "Not at all" "table_row"
233    And I select "Group 2" from the "Separate groups" singleselect
234    And I show chart data for the "multichoice1" feedback
235    And I should see "0" in the "Yes of course" "table_row"
236    And I should see "2 (66.67 %)" in the "Not at all" "table_row"
237    And I follow "Show responses"
238    # The response numbers were randomly allocated, we only can assert the number of visible responses here:
239    And the field "Separate groups" matches value "Group 2"
240    And "//tr[contains(@id,'_r2') and contains(.,'Response number')]" "xpath_element" should exist
241    And "//tr[contains(@id,'_r3') and contains(@class,'emptyrow')]" "xpath_element" should exist
242    And I select "Group 1" from the "Separate groups" singleselect
243    And "//tr[contains(@id,'_r3') and contains(.,'Response number')]" "xpath_element" should exist
244    And "//tr[contains(@id,'_r4') and contains(@class,'emptyrow')]" "xpath_element" should exist
245    And I select "All participants" from the "Separate groups" singleselect
246    And "//tr[contains(@id,'_r6') and contains(.,'Response number')]" "xpath_element" should exist
247    And "//tr[contains(@id,'_r7') and contains(@class,'emptyrow')]" "xpath_element" should exist
248