Proyectos de Subversion Moodle

Rev

Rev 11 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
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:
1441 ariadna 12
      | fullname                                                                                                                | shortname | format |
13
      | <span lang="en" class="multilang">Test course</span><span lang="fr" class="multilang">Cours test</span> & < > " ' &amp; | C1        | weeks  |
1 efrain 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 menu          | C1     | quiz1    |
20
      | qbank    | <span lang="en" class="multilang">Qbank</span><span lang="fr" class="multilang">Banqueq</span> 1 & < > " ' &amp; | Question bank 1 for testing the Add menu | C1     | qbank1   |
21
      | qbank    | Question Bank A                                                                                                  | Question Bank A for testing qbank name   | C1     | qbankA   |
22
      | qbank    | Question Bank B                                                                                                  | Question Bank B for testing qbank name   | C1     | qbankB   |
1 efrain 23
    And the following "question categories" exist:
1441 ariadna 24
      | contextlevel    | reference  | name              |
25
      | Activity module | quiz1      | Test questions    |
26
      | Activity module | qbank1     | Qbank questions   |
27
      | Activity module | qbankA     | Qbank Questions 1 |
28
      | Activity module | qbankB     | Qbank Questions 2 |
1 efrain 29
    And the following "questions" exist:
1441 ariadna 30
      | questioncategory  | qtype     | name             | user     | questiontext     | idnumber |
31
      | Test questions    | essay     | question 01 name | admin    | Question 01 text |          |
32
      | Test questions    | essay     | question 02 name | teacher1 | Question 02 text | qidnum   |
33
      | Qbank questions   | essay     | question 03 name | teacher1 | Question 03 text | q3idnum  |
34
      | Qbank questions   | essay     | question 04 name | teacher1 | Question 04 text | q4idnum  |
35
      | Qbank Questions 1 | truefalse | TF1              | admin    | Qbank 1 question |          |
36
      | Qbank Questions 2 | truefalse | TF2              | admin    | Qbank 2 question |          |
1 efrain 37
 
38
  Scenario: The questions can be filtered by tag
39
    Given I am on the "question 01 name" "core_question > edit" page logged in as teacher1
40
    And I set the following fields to these values:
41
      | Tags | foo |
42
    And I press "id_submitbutton"
43
    And I choose "Edit question" action for "question 02 name" in the question bank
44
    And I set the following fields to these values:
45
      | Tags | bar |
46
    And I press "id_submitbutton"
47
    When I am on the "Quiz 1" "mod_quiz > Edit" page
48
    And I open the "last" add to quiz menu
49
    And I follow "from question bank"
1441 ariadna 50
    And I apply question bank filter "Category" with value "Test questions"
1 efrain 51
    Then I should see "foo" in the "question 01 name" "table_row"
52
    And I should see "bar" in the "question 02 name" "table_row"
53
    And I should see "qidnum" in the "question 02 name" "table_row"
54
    When I apply question bank filter "Tag" with value "foo"
55
    And I should see "question 01 name" in the "categoryquestions" "table"
56
    And I should not see "question 02 name" in the "categoryquestions" "table"
57
 
1441 ariadna 58
  Scenario: The questions can be filtered by tag on a shared question bank
59
    Given the "multilang" filter is "on"
60
    And the "multilang" filter applies to "content and headings"
61
    And I am on the "question 03 name" "core_question > edit" page logged in as teacher1
62
    And I set the following fields to these values:
63
      | Tags | qbanktag1 |
64
    And I press "Save changes"
65
    And I am on the "question 04 name" "core_question > edit" page logged in as teacher1
66
    And I set the following fields to these values:
67
      | Tags | qbanktag2 |
68
    And I press "Save changes"
69
    When I am on the "Quiz 1" "mod_quiz > Edit" page
70
    And I open the "last" add to quiz menu
71
    And I follow "from question bank"
72
    And I click on "Switch bank" "button"
