From 9c14b28d0bdb3afa24d22f765e8fef60ba26e6ff Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Wed, 2 Oct 2019 15:58:04 +0100 Subject: [PATCH] MDL-66821 question behat: new step for acting on questions in the bank There is a proposed change MDL-66816 which will change the question bank UI. This will break any Behat tests which uses low-level steps like When I click on "Duplicate" "link" in the "Test question" "table_row" to perform an action on a question in the question bank. This commit introduces a new step: When I choose "Duplicate" action for "Test question" in the question bank This commit also converts all core Behat tests to use the new step. --- .../editing_add_from_question_bank.feature | 4 ++-- mod/quiz/tests/behat/editing_add_random.feature | 4 ++-- question/tests/behat/behat_question.php | 17 +++++++++++++++++ question/tests/behat/copy_questions.feature | 6 +++--- question/tests/behat/delete_questions.feature | 6 +++--- question/tests/behat/edit_questions.feature | 4 ++-- .../tests/behat/filter_questions_by_tag.feature | 6 +++--- question/tests/behat/preview_question.feature | 2 +- .../tests/behat/question_categories.feature | 2 +- .../behat/question_categories_idnumber.feature | 12 ++++++------ .../tests/behat/backup_and_restore.feature | 2 +- .../type/ddimageortext/tests/behat/edit.feature | 2 +- .../ddimageortext/tests/behat/preview.feature | 4 ++-- .../tests/behat/backup_and_restore.feature | 2 +- question/type/ddmarker/tests/behat/edit.feature | 2 +- .../type/ddmarker/tests/behat/preview.feature | 4 ++-- .../tests/behat/backup_and_restore.feature | 2 +- question/type/ddwtos/tests/behat/edit.feature | 2 +- .../type/ddwtos/tests/behat/preview.feature | 8 ++++---- .../tests/behat/backup_and_restore.feature | 2 +- .../type/description/tests/behat/edit.feature | 2 +- .../description/tests/behat/preview.feature | 2 +- .../tests/behat/backup_and_restore.feature | 6 +++--- question/type/essay/tests/behat/edit.feature | 2 +- question/type/essay/tests/behat/preview.feature | 6 +++--- .../gapselect/tests/behat/basic_test.feature | 4 ++-- .../tests/behat/backup_and_restore.feature | 2 +- question/type/match/tests/behat/edit.feature | 6 +++--- question/type/match/tests/behat/preview.feature | 12 ++++++------ .../tests/behat/backup_and_restore.feature | 2 +- .../type/multichoice/tests/behat/edit.feature | 4 ++-- .../multichoice/tests/behat/preview.feature | 8 ++++---- .../tests/behat/backup_and_restore.feature | 2 +- .../type/numerical/tests/behat/edit.feature | 4 ++-- .../type/numerical/tests/behat/preview.feature | 2 +- .../tests/behat/backup_and_restore.feature | 2 +- .../type/shortanswer/tests/behat/edit.feature | 6 +++--- .../shortanswer/tests/behat/preview.feature | 6 +++--- .../tests/behat/backup_and_restore.feature | 2 +- .../type/truefalse/tests/behat/edit.feature | 2 +- .../type/truefalse/tests/behat/preview.feature | 4 ++-- question/type/upgrade.txt | 15 +++++++++++++++ 42 files changed, 113 insertions(+), 81 deletions(-) diff --git a/mod/quiz/tests/behat/editing_add_from_question_bank.feature b/mod/quiz/tests/behat/editing_add_from_question_bank.feature index 2e8708e82c5..619bf30cf45 100644 --- a/mod/quiz/tests/behat/editing_add_from_question_bank.feature +++ b/mod/quiz/tests/behat/editing_add_from_question_bank.feature @@ -29,11 +29,11 @@ Feature: Adding questions to a quiz from the question bank Given I log in as "teacher1" And I am on "Course 1" course homepage When I navigate to "Question bank > Questions" in current page administration - And I click on "Edit" "link" in the "question 01 name" "table_row" + And I choose "Edit question" action for "question 01 name" in the question bank And I set the following fields to these values: | Tags | foo | And I press "id_submitbutton" - And I click on "Edit" "link" in the "question 02 name" "table_row" + 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" diff --git a/mod/quiz/tests/behat/editing_add_random.feature b/mod/quiz/tests/behat/editing_add_random.feature index 3e3a53b9384..ca91594e929 100644 --- a/mod/quiz/tests/behat/editing_add_random.feature +++ b/mod/quiz/tests/behat/editing_add_random.feature @@ -30,11 +30,11 @@ Feature: Adding random questions to a quiz based on category and tags Given I log in as "teacher1" And I am on "Course 1" course homepage When I navigate to "Question bank > Questions" in current page administration - And I click on "Edit" "link" in the "question 1 name" "table_row" + And I choose "Edit question" action for "question 1 name" in the question bank And I set the following fields to these values: | Tags | foo | And I press "id_submitbutton" - And I click on "Manage tags" "link" in the "question 2 name" "table_row" + And I choose "Manage tags" action for "question 2 name" in the question bank And I set the following fields in the "Question tags" "dialogue" to these values: | Tags | bar | And I press "Save changes" diff --git a/question/tests/behat/behat_question.php b/question/tests/behat/behat_question.php index e47f30a1dbf..3a0d7758728 100644 --- a/question/tests/behat/behat_question.php +++ b/question/tests/behat/behat_question.php @@ -86,4 +86,21 @@ class behat_question extends behat_question_base { $xpath = $questionxpath . "/div[@class='info']/div[@class='state' and contains(., {$stateliteral})]"; $this->find('xpath', $xpath, $exception); } + + /** + * Activates a particular action on a particular question in the question bank UI. + * + * @When I choose :action action for :questionname in the question bank + * @param string $action the label for the action you want to activate. + * @param string $questionname the question name. + */ + public function i_action_the_question($action, $questionname) { + if ($action == 'Edit question') { + $action = 'Edit'; + } + + // Click the action from the menu. + $this->execute("behat_general::i_click_on_in_the", + [$action, 'link', $questionname, 'table_row']); + } } diff --git a/question/tests/behat/copy_questions.feature b/question/tests/behat/copy_questions.feature index 612e4fb576f..ccc6d2719ba 100644 --- a/question/tests/behat/copy_questions.feature +++ b/question/tests/behat/copy_questions.feature @@ -26,7 +26,7 @@ Feature: A teacher can duplicate questions in the question bank @javascript Scenario: Duplicating a previously created question - When I click on "Duplicate" "link" in the "Test question to be copied" "table_row" + When I choose "Duplicate" action for "Test question to be copied" in the question bank And I set the following fields to these values: | Question name | Duplicated question name | | Question text | Write a lot about duplicating questions | @@ -38,12 +38,12 @@ Feature: A teacher can duplicate questions in the question bank @javascript Scenario: Duplicated questions automatically get a new name suggested - When I click on "Duplicate" "link" in the "Test question to be copied" "table_row" + When I choose "Duplicate" action for "Test question to be copied" in the question bank Then the field "Question name" matches value "Test question to be copied (copy)" @javascript Scenario: The duplicate operation can be cancelled - When I click on "Duplicate" "link" in the "Test question to be copied" "table_row" + When I choose "Duplicate" action for "Test question to be copied" in the question bank And I press "Cancel" Then I should see "Test question to be copied" And the field "Select a category" matches value "   Test questions (1)" diff --git a/question/tests/behat/delete_questions.feature b/question/tests/behat/delete_questions.feature index c8d3b5f7204..44354127ebf 100644 --- a/question/tests/behat/delete_questions.feature +++ b/question/tests/behat/delete_questions.feature @@ -26,14 +26,14 @@ Feature: A teacher can delete questions in the question bank @javascript Scenario: A question not used anywhere can really be deleted - When I click on "Delete" "link" in the "Test question to be deleted" "table_row" + When I choose "Delete" action for "Test question to be deleted" in the question bank And I press "Delete" And I click on "Also show old questions" "checkbox" Then I should not see "Test question to be deleted" @javascript Scenario: Deleting a question can be cancelled - When I click on "Delete" "link" in the "Test question to be deleted" "table_row" + When I choose "Delete" action for "Test question to be deleted" in the question bank And I press "Cancel" Then I should see "Test question to be deleted" @@ -47,7 +47,7 @@ Feature: A teacher can delete questions in the question bank | Question text | Write about whatever you want | And I am on "Course 1" course homepage And I navigate to "Question bank > Questions" in current page administration - When I click on "Delete" "link" in the "Test used question to be deleted" "table_row" + When 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" And I click on "Also show old questions" "checkbox" diff --git a/question/tests/behat/edit_questions.feature b/question/tests/behat/edit_questions.feature index 6adc676255b..183d0c10e07 100644 --- a/question/tests/behat/edit_questions.feature +++ b/question/tests/behat/edit_questions.feature @@ -26,7 +26,7 @@ Feature: A teacher can edit questions in the question bank @javascript Scenario: Edit a previously created question - When I click on "Edit" "link" in the "Test question to be edited" "table_row" + When I choose "Edit question" action for "Test question to be edited" in the question bank And I set the following fields to these values: | Question name | Edited question name | | Question text | Write a lot about what you want | @@ -38,7 +38,7 @@ Feature: A teacher can edit questions in the question bank @javascript Scenario: Editing a question can be cancelled - When I click on "Edit" "link" in the "Test question to be edited" "table_row" + When I choose "Edit question" action for "Test question to be edited" in the question bank And I set the field "Question name" to "Edited question name" And I press "Cancel" Then I should see "Test question to be edited" diff --git a/question/tests/behat/filter_questions_by_tag.feature b/question/tests/behat/filter_questions_by_tag.feature index 4f0be1fb97b..acbefe69762 100644 --- a/question/tests/behat/filter_questions_by_tag.feature +++ b/question/tests/behat/filter_questions_by_tag.feature @@ -18,17 +18,17 @@ Feature: The questions in the question bank can be filtered by tags | contextlevel | reference | name | | Course | C1 | Test questions | And the following "questions" exist: - | questioncategory | qtype | name | user | questiontext | + | 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 > Questions" in current page administration - And I click on "Edit" "link" in the "question 1 name" "table_row" + And I choose "Edit question" action for "question 1 name" in the question bank And I set the following fields to these values: | Tags | foo | And I press "id_submitbutton" - And I click on "Edit" "link" in the "question 2 name" "table_row" + And I choose "Edit question" action for "question 2 name" in the question bank And I set the following fields to these values: | Tags | bar | And I press "id_submitbutton" diff --git a/question/tests/behat/preview_question.feature b/question/tests/behat/preview_question.feature index 5cacce52953..cba500906f5 100644 --- a/question/tests/behat/preview_question.feature +++ b/question/tests/behat/preview_question.feature @@ -23,7 +23,7 @@ Feature: A teacher can preview questions in the question bank And I log in as "teacher1" And I am on "Course 1" course homepage And I navigate to "Question bank > Questions" in current page administration - When I click on "Preview" "link" in the "Test question to be previewed" "table_row" + When I choose "Preview" action for "Test question to be previewed" in the question bank And I switch to "questionpreview" window @javascript @_switch_window diff --git a/question/tests/behat/question_categories.feature b/question/tests/behat/question_categories.feature index b0786e07c7c..fbcba7531f1 100644 --- a/question/tests/behat/question_categories.feature +++ b/question/tests/behat/question_categories.feature @@ -78,7 +78,7 @@ Feature: A teacher can put questions in categories in the question bank Scenario: Move a question between categories via the question settings page When I navigate to "Question bank > Questions" in current page administration And I set the field "Select a category" to "Used category" - And I click on "Edit" "link" in the "Test question to be moved" "table_row" + And I choose "Edit question" action for "Test question to be moved" in the question bank And I click on "Use this category" "checkbox" And I set the field "Save in category" to "Subcategory" And I press "id_submitbutton" diff --git a/question/tests/behat/question_categories_idnumber.feature b/question/tests/behat/question_categories_idnumber.feature index 021fc14a288..5665a021ffe 100644 --- a/question/tests/behat/question_categories_idnumber.feature +++ b/question/tests/behat/question_categories_idnumber.feature @@ -58,7 +58,7 @@ Feature: A teacher can put questions with idnumbers in categories with idnumbers | Used category | essay | Test question 1 | Write about whatever you want | q1 | | Used category | essay | Test question 2 | Write about whatever you want | q2 | And I navigate to "Question bank > Questions" in current page administration - And I click on "Edit" "link" in the "Test question 2" "table_row" + And I choose "Edit question" action for "Test question 2" in the question bank And I set the field "ID number" to "q1" And I press "submitbutton" # This is the standard form warning reminding the user that the idnumber needs to be unique for a category. @@ -73,11 +73,11 @@ Feature: A teacher can put questions with idnumbers in categories with idnumbers | questioncategory | qtype | name | questiontext | idnumber | | Used category | essay | Test question 1 | Write about whatever you want | q1 | And I navigate to "Question bank > Questions" in current page administration - And I click on "Edit" "link" in the "Test question 1" "table_row" + And I choose "Edit question" action for "Test question 1" in the question bank And I press "Save changes" Then I should not see "This ID number is already in use" - Scenario: Question idnumber conficts found when saving to a different category. + Scenario: Question idnumber conflicts found when saving to a different category. When the following "question categories" exist: | contextlevel | reference | questioncategory | name | | Course | C1 | Top | top | @@ -88,7 +88,7 @@ Feature: A teacher can put questions with idnumbers in categories with idnumbers | Category 1 | essay | Question to edit | Write about whatever you want | q1 | | Category 2 | essay | Other question | Write about whatever you want | q2 | And I navigate to "Question bank > Questions" in current page administration - And I click on "Edit" "link" in the "Question to edit" "table_row" + And I choose "Edit question" action for "Question to edit" in the question bank And I set the following fields to these values: | Use this category | 0 | | ID number | q2 | @@ -109,7 +109,7 @@ Feature: A teacher can put questions with idnumbers in categories with idnumbers | Used category | essay | Test question 2 | Write about whatever you want | q2 | | Subcategory | essay | Test question 3 | Write about whatever you want | q3 | When I navigate to "Question bank > Questions" in current page administration - And I click on "Edit" "link" in the "Test question 3" "table_row" + And I choose "Edit question" action for "Test question 3" in the question bank # The q1 idnumber is allowed for this question while it is in the Subcategory. And I set the field "ID number" to "q1" And I press "submitbutton" @@ -117,6 +117,6 @@ Feature: A teacher can put questions with idnumbers in categories with idnumbers And I click on "Test question 3" "checkbox" in the "Test question 3" "table_row" And I set the field "Question category" to "Used category" And I press "Move to >>" - And I click on "Edit" "link" in the "Test question 3" "table_row" + And I choose "Edit question" action for "Test question 3" in the question bank # The question just moved into this category needs to have a unique idnumber, so a number is appended. Then the field "ID number" matches value "q1_1" diff --git a/question/type/ddimageortext/tests/behat/backup_and_restore.feature b/question/type/ddimageortext/tests/behat/backup_and_restore.feature index b81f46c1a15..653d407e32e 100644 --- a/question/type/ddimageortext/tests/behat/backup_and_restore.feature +++ b/question/type/ddimageortext/tests/behat/backup_and_restore.feature @@ -29,7 +29,7 @@ Feature: Test duplicating a quiz containing a drag and drop onto image question And I restore "test_backup.mbz" backup into a new course using this options: | Schema | Course name | Course 2 | And I navigate to "Question bank" in current page administration - And I click on "Edit" "link" in the "Drag onto image" "table_row" + And I choose "Edit question" action for "Drag onto image" in the question bank Then the following fields match these values: | Question name | Drag onto image | | General feedback |

