award_badge.feature 9.37 KB
Newer Older
1
@core @core_badges @_file_upload
2
3
4
5
6
7
Feature: Award badges
  In order to award badges to users for their achievements
  As an admin
  I need to add criteria to badges in the system

  @javascript
8
  Scenario: Award profile badge
9
    Given I log in as "admin"
10
    And I navigate to "Add a new badge" node in "Site administration > Badges"
11
    And I set the following fields to these values:
12
      | Name | Profile Badge |
13
14
15
      | Description | Test badge description |
      | issuername | Test Badge Site |
      | issuercontact | testuser@test-badge-site.com |
16
    And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
17
    And I press "Create badge"
18
19
20
21
    And I set the field "type" to "Profile completion"
    And I set the field "First name" to "1"
    And I set the field "Email address" to "1"
    And I set the field "Phone" to "1"
22
23
24
25
26
    When I press "Save"
    Then I should see "Profile completion"
    And I should see "First name"
    And I should see "Email address"
    And I should not see "Criteria for this badge have not been set up yet."
27
28
29
30
31
    And I press "Enable access"
    And I press "Continue"
    And I expand "My profile settings" node
    And I follow "Edit profile"
    And I expand all fieldsets
32
    And I set the field "Phone" to "123456789"
33
    And I press "Update profile"
34
    And I navigate to "My badges" node in "My profile"
35
36
    Then I should see "Profile Badge"
    And I should not see "There are no badges available."
37
38

  @javascript
39
  Scenario: Award site badge
40
    Given the following "users" exist:
41
42
43
      | username | firstname | lastname | email |
      | teacher | teacher | 1 | teacher1@asd.com |
      | student | student | 1 | student1@asd.com |
44
    And I log in as "admin"
45
    And I navigate to "Add a new badge" node in "Site administration > Badges"
46
    And I set the following fields to these values:
47
48
49
      | Name | Site Badge |
      | Description | Site badge description |
      | issuername | Tester of site badge |
50
    And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
51
    And I press "Create badge"
52
53
    And I set the field "type" to "Manual issue by role"
    And I set the field "Teacher" to "1"
54
55
56
    And I press "Save"
    And I press "Enable access"
    And I press "Continue"
57
58
    And I follow "Recipients (0)"
    And I press "Award badge"
59
    And I set the field "potentialrecipients[]" to "teacher 1 (teacher1@asd.com)"
60
    And I press "Award badge"
61
    And I set the field "potentialrecipients[]" to "student 1 (student1@asd.com)"
62
63
64
65
66
    And I press "Award badge"
    When I follow "Site Badge"
    Then I should see "Recipients (2)"
    And I log out
    And I log in as "student"
67
    And I navigate to "My badges" node in "My profile"
68
    Then I should see "Site Badge"
69
70
71

  @javascript
  Scenario: Award course badge
72
    Given the following "users" exist:
73
74
75
76
      | username | firstname | lastname | email |
      | teacher1 | Teacher | 1 | teacher1@asd.com |
      | student1 | Student | 1 | student1@asd.com |
      | student2 | Student | 2 | student2@asd.com |
77
    And the following "courses" exist:
78
79
      | fullname | shortname | category | groupmode |
      | Course 1 | C1 | 0 | 1 |
80
    And the following "course enrolments" exist:
81
82
83
84
85
86
      | user | course | role |
      | teacher1 | C1 | editingteacher |
      | student1 | C1 | student |
      | student2 | C1 | student |
    And I log in as "teacher1"
    And I follow "Course 1"
87
    And I navigate to "Add a new badge" node in "Course administration > Badges"
88
    And I follow "Add a new badge"
89
    And I set the following fields to these values:
90
91
92
      | Name | Course Badge |
      | Description | Course badge description |
      | issuername | Tester of course badge |
93
    And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
94
    And I press "Create badge"
95
96
    And I set the field "type" to "Manual issue by role"
    And I set the field "Teacher" to "1"
97
98
99
100
101
    And I press "Save"
    And I press "Enable access"
    And I press "Continue"
    And I follow "Recipients (0)"
    And I press "Award badge"
102
    And I set the field "potentialrecipients[]" to "Student 2 (student2@asd.com)"
103
    And I press "Award badge"
104
    And I set the field "potentialrecipients[]" to "Student 1 (student1@asd.com)"
105
106
107
108
109
110
    When I press "Award badge"
    And I follow "Course Badge"
    Then I should see "Recipients (2)"
    And I log out
    And I log in as "student1"
    And I follow "Course 1"
111
    And I navigate to "My badges" node in "My profile"
112
113
114
115
    Then I should see "Course Badge"

  @javascript
  Scenario: Award badge on activity completion
116
    Given the following "courses" exist:
117
118
      | fullname | shortname | category |
      | Course 1 | C1 | 0 |
