1 @mod @mod_quiz @javascript
2 Feature: Adding questions to a quiz from the question bank
3 In order to re-use questions
5 I want to add questions from the question bank
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 |
25 | Test questions | essay | question 01 name | admin | Question 01 text |
26 | Test questions | essay | question 02 name | teacher1 | Question 02 text |
28 Scenario: The questions can be filtered by tag
29 Given I log in as "teacher1"
30 And I am on "Course 1" course homepage
31 When I navigate to "Question bank > Questions" in current page administration
32 And I click on "Edit" "link" in the "question 01 name" "table_row"
33 And I set the following fields to these values:
35 And I press "id_submitbutton"
36 And I click on "Edit" "link" in the "question 02 name" "table_row"
37 And I set the following fields to these values:
39 And I press "id_submitbutton"
40 And I am on the "Quiz 1" "mod_quiz > Edit" page
41 And I open the "last" add to quiz menu
42 And I follow "from question bank"
43 And I set the field "Filter by tags..." to "foo"
44 And I press key "13" in the field "Filter by tags..."
45 Then I should see "question 01 name" in the "categoryquestions" "table"
46 And I should not see "question 02 name" in the "categoryquestions" "table"
48 Scenario: The question modal can be paginated
49 Given the following "questions" exist:
50 | questioncategory | qtype | name | user | questiontext |
51 | Test questions | essay | question 03 name | teacher1 | Question 03 text |
52 | Test questions | essay | question 04 name | teacher1 | Question 04 text |
53 | Test questions | essay | question 05 name | teacher1 | Question 05 text |
54 | Test questions | essay | question 06 name | teacher1 | Question 06 text |
55 | Test questions | essay | question 07 name | teacher1 | Question 07 text |
56 | Test questions | essay | question 08 name | teacher1 | Question 08 text |
57 | Test questions | essay | question 09 name | teacher1 | Question 09 text |
58 | Test questions | essay | question 10 name | teacher1 | Question 10 text |
59 | Test questions | essay | question 11 name | teacher1 | Question 11 text |
60 | Test questions | essay | question 12 name | teacher1 | Question 12 text |
61 | Test questions | essay | question 13 name | teacher1 | Question 13 text |
62 | Test questions | essay | question 14 name | teacher1 | Question 14 text |
63 | Test questions | essay | question 15 name | teacher1 | Question 15 text |
64 | Test questions | essay | question 16 name | teacher1 | Question 16 text |
65 | Test questions | essay | question 17 name | teacher1 | Question 17 text |
66 | Test questions | essay | question 18 name | teacher1 | Question 18 text |
67 | Test questions | essay | question 19 name | teacher1 | Question 19 text |
68 | Test questions | essay | question 20 name | teacher1 | Question 20 text |
69 | Test questions | essay | question 21 name | teacher1 | Question 21 text |
70 | Test questions | essay | question 22 name | teacher1 | Question 22 text |
71 And I log in as "teacher1"
72 And I am on the "Quiz 1" "mod_quiz > Edit" page
73 And I open the "last" add to quiz menu
74 And I follow "from question bank"
75 And I click on "2" "link" in the ".pagination" "css_element"
76 Then I should see "question 21 name" in the "categoryquestions" "table"
77 And I should see "question 22 name" in the "categoryquestions" "table"
78 And I should not see "question 01 name" in the "categoryquestions" "table"
80 Scenario: Questions are added in the right place with multiple sections
81 Given the following "questions" exist:
82 | questioncategory | qtype | name | questiontext |
83 | Test questions | essay | question 03 name | question 03 text |
84 And quiz "Quiz 1" contains the following questions:
86 | question 01 name | 1 |
87 | question 02 name | 2 |
88 And quiz "Quiz 1" contains the following sections:
89 | heading | firstslot | shuffle |
92 And I log in as "teacher1"
93 And I am on the "Quiz 1" "mod_quiz > Edit" page
94 When I open the "Page 1" add to quiz menu
95 And I follow "from question bank"
96 And I set the field with xpath "//tr[contains(normalize-space(.), 'question 03 name')]//input[@type='checkbox']" to "1"
97 And I click on "Add selected questions to the quiz" "button"
98 Then I should see "question 03 name" on quiz page "1"
99 And I should see "question 01 name" before "question 03 name" on the edit quiz page