73
    And I click on "Qbank 1 & < > \" ' &amp;" "link" in the "Select question bank" "dialogue"
74
    And I apply question bank filter "Category" with value "Qbank questions"
75
    Then I should see "qbanktag1" in the "question 03 name" "table_row"
76
    And I should see "qbanktag2" in the "question 04 name" "table_row"
77
    And I apply question bank filter "Tag" with value "qbanktag1"
78
    And I should see "question 03 name" in the "categoryquestions" "table"
79
    And I should not see "question 04 name" in the "categoryquestions" "table"
80
 
1 efrain 81
  Scenario: The question modal can be paginated
11 efrain 82
    Given the following "question categories" exist:
1441 ariadna 83
      | contextlevel    | reference | name           |
84
      | Activity module | quiz1    | My collection  |
11 efrain 85
    And 45 "questions" exist with the following data:
86
      | questioncategory | My collection             |
87
      | qtype            | essay                     |
88
      | name             | Feature question [count]  |
89
      | questiontext     | Write about topic [count] |
90
      | user             | teacher1                  |
91
    # Sadly, the above step generates questions which sort like FQ1, FQ11, FQ12, ..., FQ19, FQ2, FQ20, ...
92
    # so the expected paging behaviour is not immediately intuitive with 20 questions per page.
93
    When I am on the "Quiz 1" "mod_quiz > Edit" page logged in as teacher1
1 efrain 94
    And I open the "last" add to quiz menu
95
    And I follow "from question bank"
1441 ariadna 96
    And I apply question bank filter "Category" with value "Test questions"
11 efrain 97
    And I should see "question 01 name" in the "categoryquestions" "table"
98
    And I should see "question 02 name" in the "categoryquestions" "table"
99
    And I should not see "Feature question" in the "categoryquestions" "table"
100
    And I set the field "Category" to "My collection"
101
    And I press "Apply filters"
102
    And I wait until the page is ready
103
    Then I should not see "question 01 name" in the "categoryquestions" "table"
104
    And I should see "Feature question 1" in the "categoryquestions" "table"
105
    And I should see "Feature question 27" in the "categoryquestions" "table"
106
    And I should not see "Feature question 28" in the "categoryquestions" "table"
1 efrain 107
    And I click on "2" "link" in the ".pagination" "css_element"
11 efrain 108
    And I wait until the page is ready
109
    And I should not see "Feature question 27" in the "categoryquestions" "table"
110
    And I should see "Feature question 28" in the "categoryquestions" "table"
111
    And I should see "Feature question 45" in the "categoryquestions" "table"
112
    And I should not see "Feature question 5"
113
    And I click on "3" "link" in the ".pagination" "css_element"
114
    And I wait until the page is ready
115
    And I should not see "Feature question 45" in the "categoryquestions" "table"
116
    And I should see "Feature question 5"
117
    And I should see "Feature question 9"
1 efrain 118
 
11 efrain 119
  Scenario: After closing and reopening the modal, it still works
120
    Given the following "question categories" exist:
1441 ariadna 121
      | contextlevel    | reference | name           |
122
      | Activity module | quiz1     | My collection  |
11 efrain 123
    And the following "question" exists:
124
      | questioncategory | My collection     |
125
      | qtype            | essay             |
126
      | name             | Feature question  |
127
      | questiontext     | Write about topic |
128
      | user             | teacher1          |
129
    When I am on the "Quiz 1" "mod_quiz > Edit" page logged in as teacher1
130
    And I open the "last" add to quiz menu
131
    And I follow "from question bank"
132
    And I click on "Close" "button" in the "Add from the question bank at the end" "dialogue"
133
    And I open the "last" add to quiz menu
134
    And I follow "from question bank"
135
    And I set the field "Category" to "My collection"
136
    And I press "Apply filters"
137
    Then I should see "Feature question"
138
 
1 efrain 139
  Scenario: Questions are added in the right place with multiple sections
140
    Given the following "questions" exist:
