forked from moodle-an-hochschulen/moodle-local_bulkenrol
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlocal_bulkenrol_users.feature
256 lines (245 loc) · 12.8 KB
/
local_bulkenrol_users.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
@local @local_bulkenrol @local_bulkenrol_users @javascript
Feature: Using the local_bulkenrol plugin for user enrolments
In order to bulk enrol users into the course
As user with the appropriate rights
I need to be able to use the plugin local_bulkenrol
Background:
Given the following "courses" exist:
| fullname | shortname | format |
| Course 1 | C1 | topics |
And the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | [email protected] |
| student1 | Student | 1 | [email protected] |
| student2 | Student | 2 | [email protected] |
| student3 | Student | 3 | [email protected] |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
And the following config values are set as admin:
| config | value | plugin |
| enrolplugin | manual | local_bulkenrol |
| navigation | navpart | local_bulkenrol |
Given I log in as "admin"
And I navigate to "Plugins > Enrolments > User bulk enrolment" in site administration
And I set the following fields to these values:
| Role | Student |
And I press "Save changes"
And I set the following system permissions of "Teacher" role:
| capability | permission |
| local/bulkenrol:enrolusers | Allow |
And I log out
Scenario: Bulk enrol students into the course who are not enrolled yet with authentication method self
Given the following config values are set as admin:
| config | value | plugin |
| enrolplugin | self | local_bulkenrol |
When I log in as "teacher1"
And I am on "Course 1" course homepage
And I navigate to "Users > User bulk enrolment" in current page administration
And I set the field "List of users identified by your chosen field" to multiline:
"""
"""
And I click on "Enrol users" "button"
Then the following should exist in the "localbulkenrol_enrolusers" table:
| Email address | First name | Last name | User enrolment |
| [email protected] | Student | 1 | User will be enrolled |
| [email protected] | Student | 2 | User will be enrolled |
| [email protected] | Student | 3 | User will be enrolled |
And the following should exist in the "localbulkenrol_enrolinfo" table:
| Enrolment method | Assigned role |
| Self enrolment | Student |
And I click on "Enrol users" "button"
Then the following should exist in the "participants" table:
| Email address | First name | Last name | Roles |
| [email protected] | Student | 1 | Student |
| [email protected] | Student | 2 | Student |
| [email protected] | Student | 3 | Student |
And "div[data-fullname='Student 1'][data-enrolinstancename='Self enrolment (Student)'][data-status='Active']" "css_element" should exist
Scenario: Bulk enrol students into the course who are not enrolled yet with authentication method manual
When I log in as "teacher1"
And I am on "Course 1" course homepage
And I navigate to "Users > User bulk enrolment" in current page administration
And I set the field "List of users identified by your chosen field" to multiline:
"""
"""
And I click on "Enrol users" "button"
Then the following should exist in the "localbulkenrol_enrolusers" table:
| Email address | First name | Last name | User enrolment |
| [email protected] | Student | 1 | User will be enrolled |
| [email protected] | Student | 2 | User will be enrolled |
| [email protected] | Student | 3 | User will be enrolled |
And the following should exist in the "localbulkenrol_enrolinfo" table:
| Enrolment method | Assigned role |
| Manual enrolments | Student |
And I click on "Enrol users" "button"
Then the following should exist in the "participants" table:
| Email address | First name | Last name | Roles |
| [email protected] | Student | 1 | Student |
| [email protected] | Student | 2 | Student |
| [email protected] | Student | 3 | Student |
And "div[data-fullname='Student 1'][data-enrolinstancename='Manual enrolments'][data-status='Active']" "css_element" should exist
Scenario: Bulk enrol users into the course who are not enrolled yet with role teacher
Given I log in as "admin"
And I navigate to "Plugins > Enrolments > User bulk enrolment" in site administration
And I set the following fields to these values:
| Role | Teacher |
And I press "Save changes"
And I log out
When I log in as "teacher1"
And I am on "Course 1" course homepage
And I navigate to "Users > User bulk enrolment" in current page administration
And I set the field "List of users identified by your chosen field" to multiline:
"""
"""
And I click on "Enrol users" "button"
Then the following should exist in the "localbulkenrol_enrolusers" table:
| Email address | First name | Last name | User enrolment |
| [email protected] | Student | 1 | User will be enrolled |
| [email protected] | Student | 2 | User will be enrolled |
| [email protected] | Student | 3 | User will be enrolled |
And the following should exist in the "localbulkenrol_enrolinfo" table:
| Enrolment method | Assigned role |
| Manual enrolments | Teacher |
And I click on "Enrol users" "button"
Then the following should exist in the "participants" table:
| Email address | First name | Last name | Roles |
| [email protected] | Student | 1 | Teacher |
| [email protected] | Student | 2 | Teacher |
| [email protected] | Student | 3 | Teacher |
And "div[data-fullname='Student 1'][data-enrolinstancename='Manual enrolments'][data-status='Active']" "css_element" should exist
Scenario: Bulk enrol users into the course by their ID
Given I log in as "admin"
And I navigate to "Plugins > Enrolments > User bulk enrolment" in site administration
And I set the following fields to these values:
| Fieldoptions | idnumber,email,username |
And I press "Save changes"
And I log out
When I log in as "teacher1"
And I am on "Course 1" course homepage
And I navigate to "Users > User bulk enrolment" in current page administration
Then the "dbfield" select box should contain "email"
And the "dbfield" select box should contain "idnumber"
And the "dbfield" select box should contain "username"
And I set the field "List of users identified by your chosen field" to multiline:
"""
2
3
4
"""
And I click on "Enrol users" "button"
Then the following should exist in the "localbulkenrol_enrolusers" table:
| idnumber | First name | Surname | User enrolment |
| 1 | Student | 1 | User will be enrolled |
| 2 | Student | 2 | User will be enrolled |
| 3 | Student | 3 | User will be enrolled |
And the following should exist in the "localbulkenrol_enrolinfo" table:
| Enrolment method | Assigned role |
| Manual enrolments | Student |
And I click on "Enrol users" "button"
Then the following should exist in the "participants" table:
| Email address | First name | Surname | Roles |
| [email protected] | Student | 1 | Student |
| [email protected] | Student | 2 | Student |
| [email protected] | Student | 3 | Student |
When I click on "[data-enrolinstancename='Manual enrolments'] a[data-action=showdetails]" "css_element" in the "Student 1" "table_row"
Then I should see "Manual enrolments"
Scenario: Bulk enrol students into the course with students already enrolled
Given the following "course enrolments" exist:
| user | course | role |
| student1 | C1 | student |
When I log in as "teacher1"
And I am on "Course 1" course homepage
And I navigate to "Users > User bulk enrolment" in current page administration
And I set the field "List of users identified by your chosen field" to multiline:
"""
"""
And I click on "Enrol users" "button"
Then the following should exist in the "localbulkenrol_enrolusers" table:
| Email address | First name | Last name | User enrolment |
| [email protected] | Student | 1 | User is already enrolled |
| [email protected] | Student | 2 | User will be enrolled |
| [email protected] | Student | 3 | User will be enrolled |
And I click on "Enrol users" "button"
Then the following should exist in the "participants" table:
| Email address | First name | Last name | Roles |
| [email protected] | Student | 1 | Student |
| [email protected] | Student | 2 | Student |
| [email protected] | Student | 3 | Student |
Scenario: Respect existing self enrolments during bulk enrol
Given I log in as "admin"
And I am on "Course 1" course homepage
And I add "Self enrolment" enrolment method in "Course 1" with:
| Custom instance name | Self enrolment |
And I log out
And I log in as "student1"
And I am on "Course 1" course homepage
And I press "Enrol me"
And I should see "Topic 1"
And I should not see "Enrol me in this course"
And I log out
When I log in as "teacher1"
And I am on "Course 1" course homepage
And I navigate to "Users > User bulk enrolment" in current page administration
And I set the field "List of users identified by your chosen field" to multiline:
"""
"""
And I click on "Enrol users" "button"
And the following should exist in the "localbulkenrol_enrolusers" table:
| Email address | First name | Last name | User enrolment |
| [email protected] | Student | 1 | User is already enrolled |
And I click on "Enrol users" "button"
And the following should exist in the "participants" table:
| Email address | First name | Last name | Roles |
| [email protected] | Student | 1 | Student |
Then "div[data-fullname='Student 1'][data-enrolinstancename='Manual enrolments'] a[data-action=showdetails]" "css_element" should not exist
And "div[data-fullname='Student 1'][data-enrolinstancename='Self enrolment'] a[data-action=showdetails]" "css_element" should exist
Scenario: Try to bulk enrol a student into the course that is not existent in the system.
When I log in as "teacher1"
And I am on "Course 1" course homepage
And I navigate to "Users > User bulk enrolment" in current page administration
And I set the field "List of users identified by your chosen field" to multiline:
"""
"""
And I click on "Enrol users" "button"
Then I should see "No existing Moodle user account [email protected] was found."
Scenario: Try to bulk enrol a list of invalid users.
When I log in as "teacher1"
And I am on "Course 1" course homepage
And I navigate to "Users > User bulk enrolment" in current page administration
And I set the field "List of users identified by your chosen field" to multiline:
"""
foo
bar
"""
And I click on "Enrol users" "button"
Then I should see " No valid entrys were found in the given list."
And I should see "Please go back and check your input"
And "Enrol users" "button" should not exist
Scenario: Try to bulk enrol a list of mixed invalid users and empty line.
When I log in as "teacher1"
And I am on "Course 1" course homepage
And I select "Participants" from secondary navigation
And I select "User bulk enrolment" from the "jump" singleselect
And I set the field "List of e-mail addresses" to multiline:
"""
foo
"""
And I click on "Enrol users" "button"
Then I should see "Line 2 is empty and will be ignored."
And I should see "No e-mail address found in line 3 (foo). This line will be ignored."
And I should see "Manual enrolments"