Commit | Line | Data |
---|---|---|
550d842e | 1 | @core @core_badges @_only_local |
27806552 YB |
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 I am on homepage | |
9 | And I log in as "admin" | |
10 | ||
11 | @javascript | |
844d74d7 | 12 | Scenario: Award profile badge |
27806552 YB |
13 | Given I expand "Site administration" node |
14 | And I expand "Badges" node | |
15 | And I follow "Add a new badge" | |
16 | And I fill the moodle form with: | |
844d74d7 | 17 | | Name | Profile Badge | |
27806552 YB |
18 | | Description | Test badge description | |
19 | | issuername | Test Badge Site | | |
20 | | issuercontact | testuser@test-badge-site.com | | |
21 | And I upload "badges/tests/behat/badge.png" file to "Image" filepicker | |
22 | And I press "Create badge" | |
23 | And I select "Profile completion" from "type" | |
27806552 YB |
24 | And I check "First name" |
25 | And I check "Email address" | |
844d74d7 | 26 | And I check "Phone" |
27806552 YB |
27 | When I press "Save" |
28 | Then I should see "Profile completion" | |
29 | And I should see "First name" | |
30 | And I should see "Email address" | |
31 | And I should not see "Criteria for this badge have not been set up yet." | |
844d74d7 JM |
32 | And I press "Enable access" |
33 | And I press "Continue" | |
34 | And I expand "My profile settings" node | |
35 | And I follow "Edit profile" | |
36 | And I expand all fieldsets | |
37 | And I fill in "Phone" with "123456789" | |
38 | And I press "Update profile" | |
39 | And I follow "My badges" | |
40 | Then I should see "Profile Badge" | |
41 | And I should not see "There are no badges available." | |
27806552 YB |
42 | |
43 | @javascript | |
844d74d7 JM |
44 | Scenario: Award site badge |
45 | Given the following "users" exists: | |
46 | | username | firstname | lastname | email | | |
47 | | teacher | teacher | 1 | teacher1@asd.com | | |
48 | | student | student | 1 | student1@asd.com | | |
49 | And I expand "Site administration" node | |
27806552 YB |
50 | And I expand "Badges" node |
51 | And I follow "Add a new badge" | |
52 | And I fill the moodle form with: | |
844d74d7 JM |
53 | | Name | Site Badge | |
54 | | Description | Site badge description | | |
55 | | issuername | Tester of site badge | | |
27806552 YB |
56 | And I upload "badges/tests/behat/badge.png" file to "Image" filepicker |
57 | And I press "Create badge" | |
844d74d7 JM |
58 | And I select "Manual issue by role" from "type" |
59 | And I check "Teacher" | |
27806552 YB |
60 | And I press "Save" |
61 | And I press "Enable access" | |
62 | And I press "Continue" | |
844d74d7 JM |
63 | And I follow "Recipients (0)" |
64 | And I press "Award badge" | |
65 | And I select "teacher 1 (teacher1@asd.com)" from "potentialrecipients[]" | |
66 | And I press "Award badge" | |
67 | And I select "student 1 (student1@asd.com)" from "potentialrecipients[]" | |
68 | And I press "Award badge" | |
69 | When I follow "Site Badge" | |
70 | Then I should see "Recipients (2)" | |
71 | And I log out | |
72 | And I log in as "student" | |
73 | And I expand "My profile" node | |
74 | And I follow "My badges" | |
75 | Then I should see "Site Badge" | |
68c13c68 JM |
76 | |
77 | @javascript | |
78 | Scenario: Award course badge | |
79 | Given the following "users" exists: | |
80 | | username | firstname | lastname | email | | |
81 | | teacher1 | Teacher | 1 | teacher1@asd.com | | |
82 | | student1 | Student | 1 | student1@asd.com | | |
83 | | student2 | Student | 2 | student2@asd.com | | |
84 | And the following "courses" exists: | |
85 | | fullname | shortname | category | groupmode | | |
86 | | Course 1 | C1 | 0 | 1 | | |
87 | And the following "course enrolments" exists: | |
88 | | user | course | role | | |
89 | | teacher1 | C1 | editingteacher | | |
90 | | student1 | C1 | student | | |
91 | | student2 | C1 | student | | |
92 | And I log out | |
93 | And I log in as "teacher1" | |
94 | And I follow "Course 1" | |
95 | And I click on "//span[text()='Badges']" "xpath_element" in the "Administration" "block" | |
96 | And I follow "Add a new badge" | |
97 | And I fill the moodle form with: | |
98 | | Name | Course Badge | | |
99 | | Description | Course badge description | | |
100 | | issuername | Tester of course badge | | |
101 | And I upload "badges/tests/behat/badge.png" file to "Image" filepicker | |
102 | And I press "Create badge" | |
103 | And I select "Manual issue by role" from "type" | |
104 | And I check "Teacher" | |
105 | And I press "Save" | |
106 | And I press "Enable access" | |
107 | And I press "Continue" | |
108 | And I follow "Recipients (0)" | |
109 | And I press "Award badge" | |
110 | And I select "Student 2 (student2@asd.com)" from "potentialrecipients[]" | |
111 | And I press "Award badge" | |
112 | And I select "Student 1 (student1@asd.com)" from "potentialrecipients[]" | |
113 | When I press "Award badge" | |
114 | And I follow "Course Badge" | |
115 | Then I should see "Recipients (2)" | |
116 | And I log out | |
117 | And I log in as "student1" | |
118 | And I follow "Course 1" | |
119 | And I expand "My profile" node | |
120 | And I follow "My badges" | |
066ef320 JM |
121 | Then I should see "Course Badge" |
122 | ||
123 | @javascript | |
124 | Scenario: Award badge on activity completion | |
125 | Given the following "courses" exists: | |
126 | | fullname | shortname | category | | |
127 | | Course 1 | C1 | 0 | | |
128 | And the following "users" exists: | |
129 | | username | firstname | lastname | email | | |
130 | | teacher1 | Teacher | Frist | teacher1@asd.com | | |
131 | | student1 | Student | First | student1@asd.com | | |
132 | And the following "course enrolments" exists: | |
133 | | user | course | role | | |
134 | | teacher1 | C1 | editingteacher | | |
135 | | student1 | C1 | student | | |
136 | And I log out | |
137 | And I log in as "admin" | |
138 | And I set the following administration settings values: | |
139 | | Enable completion tracking | 1 | | |
140 | And I follow "Home" | |
141 | And I follow "Course 1" | |
142 | And I follow "Edit settings" | |
143 | And I fill the moodle form with: | |
144 | | Enable completion tracking | Yes | | |
145 | And I press "Save changes" | |
146 | And I turn editing mode on | |
147 | And I add a "Assignment" to section "1" and I fill the form with: | |
148 | | Assignment name | Test assignment name | | |
149 | | Description | Submit your online text | | |
150 | And I log out | |
151 | And I log in as "teacher1" | |
152 | And I follow "Course 1" | |
153 | And I click on "//span[text()='Badges']" "xpath_element" in the "Administration" "block" | |
154 | And I follow "Add a new badge" | |
155 | And I fill the moodle form with: | |
156 | | Name | Course Badge | | |
157 | | Description | Course badge description | | |
158 | | issuername | Tester of course badge | | |
159 | And I upload "badges/tests/behat/badge.png" file to "Image" filepicker | |
160 | And I press "Create badge" | |
161 | And I select "Activity completion" from "type" | |
162 | And I check "Test assignment name" | |
163 | And I press "Save" | |
164 | And I press "Enable access" | |
165 | When I press "Continue" | |
166 | And I log out | |
167 | And I log in as "student1" | |
168 | And I follow "Course 1" | |
169 | And I expand "My profile" node | |
170 | And I follow "My badges" | |
171 | Then I should see "There are no badges available." | |
172 | And I follow "Home" | |
173 | And I follow "Course 1" | |
174 | And I press "Mark as complete: Test assignment name" | |
175 | And I expand "My profile" node | |
176 | And I follow "My badges" | |
177 | Then I should see "Course Badge" | |
178 | ||
179 | @javascript | |
180 | Scenario: Award badge on course completion | |
181 | Given the following "courses" exists: | |
182 | | fullname | shortname | category | | |
183 | | Course 1 | C1 | 0 | | |
184 | And the following "users" exists: | |
185 | | username | firstname | lastname | email | | |
186 | | teacher1 | Teacher | Frist | teacher1@asd.com | | |
187 | | student1 | Student | First | student1@asd.com | | |
188 | And the following "course enrolments" exists: | |
189 | | user | course | role | | |
190 | | teacher1 | C1 | editingteacher | | |
191 | | student1 | C1 | student | | |
192 | And I log out | |
193 | And I log in as "admin" | |
194 | And I set the following administration settings values: | |
195 | | Enable completion tracking | 1 | | |
196 | And I follow "Home" | |
197 | And I follow "Course 1" | |
198 | And I follow "Edit settings" | |
199 | And I fill the moodle form with: | |
200 | | Enable completion tracking | Yes | | |
201 | And I press "Save changes" | |
202 | And I turn editing mode on | |
203 | And I add a "Assignment" to section "1" and I fill the form with: | |
204 | | Assignment name | Test assignment name | | |
205 | | Description | Submit your online text | | |
206 | | assignsubmission_onlinetext_enabled | 1 | | |
207 | And I follow "Course completion" | |
208 | And I select "2" from "id_overall_aggregation" | |
209 | And I click on "Condition: Activity completion" "link" | |
210 | And I check "Assign - Test assignment name" | |
211 | And I press "Save changes" | |
212 | And I log out | |
213 | And I log in as "teacher1" | |
214 | And I follow "Course 1" | |
215 | And I click on "//span[text()='Badges']" "xpath_element" in the "Administration" "block" | |
216 | And I follow "Add a new badge" | |
217 | And I fill the moodle form with: | |
218 | | Name | Course Badge | | |
219 | | Description | Course badge description | | |
220 | | issuername | Tester of course badge | | |
221 | And I upload "badges/tests/behat/badge.png" file to "Image" filepicker | |
222 | And I press "Create badge" | |
223 | And I select "Course completion" from "type" | |
224 | And I fill the moodle form with: | |
225 | | grade_2 | 0 | | |
226 | And I press "Save" | |
227 | And I press "Enable access" | |
228 | When I press "Continue" | |
229 | And I log out | |
230 | And I log in as "student1" | |
231 | And I follow "Course 1" | |
232 | And I expand "My profile" node | |
233 | And I follow "My badges" | |
234 | Then I should see "There are no badges available." | |
235 | And I follow "Home" | |
236 | And I follow "Course 1" | |
237 | And I press "Mark as complete: Test assignment name" | |
238 | And I log out | |
239 | And I log in as "admin" | |
240 | # We can't wait for cron to happen, so the admin manually triggers it. | |
241 | And I trigger cron | |
242 | # The admin needs to trigger cron twice to see the completion status as completed. | |
243 | And I trigger cron | |
244 | # Finally the admin goes back to homepage to continue the user story. | |
245 | And I am on homepage | |
246 | And I log out | |
247 | And I log in as "student1" | |
248 | And I expand "My profile" node | |
249 | And I follow "My badges" | |
68c13c68 | 250 | Then I should see "Course Badge" |