Skip to content

Commit

Permalink
Merge branch 'MDL-74211-400' of https://github.com/lameze/moodle into…
Browse files Browse the repository at this point in the history
… MOODLE_400_STABLE
  • Loading branch information
junpataleta committed Aug 8, 2022
2 parents ee48012 + 2937e76 commit 4e0aa8a
Show file tree
Hide file tree
Showing 19 changed files with 43 additions and 91 deletions.
4 changes: 1 addition & 3 deletions mod/quiz/tests/behat/editing_add.feature
Expand Up @@ -99,9 +99,7 @@ Feature: Edit quiz page - adding things
in various categories and add them to the question bank.

# Create a couple of sub categories.
When I am on "Course 1" course homepage
And I navigate to "Question bank" in current page administration
And I select "Categories" from the "Question bank tertiary navigation" singleselect
When I am on the "Course 1" "core_question > course question categories" page
Then I should see "Add category"
And I follow "Add category"
Then I set the field "Parent category" to "Default for C1"
Expand Down
7 changes: 2 additions & 5 deletions mod/quiz/tests/behat/editing_add_from_question_bank.feature
Expand Up @@ -26,18 +26,15 @@ Feature: Adding questions to a quiz from the question bank
| Test questions | essay | question 02 name | teacher1 | Question 02 text | qidnum |

Scenario: The questions can be filtered by tag
Given I log in as "teacher1"
And I am on "Course 1" course homepage
When I navigate to "Question bank" in current page administration
And I choose "Edit question" action for "question 01 name" in the question bank
Given I am on the "question 01 name" "core_question > edit" page logged in as teacher1
And I set the following fields to these values:
| Tags | foo |
And I press "id_submitbutton"
And I choose "Edit question" action for "question 02 name" in the question bank
And I set the following fields to these values:
| Tags | bar |
And I press "id_submitbutton"
And I am on the "Quiz 1" "mod_quiz > Edit" page
When I am on the "Quiz 1" "mod_quiz > Edit" page
And I open the "last" add to quiz menu
And I follow "from question bank"
Then I should see "foo" in the "question 01 name" "table_row"
Expand Down
Expand Up @@ -27,8 +27,7 @@ Feature: A teacher can put questions in categories in the question bank
And I am on "Course 1" course homepage

Scenario: A new question category can be created
When I navigate to "Question bank" in current page administration
And I select "Categories" from the "Question bank tertiary navigation" singleselect
When I am on the "Course 1" "core_question > course question categories" page
And I follow "Add category"
And I set the following fields to these values:
| Name | New Category 1 |
Expand All @@ -45,8 +44,7 @@ Feature: A teacher can put questions in categories in the question bank
And "New Category 1 [newcatidnumber]" "option" should exist in the "Parent category" "select"

Scenario: A question category can be edited
When I navigate to "Question bank" in current page administration
And I select "Categories" from the "Question bank tertiary navigation" singleselect
When I am on the "Course 1" "core_question > course question categories" page
And I click on "Edit this category" "link" in the "Subcategory" "list_item"
And the field "parent" matches value "   Default for C1"
And I set the following fields to these values:
Expand All @@ -57,14 +55,12 @@ Feature: A teacher can put questions in categories in the question bank
And I should see "I was edited" in the "New name" "list_item"

Scenario: An empty question category can be deleted
When I navigate to "Question bank" in current page administration
And I select "Categories" from the "Question bank tertiary navigation" singleselect
When I am on the "Course 1" "core_question > course question categories" page
And I click on "Delete" "link" in the "Subcategory" "list_item"
Then I should not see "Subcategory"

Scenario: An non-empty question category can be deleted if you move the contents elsewhere
When I navigate to "Question bank" in current page administration
And I select "Categories" from the "Question bank tertiary navigation" singleselect
When I am on the "Course 1" "core_question > course question categories" page
And I click on "Delete" "link" in the "Used category" "list_item"
And I should see "The category 'Used category' contains 1 questions"
And I press "Save in category"
Expand All @@ -74,13 +70,12 @@ Feature: A teacher can put questions in categories in the question bank

