MDL-60858 feedback: update behat tests for lang string change
[moodle.git] / mod / feedback / tests / behat / anonymous.feature
blob787bd217676fe85ecc09735591ebb074bf07357f
1 @mod @mod_feedback
2 Feature: Anonymous feedback
3   In order to collect feedbacks
4   As an admin
5   I need to be able to allow anonymous feedbacks
7   Background:
8     Given the following "users" exist:
9       | username | firstname | lastname |
10       | user1    | Username  | 1        |
11       | user2    | Username  | 2        |
12       | teacher  | Teacher   | 3        |
13       | manager  | Manager   | 4        |
14     And the following "courses" exist:
15       | fullname | shortname |
16       | Course 1 | C1        |
17     And the following "course enrolments" exist:
18       | user  | course | role    |
19       | user1 | C1     | student |
20       | user2 | C1     | student |
21       | teacher | C1   | editingteacher |
22     And the following "system role assigns" exist:
23       | user    | course               | role    |
24       | manager | Acceptance test site | manager |
25     And the following "activities" exist:
26       | activity   | name            | course               | idnumber  | anonymous | publish_stats | section |
27       | feedback   | Site feedback   | Acceptance test site | feedback0 | 1         | 1             | 1       |
28       | feedback   | Course feedback | C1                   | feedback1 | 1         | 1             | 0       |
29     When I log in as "manager"
30     And I am on site homepage
31     And I follow "Site feedback"
32     And I click on "Edit questions" "link" in the "[role=main]" "css_element"
33     And I add a "Multiple choice" question to the feedback with:
34       | Question                       | Do you like our site?              |
35       | Label                          | multichoice2                       |
36       | Multiple choice type           | Multiple choice - single answer    |
37       | Hide the "Not selected" option | Yes                                |
38       | Multiple choice values         | Yes\nNo\nI don't know              |
39     And I log out
41   Scenario: Guests can see anonymous feedback on front page but can not complete
42     When I follow "Site feedback"
43     Then I should not see "Answer the questions"
44     And I follow "Preview"
45     And I should see "Do you like our site?"
46     And I press "Continue"
48   Scenario: Complete anonymous feedback on the front page as an authenticated user
49     And I log in as "user1"
50     And I am on site homepage
51     When I follow "Site feedback"
52     And I follow "Preview"
53     And I should see "Do you like our site?"
54     And I press "Continue"
55     And I follow "Answer the questions"
56     And I should see "Do you like our site?"
57     And I set the following fields to these values:
58       | Yes | 1 |
59     And I press "Submit your answers"
60     And I should not see "Submitted answers"
61     And I press "Continue"
63   @javascript
64   Scenario: Complete anonymous feedback and view analysis on the front page as an authenticated user
65     And I log in as "admin"
66     And I set the following system permissions of "Authenticated user on frontpage" role:
67       | capability                   | permission |
68       | mod/feedback:viewanalysepage | Allow      |
69     And I log out
70     And I log in as "user1"
71     And I am on site homepage
72     When I follow "Site feedback"
73     And I follow "Preview"
74     And I should see "Do you like our site?"
75     And I press "Continue"
76     And I follow "Answer the questions"
77     And I should see "Do you like our site?"
78     And I set the following fields to these values:
79       | Yes | 1 |
80     And I press "Submit your answers"
81     And I log out
82     And I log in as "user2"
83     And I am on site homepage
84     And I follow "Site feedback"
85     And I follow "Preview"
86     And I should see "Do you like our site?"
87     And I press "Continue"
88     And I follow "Answer the questions"
89     And I set the following fields to these values:
90       | No | 1 |
91     And I press "Submit your answers"
92     And I follow "Submitted answers"
93     And I should see "Submitted answers: 2"
94     And I should see "Questions: 1"
95     # And I should not see "multichoice2" # TODO MDL-29303 do not show labels to users who can not edit feedback
96     And I show chart data for the "multichoice2" feedback
97     And I should see "Do you like our site?"
98     And I should see "1 (50.00 %)" in the "Yes" "table_row"
99     And I should see "1 (50.00 %)" in the "No" "table_row"
100     And I log out
101     And I log in as "manager"
102     And I am on site homepage
103     And I follow "Site feedback"
104     And I navigate to "Show responses" in current page administration
105     And I should not see "Username"
106     And I should see "Anonymous entries (2)"
107     And I follow "Response number: 1"
108     And I should not see "Username"
109     And I should see "Response number: 1 (Anonymous)"
110     And I log out
112   Scenario: Complete fully anonymous feedback on the front page as a guest
113     And I log in as "admin"
114     And I set the following administration settings values:
115       | feedback_allowfullanonymous | 1 |
116     And I log out
117     When I follow "Site feedback"
118     And I follow "Preview"
119     And I should see "Do you like our site?"
120     And I press "Continue"
121     And I follow "Answer the questions"
122     And I should see "Do you like our site?"
123     And I set the following fields to these values:
124       | Yes | 1 |
125     And I press "Submit your answers"
126     And I should not see "Submitted answers"
127     And I press "Continue"
129   @javascript
130   Scenario: Complete fully anonymous feedback and view analyze on the front page as a guest
131     And I log in as "admin"
132     And I set the following administration settings values:
133       | feedback_allowfullanonymous | 1 |
134     And I set the following system permissions of "Guest" role:
135       | capability                   | permission |
136       | mod/feedback:viewanalysepage | Allow      |
137     And I log out
138     When I follow "Site feedback"
139     And I follow "Preview"
140     And I should see "Do you like our site?"
141     And I press "Continue"
142     And I follow "Answer the questions"
143     And I should see "Do you like our site?"
144     And I set the following fields to these values:
145       | Yes | 1 |
146     And I press "Submit your answers"
147     And I press "Continue"
148     # Starting new feedback
149     When I follow "Site feedback"
150     And I follow "Preview"
151     And I should see "Do you like our site?"
152     And I press "Continue"
153     And I follow "Answer the questions"
154     And I should see "Do you like our site?"
155     And I set the following fields to these values:
156       | No | 1 |
157     And I press "Submit your answers"
158     And I follow "Submitted answers"
159     And I should see "Submitted answers: 2"
160     And I should see "Questions: 1"
161     # And I should not see "multichoice2" # TODO MDL-29303
162     And I show chart data for the "multichoice2" feedback
163     And I should see "Do you like our site?"
164     And I should see "1 (50.00 %)" in the "Yes" "table_row"
165     And I should see "1 (50.00 %)" in the "No" "table_row"
166     And I log in as "manager"
167     And I am on site homepage
168     And I follow "Site feedback"
169     And I navigate to "Show responses" in current page administration
170     And I should see "Anonymous entries (2)"
171     And I follow "Response number: 1"
172     And I should see "Response number: 1 (Anonymous)"
173     And I log out
175   @javascript
176   Scenario: Anonymous feedback in a course
177     # Teacher can not
178     When I log in as "teacher"
179     And I am on "Course 1" course homepage
180     And I follow "Course feedback"
181     And I click on "Edit questions" "link" in the "[role=main]" "css_element"
182     And I add a "Multiple choice" question to the feedback with:
183       | Question                       | Do you like this course?           |
184       | Label                          | multichoice1                       |
185       | Multiple choice type           | Multiple choice - single answer    |
186       | Hide the "Not selected" option | Yes                                |
187       | Multiple choice values         | Yes\nNo\nI don't know              |
188     And I log out
189     And I log in as "user1"
190     And I am on "Course 1" course homepage
191     And I follow "Course feedback"
192     And I follow "Preview"
193     Then I should see "Do you like this course?"
194     And I press "Continue"
195     And I follow "Answer the questions"
196     And I should see "Do you like this course?"
197     And I set the following fields to these values:
198       | Yes | 1 |
199     And I press "Submit your answers"
200     And I log out
201     And I log in as "user2"
202     And I am on "Course 1" course homepage
203     And I follow "Course feedback"
204     And I follow "Preview"
205     And I should see "Do you like this course?"
206     And I press "Continue"
207     And I follow "Answer the questions"
208     And I should see "Do you like this course?"
209     And I set the following fields to these values:
210       | No | 1 |
211     And I press "Submit your answers"
212     And I follow "Submitted answers"
213     And I should see "Submitted answers: 2"
214     And I should see "Questions: 1"
215     # And I should not see "multichoice2" # TODO MDL-29303
216     And I show chart data for the "multichoice1" feedback
217     And I should see "Do you like this course?"
218     And I should see "1 (50.00 %)" in the "Yes" "table_row"
219     And I should see "1 (50.00 %)" in the "No" "table_row"
220     And I log out
221     And I log in as "teacher"
222     And I am on "Course 1" course homepage
223     And I follow "Course feedback"
224     And I follow "Preview"
225     And I should see "Do you like this course?"
226     And I press "Continue"
227     And I should not see "Answer the questions"
228     And I navigate to "Show responses" in current page administration
229     And I should not see "Username"
230     And I should see "Anonymous entries (2)"
231     And I follow "Response number: 1"
232     And I should not see "Username"
233     And I should see "Response number: 1 (Anonymous)"
234     And I should not see "Prev"
235     And I follow "Next"
236     And I should see "Response number: 2 (Anonymous)"
237     And I should see "Prev"
238     And I should not see "Next"
239     And I click on "Back" "link" in the "[role=main]" "css_element"
240     # Delete anonymous response
241     And I click on "Delete entry" "link" in the "Response number: 1" "table_row"
242     And I press "Yes"
243     And I should see "Anonymous entries (1)"
244     And I should not see "Response number: 1"
245     And I should see "Response number: 2"
246     And I log out
248   Scenario: Collecting new non-anonymous feedback from a previously anonymous feedback activity
249     When I log in as "teacher"
250     And I am on "Course 1" course homepage
251     And I follow "Course feedback"
252     And I navigate to "Edit settings" in current page administration
253     And I set the following fields to these values:
254       | Allow multiple submissions | Yes |
255     And I press "Save and display"
256     And I follow "Edit questions"
257     And I add a "Short text answer" question to the feedback with:
258       | Question               | this is a short text answer |
259       | Label                  | shorttext                   |
260       | Maximum characters accepted | 200                    |
261     And I log out
262     When I log in as "user1"
263     And I am on "Course 1" course homepage
264     And I follow "Course feedback"
265     And I follow "Answer the questions"
266     And I set the following fields to these values:
267       | this is a short text answer  | anontext |
268     And I press "Submit your answers"
269     And I log out
270     # Switch to non-anon responses.
271     And I log in as "teacher"
272     And I am on "Course 1" course homepage
273     And I follow "Course feedback"
274     And I navigate to "Edit settings" in current page administration
275     And I set the following fields to these values:
276         | Record user names | User's name will be logged and shown with answers |
277     And I press "Save and display"
278     And I log out
279     # Now leave a non-anon feedback as user1
280     When I log in as "user1"
281     And I am on "Course 1" course homepage
282     And I follow "Course feedback"
283     And I follow "Answer the questions"
284     And I set the following fields to these values:
285       | this is a short text answer  | usertext |
286     And I press "Submit your answers"
287     And I log out
288     # Now check the responses are correct.
289     When I log in as "teacher"
290     And I am on "Course 1" course homepage
291     And I follow "Course feedback"
292     And I follow "Show responses"
293     And I should see "Anonymous entries (1)"
294     And I should see "Non anonymous entries (1)"
295     And I click on "," "link" in the "Username 1" "table_row"
296     And I should see "(Username 1)"
297     And I should see "usertext"
298     And I follow "Back"
299     And I follow "Response number: 1"
300     And I should see "Response number: 1 (Anonymous)"
301     Then I should see "anontext"