| Línea 1... |
Línea 1... |
| 1 |
@qbank @qbank_managecategories @javascript
|
1 |
@qbank @qbank_managecategories @question_categories @javascript
|
| 2 |
Feature: A teacher can put questions in categories in the question bank
|
2 |
Feature: A teacher can put questions in categories in the question bank
|
| 3 |
In order to organize my questions
|
3 |
In order to organize my questions
|
| 4 |
As a teacher
|
4 |
As a teacher
|
| 5 |
I create and edit categories, move questions between them and filter question using category filter
|
5 |
I create and edit categories, move questions between them and filter question using category filter
|
| Línea 6... |
Línea 6... |
| 6 |
|
6 |
|
| 7 |
Background:
|
7 |
Background:
|
| 8 |
Given the following "users" exist:
|
8 |
Given the following "users" exist:
|
| 9 |
| username | firstname | lastname | email |
|
9 |
| username | firstname | lastname | email |
|
| 10 |
| teacher1 | Teacher | 1 | teacher1@example.com |
|
10 |
| teacher1 | Teacher | 1 | teacher1@example.com |
|
| 11 |
And the following "courses" exist:
|
11 |
And the following "courses" exist:
|
| 12 |
| fullname | shortname | format |
|
12 |
| fullname | shortname | format |
|
| 13 |
| Course 1 | C1 | weeks |
|
13 |
| Course 1 | C1 | weeks |
|
| 14 |
And the following "course enrolments" exist:
|
14 |
And the following "course enrolments" exist:
|
| 15 |
| user | course | role |
|
15 |
| user | course | role |
|
| - |
|
16 |
| teacher1 | C1 | editingteacher |
|
| - |
|
17 |
And the following "activities" exist:
|
| - |
|
18 |
| activity | name | course | idnumber |
|
| 16 |
| teacher1 | C1 | editingteacher |
|
19 |
| qbank | Qbank 1 | C1 | qbank1 |
|
| 17 |
And the following "question categories" exist:
|
20 |
And the following "question categories" exist:
|
| 18 |
| contextlevel | reference | questioncategory | name |
|
- |
|
| 19 |
| Course | C1 | Top | top |
|
- |
|
| 20 |
| Course | C1 | top | Default for C1 |
|
21 |
| contextlevel | reference | questioncategory | name |
|
| 21 |
| Course | C1 | Default for C1 | Subcategory |
|
22 |
| Activity module | qbank1 | Default for Qbank 1 | Subcategory & < > " ' & |
|
| 22 |
| Course | C1 | Default for C1 | Another subcat |
|
23 |
| Activity module | qbank1 | Default for Qbank 1 | Another subcat |
|
| 23 |
| Course | C1 | top | Used category |
|
24 |
| Activity module | qbank1 | top | Used category |
|
| 24 |
| Course | C1 | top | Default & testing |
|
25 |
| Activity module | qbank1 | top | Default & testing |
|
| 25 |
And the following "questions" exist:
|
26 |
And the following "questions" exist:
|
| 26 |
| questioncategory | qtype | name | questiontext |
|
27 |
| questioncategory | qtype | name | questiontext |
|
| 27 |
| Used category | essay | Test question to be moved | Write about whatever you want |
|
28 |
| Used category | essay | Test question to be moved | Write about whatever you want |
|
| 28 |
| Another subcat | essay | Question 1 | Write about whatever you want |
|
29 |
| Another subcat | essay | Question 1 | Write about whatever you want |
|
| 29 |
And I log in as "teacher1"
|
- |
|
| Línea 30... |
Línea 30... |
| 30 |
And I am on "Course 1" course homepage
|
30 |
And I log in as "teacher1"
|
| 31 |
|
31 |
|
| 32 |
Scenario: A new question category can be created
|
32 |
Scenario: A new question category can be created
|
| 33 |
When I am on the "Course 1" "core_question > course question categories" page
|
33 |
When I am on the "Qbank 1" "core_question > question categories" page
|
| 34 |
And I follow "Add category"
|
34 |
And I press "Add category"
|
| 35 |
And I set the following fields to these values:
|
35 |
And I set the following fields to these values:
|
| 36 |
| Name | 'Test' & 'display' |
|
36 |
| Name | 'Test' & 'display' |
|
| 37 |
| Parent category | Default & testing |
|
37 |
| Parent category | Default & testing |
|
| 38 |
| Category info | Created for testing category, HTML entity & its encoding |
|
38 |
| Category info | Created for testing category, HTML entity & its encoding |
|
| 39 |
| ID number | newcatidnumber |
|
39 |
| ID number | newcatidnumber |
|
| 40 |
And I press "submitbutton"
|
40 |
And I click on "Add category" "button" in the "Add category" "dialogue"
|
| 41 |
Then I should see "Default & testing"
|
41 |
Then I should see "Default & testing"
|
| 42 |
And I should see "ID number"
|
42 |
And I should see "ID number"
|
| - |
|
43 |
And I should see "newcatidnumber"
|
| 43 |
And I should see "newcatidnumber"
|
44 |
And I should see "(0)"
|
| 44 |
And I should see "(0)"
|
45 |
And I click on "Show descriptions" "checkbox"
|
| 45 |
And I should see "Created for testing category, HTML entity & its encoding" in the "'Test' & 'display'" "list_item"
|
46 |
And I should see "Created for testing category, HTML entity & its encoding" in the "'Test' & 'display'" "list_item"
|
| Línea 46... |
Línea 47... |
| 46 |
And I follow "Add category"
|
47 |
And I press "Add category"
|
| 47 |
And the "Parent category" select box should contain "'Test' & 'display' [newcatidnumber]"
|
48 |
And the "Parent category" select box should contain "'Test' & 'display' [newcatidnumber]"
|
| 48 |
|
49 |
|
| 49 |
Scenario: A question category can be edited
|
50 |
Scenario: A question category can be edited
|
| 50 |
When I am on the "Course 1" "core_question > course question categories" page
|
51 |
When I am on the "Qbank 1" "core_question > question categories" page
|
| 51 |
# There have been bugs which only happened if a question category was not empty, so add a question.
|
52 |
# There have been bugs which only happened if a question category was not empty, so add a question.
|
| 52 |
And the following "questions" exist:
|
53 |
And the following "questions" exist:
|
| - |
|
54 |
| questioncategory | qtype | name | questiontext |
|
| 53 |
| questioncategory | qtype | name | questiontext |
|
55 |
| Subcategory & < > " ' & | essay | Test question for renaming category | Write about whatever you want |
|
| 54 |
| Subcategory | essay | Test question for renaming category | Write about whatever you want |
|
56 |
And I open the action menu in "Subcategory & < > \" ' &" "list_item"
|
| 55 |
And I click on "Edit this category" "link" in the "Subcategory" "list_item"
|
57 |
And I choose "Edit settings" in the open action menu
|
| 56 |
And the field "parent" matches value " Default for C1"
|
58 |
And the field "parent" matches value " Default for Qbank 1"
|
| 57 |
And I set the following fields to these values:
|
59 |
And I set the following fields to these values:
|
| 58 |
| Name | New name |
|
60 |
| Name | New name |
|
| - |
|
61 |
| Category info | I was edited |
|
| 59 |
| Category info | I was edited |
|
62 |
And I press "Save changes"
|
| Línea 60... |
Línea 63... |
| 60 |
And I press "Save changes"
|
63 |
Then I should see "New name"
|
| 61 |
Then I should see "New name"
|
64 |
And I click on "Show descriptions" "checkbox"
|
| - |
|
65 |
And I should see "I was edited"
|
| - |
|
66 |
|
| - |
|
67 |
Scenario: An empty question category can be deleted
|
| - |
|
68 |
When I am on the "Qbank 1" "core_question > question categories" page
|
| 62 |
And I should see "I was edited" in the "New name" "list_item"
|
69 |
And I should see "Subcategory & < > \" ' &"
|
| 63 |
|
70 |
And the "data-bs-original-title" attribute of "span.qbank_managecategories-newchild.dropready" "css_element" should contain "As new child of Subcategory & < > \" ' &"
|
| Línea 64... |
Línea 71... |
| 64 |
Scenario: An empty question category can be deleted
|
71 |
And I open the action menu in "Subcategory" "list_item"
|
| 65 |
When I am on the "Course 1" "core_question > course question categories" page
|
72 |
And I choose "Delete" in the open action menu
|
| - |
|
73 |
And I click on "Delete" "button" in the "Delete" "dialogue"
|
| - |
|
74 |
Then I should not see "Subcategory & < > \" ' &"
|
| 66 |
And I click on "Delete" "link" in the "Subcategory" "list_item"
|
75 |
|
| 67 |
Then I should not see "Subcategory"
|
76 |
Scenario: An non-empty question category can be deleted if you move the contents elsewhere
|
| 68 |
|
77 |
When I am on the "Qbank 1" "core_question > question categories" page
|
| 69 |
Scenario: An non-empty question category can be deleted if you move the contents elsewhere
|
78 |
And I open the action menu in "Used category" "list_item"
|
| 70 |
When I am on the "Course 1" "core_question > course question categories" page
|
79 |
And I choose "Delete" in the open action menu
|
| 71 |
And I click on "Delete" "link" in the "Used category" "list_item"
|
80 |
And I click on "Delete" "button" in the "Delete" "dialogue"
|
| 72 |
And I should see "The category 'Used category' contains 1 questions"
|
81 |
And I should see "The category 'Used category' contains 1 questions"
|
| Línea 73... |
Línea 82... |
| 73 |
And I select "Default for C1" from the "Category" singleselect
|
82 |
And I select "Default for Qbank 1" from the "Category" singleselect
|
| 74 |
And I press "Save in category"
|
83 |
And I press "Save in category"
|
| 75 |
Then I should not see "Used category"
|
84 |
Then I should not see "Used category"
|
| 76 |
And I follow "Add category"
|
85 |
And I press "Add category"
|
| 77 |
And I should see "Default for C1 (1)"
|
86 |
And I should see "Default for Qbank 1 (1)"
|
| 78 |
|
87 |
|
| 79 |
@_file_upload
|
88 |
@_file_upload
|
| 80 |
Scenario: Multi answer questions with their child questions can be moved to another category when the current category is deleted
|
89 |
Scenario: Multi answer questions with their child questions can be moved to another category when the current category is deleted
|
| 81 |
When I am on the "Course 1" "core_question > course question import" page
|
90 |
When I am on the "Qbank 1" "core_question > question import" page
|
| - |
|
91 |
And I set the field "id_format_xml" to "1"
|
| - |
|
92 |
And I upload "question/format/xml/tests/fixtures/multianswer.xml" file to "Import" filemanager
|
| 82 |
And I set the field "id_format_xml" to "1"
|
93 |
And I press "id_submitbutton"
|
| 83 |
And I upload "question/format/xml/tests/fixtures/multianswer.xml" file to "Import" filemanager
|
94 |
And I press "Continue"
|
| 84 |
And I press "id_submitbutton"
|
95 |
And I am on the "Qbank 1" "core_question > question categories" page
|
| 85 |
And I press "Continue"
|
96 |
And I open the action menu in "Default for Test images in backup" "list_item"
|
| 86 |
And I am on the "Course 1" "core_question > course question categories" page
|
97 |
And I choose "Delete" in the open action menu
|
| 87 |
And I click on "Delete" "link" in the "Default for Test images in backup" "list_item"
|
98 |
And I click on "Delete" "button" in the ".modal-footer" "css_element"
|
| Línea 88... |
Línea 99... |
| 88 |
And I should see "The category 'Default for Test images in backup' contains 1 questions"
|
99 |
And I should see "The category 'Default for Test images in backup' contains 1 questions"
|
| 89 |
And I select "Used category" from the "Category" singleselect
|
100 |
And I select "Used category" from the "Category" singleselect
|
| 90 |
And I press "Save in category"
|
101 |
And I press "Save in category"
|
| 91 |
Then I should not see "Default for Test images in backup"
|
102 |
Then I should not see "Default for Test images in backup"
|
| 92 |
And I follow "Add category"
|
103 |
And I press "Add category"
|
| 93 |
And I should see "Used category (2)"
|
104 |
And I should see "Used category (2)"
|
| 94 |
|
105 |
|
| - |
|
106 |
Scenario: Filter questions by category and subcategories
|
| - |
|
107 |
When I am on the "Qbank 1" "core_question > question bank" page
|
| - |
|
108 |
And I apply question bank filter "Category" with value "Default for Qbank 1"
|
| - |
|
109 |
Then I should not see "Question 1"
|
| - |
|
110 |
When I set the field "Also show questions from subcategories" to "1"
|
| - |
|
111 |
And I click on "Apply filters" "button"
|
| - |
|
112 |
Then I should see "Question 1" in the "categoryquestions" "table"
|
| - |
|
113 |
When I reload the page
|
| - |
|
114 |
Then I should see "Question 1" in the "categoryquestions" "table"
|
| - |
|
115 |
And the field "Also show questions from subcategories" matches value "1"
|
| - |
|
116 |
And I am on the "Course 1" "core_question > course question bank" page
|
| - |
|
117 |
And the field "Also show questions from subcategories" matches value "1"
|
| - |
|
118 |
|
| - |
|
119 |
Scenario: Filter question by category and subcategories in Quiz question page
|
| - |
|
120 |
Given the following "activities" exist:
|
| - |
|
121 |
| activity | name | course | idnumber |
|
| - |
|
122 |
| quiz | Test quiz | C1 | quiz1 |
|
| - |
|
123 |
And I am on the "Test quiz" "mod_quiz > Edit" page
|
| - |
|
124 |
And I open the "last" add to quiz menu
|
| - |
|
125 |
And I follow "from question bank"
|
| - |
|
126 |
And I click on "Switch bank" "button"
|
| - |
|
127 |
And I click on "Qbank 1" "link" in the "Select question bank" "dialogue"
|
| - |
|
128 |
And I apply question bank filter "Category" with value "Default for Qbank 1"
|
| - |
|
129 |
When I set the field "Also show questions from subcategories" to "1"
|
| - |
|
130 |
And I click on "Apply filters" "button"
|
| - |
|
131 |
Then I should see "Question 1" in the "categoryquestions" "table"
|
| - |
|
132 |
And I set the field "Also show questions from subcategories" to "0"
|
| - |
|
133 |
And I click on "Apply filters" "button"
|
| - |
|
134 |
And I should not see "Question 1"
|
| - |
|
135 |
And I click on "Close" "button" in the "Add from the question bank at the end" "dialogue"
|
| - |
|
136 |
And I open the "last" add to quiz menu
|
| - |
|
137 |
And I follow "from question bank"
|
| - |
|
138 |
And the field "Also show questions from subcategories" matches value "0"
|
| - |
|
139 |
|
| - |
|
140 |
Scenario: Filter question by an invalid category should show validation error
|
| - |
|
141 |
When I am on the "Qbank 1" "core_question > question bank" page
|
| - |
|
142 |
And I click on "Default for Qbank 1" "text" in the ".form-autocomplete-selection" "css_element"
|
| - |
|
143 |
And I click on "Apply filters" "button"
|
| - |
|
144 |
Then the "Category" field validity check should return "false"
|
| - |
|
145 |
And the "Category" field validation message should contain "You must select a valid category"
|
| - |
|
146 |
|
| - |
|
147 |
Scenario: Correcting an invalid category should no longer show validation error
|
| - |
|
148 |
When I am on the "Qbank 1" "core_question > question bank" page
|