1 @core @core_badges @_file_upload
3 In order to award badges to users for their achievements
5 I need to add criteria to badges in the system
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 | Description | Test badge description |
14 | issuername | Test Badge Site |
15 | 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 set the field "First name" to "1"
20 And I set the field "Email address" to "1"
21 And I set the field "Phone" to "1"
23 Then I should see "Profile completion"
24 And I should see "First name"
25 And I should see "Email address"
26 And I should not see "Criteria for this badge have not been set up yet."
27 And I press "Enable access"
28 And I press "Continue"
29 And I expand "My profile settings" node
30 And I follow "Edit profile"
31 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 Then I should see "Profile Badge"
36 And I should not see "There are no badges available."
39 Scenario: Award site badge
40 Given the following "users" exist:
41 | username | firstname | lastname | email |
42 | teacher | teacher | 1 | teacher1@asd.com |
43 | 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:
48 | Description | Site badge description |
49 | 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 And I set the field "type" to "Manual issue by role"
53 And I set the field "Teacher" to "1"
55 And I press "Enable access"
56 And I press "Continue"
57 And I follow "Recipients (0)"
58 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 And I press "Award badge"
63 When I follow "Site Badge"
64 Then I should see "Recipients (2)"
66 And I log in as "student"
67 And I navigate to "My badges" node in "My profile"
68 Then I should see "Site Badge"
71 Scenario: Award course badge
72 Given the following "users" exist:
73 | username | firstname | lastname | email |
74 | teacher1 | Teacher | 1 | teacher1@asd.com |
75 | student1 | Student | 1 | student1@asd.com |
76 | student2 | Student | 2 | student2@asd.com |
77 And the following "courses" exist:
78 | fullname | shortname | category | groupmode |
79 | Course 1 | C1 | 0 | 1 |
80 And the following "course enrolments" exist:
81 | user | course | role |
82 | teacher1 | C1 | editingteacher |
83 | student1 | C1 | student |
84 | student2 | C1 | student |
85 And I log in as "teacher1"
86 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 | Name | Course Badge |
91 | Description | Course badge description |
92 | 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 And I set the field "type" to "Manual issue by role"
96 And I set the field "Teacher" to "1"
98 And I press "Enable access"
99 And I press "Continue"
100 And I follow "Recipients (0)"
101 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 When I press "Award badge"
106 And I follow "Course Badge"
107 Then I should see "Recipients (2)"
109 And I log in as "student1"
110 And I follow "Course 1"
111 And I navigate to "My badges" node in "My profile"
112 Then I should see "Course Badge"
115 Scenario: Award badge on activity completion
116 Given the following "courses" exist:
117 | fullname | shortname | category |
118 | Course 1 | C1 | 0 |
119 And the following "users" exist:
120 | username | firstname | lastname | email |
121 | teacher1 | Teacher | Frist | teacher1@asd.com |
122 | student1 | Student | First | student1@asd.com |
123 And the following "course enrolments" exist:
124 | user | course | role |
125 | teacher1 | C1 | editingteacher |
126 | student1 | C1 | student |
127 And I log in as "admin"
128 And I set the following administration settings values:
129 | Enable completion tracking | 1 |
131 And I follow "Course 1"
132 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 changes"
136 And I turn editing mode on
137 And I add a "Assignment" to section "1" and I fill the form with:
138 | Assignment name | Test assignment name |
139 | Description | Submit your online text |
141 And I log in as "teacher1"
142 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 | Name | Course Badge |
147 | Description | Course badge description |
148 | 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 And I set the field "type" to "Activity completion"
152 And I set the field "Test assignment name" to "1"
154 And I press "Enable access"
155 When I press "Continue"
157 And I log in as "student1"
158 And I follow "Course 1"
159 And I navigate to "My badges" node in "My profile"
160 Then I should see "There are no badges available."
162 And I follow "Course 1"
163 And I press "Mark as complete: Test assignment name"
164 And I navigate to "My badges" node in "My profile"
165 Then I should see "Course Badge"
168 Scenario: Award badge on course completion
169 Given the following "courses" exist:
170 | fullname | shortname | category |
171 | Course 1 | C1 | 0 |
172 And the following "users" exist:
173 | username | firstname | lastname | email |
174 | teacher1 | Teacher | Frist | teacher1@asd.com |
175 | student1 | Student | First | student1@asd.com |
176 And the following "course enrolments" exist:
177 | user | course | role |
178 | teacher1 | C1 | editingteacher |
179 | student1 | C1 | student |
180 And I log in as "admin"
181 And I set the following administration settings values:
182 | Enable completion tracking | 1 |
184 And I follow "Course 1"
185 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 changes"
189 And I turn editing mode on
190 And I add a "Assignment" to section "1" and I fill the form with:
191 | Assignment name | Test assignment name |
192 | Description | Submit your online text |
193 | assignsubmission_onlinetext_enabled | 1 |
194 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 And I press "Save changes"
200 And I log in as "teacher1"
201 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 | Name | Course Badge |
206 | Description | Course badge description |
207 | 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"
213 And I press "Enable access"
214 When I press "Continue"
216 And I log in as "student1"
217 And I follow "Course 1"
218 And I navigate to "My badges" node in "My profile"
219 Then I should see "There are no badges available."
221 And I follow "Course 1"
222 And I press "Mark as complete: Test assignment name"
224 And I log in as "admin"
225 # We can't wait for cron to happen, so the admin manually triggers it.
227 # The admin needs to trigger cron twice to see the completion status as completed.
228 # We wait more than 1 minute because of the next cron run scheduled time.
229 And I wait "61" seconds
231 # Finally the admin goes back to homepage to continue the user story.
234 And I log in as "student1"
235 And I navigate to "My badges" node in "My profile"
236 Then I should see "Course Badge"