award_badge.feature 9.13 KB
Newer Older
1
@core @core_badges @_only_local
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
10
    Given I log in as "admin"
    And I expand "Site administration" node
11
12
13
    And I expand "Badges" node
    And I follow "Add a new badge"
    And I fill the moodle form with:
14
      | Name | Profile Badge |
15
16
17
      | Description | Test badge description |
      | issuername | Test Badge Site |
      | issuercontact | testuser@test-badge-site.com |
18
    And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
19
20
21
22
    And I press "Create badge"
    And I select "Profile completion" from "type"
    And I check "First name"
    And I check "Email address"
23
    And I check "Phone"
24
25
26
27
28
    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."
29
30
31
32
33
34
35
36
37
38
    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
    And I fill in "Phone" with "123456789"
    And I press "Update profile"
    And I follow "My badges"
    Then I should see "Profile Badge"
    And I should not see "There are no badges available."
39
40

  @javascript
41
42
43
44
45
  Scenario: Award site badge
    Given the following "users" exists:
      | username | firstname | lastname | email |
      | teacher | teacher | 1 | teacher1@asd.com |
      | student | student | 1 | student1@asd.com |
46
    And I log in as "admin"
47
    And I expand "Site administration" node
48
49
50
    And I expand "Badges" node
    And I follow "Add a new badge"
    And I fill the moodle form with:
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 select "Manual issue by role" from "type"
    And I check "Teacher"
58
59
60
    And I press "Save"
    And I press "Enable access"
    And I press "Continue"
61
62
63
64
65
66
67
68
69
70
71
72
73
    And I follow "Recipients (0)"
    And I press "Award badge"
    And I select "teacher 1 (teacher1@asd.com)" from "potentialrecipients[]"
    And I press "Award badge"
    And I select "student 1 (student1@asd.com)" from "potentialrecipients[]"
    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"
    And I expand "My profile" node
    And I follow "My badges"
    Then I should see "Site Badge"
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97

  @javascript
  Scenario: Award course badge
    Given the following "users" exists:
      | username | firstname | lastname | email |
      | teacher1 | Teacher | 1 | teacher1@asd.com |
      | student1 | Student | 1 | student1@asd.com |
      | student2 | Student | 2 | student2@asd.com |
    And the following "courses" exists:
      | fullname | shortname | category | groupmode |
      | Course 1 | C1 | 0 | 1 |
    And the following "course enrolments" exists:
      | user | course | role |
      | teacher1 | C1 | editingteacher |
      | student1 | C1 | student |
      | student2 | C1 | student |
    And I log in as "teacher1"
    And I follow "Course 1"
    And I click on "//span[text()='Badges']" "xpath_element" in the "Administration" "block"
    And I follow "Add a new badge"
    And I fill the moodle form with:
      | 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
    And I press "Create badge"
    And I select "Manual issue by role" from "type"
    And I check "Teacher"
    And I press "Save"
    And I press "Enable access"
    And I press "Continue"
    And I follow "Recipients (0)"
    And I press "Award badge"
    And I select "Student 2 (student2@asd.com)" from "potentialrecipients[]"
    And I press "Award badge"
    And I select "Student 1 (student1@asd.com)" from "potentialrecipients[]"
    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"
    And I expand "My profile" node
    And I follow "My badges"
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
    Then I should see "Course Badge"

  @javascript
  Scenario: Award badge on activity completion
    Given the following "courses" exists:
      | fullname | shortname | category |
      | Course 1 | C1 | 0 |
    And the following "users" exists:
      | username | firstname | lastname | email |
      | teacher1 | Teacher | Frist | teacher1@asd.com |
      | student1 | Student | First | student1@asd.com |
    And the following "course enrolments" exists:
      | 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"
    And I fill the moodle form with:
      | Enable completion tracking | Yes |
    And I press "Save changes"
    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"
    And I click on "//span[text()='Badges']" "xpath_element" in the "Administration" "block"
    And I follow "Add a new badge"
    And I fill the moodle form with:
      | Name | Course Badge |
      | Description | Course badge description |
      | issuername | Tester of course badge |
155
    And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
    And I press "Create badge"
    And I select "Activity completion" from "type"
    And I check "Test assignment name"
    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"
    And I expand "My profile" node
    And I follow "My badges"
    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 expand "My profile" node
    And I follow "My badges"
    Then I should see "Course Badge"

  @javascript
  Scenario: Award badge on course completion
    Given the following "courses" exists:
      | fullname | shortname | category |
      | Course 1 | C1 | 0 |
    And the following "users" exists:
      | username | firstname | lastname | email |
      | teacher1 | Teacher | Frist | teacher1@asd.com |
      | student1 | Student | First | student1@asd.com |
    And the following "course enrolments" exists:
      | 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"
    And I fill the moodle form with:
      | Enable completion tracking | Yes |
    And I press "Save changes"
    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"
    And I select "2" from "id_overall_aggregation"
    And I click on "Condition: Activity completion" "link"
    And I check "Assign - Test assignment name"
    And I press "Save changes"
    And I log out
    And I log in as "teacher1"
    And I follow "Course 1"
    And I click on "//span[text()='Badges']" "xpath_element" in the "Administration" "block"
    And I follow "Add a new badge"
    And I fill the moodle form with:
      | Name | Course Badge |
      | Description | Course badge description |
      | issuername | Tester of course badge |
216
    And I upload "badges/tests/behat/badge.png" file to "Image" filemanager
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
    And I press "Create badge"
    And I select "Course completion" from "type"
    And I fill the moodle form with:
      | grade_2 | 0 |
    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"
    And I expand "My profile" node
    And I follow "My badges"
    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.
    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"
    And I expand "My profile" node
    And I follow "My badges"
245
    Then I should see "Course Badge"