Commit 9c14b28d authored by Tim Hunt's avatar Tim Hunt
Browse files

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.
parent 5aacd5e7
......@@ -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"
......
......@@ -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"
......
......@@ -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']);
}
}
......@@ -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)"
......@@ -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"
......
......@@ -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"
......
......@@ -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"
......
......@@ -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
......
......@@ -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"
......
......@@ -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"
......@@ -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 | <p>More information about the major features of the Earth's surface can be found in Block 3, Section 6.2.</p> |
......
......@@ -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"
......
......@@ -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"
......
......@@ -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. |
......
......@@ -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"
......
......@@ -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.
......
......@@ -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. |
......
......@@ -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]]"
......
......@@ -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
......
......@@ -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. |
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment