Proyectos de Subversion Moodle

Rev

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

Rev Autor Línea Nro. Línea
1441 ariadna 1
@qbank @qbank_managecategories @question_categories @javascript
1 efrain 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:
1441 ariadna 9
      | username | firstname | lastname | email                |
10
      | teacher1 | Teacher   | 1        | teacher1@example.com |
1 efrain 11
    And the following "courses" exist:
12
      | fullname | shortname | format |
1441 ariadna 13
      | Course 1 | C1        | weeks  |
1 efrain 14
    And the following "course enrolments" exist:
15
      | user | course | role |
16
      | teacher1 | C1 | editingteacher |
1441 ariadna 17
    And the following "activities" exist:
18
      | activity | name           | course | idnumber |
19
      | qbank    | Qbank 1        | C1     | qbank1   |
1 efrain 20
    And the following "question categories" exist:
1441 ariadna 21
      | contextlevel    | reference | questioncategory    | name                        |
22
      | Activity module | qbank1    | Default for Qbank 1 | Subcategory & < > " ' &amp; |
23
      | Activity module | qbank1    | Default for Qbank 1 | Another subcat              |
24
      | Activity module | qbank1    | top                 | Used category               |
25
      | Activity module | qbank1    | top                 | Default & testing           |
1 efrain 26
    And the following "questions" exist:
27
      | questioncategory | qtype | name                      | questiontext                  |
28
      | Used category    | essay | Test question to be moved | Write about whatever you want |
29
      | Another subcat  | essay | Question 1                | Write about whatever you want |
30
    And I log in as "teacher1"
31
 
32
  Scenario: A new question category can be created
1441 ariadna 33
    When I am on the "Qbank 1" "core_question > question categories" page
34
    And I press "Add category"
1 efrain 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                                           |
1441 ariadna 40
    And I click on "Add category" "button" in the "Add category" "dialogue"
1 efrain 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)"
1441 ariadna 45
    And I click on "Show descriptions" "checkbox"
1 efrain 46
    And I should see "Created for testing category, HTML entity & its encoding" in the "'Test' & 'display'" "list_item"
1441 ariadna 47
    And I press "Add category"
1 efrain 48
    And the "Parent category" select box should contain "'Test' & 'display' [newcatidnumber]"
49
 
50
  Scenario: A question category can be edited
1441 ariadna 51
    When I am on the "Qbank 1" "core_question > question categories" page
1 efrain 52
    # There have been bugs which only happened if a question category was not empty, so add a question.
53
    And the following "questions" exist:
1441 ariadna 54
      | questioncategory            | qtype | name                                | questiontext                  |
55
      | Subcategory & < > " ' &amp; | essay | Test question for renaming category | Write about whatever you want |
56
    And I open the action menu in "Subcategory & < > \" ' &amp;" "list_item"
57
    And I choose "Edit settings" in the open action menu
58
    And the field "parent" matches value "&nbsp;&nbsp;&nbsp;Default for Qbank 1"
1 efrain 59
    And I set the following fields to these values:
60
      | Name            | New name     |
61
      | Category info   | I was edited |
62
    And I press "Save changes"
63
    Then I should see "New name"
1441 ariadna 64
    And I click on "Show descriptions" "checkbox"
65
    And I should see "I was edited"
1 efrain 66
 
67
  Scenario: An empty question category can be deleted
1441 ariadna 68
    When I am on the "Qbank 1" "core_question > question categories" page
69
    And I should see "Subcategory & < > \" ' &amp;"
70
    And the "data-bs-original-title" attribute of "span.qbank_managecategories-newchild.dropready" "css_element" should contain "As new child of Subcategory & < > \" ' &amp;"
71
    And I open the action menu in "Subcategory" "list_item"
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 & < > \" ' &amp;"
1 efrain 75
 
76
  Scenario: An non-empty question category can be deleted if you move the contents elsewhere
1441 ariadna 77
    When I am on the "Qbank 1" "core_question > question categories" page
78
    And I open the action menu in "Used category" "list_item"
79
    And I choose "Delete" in the open action menu
80
    And I click on "Delete" "button" in the "Delete" "dialogue"
1 efrain 81
    And I should see "The category 'Used category' contains 1 questions"
1441 ariadna 82
    And I select "Default for Qbank 1" from the "Category" singleselect
1 efrain 83
    And I press "Save in category"
84
    Then I should not see "Used category"
1441 ariadna 85
    And I press "Add category"
86
    And I should see "Default for Qbank 1 (1)"
1 efrain 87
 
88
  @_file_upload
89
  Scenario: Multi answer questions with their child questions can be moved to another category when the current category is deleted
1441 ariadna 90
    When I am on the "Qbank 1" "core_question > question import" page
1 efrain 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
93
    And I press "id_submitbutton"
94
    And I press "Continue"
1441 ariadna 95
    And I am on the "Qbank 1" "core_question > question categories" page
96
    And I open the action menu in "Default for Test images in backup" "list_item"
97
    And I choose "Delete" in the open action menu
98
    And I click on "Delete" "button" in the ".modal-footer" "css_element"
1 efrain 99
    And I should see "The category 'Default for Test images in backup' contains 1 questions"
100
    And I select "Used category" from the "Category" singleselect
101
    And I press "Save in category"
102
    Then I should not see "Default for Test images in backup"
1441 ariadna 103
    And I press "Add category"
1 efrain 104
    And I should see "Used category (2)"
105
 
106
  Scenario: Filter questions by category and subcategories
1441 ariadna 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"
1 efrain 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"
1441 ariadna 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
149
    # First try to submit with a blank category.
150
    And I click on "Default for Qbank 1" "text" in the ".form-autocomplete-selection" "css_element"
151
    And I click on "Apply filters" "button"
152
    # Then apply a correct category.
153
    And I apply question bank filter "Category" with value "Used category"
154
    Then the "Category" field validity check should return "true"
155
    And I should see "Test question to be moved"