119
    And the following "users" exist:
120
121
122
      | username | firstname | lastname | email |
      | teacher1 | Teacher | Frist | teacher1@asd.com |
      | student1 | Student | First | student1@asd.com |
123
    And the following "course enrolments" exist:
124
125
126
127
128
129
130
131
132
      | user | course | role |
      | teacher1 | C1 | editingteacher |
      | student1 | C1 | student |
    And I log in as "admin"
    And I set the following administration settings values:
      | Enable completion tracking | 1 |
    And I follow "Home"
    And I follow "Course 1"
    And I follow "Edit settings"
133
    And I set the following fields to these values:
134
      | Enable completion tracking | Yes |
135
    And I press "Save and display"
136
137
138
139
140
141
142
    And I turn editing mode on
    And I add a "Assignment" to section "1" and I fill the form with:
      | Assignment name | Test assignment name |
      | Description | Submit your online text |
    And I log out
    And I log in as "teacher1"
    And I follow "Course 1"
143
    And I navigate to "Add a new badge" node in "Course administration > Badges"
144
    And I follow "Add a new badge"
145
    And I set the following fields to these values:
146
147
148
      | Name | Course Badge |
      | Description | Course badge description |
      | issuername | Tester of course badge |
149
    And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
150
    And I press "Create badge"
151
152
    And I set the field "type" to "Activity completion"
    And I set the field "Test assignment name" to "1"
153
154
155
156
157
158
    And I press "Save"
    And I press "Enable access"
    When I press "Continue"
    And I log out
    And I log in as "student1"
    And I follow "Course 1"
159
    And I navigate to "My badges" node in "My profile"
160
161
162
163
    Then I should see "There are no badges available."
    And I follow "Home"
    And I follow "Course 1"
    And I press "Mark as complete: Test assignment name"
164
    And I navigate to "My badges" node in "My profile"
165
166
167
168
    Then I should see "Course Badge"

  @javascript
  Scenario: Award badge on course completion
169
    Given the following "courses" exist:
170
171
      | fullname | shortname | category |
      | Course 1 | C1 | 0 |
172
    And the following "users" exist:
173
174
175
      | username | firstname | lastname | email |
      | teacher1 | Teacher | Frist | teacher1@asd.com |
      | student1 | Student | First | student1@asd.com |
176
    And the following "course enrolments" exist:
177
178
179
180
181
182
183
184
185
      | user | course | role |
      | teacher1 | C1 | editingteacher |
      | student1 | C1 | student |
    And I log in as "admin"
    And I set the following administration settings values:
      | Enable completion tracking | 1 |
    And I follow "Home"
    And I follow "Course 1"
    And I follow "Edit settings"
186
    And I set the following fields to these values:
187
      | Enable completion tracking | Yes |
188
    And I press "Save and display"
189
190
191
192
193
194
    And I turn editing mode on
    And I add a "Assignment" to section "1" and I fill the form with:
      | Assignment name | Test assignment name |
      | Description | Submit your online text |
      | assignsubmission_onlinetext_enabled | 1 |
    And I follow "Course completion"
195
    And I set the field "id_overall_aggregation" to "2"
196
    And I click on "Condition: Activity completion" "link"
197
    And I set the field "Assign - Test assignment name" to "1"
198
199
200
201
    And I press "Save changes"
    And I log out
    And I log in as "teacher1"
    And I follow "Course 1"
202
    And I navigate to "Add a new badge" node in "Course administration > Badges"
203
    And I follow "Add a new badge"
204
    And I set the following fields to these values:
205
206
207
      | Name | Course Badge |
      | Description | Course badge description |
      | issuername | Tester of course badge |
208
    And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
209
    And I press "Create badge"
210
    And I set the field "type" to "Course completion"
211
    And I set the field with xpath "//fieldset/input[1]" to "0"
212
213
214
215
216
217
    And I press "Save"
    And I press "Enable access"
    When I press "Continue"
    And I log out
    And I log in as "student1"
    And I follow "Course 1"
218
    And I navigate to "My badges" node in "My profile"
219
220
221
222
223
224
225
226
227
    Then I should see "There are no badges available."
    And I follow "Home"
    And I follow "Course 1"
    And I press "Mark as complete: Test assignment name"
    And I log out
    And I log in as "admin"
    # We can't wait for cron to happen, so the admin manually triggers it.
    And I trigger cron
    # The admin needs to trigger cron twice to see the completion status as completed.
228
229
    # We wait more than 1 minute because of the next cron run scheduled time.
    And I wait "61" seconds
230
231
232
233
234
    And I trigger cron
    # Finally the admin goes back to homepage to continue the user story.
    And I am on homepage
    And I log out
    And I log in as "student1"
235
    And I navigate to "My badges" node in "My profile"
236
    Then I should see "Course Badge"