@_file_upload
Scenario: Multi answer questions with their child questions can be moved to another category when the current category is deleted
When I navigate to "Question bank" in current page administration
And I select "Import" from the "Question bank tertiary navigation" singleselect
When I am on the "Course 1" "core_question > course question import" page
And I set the field "id_format_xml" to "1"
And I upload "question/format/xml/tests/fixtures/multianswer.xml" file to "Import" filemanager
And I press "id_submitbutton"
And I press "Continue"
And I select "Categories" from the "Question bank tertiary navigation" singleselect
And I am on the "Course 1" "core_question > course question categories" page
And I click on "Delete" "link" in the "Default for Test images in backup" "list_item"
And I should see "The category 'Default for Test images in backup' contains 1 questions"
And I select "Used category" from the "Category" singleselect
Expand Down
Expand Up @@ -23,8 +23,7 @@ Feature: A teacher can put questions with idnumbers in categories with idnumbers
| contextlevel | reference | questioncategory | name | idnumber |
| Course | C1 | Top | top | |
| Course | C1 | top | Used category | c1used |
And I navigate to "Question bank" in current page administration
And I select "Categories" from the "Question bank tertiary navigation" singleselect
And I am on the "Course 1" "core_question > course question categories" page
And I follow "Add category"
And I set the following fields to these values:
| Name | Sub used category |
Expand All @@ -48,8 +47,7 @@ Feature: A teacher can put questions with idnumbers in categories with idnumbers
| contextlevel | reference | questioncategory | name | idnumber |
| Course | C1 | Top | top | |
| Course | C1 | top | Used category | c1used |
And I navigate to "Question bank" in current page administration
And I select "Categories" from the "Question bank tertiary navigation" singleselect
And I am on the "Course 1" "core_question > course question categories" page
And I click on "Edit this category" "link" in the "Used category" "list_item"
And I press "Save changes"
Then I should not see "This ID number is already in use"
5 changes: 1 addition & 4 deletions question/format/aiken/tests/behat/aiken_export.feature
Expand Up @@ -21,12 +21,9 @@ Feature: Test exporting questions using Aiken format.
| questioncategory | qtype | name | template |
| Test questions | multichoice | Multi-choice-001 | two_of_four |
| Test questions | multichoice | Multi-choice-002 | one_of_four |
And I log in as "teacher1"
And I am on "Course 1" course homepage

Scenario: Aiken export
When I navigate to "Question bank" in current page administration
And I select "Export" from the "Question bank tertiary navigation" singleselect
When I am on the "Course 1" "core_question > course question export" page logged in as "teacher1"
And I set the field "id_format_aiken" to "1"
When I press "Export questions to file"
Then following "click here" should download between "68" and "70" bytes
Expand Down
7 changes: 2 additions & 5 deletions question/format/aiken/tests/behat/aiken_import.feature
Expand Up @@ -14,16 +14,13 @@ Feature: Test importing questions from Aiken format.
And the following "course enrolments" exist:
| user | course | role |
| teacher | C1 | editingteacher |
And I log in as "teacher"
And I am on "Course 1" course homepage

@javascript @_file_upload
Scenario: import some Aiken questions
When I navigate to "Question bank" in current page administration
And I select "Import" from the "Question bank tertiary navigation" singleselect
Given I am on the "Course 1" "core_question > course question import" page logged in as "teacher"
And I set the field "id_format_aiken" to "1"
And I upload "question/format/aiken/tests/fixtures/questions.aiken.txt" file to "Import" filemanager
And I press "id_submitbutton"
When I press "id_submitbutton"
Then I should see "Parsing questions from import file."
And I should see "Importing 2 questions from file"
And I should see "The Moodle project was started by:"
Expand Down
15 changes: 4 additions & 11 deletions question/format/gift/tests/behat/import_export.feature
Expand Up @@ -14,14 +14,11 @@ Feature: Test importing questions from GIFT format.
And the following "course enrolments" exist:
| user | course | role |
| teacher | C1 | editingteacher |
And I log in as "teacher"
And I am on "Course 1" course homepage
And I am on the "Course 1" "core_question > course question import" page logged in as "teacher"

@javascript @_file_upload
Scenario: import some GIFT questions
When I navigate to "Question bank" in current page administration
And I select "Import" from the "Question bank tertiary navigation" singleselect
And I set the field "id_format_gift" to "1"
When I set the field "id_format_gift" to "1"
And I upload "question/format/gift/tests/fixtures/questions.gift.txt" file to "Import" filemanager
And I press "id_submitbutton"
Then I should see "Parsing questions from import file."
Expand All @@ -40,9 +37,7 @@ Feature: Test importing questions from GIFT format.

@javascript @_file_upload
Scenario: import a GIFT file which specifies the category
When I navigate to "Question bank" in current page administration
And I select "Import" from the "Question bank tertiary navigation" singleselect
And I set the field "id_format_gift" to "1"
When I set the field "id_format_gift" to "1"
And I upload "question/format/gift/tests/fixtures/questions_in_category.gift.txt" file to "Import" filemanager
And I press "id_submitbutton"
Then I should see "Parsing questions from import file."
Expand All @@ -53,9 +48,7 @@ Feature: Test importing questions from GIFT format.

