Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
@core @core_badges @_file_upload
2
Feature: Award badges
3
  In order to award badges to users for their achievements
4
  As an admin
5
  I need to add criteria to badges in the system
6
 
7
  Background:
8
    Given the following "courses" exist:
9
      | fullname | shortname | format | enablecompletion |
10
      | Course 1 | C1        | topics | 1                |
11
    And the following "users" exist:
12
      | username | firstname | lastname | email                |
13
      | teacher1 | Teacher   | 1        | teacher1@example.com |
14
      | student1 | Student   | 1        | student1@example.com |
15
      | student2 | Student   | 2        | student2@example.com |
16
    And the following "course enrolments" exist:
17
      | user     | course | role           |
18
      | teacher1 | C1     | editingteacher |
19
      | student1 | C1     | student        |
20
      | student2 | C1     | student        |
21
    And the following "activity" exists:
22
      | activity                            | assign                  |
23
      | course                              | C1                      |
24
      | section                             | 1                       |
25
      | name                                | Test assignment name    |
26
      | intro                               | Submit your online text |
27
      | completion                          | 1                       |
28
      | assignsubmission_onlinetext_enabled | 1                       |
29
 
30
  @javascript
31
  Scenario: Award badge on other badges as criteria
32
    Given I log in as "teacher1"
33
    And I am on "Course 1" course homepage
34
    # Create course badge 1.
35
    And I navigate to "Badges > Add a new badge" in current page administration
36
    And I set the following fields to these values:
37
      | Name | Course Badge 1 |
38
      | Description | Course badge 1 description |
39
    And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
40
    And I press "Create badge"
41
    And I set the field "type" to "Manual issue by role"
42
    And I expand all fieldsets
43
    # Set to ANY of the roles awards badge.
44
    And I set the field "Teacher" to "1"
45
    And I set the field "Any of the selected roles awards the badge" to "1"
46
    And I press "Save"
47
    And I press "Enable access"
48
    And I press "Continue"
49
    # Badge #2
50
    And I am on "Course 1" course homepage
51
    And I navigate to "Badges > Add a new badge" in current page administration
52
    And I set the following fields to these values:
53
      | Name | Course Badge 2 |
54
      | Description | Course badge 2 description |
55
    And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
56
    And I press "Create badge"
57
    # Set "course badge 1" as criteria
58
    And I set the field "type" to "Awarded badges"
59
    And I set the field "id_badge_badges" to "Course Badge 1"
60
    And I press "Save"
61
    And I press "Enable access"
62
    And I press "Continue"
63
    And I am on "Course 1" course homepage
64
    And I navigate to "Badges > Manage badges" in current page administration
65
    And I follow "Course Badge 1"
66
    And I select "Recipients (0)" from the "jump" singleselect
67
    And I press "Award badge"
68
    # Award course badge 1 to student 1.
69
    And I set the field "potentialrecipients[]" to "Student 1 (student1@example.com)"
70
    When I press "Award badge"
71
    And I am on "Course 1" course homepage
72
    And I navigate to "Badges > Manage badges" in current page administration
73
    And I follow "Course Badge 1"
74
    And I select "Recipients (1)" from the "jump" singleselect
75
    Then I should see "Recipients (1)"
76
    And I log out
77
    # Student 1 should have both badges.
78
    And I log in as "student1"
79
    And I follow "Profile" in the user menu
80
    When I click on "Course 1" "link" in the "region-main" "region"
81
    Then I should see "Course Badge 1"
82
    And I should see "Course Badge 2"
83
    # Student 1 should have both badges also in the Badges navigation section.
84
    When I follow "Badges"
85
    Then I should see "Course Badge 1"
86
    And I should see "Course Badge 2"
87
    And I should not see "Manage badges"
88
    And I should not see "Add a new badge"
89
    And I log out
90
    # Teacher 1 should have access to manage/create badges in the Badges navigation section.
91
    When I log in as "teacher1"
92
    And I am on "Course 1" course homepage
93
    And I navigate to "Badges > Manage badges" in current page administration
94
    Then I should see "Course Badge 1"
95
    And I should see "Course Badge 2"
96
    And I should see "Manage badges"