141
      | questioncategory | qtype | name             | questiontext     |
142
      | Test questions   | essay | question 03 name | question 03 text |
143
    And quiz "Quiz 1" contains the following questions:
144
      | question         | page |
145
      | question 01 name | 1    |
146
      | question 02 name | 2    |
147
    And quiz "Quiz 1" contains the following sections:
148
      | heading   | firstslot | shuffle |
149
      | Section 1 | 1         | 0       |
150
      | Section 2 | 2         | 0       |
151
    And I log in as "teacher1"
152
    And I am on the "Quiz 1" "mod_quiz > Edit" page
153
    When I open the "Page 1" add to quiz menu
154
    And I follow "from question bank"
1441 ariadna 155
    And I apply question bank filter "Category" with value "Test questions"
1 efrain 156
    And I set the field with xpath "//tr[contains(normalize-space(.), 'question 03 name')]//input[@type='checkbox']" to "1"
157
    And I click on "Add selected questions to the quiz" "button"
158
    Then I should see "question 03 name" on quiz page "1"
159
    And I should see "question 01 name" before "question 03 name" on the edit quiz page
160
 
161
  Scenario: Add several selected questions from the question bank
162
    Given I am on the "Quiz 1" "mod_quiz > Edit" page logged in as "teacher1"
163
    When I open the "last" add to quiz menu
164
    And I follow "from question bank"
1441 ariadna 165
    And I apply question bank filter "Category" with value "Test questions"
1 efrain 166
    And I set the field with xpath "//input[@type='checkbox' and @id='qbheadercheckbox']" to "1"
167
    And I press "Add selected questions to the quiz"
168
    Then I should see "question 01 name" on quiz page "1"
169
    And I should see "question 02 name" on quiz page "2"
170
 
1441 ariadna 171
  Scenario: Adding a question to quiz from a shared question bank
172
    Given the "multilang" filter is "on"
173
    And the "multilang" filter applies to "content and headings"
174
    And I am on the "Quiz 1" "mod_quiz > Edit" page logged in as "teacher1"
175
    When I open the "last" add to quiz menu
176
    And I follow "from question bank"
177
    Then I should see "Current bank: Quiz 1"
178
    And I apply question bank filter "Category" with value "Test questions"
179
    And I should see "question 01 name"
180
    And I click on "Switch bank" "button"
181
    And I click on "Qbank 1 & < > \" ' &amp;" "link" in the "Select question bank" "dialogue"
182
    And I apply question bank filter "Category" with value "Qbank questions"
183
    And I should see "question 03 name"
184
    But I should not see "question 01 name"
185
    And I click on "Select" "checkbox" in the "question 03 name" "table_row"
186
    And I click on "Add selected questions to the quiz" "button"
187
    And I should see "question 03 name"
188
    And "Qbank 1 & < > " "text" should appear after "question 03 name" "text"
189
 
1 efrain 190
  @javascript
191
  Scenario: Validate the sorting while adding questions from question bank
192
    Given the following "questions" exist:
193
      | questioncategory | qtype       | name              | questiontext          |
194
      | Test questions   | multichoice | question 03 name  | question 03 name text |
195
    And I am on the "Quiz 1" "mod_quiz > Edit" page logged in as "teacher1"
196
    When I open the "last" add to quiz menu
197
    And I follow "from question bank"
1441 ariadna 198
    And I apply question bank filter "Category" with value "Test questions"
1 efrain 199
    And I click on "Sort by Question ascending" "link"
200
    Then "question 01 name" "text" should appear before "question 02 name" "text"
201
    And I click on "Sort by Question descending" "link"
202
    And "question 03 name" "text" should appear before "question 01 name" "text"
203
    And I follow "Sort by Question type ascending"
204
    Then "question 01 name" "text" should appear before "question 03 name" "text"
205
    And I follow "Sort by Question type descending"
206
    Then "question 03 name" "text" should appear before "question 01 name" "text"
