1 |
efrain |
1 |
@core @core_availability
|
|
|
2 |
Feature: edit_availability
|
|
|
3 |
In order to control which students can see activities
|
|
|
4 |
As a teacher
|
|
|
5 |
I need to set up availability options for activities and sections
|
|
|
6 |
|
|
|
7 |
# PURPOSE OF THIS TEST FEATURE:
|
|
|
8 |
#
|
|
|
9 |
# This test covers the user interface around editing availability conditions,
|
|
|
10 |
# especially the JavaScript code which is not tested elsewhere (e.g. does the
|
|
|
11 |
# 'Add restriction' dialog work). It tests both forms and also the admin
|
|
|
12 |
# setting interface.
|
|
|
13 |
#
|
|
|
14 |
# This test does not check the detailed behaviour of the availability system,
|
|
|
15 |
# which is mainly covered in PHPUnit (and, from the user interface
|
|
|
16 |
# perspective, in the other Behat tests for each type of condition).
|
|
|
17 |
|
|
|
18 |
Background:
|
|
|
19 |
Given the following "courses" exist:
|
|
|
20 |
| fullname | shortname | format |
|
|
|
21 |
| Course 1 | C1 | topics |
|
|
|
22 |
And the following "users" exist:
|
|
|
23 |
| username |
|
|
|
24 |
| teacher1 |
|
|
|
25 |
| student1 |
|
|
|
26 |
And the following "course enrolments" exist:
|
|
|
27 |
| user | course | role |
|
|
|
28 |
| teacher1 | C1 | editingteacher |
|
|
|
29 |
| student1 | C1 | student |
|
|
|
30 |
And the following "activity" exists:
|
|
|
31 |
| activity | forum |
|
|
|
32 |
| course | C1 |
|
|
|
33 |
| name | MyForum |
|
|
|
34 |
|
|
|
35 |
Scenario: Confirm the 'enable availability' option is working
|
|
|
36 |
Given the following config values are set as admin:
|
|
|
37 |
| enableavailability | 0 |
|
|
|
38 |
When I log in as "teacher1"
|
|
|
39 |
And the following "activity" exists:
|
|
|
40 |
| activity | page |
|
|
|
41 |
| course | C1 |
|
|
|
42 |
| idnumber | 0001 |
|
|
|
43 |
| section | 1 |
|
|
|
44 |
| name | Page1 |
|
|
|
45 |
| intro | pageintro |
|
|
|
46 |
And I am on "Course 1" course homepage with editing mode on
|
|
|
47 |
And I follow "Page1"
|
|
|
48 |
And I navigate to "Settings" in current page administration
|
|
|
49 |
Then "Restrict access" "fieldset" should not exist
|
|
|
50 |
|
|
|
51 |
Given I am on "Course 1" course homepage
|
|
|
52 |
When I edit the section "1"
|
|
|
53 |
Then "Restrict access" "fieldset" should not exist
|
|
|
54 |
|
|
|
55 |
And the following config values are set as admin:
|
|
|
56 |
| enableavailability | 1 |
|
|
|
57 |
|
|
|
58 |
And the following "activity" exists:
|
|
|
59 |
| activity | page |
|
|
|
60 |
| course | C1 |
|
|
|
61 |
| idnumber | 0002 |
|
|
|
62 |
| name | Page2 |
|
|
|
63 |
And I am on the "Page2" "page activity editing" page
|
|
|
64 |
Then "Restrict access" "fieldset" should exist
|
|
|
65 |
|
|
|
66 |
Given I am on "Course 1" course homepage
|
|
|
67 |
When I edit the section "1"
|
|
|
68 |
Then "Restrict access" "fieldset" should exist
|
|
|
69 |
|
|
|
70 |
@javascript
|
|
|
71 |
Scenario: Edit availability using settings in activity form
|
|
|
72 |
# Set up.
|
|
|
73 |
Given the following "activity" exists:
|
|
|
74 |
| activity | page |
|
|
|
75 |
| course | C1 |
|
|
|
76 |
| section | 1 |
|
|
|
77 |
| name | P1 |
|
|
|
78 |
And I am on the "P1" "page activity editing" page logged in as "teacher1"
|
|
|
79 |
And I expand all fieldsets
|
|
|
80 |
Then I should see "None" in the "Restrict access" "fieldset"
|
|
|
81 |
|
|
|
82 |
# Add a Date restriction and check it appears.
|
|
|
83 |
When I click on "Add restriction..." "button"
|
|
|
84 |
Then "Add restriction..." "dialogue" should be visible
|
|
|
85 |
When I click on "Date" "button" in the "Add restriction..." "dialogue"
|
|
|
86 |
Then "Add restriction..." "dialogue" should not exist
|
|
|
87 |
And I should not see "None" in the "Restrict access" "fieldset"
|
|
|
88 |
And "Restriction type" "select" should be visible
|
|
|
89 |
And I should see "Date" in the "Restrict access" "fieldset"
|
|
|
90 |
And ".availability-item .availability-eye img" "css_element" should be visible
|
|
|
91 |
And ".availability-item .availability-delete img" "css_element" should be visible
|
|
|
92 |
And the "alt" attribute of ".availability-item .availability-eye img" "css_element" should contain "Displayed if student"
|
|
|
93 |
|
|
|
94 |
# Toggle the eye icon.
|
|
|
95 |
When I click on ".availability-item .availability-eye img" "css_element"
|
|
|
96 |
Then the "alt" attribute of ".availability-item .availability-eye img" "css_element" should contain "Hidden entirely"
|
|
|
97 |
When I click on ".availability-item .availability-eye img" "css_element"
|
|
|
98 |
Then the "alt" attribute of ".availability-item .availability-eye img" "css_element" should contain "Displayed if student"
|
|
|
99 |
|
|
|
100 |
# Click the delete button.
|
|
|
101 |
When I click on ".availability-item .availability-delete img" "css_element"
|
|
|
102 |
Then I should not see "Date" in the "Restrict access" "fieldset"
|
|
|
103 |
|
|
|
104 |
# Add a nested restriction set and check it appears.
|
|
|
105 |
When I click on "Add restriction..." "button"
|
|
|
106 |
And I click on "Restriction set" "button" in the "Add restriction..." "dialogue"
|
|
|
107 |
Then ".availability-children .availability-list" "css_element" should be visible
|
|
|
108 |
And I should see "None" in the ".availability-children .availability-list" "css_element"
|
|
|
109 |
And I should see "Please set" in the ".availability-children .availability-list" "css_element"
|
|
|
110 |
And I should see "Add restriction" in the ".availability-children .availability-list" "css_element"
|
|
|
111 |
|
|
|
112 |
# Click on the button to add a restriction inside the nested set.
|
|
|
113 |
When I click on "Add restriction..." "button" in the ".availability-children .availability-list" "css_element"
|
|
|
114 |
And I click on "Date" "button" in the "Add restriction..." "dialogue"
|
|
|
115 |
Then I should not see "None" in the ".availability-children .availability-list" "css_element"
|
|
|
116 |
And I should not see "Please set" in the ".availability-children .availability-list" "css_element"
|
|
|
117 |
And I should see "Date" in the ".availability-children .availability-list" "css_element"
|
|
|
118 |
|
|
|
119 |
# OK, let's delete the date inside the nested set...
|
|
|
120 |
When I click on ".availability-item .availability-delete img" "css_element" in the ".availability-item" "css_element"
|
|
|
121 |
Then I should not see "Date" in the ".availability-children .availability-list" "css_element"
|
|
|
122 |
And I should see "None" in the ".availability-children .availability-list" "css_element"
|
|
|
123 |
|
|
|
124 |
# ...and the nested set itself.
|
|
|
125 |
When I click on ".availability-none .availability-delete img" "css_element"
|
|
|
126 |
Then ".availability-children .availability-list" "css_element" should not exist
|
|
|
127 |
|
|
|
128 |
# Add two dates so we can check the connectors.
|
|
|
129 |
When I click on "Add restriction..." "button"
|
|
|
130 |
And I click on "Date" "button" in the "Add restriction..." "dialogue"
|
|
|
131 |
And I click on "Add restriction..." "button"
|
|
|
132 |
And I click on "Date" "button" in the "Add restriction..." "dialogue"
|
|
|
133 |
Then I should see "and" in the "Restrict access" "fieldset"
|
|
|
134 |
And "Required restrictions" "select" should be visible
|
|
|
135 |
|
|
|
136 |
# Try changing the connector type.
|
|
|
137 |
When I set the field "Required restrictions" to "any"
|
|
|
138 |
Then I should not see "and" in the "Restrict access" "fieldset"
|
|
|
139 |
And I should see "or" in the "Restrict access" "fieldset"
|
|
|
140 |
|
|
|
141 |
# Now delete one of the dates and check the connector goes away.
|
|
|
142 |
When I click on ".availability-item .availability-delete img" "css_element"
|
|
|
143 |
Then I should not see "or" in the "Restrict access" "fieldset"
|
|
|
144 |
|
|
|
145 |
# Add a nested restriction set with two dates so there will be inner connector.
|
|
|
146 |
When I click on "Add restriction..." "button"
|
|
|
147 |
And I click on "Restriction set" "button" in the "Add restriction..." "dialogue"
|
|
|
148 |
And I click on "Add restriction..." "button" in the ".availability-children .availability-list" "css_element"
|
|
|
149 |
And I click on "Date" "button" in the "Add restriction..." "dialogue"
|
|
|
150 |
And I click on "Add restriction..." "button" in the ".availability-children .availability-list" "css_element"
|
|
|
151 |
And I click on "Date" "button" in the "Add restriction..." "dialogue"
|
|
|
152 |
Then I should see "and" in the ".availability-children .availability-list .availability-connector" "css_element"
|
|
|
153 |
|
|
|
154 |
# Check changing the outer one does not affect the inner one.
|
|
|
155 |
When I set the field "Required restrictions" to "all"
|
|
|
156 |
Then I should not see "or" in the "Restrict access" "fieldset"
|
|
|
157 |
When I set the field "Required restrictions" to "any"
|
|
|
158 |
Then I should see "or" in the "Restrict access" "fieldset"
|
|
|
159 |
And I should not see "or" in the ".availability-children .availability-list .availability-connector" "css_element"
|
|
|
160 |
|
|
|
161 |
@javascript
|
|
|
162 |
Scenario: Edit availability using settings in section form
|
|
|
163 |
# Set up.
|
|
|
164 |
Given I log in as "teacher1"
|
|
|
165 |
And I am on "Course 1" course homepage with editing mode on
|
|
|
166 |
|
|
|
167 |
# Edit a section
|
|
|
168 |
When I edit the section "1"
|
|
|
169 |
And I expand all fieldsets
|
|
|
170 |
Then I should see "None" in the "Restrict access" "fieldset"
|
|
|
171 |
|
|
|
172 |
# Add a Date restriction and check it appears.
|
|
|
173 |
When I click on "Add restriction..." "button"
|
|
|
174 |
When I click on "Date" "button" in the "Add restriction..." "dialogue"
|
|
|
175 |
And I should not see "None" in the "Restrict access" "fieldset"
|
|
|
176 |
And "Restriction type" "select" should be visible
|
|
|
177 |
And I should see "Date" in the "Restrict access" "fieldset"
|
|
|
178 |
|
|
|
179 |
@javascript
|
|
|
180 |
Scenario: 'Add group/grouping access restriction' button unavailable
|
|
|
181 |
# Button does not exist when conditional access restrictions are turned off.
|
|
|
182 |
Given the following config values are set as admin:
|
|
|
183 |
| enableavailability | 0 |
|
|
|
184 |
And I am on the "MyForum" "forum activity editing" page logged in as admin
|
|
|
185 |
When I expand all fieldsets
|
|
|
186 |
Then "Add group/grouping access restriction" "button" should not exist
|
|
|
187 |
|
|
|
188 |
@javascript
|
|
|
189 |
Scenario: Use the 'Add group/grouping access restriction' button
|
|
|
190 |
# Button should initially be disabled.
|
|
|
191 |
Given the following "groupings" exist:
|
|
|
192 |
| name | course | idnumber |
|
|
|
193 |
| GX1 | C1 | GXI1 |
|
|
|
194 |
And I am on the "MyForum" "forum activity editing" page logged in as admin
|
|
|
195 |
When I expand all fieldsets
|
|
|
196 |
Then the "Add group/grouping access restriction" "button" should be disabled
|
|
|
197 |
|
|
|
198 |
# Turn on separate groups.
|
|
|
199 |
And I set the field "Group mode" to "Separate groups"
|
|
|
200 |
And the "Add group/grouping access restriction" "button" should be enabled
|
|
|
201 |
|
|
|
202 |
# Press the button and check it adds a restriction and disables itself.
|
|
|
203 |
And I should see "None" in the "Restrict access" "fieldset"
|
|
|
204 |
And I press "Add group/grouping access restriction"
|
|
|
205 |
And I should see "Group" in the "Restrict access" "fieldset"
|
|
|
206 |
And the "Add group/grouping access restriction" "button" should be disabled
|
|
|
207 |
|
|
|
208 |
# Delete the restriction and check it is enabled again.
|
|
|
209 |
And I click on "Delete" "link" in the "Restrict access" "fieldset"
|
|
|
210 |
And the "Add group/grouping access restriction" "button" should be enabled
|
|
|
211 |
|
|
|
212 |
# Try a grouping instead.
|
|
|
213 |
And I set the field "Grouping" to "GX1"
|
|
|
214 |
And I press "Add group/grouping access restriction"
|
|
|
215 |
And I should see "Grouping" in the "Restrict access" "fieldset"
|
|
|
216 |
|
|
|
217 |
# Check the button still works after saving and editing.
|
|
|
218 |
And I press "Save and display"
|
|
|
219 |
And I navigate to "Settings" in current page administration
|
|
|
220 |
And I expand all fieldsets
|
|
|
221 |
And the "Add group/grouping access restriction" "button" should be disabled
|
|
|
222 |
And I should see "Grouping" in the "Restrict access" "fieldset"
|
|
|
223 |
|
|
|
224 |
# And check it's still active if I delete the condition.
|
|
|
225 |
And I click on "Delete" "link" in the "Restrict access" "fieldset"
|
|
|
226 |
And the "Add group/grouping access restriction" "button" should be enabled
|
|
|
227 |
|
|
|
228 |
@javascript
|
|
|
229 |
Scenario: Edit section availability using course page link
|
|
|
230 |
# Setting a restriction up
|
|
|
231 |
Given I log in as "teacher1"
|
|
|
232 |
And I am on "Course 1" course homepage with editing mode on
|
|
|
233 |
And I edit the section "1"
|
|
|
234 |
And I expand all fieldsets
|
|
|
235 |
And I press "Add restriction..."
|
|
|
236 |
And I click on "Date" "button" in the "Add restriction..." "dialogue"
|
|
|
237 |
And I press "Save changes"
|
|
|
238 |
# Testing edit restrictions link
|
|
|
239 |
And "Edit restrictions" "link" should exist in the "section-1" "core_availability > Section availability"
|
|
|
240 |
When I click on "Edit restrictions" "link" in the "section-1" "core_availability > Section availability"
|
|
|
241 |
Then I should see "Restrict access"
|
|
|
242 |
And I should not see "Summary of General"
|
|
|
243 |
And I should see "Collapse all"
|
|
|
244 |
And I should not see "Expand all"
|
|
|
245 |
And I click on "Cancel" "button"
|
|
|
246 |
And I am on "Course 1" course homepage with editing mode off
|
|
|
247 |
And I should not see "Edit restrictions"
|
|
|
248 |
|
|
|
249 |
@javascript
|
|
|
250 |
Scenario: Edit activity availability using course page link
|
|
|
251 |
# Setting a restriction up
|
|
|
252 |
Given I am on the "MyForum" "forum activity editing" page logged in as teacher1
|
|
|
253 |
And I expand all fieldsets
|
|
|
254 |
And I press "Add restriction..."
|
|
|
255 |
And I click on "Date" "button" in the "Add restriction..." "dialogue"
|
|
|
256 |
When I press "Save and return to course"
|
|
|
257 |
# Edit restrictions link not displayed when editing mode is off.
|
|
|
258 |
Then "Edit restrictions" "link" should not exist in the "MyForum" "core_availability > Activity availability"
|
|
|
259 |
# Testing edit restrictions link
|
|
|
260 |
But I am on "Course 1" course homepage with editing mode on
|
|
|
261 |
And "Edit restrictions" "link" should exist in the "MyForum" "core_availability > Activity availability"
|
|
|
262 |
And I click on "Edit restrictions" "link" in the "MyForum" "core_availability > Activity availability"
|
|
|
263 |
And I should see "Restrict access"
|
|
|
264 |
And I should not see "Content"
|
|
|
265 |
And I should see "Collapse all"
|
|
|
266 |
And I should not see "Expand all"
|
|
|
267 |
|
|
|
268 |
@javascript
|
|
|
269 |
Scenario: Edit activity availability button is shown after duplicating an activity
|
|
|
270 |
# Setting a restriction up
|
|
|
271 |
Given I am on the "MyForum" "forum activity editing" page logged in as teacher1
|
|
|
272 |
And I expand all fieldsets
|
|
|
273 |
And I press "Add restriction..."
|
|
|
274 |
And I click on "Date" "button" in the "Add restriction..." "dialogue"
|
|
|
275 |
When I press "Save and return to course"
|
|
|
276 |
And I turn editing mode on
|
|
|
277 |
And I duplicate "MyForum" activity
|
|
|
278 |
# Testing edit restrictions link
|
|
|
279 |
Then "Edit restrictions" "link" should exist in the "MyForum (copy)" "core_availability > Activity availability"
|