97
    And I should see "Add a new badge"
98
    # Teacher 1 should NOT have access to manage/create site badges in the Site badges section.
99
    When I am on homepage
100
    And I turn editing mode on
101
    And the following config values are set as admin:
102
      | unaddableblocks | | theme_boost|
103
   # TODO MDL-57120 site "Badges" link not accessible without navigation block.
104
    And I add the "Navigation" block if not present
105
    And I click on "Site pages" "list_item" in the "Navigation" "block"
106
    And I click on "Site badges" "link" in the "Navigation" "block"
107
    Then I should see "There are currently no badges available for users to earn."
108
    And I should not see "Manage badges"
109
    And I should not see "Add a new badge"
110
 
111
  @javascript
112
  Scenario: Award profile badge
113
    Given I log in as "admin"
114
    And I navigate to "Badges > Add a new badge" in site administration
115
    And I set the following fields to these values:
116
      | Name | Profile Badge |
117
      | Description | Test badge description |
118
    And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
119
    And I press "Create badge"
120
    And I set the field "type" to "Profile completion"
121
    And I expand all fieldsets
122
    And I set the field "First name" to "1"
123
    And I set the field "Email address" to "1"
124
    And I set the field "Phone" to "1"
125
    And I set the field "id_description" to "Criterion description"
126
    When I press "Save"
127
    Then I should see "Profile completion"
128
    And I should see "First name"
129
    And I should see "Email address"
130
    And I should see "Phone"
131
    And I should see "Criterion description"
132
    And I should not see "Criteria for this badge have not been set up yet."
133
    And I press "Enable access"
134
    And I press "Continue"
135
    And I open my profile in edit mode
136
    And I expand all fieldsets
137
    And I set the field "Phone" to "123456789"
138
    And I press "Update profile"
139
    And I follow "Profile" in the user menu
140
    Then I should see "Profile Badge"
141
    And I should not see "There are currently no badges available for users to earn."
142
 
143
  @javascript
144
  Scenario: Award site badge
145
    Given I log in as "admin"
146
    And I navigate to "Badges > Add a new badge" in site administration
147
    And I set the following fields to these values:
148
      | Name | Site Badge |
149
      | Description | Site badge description |
150
    And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
151
    And I press "Create badge"
152
    And I set the field "type" to "Manual issue by role"
153
    And I set the field "Teacher" to "1"
154
    And I press "Save"
155
    And I press "Enable access"
156
    And I press "Continue"
157
    And I select "Recipients (0)" from the "jump" singleselect
158
    And I press "Award badge"
159
    And I set the field "potentialrecipients[]" to "Teacher 1 (teacher1@example.com)"
160
    And I press "Award badge"
161
    And I set the field "potentialrecipients[]" to "Student 1 (student1@example.com)"
162
    And I press "Award badge"
163
    And I navigate to "Badges > Manage badges" in site administration
164
    When I follow "Site Badge"
165
    Then I should see "Recipients (2)"
166
    And I log out
167
    And I log in as "student1"
168
    And I follow "Profile" in the user menu
169
    Then I should see "Site Badge"
170
 
171
  @javascript
172
  Scenario: Award course badge
173
    Given I log in as "teacher1"
174
    And I am on "Course 1" course homepage
175
    And I navigate to "Badges > Add a new badge" in current page administration
176
    And I set the following fields to these values:
177
      | Name | Course Badge |
178
      | Description | Course badge description |
179
    And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
180
    And I press "Create badge"
181
    And I set the field "type" to "Manual issue by role"
182
    And I set the field "Teacher" to "1"
183
    And I press "Save"
184
    And I press "Enable access"
185
    And I press "Continue"
186
    And I select "Recipients (0)" from the "jump" singleselect
187
    And I press "Award badge"
188
    And I set the field "potentialrecipients[]" to "Student 2 (student2@example.com)"
189
    And I press "Award badge"
190
    And I set the field "potentialrecipients[]" to "Student 1 (student1@example.com)"
191
    When I press "Award badge"
192
    And I am on "Course 1" course homepage
193
    And I navigate to "Badges > Manage badges" in current page administration
