1 |
efrain |
1 |
@mod @mod_quiz @core @core_badges @core_completion @javascript
|
|
|
2 |
Feature: Award badges based on activity completion
|
|
|
3 |
In order to ensure a student has learned the material before being marked complete
|
|
|
4 |
As a teacher
|
|
|
5 |
I need to configure an activity to grant a badge only when the student achieves a passing grade upon completion.
|
|
|
6 |
|
|
|
7 |
Background:
|
|
|
8 |
Given the following "users" exist:
|
|
|
9 |
| username | firstname | lastname | email |
|
|
|
10 |
| student1 | Student | 1 | student1@example.com |
|
|
|
11 |
| student2 | Student | 2 | student2@example.com |
|
|
|
12 |
| teacher1 | Teacher | 1 | teacher1@example.com |
|
|
|
13 |
And the following "courses" exist:
|
|
|
14 |
| fullname | shortname | category | enablecompletion |
|
|
|
15 |
| Course 1 | C1 | 0 | 1 |
|
|
|
16 |
And the following "course enrolments" exist:
|
|
|
17 |
| user | course | role |
|
|
|
18 |
| teacher1 | C1 | editingteacher |
|
|
|
19 |
| student1 | C1 | student |
|
|
|
20 |
| student2 | C1 | student |
|
|
|
21 |
And the following "question categories" exist:
|
|
|
22 |
| contextlevel | reference | name |
|
|
|
23 |
| Course | C1 | Test questions |
|
|
|
24 |
And the following "questions" exist:
|
|
|
25 |
| questioncategory | qtype | name | questiontext |
|
|
|
26 |
| Test questions | truefalse | First question | Answer the first question |
|
|
|
27 |
And the following "activities" exist:
|
|
|
28 |
| activity | name | course | idnumber | attempts | gradepass | completion | completionpassgrade | completionusegrade |
|
|
|
29 |
| quiz | Test quiz name 1 | C1 | quiz1 | 2 | 5.00 | 2 | 1 | 1 |
|
|
|
30 |
| quiz | Test quiz name 2 | C1 | quiz2 | 2 | 5.00 | 2 | 0 | 1 |
|
|
|
31 |
And quiz "Test quiz name 1" contains the following questions:
|
|
|
32 |
| question | page |
|
|
|
33 |
| First question | 1 |
|
|
|
34 |
And quiz "Test quiz name 2" contains the following questions:
|
|
|
35 |
| question | page |
|
|
|
36 |
| First question | 1 |
|
|
|
37 |
And the following "core_badges > Badge" exists:
|
|
|
38 |
| name | Course Badge 1 |
|
|
|
39 |
| status | 0 |
|
|
|
40 |
| type | 2 |
|
|
|
41 |
| course | C1 |
|
|
|
42 |
| description | Course badge 1 description |
|
|
|
43 |
| image | badges/tests/behat/badge.png |
|
|
|
44 |
And the following "core_badges > Badge" exists:
|
|
|
45 |
| name | Course Badge 2 |
|
|
|
46 |
| status | 0 |
|
|
|
47 |
| type | 2 |
|
|
|
48 |
| course | C1 |
|
|
|
49 |
| description | Course badge 2 description |
|
|
|
50 |
| image | badges/tests/behat/badge.png |
|
|
|
51 |
And I am on the "Course 1" course page logged in as teacher1
|
|
|
52 |
|
|
|
53 |
Scenario: Student does not earn a badge using activity completion when does not get passing grade
|
|
|
54 |
Given I navigate to "Badges" in current page administration
|
|
|
55 |
And I press "Manage badges"
|
|
|
56 |
And I follow "Course Badge 1"
|
|
|
57 |
And I select "Criteria" from the "jump" singleselect
|
|
|
58 |
And I set the field "type" to "Activity completion"
|
|
|
59 |
And I set the field "Quiz - Test quiz name 1" to "1"
|
|
|
60 |
And I press "Save"
|
|
|
61 |
And I press "Enable access"
|
|
|
62 |
And I press "Continue"
|
|
|
63 |
And I should see "Recipients (0)"
|
|
|
64 |
# Pass grade for student1. Activity is considered complete because student1 got a passing grade.
|
|
|
65 |
And user "student1" has attempted "Test quiz name 1" with responses:
|
|
|
66 |
| slot | response |
|
|
|
67 |
| 1 | True |
|
|
|
68 |
# Fail grade for student2. Activity is considered incomplete because student2 got a failing grade.
|
|
|
69 |
And user "student2" has attempted "Test quiz name 1" with responses:
|
|
|
70 |
| slot | response |
|
|
|
71 |
| 1 | False |
|
|
|
72 |
And I navigate to "Badges > Manage badges" in current page administration
|
|
|
73 |
And I follow "Course Badge 1"
|
|
|
74 |
Then I should see "Recipients (1)"
|
|
|
75 |
And I select "Recipients (1)" from the "jump" singleselect
|
|
|
76 |
And I should see "Student 1"
|
|
|
77 |
And I should not see "Student 2"
|
|
|
78 |
|
|
|
79 |
Scenario: Students with any grades in an activity will receive a badge if the completion condition is set to receive any grade
|
|
|
80 |
Given I navigate to "Badges" in current page administration
|
|
|
81 |
And I press "Manage badges"
|
|
|
82 |
And I follow "Course Badge 2"
|
|
|
83 |
And I select "Criteria" from the "jump" singleselect
|
|
|
84 |
And I set the field "type" to "Activity completion"
|
|
|
85 |
And I set the field "Quiz - Test quiz name 2" to "1"
|
|
|
86 |
And I press "Save"
|
|
|
87 |
And I press "Enable access"
|
|
|
88 |
And I press "Continue"
|
|
|
89 |
# Pass grade for student1.
|
|
|
90 |
And user "student1" has attempted "Test quiz name 2" with responses:
|
|
|
91 |
| slot | response |
|
|
|
92 |
| 1 | True |
|
|
|
93 |
# Fail grade for student2. Activity is considered complete even if student2 got a failing grade.
|
|
|
94 |
And user "student2" has attempted "Test quiz name 2" with responses:
|
|
|
95 |
| slot | response |
|
|
|
96 |
| 1 | False |
|
|
|
97 |
And I navigate to "Badges > Manage badges" in current page administration
|
|
|
98 |
And I follow "Course Badge 2"
|
|
|
99 |
Then I should see "Recipients (2)"
|
|
|
100 |
And I select "Recipients (2)" from the "jump" singleselect
|
|
|
101 |
And I should see "Student 1"
|
|
|
102 |
And I should see "Student 2"
|
|
|
103 |
|
|
|
104 |
Scenario: Previously graded pass/fail students should earn a badge after enabling a badge
|
|
|
105 |
# Pass grade for student1.
|
|
|
106 |
Given user "student1" has attempted "Test quiz name 1" with responses:
|
|
|
107 |
| slot | response |
|
|
|
108 |
| 1 | True |
|
|
|
109 |
# Fail grade for student2.
|
|
|
110 |
And user "student2" has attempted "Test quiz name 1" with responses:
|
|
|
111 |
| slot | response |
|
|
|
112 |
| 1 | False |
|
|
|
113 |
And I navigate to "Badges" in current page administration
|
|
|
114 |
And I press "Manage badges"
|
|
|
115 |
And I follow "Course Badge 1"
|
|
|
116 |
And I select "Criteria" from the "jump" singleselect
|
|
|
117 |
And I set the field "type" to "Activity completion"
|
|
|
118 |
And I set the field "Quiz - Test quiz name 1" to "1"
|
|
|
119 |
And I press "Save"
|
|
|
120 |
# Enable badge access once students have completed the activity.
|
|
|
121 |
When I press "Enable access"
|
|
|
122 |
And I press "Continue"
|
|
|
123 |
# Only student1 should earn the badge because student2 did not pass the quiz.
|
|
|
124 |
Then I should see "Recipients (1)"
|
|
|
125 |
And I select "Recipients (1)" from the "jump" singleselect
|
|
|
126 |
And I should see "Student 1"
|
|
|
127 |
And I should not see "Student 2"
|