1 |
efrain |
1 |
@mod @mod_quiz @javascript
|
|
|
2 |
Feature: Adding questions to a quiz from the question bank
|
|
|
3 |
In order to re-use questions
|
|
|
4 |
As a teacher
|
|
|
5 |
I want to add questions from the question bank
|
|
|
6 |
|
|
|
7 |
Background:
|
|
|
8 |
Given the following "users" exist:
|
|
|
9 |
| username | firstname | lastname | email |
|
|
|
10 |
| teacher1 | Teacher | 1 | teacher1@example.com |
|
|
|
11 |
And the following "courses" exist:
|
|
|
12 |
| fullname | shortname | format |
|
|
|
13 |
| Course 1 | C1 | weeks |
|
|
|
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 menu | C1 | quiz1 |
|
|
|
20 |
And the following "question categories" exist:
|
|
|
21 |
| contextlevel | reference | name |
|
|
|
22 |
| Course | C1 | Test questions |
|
|
|
23 |
And the following "questions" exist:
|
|
|
24 |
| questioncategory | qtype | name | user | questiontext | idnumber |
|
|
|
25 |
| Test questions | essay | question 01 name | admin | Question 01 text | |
|
|
|
26 |
| Test questions | essay | question 02 name | teacher1 | Question 02 text | qidnum |
|
|
|
27 |
|
|
|
28 |
Scenario: The questions can be filtered by tag
|
|
|
29 |
Given I am on the "question 01 name" "core_question > edit" page logged in as teacher1
|
|
|
30 |
And I set the following fields to these values:
|
|
|
31 |
| Tags | foo |
|
|
|
32 |
And I press "id_submitbutton"
|
|
|
33 |
And I choose "Edit question" action for "question 02 name" in the question bank
|
|
|
34 |
And I set the following fields to these values:
|
|
|
35 |
| Tags | bar |
|
|
|
36 |
And I press "id_submitbutton"
|
|
|
37 |
When I am on the "Quiz 1" "mod_quiz > Edit" page
|
|
|
38 |
And I open the "last" add to quiz menu
|
|
|
39 |
And I follow "from question bank"
|
|
|
40 |
Then I should see "foo" in the "question 01 name" "table_row"
|
|
|
41 |
And I should see "bar" in the "question 02 name" "table_row"
|
|
|
42 |
And I should see "qidnum" in the "question 02 name" "table_row"
|
|
|
43 |
When I apply question bank filter "Tag" with value "foo"
|
|
|
44 |
And I should see "question 01 name" in the "categoryquestions" "table"
|
|
|
45 |
And I should not see "question 02 name" in the "categoryquestions" "table"
|
|
|
46 |
|
|
|
47 |
Scenario: The question modal can be paginated
|
11 |
efrain |
48 |
Given the following "question categories" exist:
|
|
|
49 |
| contextlevel | reference | name |
|
|
|
50 |
| Course | C1 | My collection |
|
|
|
51 |
And 45 "questions" exist with the following data:
|
|
|
52 |
| questioncategory | My collection |
|
|
|
53 |
| qtype | essay |
|
|
|
54 |
| name | Feature question [count] |
|
|
|
55 |
| questiontext | Write about topic [count] |
|
|
|
56 |
| user | teacher1 |
|
|
|
57 |
# Sadly, the above step generates questions which sort like FQ1, FQ11, FQ12, ..., FQ19, FQ2, FQ20, ...
|
|
|
58 |
# so the expected paging behaviour is not immediately intuitive with 20 questions per page.
|
|
|
59 |
When I am on the "Quiz 1" "mod_quiz > Edit" page logged in as teacher1
|
1 |
efrain |
60 |
And I open the "last" add to quiz menu
|
|
|
61 |
And I follow "from question bank"
|
11 |
efrain |
62 |
And I should see "question 01 name" in the "categoryquestions" "table"
|
|
|
63 |
And I should see "question 02 name" in the "categoryquestions" "table"
|
|
|
64 |
And I should not see "Feature question" in the "categoryquestions" "table"
|
|
|
65 |
And I set the field "Category" to "My collection"
|
|
|
66 |
And I press "Apply filters"
|
|
|
67 |
And I wait until the page is ready
|
|
|
68 |
Then I should not see "question 01 name" in the "categoryquestions" "table"
|
|
|
69 |
And I should see "Feature question 1" in the "categoryquestions" "table"
|
|
|
70 |
And I should see "Feature question 27" in the "categoryquestions" "table"
|
|
|
71 |
And I should not see "Feature question 28" in the "categoryquestions" "table"
|
1 |
efrain |
72 |
And I click on "2" "link" in the ".pagination" "css_element"
|
11 |
efrain |
73 |
And I wait until the page is ready
|
|
|
74 |
And I should not see "Feature question 27" in the "categoryquestions" "table"
|
|
|
75 |
And I should see "Feature question 28" in the "categoryquestions" "table"
|
|
|
76 |
And I should see "Feature question 45" in the "categoryquestions" "table"
|
|
|
77 |
And I should not see "Feature question 5"
|
|
|
78 |
And I click on "3" "link" in the ".pagination" "css_element"
|
|
|
79 |
And I wait until the page is ready
|
|
|
80 |
And I should not see "Feature question 45" in the "categoryquestions" "table"
|
|
|
81 |
And I should see "Feature question 5"
|
|
|
82 |
And I should see "Feature question 9"
|
1 |
efrain |
83 |
|
11 |
efrain |
84 |
Scenario: After closing and reopening the modal, it still works
|
|
|
85 |
Given the following "question categories" exist:
|
|
|
86 |
| contextlevel | reference | name |
|
|
|
87 |
| Course | C1 | My collection |
|
|
|
88 |
And the following "question" exists:
|
|
|
89 |
| questioncategory | My collection |
|
|
|
90 |
| qtype | essay |
|
|
|
91 |
| name | Feature question |
|
|
|
92 |
| questiontext | Write about topic |
|
|
|
93 |
| user | teacher1 |
|
|
|
94 |
When 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 "from question bank"
|
|
|
97 |
And I click on "Close" "button" in the "Add from the question bank at the end" "dialogue"
|
|
|
98 |
And I open the "last" add to quiz menu
|
|
|
99 |
And I follow "from question bank"
|
|
|
100 |
And I set the field "Category" to "My collection"
|
|
|
101 |
And I press "Apply filters"
|
|
|
102 |
Then I should see "Feature question"
|
|
|
103 |
|
1 |
efrain |
104 |
Scenario: Questions are added in the right place with multiple sections
|
|
|
105 |
Given the following "questions" exist:
|
|
|
106 |
| questioncategory | qtype | name | questiontext |
|
|
|
107 |
| Test questions | essay | question 03 name | question 03 text |
|
|
|
108 |
And quiz "Quiz 1" contains the following questions:
|
|
|
109 |
| question | page |
|
|
|
110 |
| question 01 name | 1 |
|
|
|
111 |
| question 02 name | 2 |
|
|
|
112 |
And quiz "Quiz 1" contains the following sections:
|
|
|
113 |
| heading | firstslot | shuffle |
|
|
|
114 |
| Section 1 | 1 | 0 |
|
|
|
115 |
| Section 2 | 2 | 0 |
|
|
|
116 |
And I log in as "teacher1"
|
|
|
117 |
And I am on the "Quiz 1" "mod_quiz > Edit" page
|
|
|
118 |
When I open the "Page 1" add to quiz menu
|
|
|
119 |
And I follow "from question bank"
|
|
|
120 |
And I set the field with xpath "//tr[contains(normalize-space(.), 'question 03 name')]//input[@type='checkbox']" to "1"
|
|
|
121 |
And I click on "Add selected questions to the quiz" "button"
|
|
|
122 |
Then I should see "question 03 name" on quiz page "1"
|
|
|
123 |
And I should see "question 01 name" before "question 03 name" on the edit quiz page
|
|
|
124 |
|
|
|
125 |
Scenario: Add several selected questions from the question bank
|
|
|
126 |
Given I am on the "Quiz 1" "mod_quiz > Edit" page logged in as "teacher1"
|
|
|
127 |
When I open the "last" add to quiz menu
|
|
|
128 |
And I follow "from question bank"
|
|
|
129 |
And I set the field with xpath "//input[@type='checkbox' and @id='qbheadercheckbox']" to "1"
|
|
|
130 |
And I press "Add selected questions to the quiz"
|
|
|
131 |
Then I should see "question 01 name" on quiz page "1"
|
|
|
132 |
And I should see "question 02 name" on quiz page "2"
|
|
|
133 |
|
|
|
134 |
@javascript
|
|
|
135 |
Scenario: Validate the sorting while adding questions from question bank
|
|
|
136 |
Given the following "questions" exist:
|
|
|
137 |
| questioncategory | qtype | name | questiontext |
|
|
|
138 |
| Test questions | multichoice | question 03 name | question 03 name text |
|
|
|
139 |
And I am on the "Quiz 1" "mod_quiz > Edit" page logged in as "teacher1"
|
|
|
140 |
When I open the "last" add to quiz menu
|
|
|
141 |
And I follow "from question bank"
|
|
|
142 |
And I click on "Sort by Question ascending" "link"
|
|
|
143 |
Then "question 01 name" "text" should appear before "question 02 name" "text"
|
|
|
144 |
And I click on "Sort by Question descending" "link"
|
|
|
145 |
And "question 03 name" "text" should appear before "question 01 name" "text"
|
|
|
146 |
And I follow "Sort by Question type ascending"
|
|
|
147 |
Then "question 01 name" "text" should appear before "question 03 name" "text"
|
|
|
148 |
And I follow "Sort by Question type descending"
|
|
|
149 |
Then "question 03 name" "text" should appear before "question 01 name" "text"
|
|
|
150 |
|
|
|
151 |
Scenario: Shuffle option could be set before adding any question to the quiz
|
|
|
152 |
Given the following "questions" exist:
|
|
|
153 |
| questioncategory | qtype | name | questiontext |
|
|
|
154 |
| Test questions | essay | question 03 name | question 03 text |
|
|
|
155 |
And I log in as "teacher1"
|
|
|
156 |
And I am on the "Quiz 1" "mod_quiz > Edit" page
|
|
|
157 |
When I set the field "Shuffle" to "1"
|
|
|
158 |
And I open the "last" add to quiz menu
|
|
|
159 |
And I follow "from question bank"
|
|
|
160 |
Then I should see "question 01 name"
|