194
    And I follow "Course Badge"
195
    Then I should see "Recipients (2)"
196
    And I log out
197
    And I log in as "student1"
198
    And I follow "Profile" in the user menu
199
    And I click on "Course 1" "link" in the "region-main" "region"
200
    And I click on "Course Badge" "link"
201
    And I should see "Course: Course 1"
202
 
203
  @javascript
204
  Scenario: Award badge on activity completion
205
    Given I log in as "teacher1"
206
    And I am on "Course 1" course homepage
207
    And I change window size to "large"
208
    And I navigate to "Badges > Add a new badge" in current page administration
209
    And I set the following fields to these values:
210
      | Name | Course Badge |
211
      | Description | Course badge description |
212
    And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
213
    And I press "Create badge"
214
    And I set the field "type" to "Activity completion"
215
    And I set the field "Test assignment name" to "1"
216
    And I press "Save"
217
    And I press "Enable access"
218
    When I press "Continue"
219
    And I log out
220
    And I log in as "student1"
221
    And I follow "Profile" in the user menu
222
    And I click on "Course 1" "link" in the "region-main" "region"
223
    Then I should not see "badges"
224
    And I am on "Course 1" course homepage
225
    And I toggle the manual completion state of "Test assignment name"
226
    And I follow "Profile" in the user menu
227
    And I click on "Course 1" "link" in the "region-main" "region"
228
    Then I should see "Course Badge"
229
 
230
  @javascript
231
  Scenario: Award badge on course completion
232
    Given the following "activity" exists:
233
      | activity       | assign        |
234
      | course         | C1            |
235
      | name           | Music history |
236
      | section        | 1             |
237
      | completion     | 2             |
238
      | completionview | 1             |
239
    And I log in as "teacher1"
240
    And I am on "Course 1" course homepage
241
    And I navigate to "Course completion" in current page administration
242
    And I set the field "id_overall_aggregation" to "2"
243
    And I click on "Condition: Activity completion" "link"
244
    And I set the field "Assignment - Music history" to "1"
245
    And I press "Save changes"
246
    And I am on "Course 1" course homepage
247
    And I navigate to "Badges > Add a new badge" in current page administration
248
    And I set the following fields to these values:
249
      | Name | Course Badge |
250
      | Description | Course badge description |
251
    And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
252
    And I press "Create badge"
253
    And I set the field "type" to "Course completion"
254
    And I set the field with xpath ".//*[contains(., 'Minimum grade required')]/ancestor::*[contains(concat(' ', @class, ' '), ' fitem ')]//input[1]" to "0"
255
    And I press "Save"
256
    And I press "Enable access"
257
    When I press "Continue"
258
    And I log out
259
    And I log in as "student1"
260
    And I follow "Profile" in the user menu
261
    And I click on "Course 1" "link" in the "region-main" "region"
262
    Then I should not see "badges"
263
    When I am on the "Music history" "assign activity" page
264
    And I log out
265
    # Completion cron won't mark the whole course completed unless the
266
    # individual criteria was marked completed more than a second ago. So
267
    # run it twice, first to mark the criteria and second for the course.
268
    And I run the scheduled task "core\task\completion_regular_task"
269
    And I wait "1" seconds
270
    And I run the scheduled task "core\task\completion_regular_task"
271
    # The student should now see their badge.
272
    And I log in as "student1"
273
    And I follow "Profile" in the user menu
274
    And I click on "Course 1" "link" in the "region-main" "region"
275
    Then I should see "Course Badge"
276
 
277
  @javascript
278
  Scenario: All of the selected roles can award badges
279
    Given I log in as "teacher1"
280
    And I am on "Course 1" course homepage
281
    # Create course badge 1.
282
    And I navigate to "Badges > Add a new badge" in current page administration
283
    And I set the following fields to these values:
284
      | Name | Course Badge 1 |
285
      | Description | Course badge description |
286
    And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
287
    And I press "Create badge"
288
    And I set the field "type" to "Manual issue by role"
289
    And I expand all fieldsets
290
    # Set to ANY of the roles awards badge.
291
    And I set the field "Teacher" to "1"
292
    And I set the field "Any of the selected roles awards the badge" to "1"