@javascript @_file_upload
Scenario: import some GIFT questions with unsupported encoding
When I navigate to "Question bank" in current page administration
And I select "Import" from the "Question bank tertiary navigation" singleselect
And I set the field "id_format_gift" to "1"
When I set the field "id_format_gift" to "1"
And I upload "question/format/gift/tests/fixtures/questions_encoding_windows-1252.gift.txt" file to "Import" filemanager
And I press "id_submitbutton"
Then I should see "The file you selected does not use UTF-8 character encoding. GIFT format files must use UTF-8."
20 changes: 6 additions & 14 deletions question/format/xml/tests/behat/import_export.feature
Expand Up @@ -14,13 +14,10 @@ Feature: Test importing questions from Moodle XML format.
And the following "course enrolments" exist:
| user | course | role |
| teacher | C1 | editingteacher |
And I log in as "teacher"
And I am on "Course 1" course homepage

@javascript @_file_upload
Scenario: import some true/false questions from Moodle XML format
When I navigate to "Question bank" in current page administration
And I select "Import" from the "Question bank tertiary navigation" singleselect
When I am on the "Course 1" "core_question > course question import" page logged in as "teacher"
And I set the field "id_format_xml" to "1"
And I upload "question/format/xml/tests/fixtures/truefalse.xml" file to "Import" filemanager
And I press "id_submitbutton"
Expand All @@ -33,18 +30,15 @@ Feature: Test importing questions from Moodle XML format.
Then I should see "Moodle acronym (True)"

# Now export again.
And I am on "Course 1" course homepage
When I navigate to "Question bank" in current page administration
And I select "Export" from the "Question bank tertiary navigation" singleselect
When I am on the "Course 1" "core_question > course question export" page logged in as "teacher"
And I set the field "id_format_xml" to "1"
And I set the field "Export category" to "TrueFalse"
And I press "Export questions to file"
And following "click here" should download between "57100" and "58150" bytes
Then following "click here" should download between "57100" and "58150" bytes

@javascript @_file_upload
Scenario: import some multiple choice questions from Moodle XML format
When I navigate to "Question bank" in current page administration
And I select "Import" from the "Question bank tertiary navigation" singleselect
When I am on the "Course 1" "core_question > course question import" page logged in as "teacher"
And I set the field "id_format_xml" to "1"
And I upload "question/format/xml/tests/fixtures/multichoice.xml" file to "Import" filemanager
And I press "id_submitbutton"
Expand All @@ -56,8 +50,7 @@ Feature: Test importing questions from Moodle XML format.

@javascript @_file_upload
Scenario: import some multi-answer questions from Moodle XML format
When I navigate to "Question bank" in current page administration
And I select "Import" from the "Question bank tertiary navigation" singleselect
When I am on the "Course 1" "core_question > course question import" page logged in as "teacher"
And I set the field "id_format_xml" to "1"
And I upload "question/format/xml/tests/fixtures/multianswer.xml" file to "Import" filemanager
And I press "id_submitbutton"
Expand All @@ -69,8 +62,7 @@ Feature: Test importing questions from Moodle XML format.

@javascript @_file_upload
Scenario: import some questions with legacy-style images from Moodle XML format
When I navigate to "Question bank" in current page administration
And I select "Import" from the "Question bank tertiary navigation" singleselect
When I am on the "Course 1" "core_question > course question import" page logged in as "teacher"
And I set the field "id_format_xml" to "1"
And I upload "question/format/xml/tests/fixtures/sample_questions_with_old_image_tag.xml" file to "Import" filemanager
And I press "id_submitbutton"
Expand Down
4 changes: 4 additions & 0 deletions question/tests/behat/behat_core_question.php
Expand Up @@ -71,6 +71,10 @@ protected function resolve_page_instance_url(string $type, string $identifier):
return new moodle_url('/question/edit.php',
['courseid' => $this->get_course_id($identifier)]);

case 'course question categories':
return new moodle_url('/question/bank/managecategories/category.php',
['courseid' => $this->get_course_id($identifier)]);

case 'course question import':
return new moodle_url('/question/bank/importquestions/import.php',
['courseid' => $this->get_course_id($identifier)]);
Expand Down
7 changes: 2 additions & 5 deletions question/tests/behat/delete_questions.feature
Expand Up @@ -20,9 +20,7 @@ Feature: A teacher can delete questions in the question bank
And the following "questions" exist:
| questioncategory | qtype | name | questiontext |
| Test questions | essay | Test question to be deleted | Write about whatever you want |
And I log in as "teacher1"
And I am on "Course 1" course homepage
And I navigate to "Question bank" in current page administration
And I am on the "Course 1" "core_question > course question bank" page logged in as "teacher1"

