1 |
efrain |
1 |
@mod @mod_data
|
|
|
2 |
Feature: Users can add the ##actionsmenu## replacement to the database templates
|
|
|
3 |
In order to display all the actions for entries in templates
|
|
|
4 |
As a teacher
|
|
|
5 |
I need to edit the templates and add the actionsmenu replacement
|
|
|
6 |
|
|
|
7 |
Background:
|
|
|
8 |
Given the following "users" exist:
|
|
|
9 |
| username | firstname | lastname | email |
|
|
|
10 |
| teacher1 | Teacher | 1 | teacher1@example.com |
|
|
|
11 |
| student1 | Student | 1 | student1@example.com |
|
|
|
12 |
And the following "courses" exist:
|
|
|
13 |
| fullname | shortname | category |
|
|
|
14 |
| Course 1 | C1 | 0 |
|
|
|
15 |
And the following "course enrolments" exist:
|
|
|
16 |
| user | course | role |
|
|
|
17 |
| teacher1 | C1 | editingteacher |
|
|
|
18 |
| student1 | C1 | student |
|
|
|
19 |
And the following "activities" exist:
|
|
|
20 |
| activity | name | intro | course | idnumber |
|
|
|
21 |
| data | Test database name | Database intro | C1 | data1 |
|
|
|
22 |
And the following "mod_data > fields" exist:
|
|
|
23 |
| database | type | name | description |
|
|
|
24 |
| data1 | text | field1 | Test field description |
|
|
|
25 |
| data1 | text | field2 | Test field 2 description |
|
|
|
26 |
And the following "mod_data > templates" exist:
|
|
|
27 |
| database | name |
|
|
|
28 |
| data1 | singletemplate |
|
|
|
29 |
| data1 | listtemplate |
|
|
|
30 |
| data1 | addtemplate |
|
|
|
31 |
| data1 | asearchtemplate |
|
|
|
32 |
| data1 | rsstemplate |
|
|
|
33 |
And the following "mod_data > entries" exist:
|
|
|
34 |
| database | user | field1 | field2 |
|
|
|
35 |
| data1 | student1 | Student entry 1 | Some student content 1 |
|
|
|
36 |
| data1 | teacher1 | Teacher entry 1 | Some teacher content 1 |
|
|
|
37 |
And I am on the "Test database name" "data activity" page logged in as teacher1
|
|
|
38 |
And I navigate to "Templates" in current page administration
|
|
|
39 |
And I set the field "Templates tertiary navigation" to "List view template"
|
|
|
40 |
And I set the field "Enable code editor" to "0"
|
|
|
41 |
And I set the following fields to these values:
|
|
|
42 |
| Header | <table> |
|
|
|
43 |
| Repeated entry | <tr><td>[[field1]]</td><td>##actionsmenu##</td><tr> |
|
|
|
44 |
| Footer | </table> |
|
|
|
45 |
And I click on "Save" "button" in the "sticky-footer" "region"
|
|
|
46 |
And I set the field "Templates tertiary navigation" to "Single view template"
|
|
|
47 |
And I set the following fields to these values:
|
|
|
48 |
| Single view template | <table><tr><td>[[field1]]</td><td>[[field2]]</td><td>##actionsmenu##</td><tr></table> |
|
|
|
49 |
And I click on "Save" "button" in the "sticky-footer" "region"
|
|
|
50 |
|
|
|
51 |
@javascript
|
|
|
52 |
Scenario: The ##actionsmenu## replacement displays the expected actions with default settings depending on the user permissions
|
|
|
53 |
Given I navigate to "Database" in current page administration
|
|
|
54 |
# Teachers should be able to edit/delete all the entries.
|
|
|
55 |
When I open the action menu in "Student entry 1" "table_row"
|
|
|
56 |
Then I should see "Show more"
|
|
|
57 |
And I should see "Edit"
|
|
|
58 |
And I should see "Delete"
|
|
|
59 |
But I should not see "Approve"
|
|
|
60 |
And I should not see "Undo approval"
|
|
|
61 |
And I should not see "Export to portfolio"
|
|
|
62 |
And I press the escape key
|
|
|
63 |
And I open the action menu in "Teacher entry 1" "table_row"
|
|
|
64 |
And I should see "Show more"
|
|
|
65 |
And I should see "Edit"
|
|
|
66 |
And I should see "Delete"
|
|
|
67 |
# Single view (for teacher).
|
|
|
68 |
And I choose "Show more" in the open action menu
|
|
|
69 |
And I should see "Teacher entry 1"
|
|
|
70 |
And I should see "Some teacher content 1"
|
|
|
71 |
And I should not see "Student entry 1"
|
|
|
72 |
And I open the action menu in "Teacher entry 1" "table_row"
|
|
|
73 |
And I should not see "Show more"
|
|
|
74 |
And I should see "Edit"
|
|
|
75 |
And I should see "Delete"
|
|
|
76 |
And I should not see "Approve"
|
|
|
77 |
And I should not see "Undo approval"
|
|
|
78 |
And I should not see "Export to portfolio"
|
|
|
79 |
And I press the escape key
|
|
|
80 |
And I follow "Previous page"
|
|
|
81 |
And I should see "Student entry 1"
|
|
|
82 |
And I should see "Some student content 1"
|
|
|
83 |
And I should not see "Teacher entry 1"
|
|
|
84 |
And I open the action menu in "Student entry 1" "table_row"
|
|
|
85 |
And I should not see "Show more"
|
|
|
86 |
And I should see "Edit"
|
|
|
87 |
And I should see "Delete"
|
|
|
88 |
And I log out
|
|
|
89 |
# Students only should edit/delete their entries.
|
|
|
90 |
But I am on the "Test database name" "data activity" page logged in as student1
|
|
|
91 |
And I open the action menu in "Student entry 1" "table_row"
|
|
|
92 |
And I should see "Show more"
|
|
|
93 |
And I should see "Edit"
|
|
|
94 |
And I should see "Delete"
|
|
|
95 |
And I should not see "Approve"
|
|
|
96 |
And I should not see "Undo approval"
|
|
|
97 |
And I should not see "Export to portfolio"
|
|
|
98 |
And I press the escape key
|
|
|
99 |
And I open the action menu in "Teacher entry 1" "table_row"
|
|
|
100 |
And I should see "Show more"
|
|
|
101 |
And I should not see "Edit"
|
|
|
102 |
And I should not see "Delete"
|
|
|
103 |
# Single view (for student).
|
|
|
104 |
And I choose "Show more" in the open action menu
|
|
|
105 |
And I should see "Teacher entry 1"
|
|
|
106 |
And I should see "Some teacher content 1"
|
|
|
107 |
And I should not see "Student entry 1"
|
|
|
108 |
And I should not see "Actions" in the "Teacher entry 1" "table_row"
|
|
|
109 |
And I follow "Previous page"
|
|
|
110 |
And I should see "Student entry 1"
|
|
|
111 |
And I should see "Some student content 1"
|
|
|
112 |
And I should not see "Teacher entry 1"
|
|
|
113 |
And I open the action menu in "Student entry 1" "table_row"
|
|
|
114 |
And I should not see "Show more"
|
|
|
115 |
And I should see "Edit"
|
|
|
116 |
And I should see "Delete"
|
|
|
117 |
And I should not see "Approve"
|
|
|
118 |
And I should not see "Undo approval"
|
|
|
119 |
And I should not see "Export to portfolio"
|
|
|
120 |
|
|
|
121 |
@javascript
|
|
|
122 |
Scenario: The ##actionsmenu## replacement displays the Approval/Undo approval options
|
|
|
123 |
Given I navigate to "Settings" in current page administration
|
|
|
124 |
And I follow "Entries"
|
|
|
125 |
And I set the field "Approval required" to "Yes"
|
|
|
126 |
And I press "Save and display"
|
|
|
127 |
When I navigate to "Database" in current page administration
|
|
|
128 |
# Teachers should be able to approve/unapprove all the entries from list view.
|
|
|
129 |
And I open the action menu in "Student entry 1" "table_row"
|
|
|
130 |
Then I should see "Approve"
|
|
|
131 |
And I should not see "Undo approval"
|
|
|
132 |
And I choose "Approve" in the open action menu
|
|
|
133 |
And I should see "Entry approved"
|
|
|
134 |
And I press "Dismiss this notification"
|
|
|
135 |
And I open the action menu in "Student entry 1" "table_row"
|
|
|
136 |
And I should see "Undo approval"
|
|
|
137 |
And I should not see "Approve" in the ".menu-action-text" "css_element"
|
|
|
138 |
And I press the escape key
|
|
|
139 |
And I open the action menu in "Teacher entry 1" "table_row"
|
|
|
140 |
And I should see "Undo approval"
|
|
|
141 |
And I should not see "Approve" in the ".menu-action-text" "css_element"
|
|
|
142 |
# Single view (for teacher).
|
|
|
143 |
And I choose "Show more" in the open action menu
|
|
|
144 |
And I should see "Teacher entry 1"
|
|
|
145 |
And I open the action menu in "Teacher entry 1" "table_row"
|
|
|
146 |
And I should see "Undo approval"
|
|
|
147 |
And I should not see "Approve"
|
|
|
148 |
And I press the escape key
|
|
|
149 |
And I follow "Previous page"
|
|
|
150 |
And I should see "Student entry 1"
|
|
|
151 |
And I open the action menu in "Student entry 1" "table_row"
|
|
|
152 |
And I should not see "Approve"
|
|
|
153 |
And I should see "Undo approval"
|
|
|
154 |
# Check entries can be approved/unapproved from single view too.
|
|
|
155 |
And I choose "Undo approval" in the open action menu
|
|
|
156 |
And I should see "Entry unapproved"
|
|
|
157 |
And I press "Dismiss this notification"
|
|
|
158 |
And I open the action menu in "Student entry 1" "table_row"
|
|
|
159 |
And I should see "Approve"
|
|
|
160 |
And I should not see "Undo approval"
|
|
|
161 |
And I log out
|
|
|
162 |
# Students should not see the Approve/Undo approval options.
|
|
|
163 |
But I am on the "Test database name" "data activity" page logged in as student1
|
|
|
164 |
And I open the action menu in "Teacher entry 1" "table_row"
|
|
|
165 |
And I should not see "Approve"
|
|
|
166 |
And I should not see "Undo approval"
|
|
|
167 |
And I press the escape key
|
|
|
168 |
And I open the action menu in "Student entry 1" "table_row"
|
|
|
169 |
And I should not see "Approve"
|
|
|
170 |
And I should not see "Undo approval"
|
|
|
171 |
# Single view (for student).
|
|
|
172 |
And I choose "Show more" in the open action menu
|
|
|
173 |
And I should see "Student entry 1"
|
|
|
174 |
And I open the action menu in "Student entry 1" "table_row"
|
|
|
175 |
And I should not see "Approve"
|
|
|
176 |
And I should not see "Undo approval"
|
|
|
177 |
And I follow "Next page"
|
|
|
178 |
And I should see "Teacher entry 1"
|
|
|
179 |
And I should not see "Actions" in the "Teacher entry 1" "table_row"
|
|
|
180 |
|
|
|
181 |
@javascript
|
|
|
182 |
Scenario: The ##actionsmenu## replacement displays the Export to portfolio options
|
|
|
183 |
Given I log in as "admin"
|
|
|
184 |
And the following config values are set as admin:
|
|
|
185 |
| enableportfolios | 1 |
|
|
|
186 |
And I navigate to "Plugins > Portfolios > Manage portfolios" in site administration
|
|
|
187 |
And I set portfolio instance "File download" to "Enabled and visible"
|
|
|
188 |
And I click on "Save" "button"
|
|
|
189 |
And I log out
|
|
|
190 |
And I am on the "Test database name" "data activity" page logged in as teacher1
|
|
|
191 |
# Teachers should be able to export to portfolio all the entries from list view.
|
|
|
192 |
When I open the action menu in "Student entry 1" "table_row"
|
|
|
193 |
Then I should see "Export to portfolio"
|
|
|
194 |
And I choose "Export to portfolio" in the open action menu
|
|
|
195 |
And I should see "Configure exported data"
|
|
|
196 |
And I press "Cancel"
|
|
|
197 |
And I click on "Yes" "button" in the "Confirm" "dialogue"
|
|
|
198 |
And I open the action menu in "Teacher entry 1" "table_row"
|
|
|
199 |
And I should see "Export to portfolio"
|
|
|
200 |
# Single view (for teacher).
|
|
|
201 |
And I choose "Show more" in the open action menu
|
|
|
202 |
And I should see "Teacher entry 1"
|
|
|
203 |
And I open the action menu in "Teacher entry 1" "table_row"
|
|
|
204 |
And I should see "Export to portfolio"
|
|
|
205 |
And I press the escape key
|
|
|
206 |
And I follow "Previous page"
|
|
|
207 |
And I should see "Student entry 1"
|
|
|
208 |
And I open the action menu in "Student entry 1" "table_row"
|
|
|
209 |
And I should see "Export to portfolio"
|
|
|
210 |
# Check entries can be exported from single view too.
|
|
|
211 |
And I choose "Export to portfolio" in the open action menu
|
|
|
212 |
And I should see "Configure exported data"
|
|
|
213 |
And I log out
|
|
|
214 |
# Students should only export their entries.
|
|
|
215 |
But I am on the "Test database name" "data activity" page logged in as student1
|
|
|
216 |
And I open the action menu in "Teacher entry 1" "table_row"
|
|
|
217 |
And I should not see "Export to portfolio"
|
|
|
218 |
And I press the escape key
|
|
|
219 |
And I open the action menu in "Student entry 1" "table_row"
|
|
|
220 |
And I should see "Export to portfolio"
|
|
|
221 |
And I choose "Export to portfolio" in the open action menu
|
|
|
222 |
And I should see "Configure exported data"
|
|
|
223 |
And I press "Cancel"
|
|
|
224 |
And I click on "Yes" "button" in the "Confirm" "dialogue"
|
|
|
225 |
And I open the action menu in "Teacher entry 1" "table_row"
|
|
|
226 |
# Single view (for student).
|
|
|
227 |
And I choose "Show more" in the open action menu
|
|
|
228 |
And I should see "Teacher entry 1"
|
|
|
229 |
And I should not see "Actions" in the "Teacher entry 1" "table_row"
|
|
|
230 |
And I follow "Previous page"
|
|
|
231 |
And I should see "Student entry 1"
|
|
|
232 |
And I open the action menu in "Student entry 1" "table_row"
|
|
|
233 |
And I should see "Export to portfolio"
|
|
|
234 |
And I choose "Export to portfolio" in the open action menu
|
|
|
235 |
And I should see "Configure exported data"
|
|
|
236 |
|
|
|
237 |
@javascript
|
|
|
238 |
Scenario: The ##actionsmenu## replacement does not display the Export to portfolio option when there are no portfolios enabled
|
|
|
239 |
Given I log in as "admin"
|
|
|
240 |
And the following config values are set as admin:
|
|
|
241 |
| enableportfolios | 1 |
|
|
|
242 |
And I log out
|
|
|
243 |
And I am on the "Test database name" "data activity" page logged in as teacher1
|
|
|
244 |
When I open the action menu in "Student entry 1" "table_row"
|
|
|
245 |
Then I should not see "Export to portfolio"
|
|
|
246 |
And I log out
|
|
|
247 |
# If we enable, at least, one portfolio, the Export to portfolio option should be displayed.
|
|
|
248 |
But I log in as "admin"
|
|
|
249 |
And I navigate to "Plugins > Portfolios > Manage portfolios" in site administration
|
|
|
250 |
And I set portfolio instance "File download" to "Enabled and visible"
|
|
|
251 |
And I click on "Save" "button"
|
|
|
252 |
And I log out
|
|
|
253 |
And I am on the "Test database name" "data activity" page logged in as teacher1
|
|
|
254 |
And I open the action menu in "Student entry 1" "table_row"
|
|
|
255 |
And I should see "Export to portfolio"
|
|
|
256 |
|
|
|
257 |
@javascript
|
|
|
258 |
Scenario: The Edit option in the ##actionsmenu## replacement is working
|
|
|
259 |
Given I navigate to "Database" in current page administration
|
|
|
260 |
# Teachers should be able to edit any entry.
|
|
|
261 |
And I open the action menu in "Student entry 1" "table_row"
|
|
|
262 |
When I choose "Edit" in the open action menu
|
|
|
263 |
And I set the field "field2" to "Some MODIFIED BY THE TEACHER student content 1"
|
|
|
264 |
And I click on "Save" "button"
|
|
|
265 |
# Single view (for teacher).
|
|
|
266 |
Then I should see "Some MODIFIED BY THE TEACHER student content 1"
|
|
|
267 |
And I should not see "Some student content 1"
|
|
|
268 |
And I open the action menu in "Student entry 1" "table_row"
|
|
|
269 |
And I choose "Edit" in the open action menu
|
|
|
270 |
And I set the field "field2" to "Some MORE TEACHER MODIFICATIONS FOR student content 1"
|
|
|
271 |
And I click on "Save" "button"
|
|
|
272 |
And I should see "Some MORE TEACHER MODIFICATIONS FOR student content 1"
|
|
|
273 |
And I should not see "Some MODIFIED BY THE TEACHER student content 1"
|
|
|
274 |
And I log out
|
|
|
275 |
# Students only should edit their entries.
|
|
|
276 |
But I am on the "Test database name" "data activity" page logged in as student1
|
|
|
277 |
And I open the action menu in "Student entry 1" "table_row"
|
|
|
278 |
And I choose "Edit" in the open action menu
|
|
|
279 |
And I set the field "field2" to "Some MODIFIED student content 1"
|
|
|
280 |
And I click on "Save" "button"
|
|
|
281 |
# Single view (for student).
|
|
|
282 |
And I should see "Some MODIFIED student content 1"
|
|
|
283 |
And I should not see "Some MORE TEACHER MODIFICATIONS FOR student content 1"
|
|
|
284 |
And I open the action menu in "Student entry 1" "table_row"
|
|
|
285 |
And I choose "Edit" in the open action menu
|
|
|
286 |
And I set the field "field2" to "Some MORE MODIFICATIONS FOR student content 1"
|
|
|
287 |
And I click on "Save" "button"
|
|
|
288 |
And I should see "Some MORE MODIFICATIONS FOR student content 1"
|
|
|
289 |
And I should not see "Some MODIFIED student content 1"
|
|
|
290 |
|
|
|
291 |
@javascript
|
|
|
292 |
Scenario: The Delete option in the ##actionsmenu## replacement is working
|
|
|
293 |
Given the following "mod_data > entries" exist:
|
|
|
294 |
| database | user | field1 | field2 |
|
|
|
295 |
| data1 | student1 | Student entry 2 | Some student content 2 |
|
|
|
296 |
| data1 | teacher1 | Teacher entry 2 | Some teacher content 2 |
|
|
|
297 |
And I navigate to "Database" in current page administration
|
|
|
298 |
# Teachers should be able to delete any entry.
|
|
|
299 |
And I open the action menu in "Student entry 1" "table_row"
|
|
|
300 |
When I choose "Delete" in the open action menu
|
|
|
301 |
Then I should see "Delete entry"
|
|
|
302 |
# Cancel doesn't delete the entry.
|
|
|
303 |
And I click on "Cancel" "button" in the "Confirm" "dialogue"
|
|
|
304 |
And I open the action menu in "Teacher entry 1" "table_row"
|
|
|
305 |
# But Delete removes the entry.
|
|
|
306 |
And I choose "Delete" in the open action menu
|
|
|
307 |
And I should see "Delete entry"
|
|
|
308 |
And I click on "Delete" "button" in the "Confirm" "dialogue"
|
|
|
309 |
And I should see "Entry deleted"
|
|
|
310 |
And I should not see "Teacher entry 1"
|
|
|
311 |
And I should see "Teacher entry 2"
|
|
|
312 |
And I should see "Student entry 1"
|
|
|
313 |
And I should see "Student entry 2"
|
|
|
314 |
# Single view (for teacher).
|
|
|
315 |
And I open the action menu in "Teacher entry 2" "table_row"
|
|
|
316 |
And I choose "Delete" in the open action menu
|
|
|
317 |
And I should see "Delete entry"
|
|
|
318 |
And I click on "Delete" "button" in the "Confirm" "dialogue"
|
|
|
319 |
And I should see "Entry deleted"
|
|
|
320 |
And I should not see "Teacher entry 1"
|
|
|
321 |
And I should not see "Teacher entry 2"
|
|
|
322 |
And I should see "Student entry 1"
|
|
|
323 |
And I should see "Student entry 2"
|
|
|
324 |
And I log out
|
|
|
325 |
# Students only should edit their entries.
|
|
|
326 |
But I am on the "Test database name" "data activity" page logged in as student1
|
|
|
327 |
And I open the action menu in "Student entry 1" "table_row"
|
|
|
328 |
When I choose "Delete" in the open action menu
|
|
|
329 |
Then I should see "Delete entry"
|
|
|
330 |
# Cancel doesn't delete the entry.
|
|
|
331 |
And I click on "Cancel" "button" in the "Confirm" "dialogue"
|
|
|
332 |
And I open the action menu in "Student entry 1" "table_row"
|
|
|
333 |
# But Delete removes the entry.
|
|
|
334 |
And I choose "Delete" in the open action menu
|
|
|
335 |
And I should see "Delete entry"
|
|
|
336 |
And I click on "Delete" "button" in the "Confirm" "dialogue"
|
|
|
337 |
And I should see "Entry deleted"
|
|
|
338 |
And I should not see "Teacher entry 1"
|
|
|
339 |
And I should not see "Teacher entry 2"
|
|
|
340 |
And I should not see "Student entry 1"
|
|
|
341 |
And I should see "Student entry 2"
|
|
|
342 |
# Single view (for student).
|
|
|
343 |
And I open the action menu in "Student entry 2" "table_row"
|
|
|
344 |
And I choose "Delete" in the open action menu
|
|
|
345 |
And I should see "Delete entry"
|
|
|
346 |
And I click on "Delete" "button" in the "Confirm" "dialogue"
|
|
|
347 |
And I should see "Entry deleted"
|
|
|
348 |
And I should not see "Teacher entry 1"
|
|
|
349 |
And I should not see "Teacher entry 2"
|
|
|
350 |
And I should not see "Student entry 1"
|
|
|
351 |
And I should not see "Student entry 2"
|