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:
|
|
|
18 |
| activity | name | intro | course | idnumber |
|
|
|
19 |
| quiz | Quiz 1 | Quiz 1 for testing the Add random question form | C1 | quiz1 |
|
|
|
20 |
And the following "question categories" exist:
|
|
|
21 |
| contextlevel | reference | name |
|
|
|
22 |
| Course | C1 | Questions Category 1 |
|
|
|
23 |
| Course | C1 | Questions Category 2 |
|
|
|
24 |
And the following "question categories" exist:
|
|
|
25 |
| contextlevel | reference | name | questioncategory |
|
|
|
26 |
| Course | C1 | Subcategory | Questions Category 1 |
|
|
|
27 |
And the following "questions" exist:
|
|
|
28 |
| questioncategory | qtype | name | user | questiontext |
|
|
|
29 |
| Questions Category 1 | essay | question 1 name | admin | Question 1 text |
|
|
|
30 |
| Questions Category 1 | essay | question 2 name | teacher1 | Question 2 text |
|
|
|
31 |
| Subcategory | essay | question 3 name | teacher1 | Question 3 text |
|
|
|
32 |
| Subcategory | essay | question 4 name | teacher1 | Question 4 text |
|
|
|
33 |
| Questions Category 1 | essay | "listen" & "answer" | teacher1 | Question 5 text |
|
|
|
34 |
And the following "core_question > Tags" exist:
|
|
|
35 |
| question | tag |
|
|
|
36 |
| question 1 name | foo |
|
|
|
37 |
| question 2 name | bar |
|
|
|
38 |
| question 3 name | foo |
|
|
|
39 |
| question 4 name | bar |
|
|
|
40 |
| "listen" & "answer" | foo |
|
|
|
41 |
|
|
|
42 |
Scenario: Available tags are shown in the autocomplete tag field
|
|
|
43 |
Given I am on the "Quiz 1" "mod_quiz > Edit" page logged in as "teacher1"
|
|
|
44 |
When I open the "last" add to quiz menu
|
|
|
45 |
And I follow "a random question"
|
|
|
46 |
And I add question bank filter "Tag"
|
|
|
47 |
And I click on "Tag" "field"
|
|
|
48 |
And I press the down key
|
|
|
49 |
Then "foo" "autocomplete_suggestions" should exist
|
|
|
50 |
And "bar" "autocomplete_suggestions" should exist
|
|
|
51 |
|
|
|
52 |
Scenario: Questions can be filtered by tags
|
|
|
53 |
Given I am on the "Quiz 1" "mod_quiz > Edit" page logged in as "teacher1"
|
|
|
54 |
When I open the "last" add to quiz menu
|
|
|
55 |
And I follow "a random question"
|
|
|
56 |
And I apply question bank filter "Tag" with value "foo"
|
|
|
57 |
And I wait until the page is ready
|
|
|
58 |
And I should see "question 1 name"
|
|
|
59 |
And I should see "\"listen\" & \"answer\""
|
|
|
60 |
And I should not see "question 2 name"
|
|
|
61 |
And I should not see "question 3 name"
|
|
|
62 |
And I should not see "question 4 name"
|
|
|
63 |
# Ensure tagged questions inside subcategories are also matched.
|
|
|
64 |
And I set the field "Also show questions from subcategories" to "1"
|
|
|
65 |
And I click on "Apply filters" "button"
|
|
|
66 |
And I wait until the page is ready
|
|
|
67 |
And I should see "question 1 name"
|
|
|
68 |
And I should see "question 3 name"
|
|
|
69 |
And I should see "\"listen\" & \"answer\""
|
|
|
70 |
And I should not see "question 2 name"
|
|
|
71 |
And I should not see "question 4 name"
|
|
|
72 |
|
|
|
73 |
Scenario: A random question can be added to the quiz
|
|
|
74 |
Given I am on the "Quiz 1" "mod_quiz > Edit" page logged in as "teacher1"
|
|
|
75 |
When I open the "last" add to quiz menu
|
|
|
76 |
And I follow "a random question"
|
|
|
77 |
And I apply question bank filter "Tag" with value "foo"
|
|
|
78 |
And I select "1" from the "randomcount" singleselect
|
|
|
79 |
And I press "Add random question"
|
|
|
80 |
And I should see "Random question based on filter condition with tags: foo" on quiz page "1"
|
|
|
81 |
When I click on "Configure question" "link" in the "Random question based on filter condition with tags: foo" "list_item"
|
|
|
82 |
Then I should see "Questions Category 1"
|
|
|
83 |
And I should see "foo"
|
|
|
84 |
And I should see "question 1 name"
|
|
|
85 |
And I should see "\"listen\" & \"answer\""
|
|
|
86 |
|
11 |
efrain |
87 |
Scenario: After closing and reopening the modal, it still works
|
|
|
88 |
When I am on the "Quiz 1" "mod_quiz > Edit" page logged in as teacher1
|
|
|
89 |
And I open the "last" add to quiz menu
|
|
|
90 |
And I follow "a random question"
|
|
|
91 |
And I click on "Close" "button" in the "Add a random question at the end" "dialogue"
|
|
|
92 |
And I open the "last" add to quiz menu
|
|
|
93 |
And I follow "a random question"
|
|
|
94 |
And I should not see "question 3 name"
|
|
|
95 |
And I set the field "Category" to "Subcategory"
|
|
|
96 |
And I press "Apply filters"
|
|
|
97 |
Then I should see "question 3 name"
|
|
|
98 |
|
1 |
efrain |
99 |
Scenario: Teacher without moodle/question:useall should not see the add a random question menu item
|
|
|
100 |
Given the following "permission overrides" exist:
|
|
|
101 |
| capability | permission | role | contextlevel | reference |
|
|
|
102 |
| moodle/question:useall | Prevent | editingteacher | Course | C1 |
|
|
|
103 |
And I log in as "teacher1"
|
|
|
104 |
And I am on the "Quiz 1" "mod_quiz > Edit" page
|
|
|
105 |
When I open the "last" add to quiz menu
|
|
|
106 |
Then I should not see "a random question"
|
|
|
107 |
|
|
|
108 |
Scenario: A random question can be added to the quiz by creating a new category
|
|
|
109 |
Given I am on the "Quiz 1" "mod_quiz > Edit" page logged in as "teacher1"
|
|
|
110 |
When I open the "last" add to quiz menu
|
|
|
111 |
And I follow "a random question"
|
|
|
112 |
And I follow "New category"
|
|
|
113 |
And "Help with Parent category" "icon" should exist in the "Random question using a new category" "fieldset"
|
|
|
114 |
And I set the following fields to these values:
|
|
|
115 |
| Name | New Random category |
|
|
|
116 |
| Parent category | Default for Quiz 1 |
|
|
|
117 |
And I press "Create category and add random question"
|
|
|
118 |
And I should see "Random question based on filter condition" on quiz page "1"
|
|
|
119 |
And I click on "Configure question" "link" in the "Random question based on filter condition" "list_item"
|
|
|
120 |
Then I should see "New Random category"
|