@javascript
Scenario: A question not used anywhere can really be deleted
Expand Down Expand Up @@ -52,8 +50,7 @@ Feature: A teacher can delete questions in the question bank
And quiz "Test quiz" contains the following questions:
| question | page | requireprevious |
| Test used question to be deleted | 1 | 0 |
When I am on "Course 1" course homepage
And I navigate to "Question bank" in current page administration
When I am on the "Course 1" "core_question > course question bank" page
And I choose "Delete" action for "Test used question to be deleted" in the question bank
And I press "Delete"
Then I should not see "Test used question to be deleted"
Expand Down
4 changes: 1 addition & 3 deletions question/tests/behat/duplicate_questions.feature
Expand Up @@ -20,9 +20,7 @@ Feature: A teacher can duplicate questions in the question bank
And the following "questions" exist:
| questioncategory | qtype | name | questiontext | idnumber |
| Test questions | essay | Test question to be copied | Write about whatever you want | qid |
And I log in as "teacher"
And I am on "Course 1" course homepage
And I navigate to "Question bank" in current page administration
And I am on the "Course 1" "core_question > course question bank" page logged in as "teacher"

Scenario: Duplicating a previously created question
When I choose "Duplicate" action for "Test question to be copied" in the question bank
Expand Down
4 changes: 1 addition & 3 deletions question/tests/behat/edit_question_tags.feature
Expand Up @@ -20,9 +20,7 @@ Feature: A teacher can manage tags on questions in the question bank
And the following "questions" exist:
| questioncategory | qtype | name | questiontext |
| Test questions | essay | Test question to be tagged | Write about whatever you want |
And I log in as "teacher1"
And I am on "Course 1" course homepage
And I navigate to "Question bank" in current page administration
And I am on the "Course 1" "core_question > course question bank" page logged in as "teacher1"

@javascript
Scenario: Manage tags on a question
Expand Down
1 change: 1 addition & 0 deletions question/tests/behat/edit_questions.feature
Expand Up @@ -20,6 +20,7 @@ Feature: A teacher can edit questions in the question bank
And the following "questions" exist:
| questioncategory | qtype | name | questiontext |
| Test questions | essay | Test question to be edited | Write about whatever you want |
And I am on the "Course 1" "core_question > course question bank" page logged in as "teacher1"

Scenario: Edit a previously created question
When I am on the "Test question to be edited" "core_question > edit" page logged in as "teacher1"
Expand Down
4 changes: 1 addition & 3 deletions question/tests/behat/edit_questions_standard_tags.feature
Expand Up @@ -20,9 +20,7 @@ Feature: The questions can be tagged
| bar | 1 |

Scenario: The tags autocomplete should include standard tags
When I log in as "teacher1"
And I am on "Course 1" course homepage
And I navigate to "Question bank" in current page administration
When I am on the "Course 1" "core_question > course question bank" page logged in as "teacher1"
And I press "Create a new question ..."
And I set the field "item_qtype_truefalse" to "1"
And I click on "Add" "button" in the "Choose a question type to add" "dialogue"
Expand Down
7 changes: 2 additions & 5 deletions question/tests/behat/filter_questions_by_tag.feature
Expand Up @@ -21,14 +21,11 @@ Feature: The questions in the question bank can be filtered by tags
| questioncategory | qtype | name | user | questiontext |
| Test questions | essay | question 1 name | admin | Question 1 text |
| Test questions | essay | question 2 name | teacher1 | Question 2 text |
And I log in as "teacher1"
And I am on "Course 1" course homepage
And I navigate to "Question bank" in current page administration
And I choose "Edit question" action for "question 1 name" in the question bank
And I am on the "question 1 name" "core_question > edit" page logged in as "teacher1"
And I set the following fields to these values:
| Tags | foo |
And I press "id_submitbutton"
And I choose "Edit question" action for "question 2 name" in the question bank
And I am on the "question 2 name" "core_question > edit" page
And I set the following fields to these values:
| Tags | bar |
And I press "id_submitbutton"
Expand Down
2 changes: 1 addition & 1 deletion question/tests/behat/question_categories.feature
Expand Up @@ -28,7 +28,7 @@ Feature: A teacher can move questions between categories in the question bank

@javascript
Scenario: Move a question between categories via the question page
When I navigate to "Question bank" in current page administration
When I am on the "Course 1" "core_question > course question bank" page logged in as "teacher1"
And I set the field "Select a category" to "Used category"
And I click on "Test question to be moved" "checkbox" in the "Test question to be moved" "table_row"
And I click on "With selected" "button"
Expand Down

0 comments on commit 4e0aa8a

Please sign in to comment.