award_badge.feature 9.39 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
      | Description | Test badge description |
      | issuername | Test Badge Site |
15
      | issuercontact | testuser@example.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
    And I press "Enable access"
    And I press "Continue"
33
34
    And I click on "Admin User" "link"
    And I follow "My profile" in the open menu
35
36
    And I follow "Edit profile"
    And I expand all fieldsets
37
    And I set the field "Phone" to "123456789"
38
    And I press "Update profile"
39
    And I follow "My profile" in the user menu
40
41
    Then I should see "Profile Badge"
    And I should not see "There are no badges available."
42
43

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

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

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

  @javascript
  Scenario: Award badge on course completion
172
    Given the following "courses" exist:
173
174
      | fullname | shortname | category |
      | Course 1 | C1 | 0 |
175
    And the following "users" exist:
176
      | username | firstname | lastname | email |
177
178
      | teacher1 | Teacher | Frist | teacher1@example.com |
      | student1 | Student | First | student1@example.com |
179
    And the following "course enrolments" exist:
180
181
182
      | user | course | role |
      | teacher1 | C1 | editingteacher |
      | student1 | C1 | student |
183
184
185
    And the following config values are set as admin:
      | enablecompletion | 1 |
    And I log in as "teacher1"
186
187
    And I follow "Course 1"
    And I follow "Edit settings"
188
    And I set the following fields to these values:
189
      | Enable completion tracking | Yes |
190
    And I press "Save and display"
191
192
193
194
195
196
    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"
197
    And I set the field "id_overall_aggregation" to "2"
198
    And I click on "Condition: Activity completion" "link"
199
    And I set the field "Assign - Test assignment name" to "1"
200
201
    And I press "Save changes"
    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
    And I press "Save"
    And I press "Enable access"
    When I press "Continue"
    And I log out
    And I log in as "student1"
217
    And I follow "My profile" in the user menu
218
    And I follow "Course 1"
219
220
    Then I should not see "badges"
    And I am on homepage
221
222
223
224
225
226
227
    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
    And I trigger cron
    # Finally the admin goes back to homepage to continue the user story.
232
    And I am on site homepage
233
234
    And I log out
    And I log in as "student1"
235
    And I follow "My profile" in the user menu
236
    Then I should see "Course Badge"