Proyectos de Subversion Moodle

Rev

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