293
    And I press "Save"
294
    And I press "Enable access"
295
    And I press "Continue"
296
    And I select "Recipients (0)" from the "jump" singleselect
297
    And I press "Award badge"
298
    # Award course badge 1 to student 1.
299
    And I set the field "potentialrecipients[]" to "Student 1 (student1@example.com)"
300
    When I press "Award badge"
301
    And I am on "Course 1" course homepage
302
    And I navigate to "Badges > Manage badges" in current page administration
303
    And I follow "Course Badge 1"
304
    And I select "Recipients (1)" from the "jump" singleselect
305
    Then I should see "Recipients (1)"
306
    # Add course badge 2.
307
    And I am on "Course 1" course homepage
308
    And I navigate to "Badges > Add a new badge" in current page administration
309
    And I set the following fields to these values:
310
      | Name | Course Badge 2 |
311
      | Description | Course badge description |
312
    And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
313
    And I press "Create badge"
314
    And I set the field "type" to "Manual issue by role"
315
    And I expand all fieldsets
316
    # Set to ALL of the selected roles award badge.
317
    And I set the field "Teacher" to "1"
318
    And I set the field "All of the selected roles award the badge" to "1"
319
    And I press "Save"
320
    And I press "Enable access"
321
    And I press "Continue"
322
    And I select "Recipients (0)" from the "jump" singleselect
323
    And I press "Award badge"
324
    # Award course badge 2 to student 2.
325
    And I set the field "potentialrecipients[]" to "Student 2 (student2@example.com)"
326
    When I press "Award badge"
327
    And I am on "Course 1" course homepage
328
    And I navigate to "Badges > Manage badges" in current page administration
329
    And I follow "Course Badge 2"
330
    And I select "Recipients (1)" from the "jump" singleselect
331
    Then I should see "Recipients (1)"
332
    And I log out
333
    And I trigger cron
334
    # Student 1 should have just course badge 1.
335
    And I log in as "student1"
336
    And I follow "Profile" in the user menu
337
    When I click on "Course 1" "link" in the "region-main" "region"
338
    Then I should see "Course Badge 1"
339
    And I should not see "Course Badge 2"
340
    And I log out
341
    # Student 2 should have just course badge 2.
342
    And I log in as "student2"
343
    And I follow "Profile" in the user menu
344
    When I click on "Course 1" "link" in the "region-main" "region"
345
    Then I should see "Course Badge 2"
346
    Then I should not see "Course Badge 1"
347
 
348
  @javascript
349
  Scenario: Revoke badge
350
    Given I log in as "teacher1"
351
    And I am on "Course 1" course homepage
352
    And I navigate to "Badges > Add a new badge" in current page administration
353
    And I set the following fields to these values:
354
      | Name | Course Badge |
355
      | Description | Course badge description |
356
    And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
357
    And I press "Create badge"
358
    And I set the field "type" to "Manual issue by role"
359
    And I set the field "Teacher" to "1"
360
    And I press "Save"
361
    And I press "Enable access"
362
    And I press "Continue"
363
    And I select "Recipients (0)" from the "jump" singleselect
364
    And I press "Award badge"
365
    And I set the field "potentialrecipients[]" to "Student 2 (student2@example.com)"
366
    And I press "Award badge"
367
    And I set the field "potentialrecipients[]" to "Student 1 (student1@example.com)"
368
    When I press "Award badge"
369
    And I am on "Course 1" course homepage
370
    And I navigate to "Badges > Manage badges" in current page administration
371
    And I follow "Course Badge"
372
    Then I should see "Recipients (2)"
373
    And I select "Recipients (2)" from the "jump" singleselect
374
    And I press "Award badge"
375
    And I set the field "existingrecipients[]" to "Student 2 (student2@example.com)"
376
    And I press "Revoke badge"
377
    And I set the field "existingrecipients[]" to "Student 1 (student1@example.com)"
378
    When I press "Revoke badge"
379
    And I am on "Course 1" course homepage
380
    And I navigate to "Badges > Manage badges" in current page administration
381
    And I follow "Course Badge"
382
    Then I should see "Recipients (0)"