More information about the major features of the Earth's surface can be found in Block 3, Section 6.2.

| diff --git a/question/type/ddimageortext/tests/behat/edit.feature b/question/type/ddimageortext/tests/behat/edit.feature index 19c87f9d59a..7fecbcfe477 100644 --- a/question/type/ddimageortext/tests/behat/edit.feature +++ b/question/type/ddimageortext/tests/behat/edit.feature @@ -26,7 +26,7 @@ Feature: Test editing a drag and drop onto image questions @javascript Scenario: Edit a drag and drop onto image question - When I click on "Edit" "link" in the "Drag onto image" "table_row" + And I choose "Edit question" action for "Drag onto image" in the question bank And I set the following fields to these values: | Question name | Edited question name | And I press "id_submitbutton" diff --git a/question/type/ddimageortext/tests/behat/preview.feature b/question/type/ddimageortext/tests/behat/preview.feature index eac31a37f46..4a286418840 100644 --- a/question/type/ddimageortext/tests/behat/preview.feature +++ b/question/type/ddimageortext/tests/behat/preview.feature @@ -26,7 +26,7 @@ Feature: Preview a drag-drop onto image question @javascript @_bug_phantomjs Scenario: Preview a question using the mouse. - When I click on "Preview" "link" in the "Drag onto image" "table_row" + When I choose "Preview" action for "Drag onto image" in the question bank And I switch to "questionpreview" window # Increase window size and wait 2 seconds to ensure elements are placed properly by js. # Keep window large else drag will scroll the window to find element. @@ -48,7 +48,7 @@ Feature: Preview a drag-drop onto image question @javascript Scenario: Preview a question using the keyboard. - When I click on "Preview" "link" in the "Drag onto image" "table_row" + When I choose "Preview" action for "Drag onto image" in the question bank And I switch to "questionpreview" window # Increase window size and wait 2 seconds to ensure elements are placed properly by js. And I change window size to "medium" diff --git a/question/type/ddmarker/tests/behat/backup_and_restore.feature b/question/type/ddmarker/tests/behat/backup_and_restore.feature index ec744984405..5fde8360817 100644 --- a/question/type/ddmarker/tests/behat/backup_and_restore.feature +++ b/question/type/ddmarker/tests/behat/backup_and_restore.feature @@ -29,7 +29,7 @@ Feature: Test duplicating a quiz containing a drag and drop markers question And I restore "test_backup.mbz" backup into a new course using this options: | Schema | Course name | Course 2 | And I navigate to "Question bank" in current page administration - And I click on "Edit" "link" in the "Drag markers" "table_row" + And I choose "Edit question" action for "Drag markers" in the question bank Then the following fields match these values: | Question name | Drag markers | | Question text | Please place the markers on the map of Milton Keynes and be aware that there is more than one railway station. | diff --git a/question/type/ddmarker/tests/behat/edit.feature b/question/type/ddmarker/tests/behat/edit.feature index c3d761f71fc..9e918177c36 100644 --- a/question/type/ddmarker/tests/behat/edit.feature +++ b/question/type/ddmarker/tests/behat/edit.feature @@ -26,7 +26,7 @@ Feature: Test editing a drag and drop markers questions @javascript Scenario: Edit a drag and drop markers question - When I click on "Edit" "link" in the "Drag markers" "table_row" + When I choose "Edit question" action for "Drag markers" in the question bank And I set the following fields to these values: | Question name | Edited question name | And I press "id_submitbutton" diff --git a/question/type/ddmarker/tests/behat/preview.feature b/question/type/ddmarker/tests/behat/preview.feature index 187affa9b73..b95996eddab 100644 --- a/question/type/ddmarker/tests/behat/preview.feature +++ b/question/type/ddmarker/tests/behat/preview.feature @@ -26,7 +26,7 @@ Feature: Preview a drag-drop marker question @javascript @_bug_phantomjs Scenario: Preview a question using the mouse. - When I click on "Preview" "link" in the "Drag markers" "table_row" + When I choose "Preview" action for "Drag markers" in the question bank And I switch to "questionpreview" window # Increase window size and wait 2 seconds to ensure elements are placed properly by js. # Keep window large else drag will scroll the window to find element. @@ -44,7 +44,7 @@ Feature: Preview a drag-drop marker question @javascript Scenario: Preview a question using the keyboard. - When I click on "Preview" "link" in the "Drag markers" "table_row" + When I choose "Preview" action for "Drag markers" in the question bank And I switch to "questionpreview" window # Increase window size and wait 2 seconds to ensure elements are placed properly by js. # Keep window large else drag will scroll the window to find element. diff --git a/question/type/ddwtos/tests/behat/backup_and_restore.feature b/question/type/ddwtos/tests/behat/backup_and_restore.feature index c3d5731245a..87a7fc712b4 100644 --- a/question/type/ddwtos/tests/behat/backup_and_restore.feature +++ b/question/type/ddwtos/tests/behat/backup_and_restore.feature @@ -29,7 +29,7 @@ Feature: Test duplicating a quiz containing a drag and drop into text question And I restore "test_backup.mbz" backup into a new course using this options: | Schema | Course name | Course 2 | And I navigate to "Question bank" in current page administration - And I click on "Edit" "link" in the "Drag to text" "table_row" + And I choose "Edit question" action for "Drag to text" in the question bank Then the following fields match these values: | Question name | Drag to text | | Question text | The [[1]] brown [[2]] jumped over the [[3]] dog. | diff --git a/question/type/ddwtos/tests/behat/edit.feature b/question/type/ddwtos/tests/behat/edit.feature index 288830234bb..d7c3872f68f 100644 --- a/question/type/ddwtos/tests/behat/edit.feature +++ b/question/type/ddwtos/tests/behat/edit.feature @@ -26,7 +26,7 @@ Feature: Test editing a drag and drop into text questions @javascript Scenario: Edit a drag and drop into text question - When I click on "Edit" "link" in the "Drag to text" "table_row" + When I choose "Edit question" action for "Drag to text" in the question bank Then I should see "Choice [[1]]" And I should see "Choice [[2]]" And I should see "Choice [[3]]" diff --git a/question/type/ddwtos/tests/behat/preview.feature b/question/type/ddwtos/tests/behat/preview.feature index fe4a9138b3a..4abf47cf0ec 100644 --- a/question/type/ddwtos/tests/behat/preview.feature +++ b/question/type/ddwtos/tests/behat/preview.feature @@ -26,7 +26,7 @@ Feature: Preview a drag-drop into text question @javascript @_bug_phantomjs Scenario: Preview a question using the mouse. - When I click on "Preview" "link" in the "Drag to text" "table_row" + When I choose "Preview" action for "Drag to text" in the question bank And I switch to "questionpreview" window # Increase window size and wait 2 seconds to ensure elements are placed properly by js. # Keep window large else drag will scroll the window to find element. @@ -42,7 +42,7 @@ Feature: Preview a drag-drop into text question @javascript Scenario: Preview a question using the keyboard & submit incomplete. - When I click on "Preview" "link" in the "Drag to text" "table_row" + When I choose "Preview" action for "Drag to text" in the question bank And I switch to "questionpreview" window And I type " " into space "1" in the drag and drop onto image question And I type " " into space "2" in the drag and drop onto image question @@ -54,7 +54,7 @@ Feature: Preview a drag-drop into text question @javascript Scenario: Preview a question using the keyboard. - When I click on "Preview" "link" in the "Drag to text" "table_row" + When I choose "Preview" action for "Drag to text" in the question bank And I switch to "questionpreview" window And I type " " into space "1" in the drag and drop onto image question And I type " " into space "2" in the drag and drop onto image question @@ -70,7 +70,7 @@ Feature: Preview a drag-drop into text question | questioncategory | qtype | name | template | | Test questions | ddwtos | Funny groups | oddgroups | And I reload the page - When I click on "Preview" "link" in the "Funny groups" "table_row" + When I choose "Preview" action for "Funny groups" in the question bank And I switch to "questionpreview" window And I type " " into space "1" in the drag and drop onto image question And I type " " into space "2" in the drag and drop onto image question diff --git a/question/type/description/tests/behat/backup_and_restore.feature b/question/type/description/tests/behat/backup_and_restore.feature index 633703a861b..6e9178e6733 100644 --- a/question/type/description/tests/behat/backup_and_restore.feature +++ b/question/type/description/tests/behat/backup_and_restore.feature @@ -29,7 +29,7 @@ Feature: Test duplicating a quiz containing a Description question And I restore "test_backup.mbz" backup into a new course using this options: | Schema | Course name | Course 2 | And I navigate to "Question bank" in current page administration - And I click on "Edit" "link" in the "description-001" "table_row" + And I choose "Edit question" action for "description-001" in the question bank Then the following fields match these values: | Question name | description-001 | | Question text | Here is some information about the questions you are about to attempt. | diff --git a/question/type/description/tests/behat/edit.feature b/question/type/description/tests/behat/edit.feature index 67b225615e7..0aa144e60eb 100644 --- a/question/type/description/tests/behat/edit.feature +++ b/question/type/description/tests/behat/edit.feature @@ -25,7 +25,7 @@ Feature: Test editing a Description question And I navigate to "Question bank" in current page administration Scenario: Edit a Description question - When I click on "Edit" "link" in the "description-001" "table_row" + When I choose "Edit question" action for "description-001" in the question bank And I set the following fields to these values: | Question name | | And I press "id_submitbutton" diff --git a/question/type/description/tests/behat/preview.feature b/question/type/description/tests/behat/preview.feature index f65eebda0d9..13b4660369c 100644 --- a/question/type/description/tests/behat/preview.feature +++ b/question/type/description/tests/behat/preview.feature @@ -26,7 +26,7 @@ Feature: Preview a Description question @javascript @_switch_window Scenario: Preview a Description question and submit a correct response. - When I click on "Preview" "link" in the "description-001" "table_row" + When I choose "Preview" action for "description-001" in the question bank And I switch to "questionpreview" window And I set the field "How questions behave" to "Immediate feedback" And I press "Start again with these options" diff --git a/question/type/essay/tests/behat/backup_and_restore.feature b/question/type/essay/tests/behat/backup_and_restore.feature index 609da1c4ba1..e16bbf2ff73 100644 --- a/question/type/essay/tests/behat/backup_and_restore.feature +++ b/question/type/essay/tests/behat/backup_and_restore.feature @@ -36,7 +36,7 @@ Feature: Test duplicating a quiz containing an Assay question And I should see "essay-001" And I should see "essay-002" And I should see "essay-003" - And I click on "Edit" "link" in the "essay-001" "table_row" + And I choose "Edit question" action for "essay-001" in the question bank Then the following fields match these values: | Question name | essay-001 | | Question text | Please write a story about a frog. | @@ -44,7 +44,7 @@ Feature: Test duplicating a quiz containing an Assay question | Response format | HTML editor | | Require text | Require the student to enter text | And I press "Cancel" - And I click on "Edit" "link" in the "essay-002" "table_row" + And I choose "Edit question" action for "essay-002" in the question bank Then the following fields match these values: | Question name | essay-002 | | Question text | Please write a story about a frog. | @@ -52,7 +52,7 @@ Feature: Test duplicating a quiz containing an Assay question | Response format | HTML editor with file picker | | Require text | Require the student to enter text | And I press "Cancel" - And I click on "Edit" "link" in the "essay-003" "table_row" + And I choose "Edit question" action for "essay-003" in the question bank Then the following fields match these values: | Question name | essay-003 | | Question text | Please write a story about a frog. | diff --git a/question/type/essay/tests/behat/edit.feature b/question/type/essay/tests/behat/edit.feature index 0657b0bc541..dd25a99dde8 100644 --- a/question/type/essay/tests/behat/edit.feature +++ b/question/type/essay/tests/behat/edit.feature @@ -27,7 +27,7 @@ Feature: Test editing an Essay question And I navigate to "Question bank" in current page administration Scenario: Edit an Essay question - When I click on "Edit" "link" in the "essay-001" "table_row" + When I choose "Edit question" action for "essay-001" in the question bank And I set the following fields to these values: | Question name | | And I press "id_submitbutton" diff --git a/question/type/essay/tests/behat/preview.feature b/question/type/essay/tests/behat/preview.feature index 0aad34244a6..6eb52f327a8 100644 --- a/question/type/essay/tests/behat/preview.feature +++ b/question/type/essay/tests/behat/preview.feature @@ -28,7 +28,7 @@ Feature: Preview Essay questions @javascript @_switch_window Scenario: Preview an Essay question and submit a partially correct response. - When I click on "Preview" "link" in the "essay-001" "table_row" + When I choose "Preview" action for "essay-001" in the question bank And I switch to "questionpreview" window And I set the field "How questions behave" to "Immediate feedback" And I press "Start again with these options" @@ -37,7 +37,7 @@ Feature: Preview Essay questions @javascript @_switch_window Scenario: Preview an Essay question and submit a partially correct response. - When I click on "Preview" "link" in the "essay-002" "table_row" + When I choose "Preview" action for "essay-002" in the question bank And I switch to "questionpreview" window And I set the field "How questions behave" to "Immediate feedback" And I press "Start again with these options" @@ -47,7 +47,7 @@ Feature: Preview Essay questions @javascript @_switch_window Scenario: Preview an Essay question and submit a partially correct response. - When I click on "Preview" "link" in the "essay-003" "table_row" + When I choose "Preview" action for "essay-003" in the question bank And I switch to "questionpreview" window And I set the field "How questions behave" to "Immediate feedback" And I press "Start again with these options" diff --git a/question/type/gapselect/tests/behat/basic_test.feature b/question/type/gapselect/tests/behat/basic_test.feature index 9ae9e369ba0..b2301ad35f0 100644 --- a/question/type/gapselect/tests/behat/basic_test.feature +++ b/question/type/gapselect/tests/behat/basic_test.feature @@ -38,7 +38,7 @@ Feature: Test all the basic functionality of this question type Then I should see "Select missing words 001" # Preview it. - When I click on "Preview" "link" in the "Select missing words 001" "table_row" + When I choose "Preview" action for "Select missing words 001" in the question bank And I switch to "questionpreview" window # Gaps (drop-down menus) do not have labels. ids and names are generated @@ -136,7 +136,7 @@ Feature: Test all the basic functionality of this question type Then I should see "Select missing words 001" # Edit the copy and verify the form field contents. - When I click on "Edit" "link" in the "Select missing words 001" "table_row" + When I choose "Edit question" action for "Select missing words 001" in the question bank Then the following fields match these values: | Question name | Select missing words 001 | | Question text | The [[1]] [[2]] on the [[3]]. | diff --git a/question/type/match/tests/behat/backup_and_restore.feature b/question/type/match/tests/behat/backup_and_restore.feature index 05b3ebd140f..5b9841b3d0d 100644 --- a/question/type/match/tests/behat/backup_and_restore.feature +++ b/question/type/match/tests/behat/backup_and_restore.feature @@ -29,7 +29,7 @@ Feature: Test duplicating a quiz containing a Matching question And I restore "test_backup.mbz" backup into a new course using this options: | Schema | Course name | Course 2 | And I navigate to "Question bank" in current page administration - And I click on "Edit" "link" in the "matching-001" "table_row" + And I choose "Edit question" action for "matching-001" in the question bank Then the following fields match these values: | Question name | matching-001 | | Question text | Classify the animals. | diff --git a/question/type/match/tests/behat/edit.feature b/question/type/match/tests/behat/edit.feature index 480b0eac295..3f6e383d12c 100644 --- a/question/type/match/tests/behat/edit.feature +++ b/question/type/match/tests/behat/edit.feature @@ -26,7 +26,7 @@ Feature: Test editing a Matching question @javascript @_switch_window Scenario: Edit a Matching question - When I click on "Edit" "link" in the "Matching for editing" "table_row" + When I choose "Edit question" action for "Matching for editing" in the question bank And I set the following fields to these values: | Question name | | And I press "id_submitbutton" @@ -35,14 +35,14 @@ Feature: Test editing a Matching question | Question name | Edited Matching name | And I press "id_submitbutton" Then I should see "Edited Matching name" - When I click on "Edit" "link" in the "Edited Matching name" "table_row" + When I choose "Edit question" action for "Edited Matching name" in the question bank And I set the following fields to these values: | Shuffle | 0 | | Question 2 | dog | | Question 4 | fly | And I press "id_submitbutton" Then I should see "Edited Matching name" - When I click on "Preview" "link" in the "Edited Matching name" "table_row" + When I choose "Preview" action for "Edited Matching name" in the question bank And I switch to "questionpreview" window Then I should see "frog" And I should see "dog" diff --git a/question/type/match/tests/behat/preview.feature b/question/type/match/tests/behat/preview.feature index 6683a9f17f4..fc2b90c0d1f 100644 --- a/question/type/match/tests/behat/preview.feature +++ b/question/type/match/tests/behat/preview.feature @@ -26,11 +26,11 @@ Feature: Preview a Matching question @javascript @_switch_window Scenario: Preview a Matching question and submit a correct response. - When I click on "Edit" "link" in the "matching-001" "table_row" + When I choose "Edit question" action for "matching-001" in the question bank And I set the following fields to these values: | Shuffle | 0 | And I press "id_submitbutton" - When I click on "Preview" "link" in the "matching-001" "table_row" + When I choose "Preview" action for "matching-001" in the question bank And I switch to "questionpreview" window And I set the field "How questions behave" to "Immediate feedback" And I press "Start again with these options" @@ -44,11 +44,11 @@ Feature: Preview a Matching question @javascript @_switch_window Scenario: Preview a Matching question and submit a partially correct response. - When I click on "Edit" "link" in the "matching-001" "table_row" + When I choose "Edit question" action for "matching-001" in the question bank And I set the following fields to these values: | Shuffle | 0 | And I press "id_submitbutton" - When I click on "Preview" "link" in the "matching-001" "table_row" + When I choose "Preview" action for "matching-001" in the question bank And I switch to "questionpreview" window And I set the field "How questions behave" to "Immediate feedback" And I press "Start again with these options" @@ -62,11 +62,11 @@ Feature: Preview a Matching question @javascript @_switch_window Scenario: Preview a Matching question and submit an incorrect response. - When I click on "Edit" "link" in the "matching-001" "table_row" + When I choose "Edit question" action for "matching-001" in the question bank And I set the following fields to these values: | Shuffle | 0 | And I press "id_submitbutton" - When I click on "Preview" "link" in the "matching-001" "table_row" + When I choose "Preview" action for "matching-001" in the question bank And I switch to "questionpreview" window And I set the field "How questions behave" to "Immediate feedback" And I press "Start again with these options" diff --git a/question/type/multichoice/tests/behat/backup_and_restore.feature b/question/type/multichoice/tests/behat/backup_and_restore.feature index 62112bcf6d1..afc1c2ad268 100644 --- a/question/type/multichoice/tests/behat/backup_and_restore.feature +++ b/question/type/multichoice/tests/behat/backup_and_restore.feature @@ -29,7 +29,7 @@ Feature: Test duplicating a quiz containing a Multiple choice question And I restore "test_backup.mbz" backup into a new course using this options: | Schema | Course name | Course 2 | And I navigate to "Question bank" in current page administration - And I click on "Edit" "link" in the "Multi-choice-001" "table_row" + And I choose "Edit question" action for "Multi-choice-001" in the question bank Then the following fields match these values: | Question name | Multi-choice-001 | | Question text | Which are the odd numbers? | diff --git a/question/type/multichoice/tests/behat/edit.feature b/question/type/multichoice/tests/behat/edit.feature index 5cb83b1528c..ad50bee4b0a 100644 --- a/question/type/multichoice/tests/behat/edit.feature +++ b/question/type/multichoice/tests/behat/edit.feature @@ -26,7 +26,7 @@ Feature: Test editing a Multiple choice question And I navigate to "Question bank" in current page administration Scenario: Edit a Multiple choice question with multiple response (checkboxes) - When I click on "Edit" "link" in the "Multiple choice for editing" "table_row" + When I choose "Edit question" action for "Multiple choice for editing" in the question bank And I set the following fields to these values: | Question name | | And I press "id_submitbutton" @@ -37,7 +37,7 @@ Feature: Test editing a Multiple choice question Then I should see "Edited Multiple choice name" Scenario: Edit a Multiple choice question with single response (radio buttons) - When I click on "Edit" "link" in the "Single choice for editing" "table_row" + When I choose "Edit question" action for "Single choice for editing" in the question bank And I set the following fields to these values: | Question name | Edited Single choice name | And I press "id_submitbutton" diff --git a/question/type/multichoice/tests/behat/preview.feature b/question/type/multichoice/tests/behat/preview.feature index 19e3e797c18..8ba3b9e6723 100644 --- a/question/type/multichoice/tests/behat/preview.feature +++ b/question/type/multichoice/tests/behat/preview.feature @@ -27,7 +27,7 @@ Feature: Preview a Multiple choice question @javascript @_switch_window Scenario: Preview a Multiple choice question and submit a partially correct response. - When I click on "Preview" "link" in the "Multi-choice-001" "table_row" + When I choose "Preview" action for "Multi-choice-001" in the question bank And I switch to "questionpreview" window And I set the field "How questions behave" to "Immediate feedback" And I press "Start again with these options" @@ -42,7 +42,7 @@ Feature: Preview a Multiple choice question @javascript @_switch_window Scenario: Preview a Multiple choice question and submit a correct response. - When I click on "Preview" "link" in the "Multi-choice-001" "table_row" + When I choose "Preview" action for "Multi-choice-001" in the question bank And I switch to "questionpreview" window And I set the field "How questions behave" to "Immediate feedback" And I press "Start again with these options" @@ -59,7 +59,7 @@ Feature: Preview a Multiple choice question @javascript @_switch_window Scenario: Preview a Multiple choice question and submit a correct response. - When I click on "Preview" "link" in the "Multi-choice-002" "table_row" + When I choose "Preview" action for "Multi-choice-002" in the question bank And I switch to "questionpreview" window And I set the field "How questions behave" to "Immediate feedback" And I press "Start again with these options" @@ -73,7 +73,7 @@ Feature: Preview a Multiple choice question @javascript @_switch_window Scenario: Preview a multiple choice question (single response) and clear a previous selected option. - When I click on "Preview" "link" in the "Multi-choice-002" "table_row" + When I choose "Preview" action for "Multi-choice-002" in the question bank And I switch to "questionpreview" window And I set the field "How questions behave" to "Immediate feedback" And I press "Start again with these options" diff --git a/question/type/numerical/tests/behat/backup_and_restore.feature b/question/type/numerical/tests/behat/backup_and_restore.feature index faac89a51b1..293a942782b 100644 --- a/question/type/numerical/tests/behat/backup_and_restore.feature +++ b/question/type/numerical/tests/behat/backup_and_restore.feature @@ -29,7 +29,7 @@ Feature: Test duplicating a quiz containing a Numerical question And I restore "test_backup.mbz" backup into a new course using this options: | Schema | Course name | Course 2 | And I navigate to "Question bank" in current page administration - And I click on "Edit" "link" in the "Numerical-001" "table_row" + And I choose "Edit question" action for "Numerical-001" in the question bank Then the following fields match these values: | Question name | Numerical-001 | | Question text | What is pi to two d.p.? | diff --git a/question/type/numerical/tests/behat/edit.feature b/question/type/numerical/tests/behat/edit.feature index 53435104f21..a365876e32d 100644 --- a/question/type/numerical/tests/behat/edit.feature +++ b/question/type/numerical/tests/behat/edit.feature @@ -28,7 +28,7 @@ Feature: Test editing a Numerical question And I navigate to "Question bank" in current page administration Scenario: Edit a Numerical question - When I click on "Edit" "link" in the "Numerical for editing" "table_row" + When I choose "Edit question" action for "Numerical for editing" in the question bank Then the field "id_answer_0" matches value "3#14" When I set the following fields to these values: | Question name | | @@ -38,7 +38,7 @@ Feature: Test editing a Numerical question | Question name | Edited Numerical name | And I press "id_submitbutton" Then I should see "Edited Numerical name" - When I click on "Edit" "link" in the "Edited Numerical name" "table_row" + When I choose "Edit question" action for "Edited Numerical name" in the question bank And I set the following fields to these values: | id_answer_1 | 3#141592 | | id_tolerance_1 | 0#005 | diff --git a/question/type/numerical/tests/behat/preview.feature b/question/type/numerical/tests/behat/preview.feature index c794d889e69..747b9c360c2 100644 --- a/question/type/numerical/tests/behat/preview.feature +++ b/question/type/numerical/tests/behat/preview.feature @@ -30,7 +30,7 @@ Feature: Preview a Numerical question @javascript @_switch_window Scenario: Preview a Numerical question and submit a correct response. - When I click on "Preview" "link" in the "Numerical-001" "table_row" + When I choose "Preview" action for "Numerical-001" in the question bank And I switch to "questionpreview" window Then I should see "What is pi to two d.p.?" When I set the field "How questions behave" to "Immediate feedback" diff --git a/question/type/shortanswer/tests/behat/backup_and_restore.feature b/question/type/shortanswer/tests/behat/backup_and_restore.feature index 5903e95e271..d8f2c606e00 100644 --- a/question/type/shortanswer/tests/behat/backup_and_restore.feature +++ b/question/type/shortanswer/tests/behat/backup_and_restore.feature @@ -29,7 +29,7 @@ Feature: Test duplicating a quiz containing a Short answer question And I restore "test_backup.mbz" backup into a new course using this options: | Schema | Course name | Course 2 | And I navigate to "Question bank" in current page administration - And I click on "Edit" "link" in the "shortanswer-001" "table_row" + And I choose "Edit question" action for "shortanswer-001" in the question bank Then the following fields match these values: | Question name | shortanswer-001 | | Question text | Name an amphibian: __________ | diff --git a/question/type/shortanswer/tests/behat/edit.feature b/question/type/shortanswer/tests/behat/edit.feature index 72741701ea6..996eb12003e 100644 --- a/question/type/shortanswer/tests/behat/edit.feature +++ b/question/type/shortanswer/tests/behat/edit.feature @@ -26,7 +26,7 @@ Feature: Test editing a Short answer question @javascript @_switch_window Scenario: Edit a Short answer question - When I click on "Edit" "link" in the "shortanswer-001 for editing" "table_row" + When I choose "Edit question" action for "shortanswer-001" in the question bank And I set the following fields to these values: | Question name | | And I press "id_submitbutton" @@ -35,14 +35,14 @@ Feature: Test editing a Short answer question | Question name | Edited shortanswer-001 name | And I press "id_submitbutton" Then I should see "Edited shortanswer-001 name" - When I click on "Edit" "link" in the "Edited shortanswer-001 name" "table_row" + When I choose "Edit question" action for "Edited shortanswer-001" in the question bank And I set the following fields to these values: | id_answer_1 | newt | | id_fraction_1 | 70% | | id_feedback_1 | Newt is an OK good answer. | And I press "id_submitbutton" Then I should see "Edited shortanswer-001 name" - When I click on "Preview" "link" in the "Edited shortanswer-001 name" "table_row" + When I choose "Preview" action for "Edited shortanswer-001" in the question bank And I switch to "questionpreview" window Then I should see "Name an amphibian:" # Set behaviour options diff --git a/question/type/shortanswer/tests/behat/preview.feature b/question/type/shortanswer/tests/behat/preview.feature index e1613b97bb8..2772c38cfc5 100644 --- a/question/type/shortanswer/tests/behat/preview.feature +++ b/question/type/shortanswer/tests/behat/preview.feature @@ -26,7 +26,7 @@ Feature: Preview a Short answer question @javascript @_switch_window Scenario: Preview a Short answer question with correct answer - When I click on "Preview" "link" in the "shortanswer-001" "table_row" + When I choose "Preview" action for "shortanswer-001" in the question bank And I switch to "questionpreview" window Then I should see "Name an amphibian:" # Set behaviour options @@ -41,7 +41,7 @@ Feature: Preview a Short answer question @javascript @_switch_window Scenario: Preview a Short answer question with almost correct answer - When I click on "Preview" "link" in the "shortanswer-001" "table_row" + When I choose "Preview" action for "shortanswer-001" in the question bank And I switch to "questionpreview" window Then I should see "Name an amphibian:" # Set behaviour options @@ -56,7 +56,7 @@ Feature: Preview a Short answer question @javascript @_switch_window Scenario: Preview a Short answer question with incorrect answer - When I click on "Preview" "link" in the "shortanswer-001" "table_row" + When I choose "Preview" action for "shortanswer-001" in the question bank And I switch to "questionpreview" window Then I should see "Name an amphibian:" # Set behaviour options diff --git a/question/type/truefalse/tests/behat/backup_and_restore.feature b/question/type/truefalse/tests/behat/backup_and_restore.feature index 32e6544077b..dce13d6493e 100644 --- a/question/type/truefalse/tests/behat/backup_and_restore.feature +++ b/question/type/truefalse/tests/behat/backup_and_restore.feature @@ -29,7 +29,7 @@ Feature: Test duplicating a quiz containing a True/False question And I restore "test_backup.mbz" backup into a new course using this options: | Schema | Course name | Course 2 | And I navigate to "Question bank" in current page administration - And I click on "Edit" "link" in the "true-false-001" "table_row" + And I choose "Edit question" action for "true-false-001" in the question bank Then the following fields match these values: | Question name | true-false-001 | | Question text | The answer is true. | diff --git a/question/type/truefalse/tests/behat/edit.feature b/question/type/truefalse/tests/behat/edit.feature index 059f7e5f7e4..7fa05952dce 100644 --- a/question/type/truefalse/tests/behat/edit.feature +++ b/question/type/truefalse/tests/behat/edit.feature @@ -25,7 +25,7 @@ Feature: Test editing a True/False question And I navigate to "Question bank" in current page administration Scenario: Edit a True/False question - When I click on "Edit" "link" in the "true-false-001" "table_row" + When I choose "Edit question" action for "true-false-001" in the question bank And I set the following fields to these values: | Question name | | And I press "id_submitbutton" diff --git a/question/type/truefalse/tests/behat/preview.feature b/question/type/truefalse/tests/behat/preview.feature index e85ef1b48bf..83baede4749 100644 --- a/question/type/truefalse/tests/behat/preview.feature +++ b/question/type/truefalse/tests/behat/preview.feature @@ -26,7 +26,7 @@ Feature: Preview a Trtue/False question @javascript @_switch_window Scenario: Preview a True/False question and submit a correct response. - When I click on "Preview" "link" in the "true-false-001" "table_row" + When I choose "Preview" action for "true-false-001" in the question bank And I switch to "questionpreview" window And I set the field "How questions behave" to "Immediate feedback" And I press "Start again with these options" @@ -38,7 +38,7 @@ Feature: Preview a Trtue/False question @javascript @_switch_window Scenario: Preview a True/False question and submit an incorrect response. - When I click on "Preview" "link" in the "true-false-001" "table_row" + When I choose "Preview" action for "true-false-001" in the question bank And I switch to "questionpreview" window And I set the field "How questions behave" to "Immediate feedback" And I press "Start again with these options" diff --git a/question/type/upgrade.txt b/question/type/upgrade.txt index f7fd3cb93e0..dd5545f3723 100644 --- a/question/type/upgrade.txt +++ b/question/type/upgrade.txt @@ -1,6 +1,21 @@ This files describes API changes for question type plugins. +=== 3.8, 3.7.3, 3.6.7 === + +* Coming up in Moodle 3.8 are some changes to the question bank UI. These will break any + Behat automated tests which use the common pattern + When I click on "Duplicate" "link" in the "Test question" "table_row" + to trigger actions on questions when looking at the question bank screen. Therefore, + a new step has been introduced: + When I choose "Duplicate" action for "Test question" in the question bank + If you want your Behat tests to continue working with Moodle 3.8, you will need to use + the new step. The new step has been back-ported, so you can start updating your tests + and have them work with Moodle 3.6 and 3.7. In addition, if you want to trigger the + "Edit" action, you should change that to "Edit question". + + === 3.5 === + + Added new classes backup_qtype_extrafields_plugin and restore_qtype_extrafields_plugin in order to use extra fields method in backup/restore question type. Require and inherit new classes for using it. See backup_qtype_shortanswer_plugin and restore_qtype_shortanswer_plugin for an example of using this.