1 |
efrain |
1 |
@qbank @qbank_managecategories @javascript
|
|
|
2 |
Feature: A teacher can put questions in categories in the question bank
|
|
|
3 |
In order to organize my questions
|
|
|
4 |
As a teacher
|
|
|
5 |
I create and edit categories, move questions between them and filter question using category filter
|
|
|
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 "question categories" exist:
|
|
|
18 |
| contextlevel | reference | questioncategory | name |
|
|
|
19 |
| Course | C1 | Top | top |
|
|
|
20 |
| Course | C1 | top | Default for C1 |
|
|
|
21 |
| Course | C1 | Default for C1 | Subcategory |
|
|
|
22 |
| Course | C1 | Default for C1 | Another subcat |
|
|
|
23 |
| Course | C1 | top | Used category |
|
|
|
24 |
| Course | C1 | top | Default & testing |
|
|
|
25 |
And the following "questions" exist:
|
|
|
26 |
| questioncategory | qtype | name | questiontext |
|
|
|
27 |
| 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 |
And I log in as "teacher1"
|
|
|
30 |
And I am on "Course 1" course homepage
|
|
|
31 |
|
|
|
32 |
Scenario: A new question category can be created
|
|
|
33 |
When I am on the "Course 1" "core_question > course question categories" page
|
|
|
34 |
And I follow "Add category"
|
|
|
35 |
And I set the following fields to these values:
|
|
|
36 |
| Name | 'Test' & 'display' |
|
|
|
37 |
| Parent category | Default & testing |
|
|
|
38 |
| Category info | Created for testing category, HTML entity & its encoding |
|
|
|
39 |
| ID number | newcatidnumber |
|
|
|
40 |
And I press "submitbutton"
|
|
|
41 |
Then I should see "Default & testing"
|
|
|
42 |
And I should see "ID number"
|
|
|
43 |
And I should see "newcatidnumber"
|
|
|
44 |
And I should see "(0)"
|
|
|
45 |
And I should see "Created for testing category, HTML entity & its encoding" in the "'Test' & 'display'" "list_item"
|
|
|
46 |
And I follow "Add category"
|
|
|
47 |
And the "Parent category" select box should contain "'Test' & 'display' [newcatidnumber]"
|
|
|
48 |
|
|
|
49 |
Scenario: A question category can be edited
|
|
|
50 |
When I am on the "Course 1" "core_question > course question categories" page
|
|
|
51 |
# 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 |
| questioncategory | qtype | name | questiontext |
|
|
|
54 |
| Subcategory | essay | Test question for renaming category | Write about whatever you want |
|
|
|
55 |
And I click on "Edit this category" "link" in the "Subcategory" "list_item"
|
|
|
56 |
And the field "parent" matches value " Default for C1"
|
|
|
57 |
And I set the following fields to these values:
|
|
|
58 |
| Name | New name |
|
|
|
59 |
| Category info | I was edited |
|
|
|
60 |
And I press "Save changes"
|
|
|
61 |
Then I should see "New name"
|
|
|
62 |
And I should see "I was edited" in the "New name" "list_item"
|
|
|
63 |
|
|
|
64 |
Scenario: An empty question category can be deleted
|
|
|
65 |
When I am on the "Course 1" "core_question > course question categories" page
|
|
|
66 |
And I click on "Delete" "link" in the "Subcategory" "list_item"
|
|
|
67 |
Then I should not see "Subcategory"
|
|
|
68 |
|
|
|
69 |
Scenario: An non-empty question category can be deleted if you move the contents elsewhere
|
|
|
70 |
When I am on the "Course 1" "core_question > course question categories" page
|
|
|
71 |
And I click on "Delete" "link" in the "Used category" "list_item"
|
|
|
72 |
And I should see "The category 'Used category' contains 1 questions"
|
|
|
73 |
And I select "Default for C1" from the "Category" singleselect
|
|
|
74 |
And I press "Save in category"
|
|
|
75 |
Then I should not see "Used category"
|
|
|
76 |
And I follow "Add category"
|
|
|
77 |
And I should see "Default for C1 (1)"
|
|
|
78 |
|
|
|
79 |
@_file_upload
|
|
|
80 |
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
|
|
|
82 |
And I set the field "id_format_xml" to "1"
|
|
|
83 |
And I upload "question/format/xml/tests/fixtures/multianswer.xml" file to "Import" filemanager
|
|
|
84 |
And I press "id_submitbutton"
|
|
|
85 |
And I press "Continue"
|
|
|
86 |
And I am on the "Course 1" "core_question > course question categories" page
|
|
|
87 |
And I click on "Delete" "link" in the "Default for Test images in backup" "list_item"
|
|
|
88 |
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
|
|
|
90 |
And I press "Save in category"
|
|
|
91 |
Then I should not see "Default for Test images in backup"
|
|
|
92 |
And I follow "Add category"
|
|
|
93 |
And I should see "Used category (2)"
|
|
|
94 |
|
|
|
95 |
Scenario: Filter questions by category and subcategories
|
|
|
96 |
When I am on the "Course 1" "core_question > course question bank" page
|
|
|
97 |
And I apply question bank filter "Category" with value "Default for C1"
|
|
|
98 |
Then I should not see "Question 1"
|
|
|
99 |
When I set the field "Also show questions from subcategories" to "1"
|
|
|
100 |
And I click on "Apply filters" "button"
|
|
|
101 |
Then I should see "Question 1" in the "categoryquestions" "table"
|