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
    And I set the field "type" to "Profile completion"
19
    And I expand all fieldsets
20
21
22
    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"
23
    And I set the field "id_description" to "Criterion description"
24
25
26
27
    When I press "Save"
    Then I should see "Profile completion"
    And I should see "First name"
    And I should see "Email address"
28
29
    And I should see "Phone"
    And I should see "Criterion description"
30
    And I should not see "Criteria for this badge have not been set up yet."
31
32
33
34
35
    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
36
    And I set the field "Phone" to "123456789"
37
    And I press "Update profile"
38
    And I navigate to "My badges" node in "My profile"
39
40
    Then I should see "Profile Badge"
    And I should not see "There are no badges available."
41
42

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

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

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

  @javascript
  Scenario: Award badge on course completion
170
    Given the following "courses" exist:
171
172
      | fullname | shortname | category |
      | Course 1 | C1 | 0 |
173
    And the following "users" exist:
174
175
176
      | username | firstname | lastname | email |
      | teacher1 | Teacher | Frist | teacher1@asd.com |
      | student1 | Student | First | student1@asd.com |
177
    And the following "course enrolments" exist:
178
179
180
      | user | course | role |
      | teacher1 | C1 | editingteacher |
      | student1 | C1 | student |
181
182
183
    And the following config values are set as admin:
      | enablecompletion | 1 |
    And I log in as "teacher1"
184
185
    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
    And I press "Save changes"
    And I follow "Course 1"
200
    And I navigate to "Add a new badge" node in "Course administration > Badges"
201
    And I follow "Add a new badge"
202
    And I set the following fields to these values:
203
204
205
      | Name | Course Badge |
      | Description | Course badge description |
      | issuername | Tester of course badge |
206
    And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
207
    And I press "Create badge"
208
    And I set the field "type" to "Course completion"
209
    And I set the field with xpath "//fieldset/input[1]" to "0"
210
211
212
213
214
215
    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"
216
    And I navigate to "My badges" node in "My profile"
217
218
219
220
221
222
223
224
225
    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.
226
227
    # We wait more than 1 minute because of the next cron run scheduled time.
    And I wait "61" seconds
228
229
230
231
232
    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"
233
    And I navigate to "My badges" node in "My profile"
234
    Then I should see "Course Badge"