207
 
208
  Scenario: Shuffle option could be set before adding any question to the quiz
209
    Given the following "questions" exist:
210
      | questioncategory | qtype | name             | questiontext     |
211
      | Test questions   | essay | question 03 name | question 03 text |
212
    And I log in as "teacher1"
213
    And I am on the "Quiz 1" "mod_quiz > Edit" page
214
    When I set the field "Shuffle" to "1"
215
    And I open the "last" add to quiz menu
216
    And I follow "from question bank"
1441 ariadna 217
    And I apply question bank filter "Category" with value "Test questions"
1 efrain 218
    Then I should see "question 01 name"
1441 ariadna 219
 
220
  Scenario: Question bank names are displayed in quiz questions
221
    Given quiz "Quiz 1" contains the following questions:
222
      | question | page |
223
      | TF1      | 1    |
224
      | TF2      | 1    |
225
    When I am on the "Quiz 1" "mod_quiz > Edit" page logged in as teacher1
226
    Then I should see "Question Bank A" in the "TF1" "list_item"
227
    And I should see "Question Bank B" in the "TF2" "list_item"
228
 
229
  Scenario: User doesn't see the option to switch to a bank they can't use
230
    Given the "multilang" filter is "on"
231
    And the "multilang" filter applies to "content and headings"
232
    And the following "users" exist:
233
      | username | firstname | lastname | email                |
234
      | teacher2 | Teacher   | 2        | teacher2@example.com |
235
    And the following "role" exists:
236
      | shortname               | noquestions          |
237
      | name                    | Cannot use questions |
238
      | moodle/question:usemine | prohibit             |
239
      | moodle/question:useall  | prohibit             |
240
    And the following "course enrolments" exist:
241
      | user     | course | role           |
242
      | teacher2 | C1     | editingteacher |
243
    And I am on the "Quiz 1" "mod_quiz > Edit" page logged in as "teacher2"
244
    And I open the "last" add to quiz menu
245
    And I follow "from question bank"
246
    And I click on "Switch bank" "button"
247
    And I click on "Qbank 1 & < > \" ' &amp;" "link" in the "Select question bank" "dialogue"
248
    And I apply question bank filter "Category" with value "Qbank questions"
249
    And I click on "Select" "checkbox" in the "question 03 name" "table_row"
250
    And I click on "Add selected questions to the quiz" "button"
251
    When the following "role assigns" exist:
252
      | user     | role        | contextlevel    | reference |
253
      | teacher2 | noquestions | Activity module | qbank1    |
254
    And I open the "Page 1" add to quiz menu
255
    And I follow "from question bank"
256
    And I click on "Switch bank" "button"
257
    Then "Qbank 1 & < > \" ' &amp;" "link" should not exist in the "Select question bank" "dialogue"
258
 
259
  @javascript
260
  Scenario: Don't show the edit link if the user doesn't have permission
261
    Given the following "courses" exist:
262
      | fullname | shortname | category |
263
      | Course 2 | C2        | 0        |
264
    And the following "activities" exist:
265
      | activity   | name            | course | idnumber |
266
      | qbank      | Question Bank C | C2     | qbankC   |
267
    And the following "question categories" exist:
268
      | contextlevel    | reference | name              |
269
      | Activity module | qbankC    | Qbank Questions 3 |
270
    And the following "questions" exist:
271
      | questioncategory  | qtype     | name            | questiontext        |
272
      | Qbank Questions 3 | truefalse | Shared question | Answer the question |
273
    And quiz "Quiz 1" contains the following questions:
274
      | question        | page |
275
      | TF1             | 1    |
276
      | Shared question | 1    |
277
    When I am on the "Quiz 1" "mod_quiz > Edit" page logged in as teacher1
278
    Then "TF1" "link" should exist
279
    And "Question Bank A" "link" should exist
280
    And "Shared question" "link" should not exist
281
    And "Question Bank C" "link" should not exist