1 |
efrain |
1 |
@mod @mod_quiz @javascript
|
|
|
2 |
Feature: Adding random questions to a quiz based on category and tags
|
|
|
3 |
In order to have better assessment
|
|
|
4 |
As a teacher
|
|
|
5 |
I want to display questions that are randomly picked from the question bank
|
|
|
6 |
|
|
|
7 |
Background:
|
|
|
8 |
Given the following "users" exist:
|
|
|
9 |
| username | firstname | lastname | email |
|
|
|
10 |
| teacher1 | Teacher | 1 | t1@example.com |
|
|
|
11 |
And the following "courses" exist:
|
|
|
12 |
| fullname | shortname |
|
|
|
13 |
| Course 1 | C1 |
|
|
|
14 |
And the following "course enrolments" exist:
|
|
|
15 |
| user | course | role |
|
|
|
16 |
| teacher1 | C1 | editingteacher |
|
|
|
17 |
And the following "activities" exist:
|
1441 |
ariadna |
18 |
| activity | name | intro | course | idnumber |
|
|
|
19 |
| quiz | Quiz 1 | Quiz 1 for testing the Add random question form | C1 | quiz1 |
|
|
|
20 |
| qbank | Qbank 1 | Question bank 1 for testing the Add menu | C1 | qbank1 |
|
1 |
efrain |
21 |
And the following "question categories" exist:
|
1441 |
ariadna |
22 |
| contextlevel | reference | name |
|
|
|
23 |
| Activity module | quiz1 | Questions Category 1 |
|
|
|
24 |
| Activity module | quiz1 | Questions Category 2 |
|
|
|
25 |
| Activity module | qbank1 | Qbank questions |
|
1 |
efrain |
26 |
And the following "question categories" exist:
|
1441 |
ariadna |
27 |
| contextlevel | reference | name | questioncategory |
|
|
|
28 |
| Activity module | quiz1 | Subcategory | Questions Category 1 |
|
1 |
efrain |
29 |
And the following "questions" exist:
|
|
|
30 |
| questioncategory | qtype | name | user | questiontext |
|
|
|
31 |
| Questions Category 1 | essay | question 1 name | admin | Question 1 text |
|
|
|
32 |
| Questions Category 1 | essay | question 2 name | teacher1 | Question 2 text |
|
|
|
33 |
| Subcategory | essay | question 3 name | teacher1 | Question 3 text |
|
|
|
34 |
| Subcategory | essay | question 4 name | teacher1 | Question 4 text |
|
|
|
35 |
| Questions Category 1 | essay | "listen" & "answer" | teacher1 | Question 5 text |
|
1441 |
ariadna |
36 |
| Qbank questions | essay | Qbank question 1 | teacher1 | Qbank question |
|
1 |
efrain |
37 |
And the following "core_question > Tags" exist:
|
1441 |
ariadna |
38 |
| question | tag |
|
|
|
39 |
| question 1 name | foo |
|
|
|
40 |
| question 2 name | bar |
|
|
|
41 |
| question 3 name | foo |
|
|
|
42 |
| question 4 name | bar |
|
|
|
43 |
| "listen" & "answer" | foo |
|
|
|
44 |
| Qbank question 1 | qbanktag |
|
1 |
efrain |
45 |
|
|
|
46 |
Scenario: Available tags are shown in the autocomplete tag field
|
|
|
47 |
Given I am on the "Quiz 1" "mod_quiz > Edit" page logged in as "teacher1"
|
|
|
48 |
When I open the "last" add to quiz menu
|
|
|
49 |
And I follow "a random question"
|
|
|
50 |
And I add question bank filter "Tag"
|
|
|
51 |
And I click on "Tag" "field"
|
|
|
52 |
And I press the down key
|
|
|
53 |
Then "foo" "autocomplete_suggestions" should exist
|
|
|
54 |
And "bar" "autocomplete_suggestions" should exist
|
|
|
55 |
|
|
|
56 |
Scenario: Questions can be filtered by tags
|
|
|
57 |
Given I am on the "Quiz 1" "mod_quiz > Edit" page logged in as "teacher1"
|
|
|
58 |
When I open the "last" add to quiz menu
|
|
|
59 |
And I follow "a random question"
|
1441 |
ariadna |
60 |
And I apply question bank filter "Category" with value "Questions Category 1"
|
1 |
efrain |
61 |
And I apply question bank filter "Tag" with value "foo"
|
|
|
62 |
And I wait until the page is ready
|
|
|
63 |
And I should see "question 1 name"
|
|
|
64 |
And I should see "\"listen\" & \"answer\""
|
|
|
65 |
And I should not see "question 2 name"
|
|
|
66 |
And I should not see "question 3 name"
|
|
|
67 |
And I should not see "question 4 name"
|
|
|
68 |
# Ensure tagged questions inside subcategories are also matched.
|
|
|
69 |
And I set the field "Also show questions from subcategories" to "1"
|
|
|
70 |
And I click on "Apply filters" "button"
|
|
|
71 |
And I wait until the page is ready
|
|
|
72 |
And I should see "question 1 name"
|
|
|
73 |
And I should see "question 3 name"
|
|
|
74 |
And I should see "\"listen\" & \"answer\""
|
|
|
75 |
And I should not see "question 2 name"
|
|
|
76 |
And I should not see "question 4 name"
|
|
|
77 |
|
1441 |
ariadna |
78 |
Scenario: Questions can be filtered by tags on a shared question bank
|
1 |
efrain |
79 |
Given I am on the "Quiz 1" "mod_quiz > Edit" page logged in as "teacher1"
|
|
|
80 |
When I open the "last" add to quiz menu
|
|
|
81 |
And I follow "a random question"
|
1441 |
ariadna |
82 |
Then I click on "Switch bank" "button"
|
|
|
83 |
And I click on "Qbank 1" "link" in the "Select question bank" "dialogue"
|
|
|
84 |
And I apply question bank filter "Category" with value "Qbank questions"
|
|
|
85 |
And I apply question bank filter "Tag" with value "qbanktag"
|
|
|
86 |
And I click on "Apply filters" "button"
|
|
|
87 |
And I wait until the page is ready
|
|
|
88 |
And I should see "Qbank question 1"
|
|
|
89 |
And I should not see "question 3 name"
|
|
|
90 |
And I should not see "question 2 name"
|
|
|
91 |
And I should not see "question 4 name"
|
|
|
92 |
|
|
|
93 |
Scenario: A random question can be added to the quiz
|
|
|
94 |
Given I am on the "Quiz 1" "mod_quiz > Edit" page logged in as "teacher1"
|
|
|
95 |
And I open the "last" add to quiz menu
|
|
|
96 |
And I follow "a random question"
|
|
|
97 |
And I apply question bank filter "Category" with value "Questions Category 1"
|
1 |
efrain |
98 |
And I apply question bank filter "Tag" with value "foo"
|
|
|
99 |
And I select "1" from the "randomcount" singleselect
|
|
|
100 |
And I press "Add random question"
|
1441 |
ariadna |
101 |
And I should see "Random (Questions Category 1) based on filter condition with tags: foo" on quiz page "1"
|
|
|
102 |
When I click on "Configure question" "link" in the "Random (Questions Category 1) based on filter condition with tags: foo" "list_item"
|
1 |
efrain |
103 |
Then I should see "Questions Category 1"
|
|
|
104 |
And I should see "foo"
|
|
|
105 |
And I should see "question 1 name"
|
|
|
106 |
And I should see "\"listen\" & \"answer\""
|
1441 |
ariadna |
107 |
And I click on "Cancel" "button" in the "Editing a random question" "dialogue"
|
|
|
108 |
# Include subcategories.
|
|
|
109 |
And I navigate to "Questions" in current page administration
|
|
|
110 |
And I open the "Page 1" add to quiz menu
|
|
|
111 |
And I follow "a random question"
|
|
|
112 |
And I apply question bank filter "Category" with value "Questions Category 1"
|
|
|
113 |
And I set the field "Also show questions from subcategories" to "1"
|
|
|
114 |
And I click on "Apply filters" "button"
|
|
|
115 |
And I apply question bank filter "Tag" with value "foo"
|
|
|
116 |
And I select "1" from the "randomcount" singleselect
|
|
|
117 |
And I press "Add random question"
|
|
|
118 |
And I should see "Random (Questions Category 1 and subcategories) based on filter condition with tags: foo" on quiz page "1"
|
|
|
119 |
And I click on "Configure question" "link" in the "Random (Questions Category 1 and subcategories) based on filter condition with tags: foo" "list_item"
|
|
|
120 |
And I should see "Questions Category 1"
|
|
|
121 |
And I should see "foo"
|
|
|
122 |
And I should see "question 1 name"
|
|
|
123 |
And I should see "\"listen\" & \"answer\""
|
|
|
124 |
And I should see "question 3 name"
|
1 |
efrain |
125 |
|
1441 |
ariadna |
126 |
Scenario: A random question from the quiz's top category can be added to the quiz
|
|
|
127 |
Given the following "question categories" exist:
|
|
|
128 |
| contextlevel | reference | name |
|
|
|
129 |
| Activity module | quiz1 | Quiz 1 category |
|
|
|
130 |
And the following "questions" exist:
|
|
|
131 |
| questioncategory | qtype | name | user | questiontext |
|
|
|
132 |
| Quiz 1 category | essay | quiz 1 question 1 name | teacher1 | Quiz 1 question 1 text |
|
|
|
133 |
| Quiz 1 category | essay | quiz 1 question 2 name | teacher1 | Quiz 1 question 2 text |
|
|
|
134 |
And the following "core_question > Tags" exist:
|
|
|
135 |
| question | tag |
|
|
|
136 |
| quiz 1 question 1 name | foo |
|
|
|
137 |
And I am on the "Quiz 1" "mod_quiz > Edit" page logged in as "teacher1"
|
|
|
138 |
And I open the "last" add to quiz menu
|
|
|
139 |
And I follow "a random question"
|
|
|
140 |
And I apply question bank filter "Category" with value "Top for Quiz 1"
|
|
|
141 |
And I set the field "Also show questions from subcategories" to "1"
|
|
|
142 |
And I click on "Apply filters" "button"
|
|
|
143 |
And I apply question bank filter "Tag" with value "foo"
|
|
|
144 |
And I select "1" from the "randomcount" singleselect
|
|
|
145 |
When I press "Add random question"
|
|
|
146 |
Then I should see "Random (Any category of this quiz) based on filter condition with tags: foo" on quiz page "1"
|
|
|
147 |
And I click on "Configure question" "link" in the "Random (Any category of this quiz) based on filter condition with tags: foo" "list_item"
|
|
|
148 |
And I should see "Top for Quiz 1"
|
|
|
149 |
And I should see "foo"
|
|
|
150 |
And I should see "quiz 1 question 1 name"
|
|
|
151 |
And I should not see "quiz 1 question 2 name"
|
|
|
152 |
|
|
|
153 |
Scenario: A random question from a top category, excluding subcategories, shows an indicator of being faulty
|
|
|
154 |
Given I am on the "Quiz 1" "mod_quiz > Edit" page logged in as "teacher1"
|
|
|
155 |
And I open the "last" add to quiz menu
|
|
|
156 |
And I follow "a random question"
|
|
|
157 |
And I apply question bank filter "Category" with value "Top for Quiz 1"
|
|
|
158 |
And I set the field "Also show questions from subcategories" to "0"
|
|
|
159 |
And I click on "Apply filters" "button"
|
|
|
160 |
And I apply question bank filter "Tag" with value "foo"
|
|
|
161 |
And I select "1" from the "randomcount" singleselect
|
|
|
162 |
When I press "Add random question"
|
|
|
163 |
Then I should see "Random (Faulty question) based on filter condition" on quiz page "1"
|
|
|
164 |
|
11 |
efrain |
165 |
Scenario: After closing and reopening the modal, it still works
|
|
|
166 |
When I am on the "Quiz 1" "mod_quiz > Edit" page logged in as teacher1
|
|
|
167 |
And I open the "last" add to quiz menu
|
|
|
168 |
And I follow "a random question"
|
|
|
169 |
And I click on "Close" "button" in the "Add a random question at the end" "dialogue"
|
|
|
170 |
And I open the "last" add to quiz menu
|
|
|
171 |
And I follow "a random question"
|
|
|
172 |
And I should not see "question 3 name"
|
|
|
173 |
And I set the field "Category" to "Subcategory"
|
|
|
174 |
And I press "Apply filters"
|
|
|
175 |
Then I should see "question 3 name"
|
|
|
176 |
|
1441 |
ariadna |
177 |
Scenario: A random question can be added to the quiz from a shared question bank
|
|
|
178 |
Given I am on the "Quiz 1" "mod_quiz > Edit" page logged in as "teacher1"
|
|
|
179 |
And I open the "last" add to quiz menu
|
|
|
180 |
And I follow "a random question"
|
|
|
181 |
And I should see "Current bank: Quiz 1"
|
|
|
182 |
And I apply question bank filter "Category" with value "Questions Category 1"
|
|
|
183 |
And I should see "question 1 name"
|
|
|
184 |
And I click on "Switch bank" "button"
|
|
|
185 |
And I click on "Qbank 1" "link" in the "Select question bank" "dialogue"
|
|
|
186 |
And I should see "Current bank: Qbank 1"
|
|
|
187 |
And I should not see "question 1 name"
|
|
|
188 |
And I apply question bank filter "Category" with value "Qbank questions"
|
|
|
189 |
And I should see "Qbank question 1"
|
|
|
190 |
When I apply question bank filter "Tag" with value "qbanktag"
|
|
|
191 |
And I select "1" from the "randomcount" singleselect
|
|
|
192 |
And I press "Add random question"
|
|
|
193 |
Then I should see "Random (Qbank questions) based on filter condition with tags: qbanktag" on quiz page "1"
|
|
|
194 |
And I click on "Configure question" "link" in the "Random (Qbank questions) based on filter condition with tags: qbank" "list_item"
|
|
|
195 |
And I should see "Qbank questions"
|
|
|
196 |
And I should see "qbanktag"
|
|
|
197 |
And I should see "Qbank question 1"
|
|
|
198 |
|
1 |
efrain |
199 |
Scenario: Teacher without moodle/question:useall should not see the add a random question menu item
|
|
|
200 |
Given the following "permission overrides" exist:
|
|
|
201 |
| capability | permission | role | contextlevel | reference |
|
|
|
202 |
| moodle/question:useall | Prevent | editingteacher | Course | C1 |
|
|
|
203 |
And I log in as "teacher1"
|
|
|
204 |
And I am on the "Quiz 1" "mod_quiz > Edit" page
|
|
|
205 |
When I open the "last" add to quiz menu
|
|
|
206 |
Then I should not see "a random question"
|
|
|
207 |
|
|
|
208 |
Scenario: A random question can be added to the quiz by creating a new category
|
|
|
209 |
Given I am on the "Quiz 1" "mod_quiz > Edit" page logged in as "teacher1"
|
|
|
210 |
When I open the "last" add to quiz menu
|
|
|
211 |
And I follow "a random question"
|
|
|
212 |
And I follow "New category"
|
|
|
213 |
And "Help with Parent category" "icon" should exist in the "Random question using a new category" "fieldset"
|
|
|
214 |
And I set the following fields to these values:
|
|
|
215 |
| Name | New Random category |
|
1441 |
ariadna |
216 |
| Parent category | Questions Category 1 |
|
1 |
efrain |
217 |
And I press "Create category and add random question"
|
1441 |
ariadna |
218 |
And I should see "Random (New Random category) based on filter condition" on quiz page "1"
|
|
|
219 |
And I click on "Configure question" "link" in the "Random (New Random category) based on filter condition" "list_item"
|
1 |
efrain |
220 |
Then I should see "New Random category"
|
1441 |
ariadna |
221 |
|
|
|
222 |
Scenario: See questions link applies all random question filters
|
|
|
223 |
Given I am on the "Quiz 1" "mod_quiz > Edit" page logged in as "teacher1"
|
|
|
224 |
And I open the "last" add to quiz menu
|
|
|
225 |
And I follow "a random question"
|
|
|
226 |
And I apply question bank filter "Category" with value "Questions Category 1"
|
|
|
227 |
And I apply question bank filter "Tag" with value "foo"
|
|
|
228 |
And I select "1" from the "randomcount" singleselect
|
|
|
229 |
And I press "Add random question"
|
|
|
230 |
And I should see "Random (Questions Category 1) based on filter condition with tags: foo" on quiz page "1"
|
|
|
231 |
And I click on "Configure question" "link" in the "Random (Questions Category 1) based on filter condition with tags: foo" "list_item"
|
|
|
232 |
And I should see "Questions Category 1"
|
|
|
233 |
And I should see "foo"
|
|
|
234 |
And I should see "question 1 name"
|
|
|
235 |
And I should see "\"listen\" & \"answer\""
|
|
|
236 |
And I should not see "bar"
|
|
|
237 |
And I should not see "question 2 name"
|
|
|
238 |
When I am on the "Quiz 1" "mod_quiz > Edit" page
|
|
|
239 |
And I click on "(See questions)" "link" in the "Random (Questions Category 1) based on filter condition with tags: foo" "list_item"
|
|
|
240 |
Then I should see "Questions Category 1"
|
|
|
241 |
And I should see "foo"
|
|
|
242 |
And I should see "question 1 name"
|
|
|
243 |
And I should see "\"listen\" & \"answer\""
|
|
|
244 |
And I should not see "bar"
|
|
|
245 |
And I should not see "question 2 name"
|