forked from moodle/moodle
/
restore_moodle2_courses.feature
319 lines (304 loc) · 15.2 KB
/
restore_moodle2_courses.feature
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
@core @core_backup
Feature: Restore Moodle 2 course backups
In order to continue using my stored course contents
As a teacher and an admin
I need to restore them inside other Moodle courses or in new courses
Background:
Given the following "courses" exist:
| fullname | shortname | category | format | numsections | coursedisplay |
| Course 1 | C1 | 0 | topics | 15 | 1 |
| Course 2 | C2 | 0 | topics | 5 | 0 |
| Course 3 | C3 | 0 | topics | 2 | 0 |
| Course 4 | C4 | 0 | topics | 20 | 0 |
And the following "activities" exist:
| activity | course | idnumber | name | intro | section | externalurl |
| assign | C3 | assign1 | Test assign name | Assign description | 1 | |
| data | C3 | data1 | Test database name | Database description | 2 | |
| forum | C1 | 0001 | Test forum name | | 1 | |
| url | C1 | url1 | Test URL name | Test URL description | 3 | http://www.moodle.org |
And the following "blocks" exist:
| blockname | contextlevel | reference | pagetypepattern | defaultregion |
| activity_modules | Course | C1 | course-view-* | side-pre |
And I log in as "admin"
And I am on "Course 1" course homepage with editing mode on
@javascript
Scenario: Restore a course in another existing course
When I backup "Course 1" course using this options:
| Confirmation | Filename | test_backup.mbz |
And I restore "test_backup.mbz" backup into "Course 2" course using this options:
Then I should see "Course 2"
And I should see "Activities" in the "Activities" "block"
And I should see "Test forum name"
@javascript
Scenario: Restore a course in a new course
When I backup "Course 1" course using this options:
| Confirmation | Filename | test_backup.mbz |
And I restore "test_backup.mbz" backup into a new course using this options:
| Schema | Course name | Course 1 restored in a new course |
Then I should see "Course 1 restored in a new course"
And I should see "Activities" in the "Activities" "block"
And I should see "Test forum name"
And I should see "Topic 15"
And I should not see "Topic 16"
And I navigate to "Settings" in current page administration
And I expand all fieldsets
And the field "id_format" matches value "Custom sections"
And I press "Cancel"
@javascript
Scenario: Restore a course with a customfield in a new course
Given the following "custom field categories" exist:
| name | component | area | itemid |
| Category for test | core_course | course | 0 |
When I navigate to "Courses > Course custom fields" in site administration
And I click on "Add a new custom field" "link"
And I click on "Dropdown menu" "link"
And I set the following fields to these values:
| Name | Test field1 |
| Short name | testfield1 |
| Locked | No |
And I set the field "Menu options (one per line)" to multiline:
"""
a
b
"""
And I click on "Save changes" "button" in the "Adding a new Dropdown menu" "dialogue"
And I am on "Course 1" course homepage
And I navigate to "Settings" in current page administration
And I set the following fields to these values:
| Test field1 | b |
And I press "Save and display"
And I am on "Course 1" course homepage with editing mode on
When I backup "Course 1" course using this options:
| Confirmation | Filename | test_backup.mbz |
And I restore "test_backup.mbz" backup into a new course using this options:
| Schema | Course name | Course 1 restored in a new course |
| Schema | Course short name | Course 1 restored in a new course |
And I am on "Course 1 restored in a new course" course homepage
And I navigate to "Settings" in current page administration
And I expand all fieldsets
Then the field "id_customfield_testfield1" matches value "b"
And I press "Cancel"
@javascript @_file_upload
Scenario: Restore a course with a customfield from a backup before MDL-75809
Given the following "custom field categories" exist:
| name | component | area | itemid |
| Category for test | core_course | course | 0 |
When I navigate to "Courses > Course custom fields" in site administration
And I click on "Add a new custom field" "link"
And I click on "Dropdown menu" "link"
And I set the following fields to these values:
| Name | Test field1 |
| Short name | dropdownmenu |
| Locked | No |
And I set the field "Menu options (one per line)" to multiline:
"""
First
Second
Third
Fourth
"""
And I click on "Save changes" "button" in the "Adding a new Dropdown menu" "dialogue"
And I am on the "Course 1" "restore" page logged in as "admin"
And I press "Manage backup files"
And I upload "backup/moodle2/tests/fixtures/pre-mdl-75809.mbz" file to "Files" filemanager
And I press "Save changes"
And I restore "pre-mdl-75809.mbz" backup into a new course using this options:
| Schema | Course name | Course 5 |
| Schema | Course short name | C5 |
And I am on "C5" course homepage
And I navigate to "Settings" in current page administration
And I expand all fieldsets
Then the field "id_customfield_dropdownmenu" matches value "Second"
And I press "Cancel"
@javascript
Scenario: Restore a backup into the same course
When I backup "Course 3" course using this options:
| Confirmation | Filename | test_backup.mbz |
And I restore "test_backup.mbz" backup into "Course 2" course using this options:
| Schema | Test database name | 0 |
| Schema | Section 2 | 0 |
Then I should see "Course 2"
And I should see "Test assign name"
And I should not see "Test database name"
@javascript
Scenario: Restore a backup into the same course removing it's contents before that
When I backup "Course 1" course using this options:
| Confirmation | Filename | test_backup.mbz |
And the following "activity" exists:
| activity | forum |
| course | C1 |
| section | 1 |
| name | Test forum post backup name |
And I am on the "Course 1" "restore" page
And I merge "test_backup.mbz" backup into the current course after deleting it's contents using this options:
| Schema | Section 3 | 0 |
Then I should see "Course 1"
And I should not see "Section 3"
And I should not see "Test forum post backup name"
And I should see "Activities" in the "Activities" "block"
And I should see "Test forum name"
@javascript
Scenario: Restore a backup into a new course changing the course format afterwards
Given I backup "Course 1" course using this options:
| Confirmation | Filename | test_backup.mbz |
When I restore "test_backup.mbz" backup into a new course using this options:
Then I should see "Topic 1"
And I should see "Test forum name"
And I navigate to "Settings" in current page administration
And I expand all fieldsets
And the field "id_format" matches value "Custom sections"
And I set the following fields to these values:
| id_startdate_day | 1 |
| id_startdate_month | January |
| id_startdate_year | 2020 |
| id_format | Weekly sections |
| id_enddate_enabled | 0 |
And I press "Save and display"
And I should see "1 January - 7 January"
And I should see "Test forum name"
And I navigate to "Settings" in current page administration
And I expand all fieldsets
And the field "id_format" matches value "Weekly sections"
And I set the following fields to these values:
| id_format | Social |
And I press "Save and display"
And I should see "An open forum for chatting about anything you want to"
And I navigate to "Settings" in current page administration
And I expand all fieldsets
And the field "id_format" matches value "Social"
And I press "Cancel"
@javascript
Scenario: Restore a backup in an existing course retaining the backup course settings
Given I hide section "3"
And I hide section "7"
When I backup "Course 1" course using this options:
| Confirmation | Filename | test_backup.mbz |
And I restore "test_backup.mbz" backup into "Course 2" course using this options:
| Schema | Overwrite course configuration | Yes |
And I navigate to "Settings" in current page administration
And I expand all fieldsets
Then the field "id_format" matches value "Custom sections"
And the field "Course layout" matches value "Show one section per page"
And the field "Course short name" matches value "C1_1"
And I press "Cancel"
And section "3" should be visible
And section "7" should be hidden
And section "15" should be visible
And I should see "Topic 15"
And I should not see "Topic 16"
And I should see "Test URL name" in the "Topic 3" "section"
And I should see "Test forum name" in the "Topic 1" "section"
@javascript
Scenario: Restore a backup in an existing course keeping the target course settings
Given I hide section "3"
And I hide section "7"
When I backup "Course 1" course using this options:
| Confirmation | Filename | test_backup.mbz |
And I restore "test_backup.mbz" backup into "Course 2" course using this options:
| Schema | Overwrite course configuration | No |
And I navigate to "Settings" in current page administration
And I expand all fieldsets
Then the field "id_format" matches value "Custom sections"
And the field "Course short name" matches value "C2"
And the field "Course layout" matches value "Show all sections on one page"
And I press "Cancel"
And section "3" should be visible
And section "7" should be hidden
And section "15" should be visible
And I should see "Topic 15"
And I should not see "Topic 16"
And I should see "Test URL name" in the "Topic 3" "section"
And I should see "Test forum name" in the "Topic 1" "section"
@javascript
Scenario: Restore a backup in an existing course deleting contents and retaining the backup course settings
Given I hide section "3"
And I hide section "7"
When I backup "Course 1" course using this options:
| Initial | Include enrolled users | 0 |
| Confirmation | Filename | test_backup.mbz |
And I am on the "Course 2" "restore" page
And I merge "test_backup.mbz" backup into the current course after deleting it's contents using this options:
| Schema | Overwrite course configuration | Yes |
And I navigate to "Settings" in current page administration
And I expand all fieldsets
Then the field "id_format" matches value "Custom sections"
And the field "Course layout" matches value "Show one section per page"
And the field "Course short name" matches value "C1_1"
And I press "Cancel"
And section "3" should be hidden
And section "7" should be hidden
And section "15" should be visible
And I should see "Topic 15"
And I should not see "Topic 16"
And I should see "Test URL name" in the "Topic 3" "section"
And I should see "Test forum name" in the "Topic 1" "section"
@javascript
Scenario: Restore a backup in an existing course deleting contents and keeping the current course settings
Given I hide section "3"
And I hide section "7"
When I backup "Course 1" course using this options:
| Initial | Include enrolled users | 0 |
| Confirmation | Filename | test_backup.mbz |
And I am on the "Course 2" "restore" page
And I merge "test_backup.mbz" backup into the current course after deleting it's contents using this options:
| Schema | Overwrite course configuration | No |
And I navigate to "Settings" in current page administration
And I expand all fieldsets
Then the field "id_format" matches value "Custom sections"
And the field "Course short name" matches value "C2"
And the field "Course layout" matches value "Show all sections on one page"
And I press "Cancel"
And section "3" should be hidden
And section "7" should be hidden
And section "15" should be visible
And I should see "Topic 15"
And I should not see "Topic 16"
And I should see "Test URL name" in the "Topic 3" "section"
And I should see "Test forum name" in the "Topic 1" "section"
@javascript
Scenario: Restore a backup in an existing course deleting contents decreasing the number of sections
Given I hide section "3"
And I hide section "7"
When I backup "Course 1" course using this options:
| Initial | Include enrolled users | 0 |
| Confirmation | Filename | test_backup.mbz |
And I am on the "Course 4" "restore" page
And I merge "test_backup.mbz" backup into the current course after deleting it's contents using this options:
| Schema | Overwrite course configuration | No |
And I navigate to "Settings" in current page administration
And I expand all fieldsets
Then the field "id_format" matches value "Custom sections"
And the field "Course short name" matches value "C4"
And the field "Course layout" matches value "Show all sections on one page"
And I press "Cancel"
And section "3" should be hidden
And section "7" should be hidden
And section "15" should be visible
And I should see "Topic 15"
And I should not see "Topic 16"
And I should see "Test URL name" in the "Topic 3" "section"
And I should see "Test forum name" in the "Topic 1" "section"
@javascript
Scenario: Restore a backup with override permission
Given the following "permission overrides" exist:
| capability | permission | role | contextlevel | reference |
| enrol/manual:enrol | Allow | teacher | Course | C1 |
And I backup "Course 1" course using this options:
| Confirmation | Filename | test_backup.mbz |
When I restore "test_backup.mbz" backup into a new course using this options:
| Settings | Include permission overrides | 1 |
Then I am on the "Course 1 copy 1" "permissions" page
And I should see "Non-editing teacher (1)"
And I set the field "Advanced role override" to "Non-editing teacher (1)"
And "enrol/manual:enrol" capability has "Allow" permission
@javascript
Scenario: Restore a backup without override permission
Given the following "permission overrides" exist:
| capability | permission | role | contextlevel | reference |
| enrol/manual:enrol | Allow | teacher | Course | C1 |
And I backup "Course 1" course using this options:
| Confirmation | Filename | test_backup.mbz |
When I restore "test_backup.mbz" backup into a new course using this options:
| Settings | Include permission overrides | 0 |
Then I am on the "Course 1 copy 1" "permissions" page
And I should see "Non-editing teacher (0)"