diff --git a/question/tests/behat/behat_core_question.php b/question/tests/behat/behat_core_question.php new file mode 100644 index 00000000000..e2ffbed854d --- /dev/null +++ b/question/tests/behat/behat_core_question.php @@ -0,0 +1,217 @@ +. + +// NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php. + +require_once(__DIR__ . '/behat_question_base.php'); + +use Behat\Gherkin\Node\TableNode as TableNode; +use Behat\Mink\Exception\ExpectationException as ExpectationException; +use Behat\Mink\Exception\ElementNotFoundException as ElementNotFoundException; + +/** + * Steps definitions related with the question bank management. + * + * @package core_question + * @category test + * @copyright 2013 David Monllaó + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class behat_core_question extends behat_question_base { + + /** + * Convert page names to URLs for steps like 'When I am on the "[page name]" page'. + * + * Recognised page names are: + * | None so far! | | + * + * @param string $page name of the page, with the component name removed e.g. 'Admin notification'. + * @return moodle_url the corresponding URL. + * @throws Exception with a meaningful error message if the specified page cannot be found. + */ + protected function resolve_page_url(string $page): moodle_url { + switch (strtolower($page)) { + default: + throw new Exception('Unrecognised core_question page type "' . $page . '."'); + } + } + + /** + * Convert page names to URLs for steps like 'When I am on the "[identifier]" "[page type]" page'. + * + * Recognised page names are: + * | pagetype | name meaning | description | + * | course question bank | Course name | The question bank for a course | + * | course question import | Course name | The import questions screen for a course | + * | course question export | Course name | The export questions screen for a course | + * | preview | Question name | The screen to preview a question | + * | edit | Question name | The screen to edit a question | + * + * @param string $type identifies which type of page this is, e.g. 'Preview'. + * @param string $identifier identifies the particular page, e.g. 'My question'. + * @return moodle_url the corresponding URL. + * @throws Exception with a meaningful error message if the specified page cannot be found. + */ + protected function resolve_page_instance_url(string $type, string $identifier): moodle_url { + switch (strtolower($type)) { + case 'course question bank': + return new moodle_url('/question/edit.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)]); + + case 'course question export': + return new moodle_url('/question/bank/exportquestions/export.php', + ['courseid' => $this->get_course_id($identifier)]); + + case 'preview': + [$questionid, $otheridtype, $otherid] = $this->find_question_by_name($identifier); + return new moodle_url('/question/bank/previewquestion/preview.php', + ['id' => $questionid, $otheridtype => $otherid]); + + case 'edit': + [$questionid, $otheridtype, $otherid] = $this->find_question_by_name($identifier); + return new moodle_url('/question/bank/editquestion/question.php', + ['id' => $questionid, $otheridtype => $otherid]); + + default: + throw new Exception('Unrecognised core_question page type "' . $type . '."'); + } + } + + /** + * Find a question, and where it is, from the question name. + * + * This is a helper used by resolve_page_instance_url. + * + * @param string $questionname + * @return array with three elemnets, int question id, a string 'cmid' or 'courseid', + * and int either cmid or courseid as applicable. + */ + protected function find_question_by_name(string $questionname): array { + global $DB; + $questionid = $DB->get_field('question', 'id', ['name' => $questionname], MUST_EXIST); + $question = question_bank::load_question_data($questionid); + $context = context_helper::instance_by_id($question->contextid); + + if ($context->contextlevel == CONTEXT_MODULE) { + return [$questionid, 'cmid', $context->instanceid]; + } else if ($context->contextlevel == CONTEXT_COURSE) { + return [$questionid, 'courseid', $context->instanceid]; + } else { + throw new coding_exception('Unsupported context level ' . $context->contextlevel); + } + } + + /** + * Creates a question in the current course questions bank with the provided data. + * This step can only be used when creating question types composed by a single form. + * + * @Given /^I add a "(?P(?:[^"]|\\")*)" question filling the form with:$/ + * @param string $questiontypename The question type name + * @param TableNode $questiondata The data to fill the question type form. + */ + public function i_add_a_question_filling_the_form_with($questiontypename, TableNode $questiondata) { + // Click on create question. + $this->execute('behat_forms::press_button', get_string('createnewquestion', 'question')); + + // Add question. + $this->finish_adding_question($questiontypename, $questiondata); + } + + /** + * Checks the state of the specified question. + * + * @Then /^the state of "(?P(?:[^"]|\\")*)" question is shown as "(?P(?:[^"]|\\")*)"$/ + * @throws ExpectationException + * @throws ElementNotFoundException + * @param string $questiondescription + * @param string $state + */ + public function the_state_of_question_is_shown_as($questiondescription, $state) { + + // Using xpath literal to avoid quotes problems. + $questiondescriptionliteral = behat_context_helper::escape($questiondescription); + $stateliteral = behat_context_helper::escape($state); + + // Split in two checkings to give more feedback in case of exception. + $exception = new ElementNotFoundException($this->getSession(), 'Question "' . $questiondescription . '" '); + $questionxpath = "//div[contains(concat(' ', normalize-space(@class), ' '), ' que ')]" . + "[contains(div[@class='content']/div[contains(concat(' ', normalize-space(@class), ' '), ' formulation ')]," . + "{$questiondescriptionliteral})]"; + $this->find('xpath', $questionxpath, $exception); + + $exception = new ExpectationException('Question "' . $questiondescription . + '" state is not "' . $state . '"', $this->getSession()); + $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) { + // Open the menu. + $this->execute("behat_general::i_click_on_in_the", + [get_string('edit'), 'link', $questionname, 'table_row']); + + // Click the action from the menu. + $this->execute("behat_general::i_click_on_in_the", + [$action, 'link', $questionname, 'table_row']); + } + + /** + * A particular bulk action is visible in the question bank UI. + * + * @When I should see question bulk action :action + * @param string $action the value of the input for the action. + */ + public function i_should_see_question_bulk_action($action) { + // Check if its visible. + $this->execute("behat_general::should_be_visible", + ["#bulkactionsui-container input[name='$action']", "css_element"]); + } + + /** + * A particular bulk action should not be visible in the question bank UI. + * + * @When I should not see question bulk action :action + * @param string $action the value of the input for the action. + */ + public function i_should_not_see_question_bulk_action($action) { + // Check if its visible. + $this->execute("behat_general::should_not_be_visible", + ["#bulkactionsui-container input[name='$action']", "css_element"]); + } + + /** + * A click on a particular bulk action in the question bank UI. + * + * @When I click on question bulk action :action + * @param string $action the value of the input for the action. + */ + public function i_click_on_question_bulk_action($action) { + // Click the bulk action. + $this->execute("behat_general::i_click_on", + ["#bulkactionsui-container input[name='$action']", "css_element"]); + } +} diff --git a/question/tests/behat/behat_question.php b/question/tests/behat/behat_question.php index d059e3fcd8d..405a3e7fde9 100644 --- a/question/tests/behat/behat_question.php +++ b/question/tests/behat/behat_question.php @@ -14,125 +14,26 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -/** - * Behat question-related steps definitions. - * - * @package core_question - * @category test - * @copyright 2013 David Monllaó - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - // NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php. +require_once(__DIR__ . '/../../../lib/behat/behat_deprecated_base.php'); require_once(__DIR__ . '/behat_question_base.php'); -use Behat\Gherkin\Node\TableNode as TableNode, - Behat\Mink\Exception\ExpectationException as ExpectationException, - Behat\Mink\Exception\ElementNotFoundException as ElementNotFoundException; - /** - * Steps definitions related with the question bank management. + * Deprecated class, only kept for backwards compatibility. * - * @package core_question - * @category test - * @copyright 2013 David Monllaó - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @package core_question + * @category test + * @copyright 2022 The Open University + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @deprecated since Moodle 4.0. Use behat_core_question instead + * (if you need to refer to this class at all, which you probably don't). */ -class behat_question extends behat_question_base { - - /** - * Creates a question in the current course questions bank with the provided data. This step can only be used when creating question types composed by a single form. - * - * @Given /^I add a "(?P(?:[^"]|\\")*)" question filling the form with:$/ - * @param string $questiontypename The question type name - * @param TableNode $questiondata The data to fill the question type form. - */ - public function i_add_a_question_filling_the_form_with($questiontypename, TableNode $questiondata) { - // Click on create question. - $this->execute('behat_forms::press_button', get_string('createnewquestion', 'question')); - - // Add question. - $this->finish_adding_question($questiontypename, $questiondata); - } - - /** - * Checks the state of the specified question. - * - * @Then /^the state of "(?P(?:[^"]|\\")*)" question is shown as "(?P(?:[^"]|\\")*)"$/ - * @throws ExpectationException - * @throws ElementNotFoundException - * @param string $questiondescription - * @param string $state - */ - public function the_state_of_question_is_shown_as($questiondescription, $state) { - - // Using xpath literal to avoid quotes problems. - $questiondescriptionliteral = behat_context_helper::escape($questiondescription); - $stateliteral = behat_context_helper::escape($state); - - // Split in two checkings to give more feedback in case of exception. - $exception = new ElementNotFoundException($this->getSession(), 'Question "' . $questiondescription . '" '); - $questionxpath = "//div[contains(concat(' ', normalize-space(@class), ' '), ' que ')]" . - "[contains(div[@class='content']/div[contains(concat(' ', normalize-space(@class), ' '), ' formulation ')]," . - "{$questiondescriptionliteral})]"; - $this->find('xpath', $questionxpath, $exception); - - $exception = new ExpectationException('Question "' . $questiondescription . '" state is not "' . $state . '"', $this->getSession()); - $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) { - // Open the menu. - $this->execute("behat_general::i_click_on_in_the", - [get_string('edit'), 'link', $questionname, 'table_row']); - - // Click the action from the menu. - $this->execute("behat_general::i_click_on_in_the", - [$action, 'link', $questionname, 'table_row']); - } - - /** - * A particular bulk action is visible in the question bank UI. - * - * @When I should see question bulk action :action - * @param string $action the value of the input for the action. - */ - public function i_should_see_question_bulk_action($action) { - // Check if its visible. - $this->execute("behat_general::should_be_visible", - ["#bulkactionsui-container input[name='$action']", "css_element"]); - } - - /** - * A particular bulk action should not be visible in the question bank UI. - * - * @When I should not see question bulk action :action - * @param string $action the value of the input for the action. - */ - public function i_should_not_see_question_bulk_action($action) { - // Check if its visible. - $this->execute("behat_general::should_not_be_visible", - ["#bulkactionsui-container input[name='$action']", "css_element"]); - } - - /** - * A click on a particular bulk action in the question bank UI. - * - * @When I click on question bulk action :action - * @param string $action the value of the input for the action. - */ - public function i_click_on_question_bulk_action($action) { - // Click the bulk action. - $this->execute("behat_general::i_click_on", - ["#bulkactionsui-container input[name='$action']", "css_element"]); +class behat_question extends behat_deprecated_base { + public function __call($name, $arguments) { + if (method_exists(behat_core_question::class, $name)) { + $this->deprecated_message('The behat_question class has been moved to behat_core_question.'); + $this->execute("behat_core_question::{$name}", $arguments); + } } } diff --git a/question/type/ddimageortext/tests/behat/add.feature b/question/type/ddimageortext/tests/behat/add.feature index 3146e391455..1aa0de85545 100644 --- a/question/type/ddimageortext/tests/behat/add.feature +++ b/question/type/ddimageortext/tests/behat/add.feature @@ -6,21 +6,19 @@ Feature: Test creating a drag and drop onto image question Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@moodle.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: | user | course | role | - | teacher1 | C1 | editingteacher | - And I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Question bank" in current page administration + | teacher | C1 | editingteacher | @javascript @_file_upload Scenario: Create a drag and drop onto image question - When I press "Create a new question ..." + When I am on the "Course 1" "core_question > course question bank" page logged in as teacher + And I press "Create a new question ..." And I set the field "Drag and drop onto image" to "1" And I click on "Add" "button" in the "Choose a question type to add" "dialogue" And I set the field "Question name" to "Drag and drop onto image 001" @@ -96,8 +94,8 @@ Feature: Test creating a drag and drop onto image question And I press "id_submitbutton" Then I should see "Drag and drop onto image 001" # Checking that the next new question form displays user preferences settings. - When I press "Create a new question ..." + And I press "Create a new question ..." And I set the field "item_qtype_ddimageortext" to "1" And I click on "Add" "button" in the "Choose a question type to add" "dialogue" - Then the following fields match these values: + And the following fields match these values: | id_shuffleanswers | 1 | diff --git a/question/type/ddimageortext/tests/behat/backup_and_restore.feature b/question/type/ddimageortext/tests/behat/backup_and_restore.feature index ca724b4c340..a779d717d7b 100644 --- a/question/type/ddimageortext/tests/behat/backup_and_restore.feature +++ b/question/type/ddimageortext/tests/behat/backup_and_restore.feature @@ -19,16 +19,16 @@ Feature: Test duplicating a quiz containing a drag and drop onto image question | quiz | Test quiz | C1 | quiz1 | And quiz "Test quiz" contains the following questions: | Drag onto image | 1 | - And I log in as "admin" - And I am on "Course 1" course homepage @javascript Scenario: Backup and restore a course containing a drag and drop onto image question - When I backup "Course 1" course using this options: + When I am on the "Course 1" course page logged in as admin + And I backup "Course 1" course using this options: | Confirmation | Filename | test_backup.mbz | 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 + | Schema | Course name | Course 2 | + | Schema | Course short name | C2 | + And I am on the "Course 2" "core_question > course question bank" page 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 | diff --git a/question/type/ddimageortext/tests/behat/edit.feature b/question/type/ddimageortext/tests/behat/edit.feature index 9bb97d495ef..d55affcd5c4 100644 --- a/question/type/ddimageortext/tests/behat/edit.feature +++ b/question/type/ddimageortext/tests/behat/edit.feature @@ -6,44 +6,41 @@ Feature: Test editing a drag and drop onto image questions Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@example.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | + | user | course | role | + | teacher | C1 | editingteacher | And the following "question categories" exist: | contextlevel | reference | name | | Course | C1 | Test questions | And the following "questions" exist: | questioncategory | qtype | name | template | | Test questions | ddimageortext | Drag onto image | xsection | - And I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Question bank" in current page administration @javascript Scenario: Edit a drag and drop onto image question - And I choose "Edit question" action for "Drag onto image" in the question bank + When I am on the "Drag onto image" "core_question > edit" page logged in as teacher And I set the following fields to these values: | Question name | Edited question name | And I press "id_submitbutton" Then I should see "Edited question name" Scenario: Edit a drag and drop onto image question and verify penalty works as expected - When I choose "Edit question" action for "Drag onto image" in the question bank + When I am on the "Drag onto image" "core_question > edit" page logged in as teacher Then the following fields match these values: | Question name | Drag onto image | | Penalty for each incorrect try | 33.33333% | | Penalty for each incorrect try | 0.3333333 | Scenario: Edit a drag and drop onto image question and verify penalty works as expected with custom decimal separator - When the following "language customisations" exist: + Given the following "language customisations" exist: | component | stringid | value | | core_langconfig | decsep | # | - And I choose "Edit question" action for "Drag onto image" in the question bank + When I am on the "Drag onto image" "core_question > edit" page logged in as teacher Then the following fields match these values: | Question name | Drag onto image | | Penalty for each incorrect try | 33#33333% | diff --git a/question/type/ddimageortext/tests/behat/export.feature b/question/type/ddimageortext/tests/behat/export.feature index 1b4fa9d0bd1..06d83e284ea 100644 --- a/question/type/ddimageortext/tests/behat/export.feature +++ b/question/type/ddimageortext/tests/behat/export.feature @@ -6,31 +6,27 @@ Feature: Test exporting drag and drop onto image questions Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@example.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | + | user | course | role | + | teacher | C1 | editingteacher | And the following "question categories" exist: | contextlevel | reference | name | | Course | C1 | Test questions | And the following "questions" exist: | questioncategory | qtype | name | template | | Test questions | ddimageortext | Drag onto image | xsection | - And I log in as "teacher1" - And I am on "Course 1" course homepage @javascript Scenario: Export a drag and drop onto image question - # Import sample file. - 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 press "Export questions to file" - And following "click here" should download between "18600" and "19150" bytes + Then following "click here" should download between "18600" and "19150" bytes # If the download step is the last in the scenario then we can sometimes run # into the situation where the download page causes a http redirect but behat # has already conducted its reset (generating an error). By putting a logout diff --git a/question/type/ddimageortext/tests/behat/import.feature b/question/type/ddimageortext/tests/behat/import.feature index d4996633f79..828403bb71d 100644 --- a/question/type/ddimageortext/tests/behat/import.feature +++ b/question/type/ddimageortext/tests/behat/import.feature @@ -6,21 +6,18 @@ Feature: Test importing drag and drop onto image questions Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@example.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | - And I log in as "teacher1" - And I am on "Course 1" course homepage + | user | course | role | + | teacher | C1 | editingteacher | @javascript @_file_upload Scenario: import drag and drop onto image question. - 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/type/ddimageortext/tests/fixtures/testquestion.moodle.xml" file to "Import" filemanager And I press "id_submitbutton" diff --git a/question/type/ddimageortext/tests/behat/preview.feature b/question/type/ddimageortext/tests/behat/preview.feature index cff7bfc8bf3..bb5c5c868de 100644 --- a/question/type/ddimageortext/tests/behat/preview.feature +++ b/question/type/ddimageortext/tests/behat/preview.feature @@ -6,30 +6,24 @@ Feature: Preview a drag-drop onto image question Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@moodle.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | + | user | course | role | + | teacher | C1 | editingteacher | And the following "question categories" exist: | contextlevel | reference | name | | Course | C1 | Test questions | And the following "questions" exist: | questioncategory | qtype | name | template | | Test questions | ddimageortext | Drag onto image | xsection | - Given I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Question bank" in current page administration @javascript @_bug_phantomjs Scenario: Preview a question using the mouse. - When I choose "Preview" action for "Drag onto image" in the question bank - # 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. - And I change window size to "medium" + When I am on the "Drag onto image" "core_question > preview" page logged in as teacher And I wait "2" seconds # Odd, but the
s go to nothing, not a space. And I drag "mountainbelt" to place "1" in the drag and drop onto image question @@ -43,11 +37,10 @@ Feature: Preview a drag-drop onto image question And I press "Submit and finish" Then the state of "Identify the features" question is shown as "Correct" And I should see "Mark 1.00 out of 1.00" - And I press "Close preview" @javascript Scenario: Preview a question using the keyboard. - When I choose "Preview" action for "Drag onto image" in the question bank + When I am on the "Drag onto image" "core_question > preview" page logged in as teacher # Increase window size and wait 2 seconds to ensure elements are placed properly by js. And I type " " on place "1" in the drag and drop onto image question And I type " " on place "2" in the drag and drop onto image question @@ -60,4 +53,3 @@ Feature: Preview a drag-drop onto image question And I press "Submit and finish" Then the state of "Identify the features" question is shown as "Correct" And I should see "Mark 1.00 out of 1.00" - And I press "Close preview" diff --git a/question/type/ddmarker/tests/behat/add.feature b/question/type/ddmarker/tests/behat/add.feature index 6f86eeb9444..5ec52ddfc7c 100644 --- a/question/type/ddmarker/tests/behat/add.feature +++ b/question/type/ddmarker/tests/behat/add.feature @@ -6,21 +6,19 @@ Feature: Test creating a drag and drop markers question Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@moodle.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | - And I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Question bank" in current page administration + | user | course | role | + | teacher | C1 | editingteacher | @javascript @_file_upload Scenario: Create a drag and drop markers question - When I press "Create a new question ..." + When I am on the "Course 1" "core_question > course question bank" page logged in as teacher + And I press "Create a new question ..." And I set the field "Drag and drop markers" to "1" And I click on "Add" "button" in the "Choose a question type to add" "dialogue" And I set the field "Question name" to "Drag and drop markers" @@ -59,9 +57,9 @@ Feature: Test creating a drag and drop markers question And I press "id_submitbutton" And I should see "Drag and drop markers" # Checking that the next new question form displays user preferences settings. - When I press "Create a new question ..." + And I press "Create a new question ..." And I set the field "item_qtype_ddmarker" to "1" And I click on "Add" "button" in the "Choose a question type to add" "dialogue" - Then the following fields match these values: + And the following fields match these values: | id_showmisplaced | 1 | | id_shuffleanswers | 1 | diff --git a/question/type/ddmarker/tests/behat/backup_and_restore.feature b/question/type/ddmarker/tests/behat/backup_and_restore.feature index a5d15a262af..f9432366c6d 100644 --- a/question/type/ddmarker/tests/behat/backup_and_restore.feature +++ b/question/type/ddmarker/tests/behat/backup_and_restore.feature @@ -27,7 +27,8 @@ Feature: Test duplicating a quiz containing a drag and drop markers question When I backup "Course 1" course using this options: | Confirmation | Filename | test_backup.mbz | And I restore "test_backup.mbz" backup into a new course using this options: - | Schema | Course name | Course 2 | + | Schema | Course name | Course 2 | + | Schema | Course short name | C2 | And I navigate to "Question bank" in current page administration And I choose "Edit question" action for "Drag markers" in the question bank Then the following fields match these values: diff --git a/question/type/ddmarker/tests/behat/edit.feature b/question/type/ddmarker/tests/behat/edit.feature index 9e918177c36..01829e0148f 100644 --- a/question/type/ddmarker/tests/behat/edit.feature +++ b/question/type/ddmarker/tests/behat/edit.feature @@ -6,27 +6,24 @@ Feature: Test editing a drag and drop markers questions Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@example.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | + | user | course | role | + | teacher | C1 | editingteacher | And the following "question categories" exist: | contextlevel | reference | name | | Course | C1 | Test questions | And the following "questions" exist: | questioncategory | qtype | name | template | | Test questions | ddmarker | Drag markers | mkmap | - And I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Question bank" in current page administration @javascript Scenario: Edit a drag and drop markers question - When I choose "Edit question" action for "Drag markers" in the question bank + When I am on the "Drag markers" "core_question > edit" page logged in as teacher 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/export.feature b/question/type/ddmarker/tests/behat/export.feature index 0efe8e614ba..edb928239ae 100644 --- a/question/type/ddmarker/tests/behat/export.feature +++ b/question/type/ddmarker/tests/behat/export.feature @@ -6,31 +6,27 @@ Feature: Test exporting drag and drop markers questions Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@example.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | + | user | course | role | + | teacher | C1 | editingteacher | And the following "question categories" exist: | contextlevel | reference | name | | Course | C1 | Test questions | And the following "questions" exist: | questioncategory | qtype | name | template | | Test questions | ddmarker | Drag markers | mkmap | - And I log in as "teacher1" - And I am on "Course 1" course homepage @javascript Scenario: Export a drag and drop markers question - # Import sample file. - 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 press "Export questions to file" - And following "click here" should download between "233700" and "233950" bytes + Then following "click here" should download between "233700" and "233950" bytes # If the download step is the last in the scenario then we can sometimes run # into the situation where the download page causes a http redirect but behat # has already conducted its reset (generating an error). By putting a logout diff --git a/question/type/ddmarker/tests/behat/import.feature b/question/type/ddmarker/tests/behat/import.feature index 671dedfc070..d822f015dcc 100644 --- a/question/type/ddmarker/tests/behat/import.feature +++ b/question/type/ddmarker/tests/behat/import.feature @@ -6,21 +6,18 @@ Feature: Test importing drag and drop markers questions Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@example.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | - And I log in as "teacher1" - And I am on "Course 1" course homepage + | user | course | role | + | teacher | C1 | editingteacher | @javascript @_file_upload Scenario: import drag and drop markers question. - 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/type/ddmarker/tests/fixtures/testquestion.moodle.xml" file to "Import" filemanager And I press "id_submitbutton" diff --git a/question/type/ddmarker/tests/behat/preview.feature b/question/type/ddmarker/tests/behat/preview.feature index 82188de60e1..528c98e20ad 100644 --- a/question/type/ddmarker/tests/behat/preview.feature +++ b/question/type/ddmarker/tests/behat/preview.feature @@ -6,28 +6,24 @@ Feature: Preview a drag-drop marker question Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@moodle.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | + | user | course | role | + | teacher | C1 | editingteacher | And the following "question categories" exist: | contextlevel | reference | name | | Course | C1 | Test questions | And the following "questions" exist: | questioncategory | qtype | name | template | | Test questions | ddmarker | Drag markers | mkmap | - Given I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Question bank" in current page administration @javascript @_bug_phantomjs - Scenario: Preview a question using the mouse. - When I choose "Preview" action for "Drag markers" in the question bank - # Odd, but the
s go to nothing, not a space. + Scenario: Preview a question using the mouse + When I am on the "Drag markers" "core_question > preview" page logged in as teacher And I drag "OU" to "322,213" in the drag and drop markers question And I drag "Railway station" to "144,84" in the drag and drop markers question And I drag "Railway station" to "195,180" in the drag and drop markers question @@ -35,21 +31,19 @@ Feature: Preview a drag-drop marker question And I press "Submit and finish" Then the state of "Please place the markers on the map of Milton Keynes" question is shown as "Correct" And I should see "Mark 1.00 out of 1.00" - And I press "Close preview" @javascript - Scenario: Preview a question using the keyboard. - When I choose "Preview" action for "Drag markers" in the question bank + Scenario: Preview a question using the keyboard + When I am on the "Drag markers" "core_question > preview" page logged in as teacher And I type "up" "88" times on marker "Railway station" in the drag and drop markers question And I type "right" "26" times on marker "Railway station" in the drag and drop markers question And I press "Submit and finish" Then the state of "Please place the markers on the map of Milton Keynes" question is shown as "Partially correct" And I should see "Mark 0.25 out of 1.00" - And I press "Close preview" @javascript - Scenario: Preview a question in multiple viewports. - When I choose "Preview" action for "Drag markers" in the question bank + Scenario: Preview a question in multiple viewports + When I am on the "Drag markers" "core_question > preview" page logged in as teacher And I change viewport size to "large" And I drag "OU" to "322,213" in the drag and drop markers question And I drag "Railway station" to "144,84" in the drag and drop markers question diff --git a/question/type/ddwtos/tests/behat/add.feature b/question/type/ddwtos/tests/behat/add.feature index a712f027bbd..a73b9c86d9b 100644 --- a/question/type/ddwtos/tests/behat/add.feature +++ b/question/type/ddwtos/tests/behat/add.feature @@ -6,21 +6,19 @@ Feature: Test creating a drag and drop into text question Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@moodle.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | - And I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Question bank" in current page administration + | user | course | role | + | teacher | C1 | editingteacher | @javascript Scenario: Create a drag and drop into text question - Given I add a "Drag and drop into text" question filling the form with: + When I am on the "Course 1" "core_question > course question bank" page logged in as teacher + And I add a "Drag and drop into text" question filling the form with: | Question name | Drag and drop into text 001 | | Question text | The [[1]] [[2]] on the [[3]]. | | General feedback | The cat sat on the mat. | @@ -33,11 +31,11 @@ Feature: Test creating a drag and drop into text question | Penalty for each incorrect try | 20% | | Hint 1 | First hint | | Hint 2 | Second hint | - And I should see "Drag and drop into text 001" + Then I should see "Drag and drop into text 001" # Checking that the next new question form displays user preferences settings. - When I press "Create a new question ..." + And I press "Create a new question ..." And I set the field "item_qtype_ddwtos" to "1" And I click on "Add" "button" in the "Choose a question type to add" "dialogue" - Then the following fields match these values: + And the following fields match these values: | id_shuffleanswers | 1 | | Penalty for each incorrect try | 20% | diff --git a/question/type/ddwtos/tests/behat/backup_and_restore.feature b/question/type/ddwtos/tests/behat/backup_and_restore.feature index 87a7fc712b4..8a006197ffb 100644 --- a/question/type/ddwtos/tests/behat/backup_and_restore.feature +++ b/question/type/ddwtos/tests/behat/backup_and_restore.feature @@ -19,16 +19,16 @@ Feature: Test duplicating a quiz containing a drag and drop into text question | quiz | Test quiz | C1 | quiz1 | And quiz "Test quiz" contains the following questions: | Drag to text | 1 | - And I log in as "admin" - And I am on "Course 1" course homepage @javascript Scenario: Backup and restore a course containing a drag and drop into text question - When I backup "Course 1" course using this options: + When I am on the "Course 1" course page logged in as admin + And I backup "Course 1" course using this options: | Confirmation | Filename | test_backup.mbz | 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 + | Schema | Course name | Course 2 | + | Schema | Course short name | C2 | + And I am on the "Course 2" "core_question > course question bank" page 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 | diff --git a/question/type/ddwtos/tests/behat/edit.feature b/question/type/ddwtos/tests/behat/edit.feature index d7c3872f68f..eeb1dd21f7a 100644 --- a/question/type/ddwtos/tests/behat/edit.feature +++ b/question/type/ddwtos/tests/behat/edit.feature @@ -6,28 +6,25 @@ Feature: Test editing a drag and drop into text questions Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@example.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | + | user | course | role | + | teacher | C1 | editingteacher | And the following "question categories" exist: | contextlevel | reference | name | | Course | C1 | Test questions | And the following "questions" exist: | questioncategory | qtype | name | template | | Test questions | ddwtos | Drag to text | fox | - And I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Question bank" in current page administration @javascript Scenario: Edit a drag and drop into text question - When I choose "Edit question" action for "Drag to text" in the question bank - Then I should see "Choice [[1]]" + When I am on the "Drag to text" "core_question > edit" page logged in as teacher + And I should see "Choice [[1]]" And I should see "Choice [[2]]" And I should see "Choice [[3]]" And I set the following fields to these values: diff --git a/question/type/ddwtos/tests/behat/export.feature b/question/type/ddwtos/tests/behat/export.feature index 2580e6cc787..a74915b78e5 100644 --- a/question/type/ddwtos/tests/behat/export.feature +++ b/question/type/ddwtos/tests/behat/export.feature @@ -6,28 +6,24 @@ Feature: Test exporting drag and drop into text questions Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@example.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | + | user | course | role | + | teacher | C1 | editingteacher | And the following "question categories" exist: | contextlevel | reference | name | | Course | C1 | Test questions | And the following "questions" exist: | questioncategory | qtype | name | template | | Test questions | ddwtos | Drag to text | fox | - And I log in as "teacher1" - And I am on "Course 1" course homepage @javascript Scenario: Export a drag and drop into text question - # Import sample file. - 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 press "Export questions to file" And following "click here" should download between "1550" and "1700" bytes diff --git a/question/type/ddwtos/tests/behat/import.feature b/question/type/ddwtos/tests/behat/import.feature index 119359a8c3f..0a0aabcc872 100644 --- a/question/type/ddwtos/tests/behat/import.feature +++ b/question/type/ddwtos/tests/behat/import.feature @@ -6,21 +6,18 @@ Feature: Test importing drag and drop into text questions Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@example.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | - And I log in as "teacher1" - And I am on "Course 1" course homepage + | user | course | role | + | teacher | C1 | editingteacher | @javascript @_file_upload Scenario: import drag and drop into text question. - 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/type/ddwtos/tests/fixtures/testquestion.moodle.xml" file to "Import" filemanager And I press "id_submitbutton" diff --git a/question/type/ddwtos/tests/behat/preview.feature b/question/type/ddwtos/tests/behat/preview.feature index 46cd2ef6a02..701c4c7d4f2 100644 --- a/question/type/ddwtos/tests/behat/preview.feature +++ b/question/type/ddwtos/tests/behat/preview.feature @@ -6,14 +6,14 @@ Feature: Preview a drag-drop into text question Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@moodle.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | + | user | course | role | + | teacher | C1 | editingteacher | And the following "question categories" exist: | contextlevel | reference | name | | Course | C1 | Test questions | @@ -21,63 +21,54 @@ Feature: Preview a drag-drop into text question | questioncategory | qtype | name | template | | Test questions | ddwtos | Drag to text | fox | | Test questions | ddwtos | Drag to text infinite | infinite | - Given I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Question bank" in current page administration @javascript @_bug_phantomjs Scenario: Preview a question using the mouse. - When I choose "Preview" action for "Drag to text" in the question bank + When I am on the "Drag to text" "core_question > preview" page logged in as teacher And I drag "quick" to space "1" in the drag and drop into text question And I drag "fox" to space "2" in the drag and drop into text question And I drag "assiduous" to space "3" in the drag and drop into text question And I press "Submit and finish" Then the state of "The" question is shown as "Partially correct" And I should see "Mark 0.67 out of 1.00" - And I press "Close preview" @javascript Scenario: Preview a question using the keyboard & submit incomplete. - When I choose "Preview" action for "Drag to text" in the question bank + When I am on the "Drag to text" "core_question > preview" page logged in as teacher 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 And I type " " into space "3" in the drag and drop onto image question And I press "Save" Then the state of "The" question is shown as "Incomplete answer" And I should see "Please put an answer in each box." - And I press "Close preview" @javascript Scenario: Preview a question using the keyboard. - When I choose "Preview" action for "Drag to text" in the question bank + When I am on the "Drag to text" "core_question > preview" page logged in as teacher 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 And I type " " into space "3" in the drag and drop onto image question And I press "Submit and finish" Then the state of "The" question is shown as "Incorrect" And I should see "Mark 0.00 out of 1.00" - And I press "Close preview" @javascript Scenario: Preview a question that uses strange group numbers using the keyboard. Given the following "questions" exist: | questioncategory | qtype | name | template | | Test questions | ddwtos | Funny groups | oddgroups | - And I reload the page - When I choose "Preview" action for "Funny groups" in the question bank + When I am on the "Funny groups" "core_question > preview" page logged in as teacher 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 And I type " " into space "3" in the drag and drop onto image question And I press "Submit and finish" Then the state of "The" question is shown as "Correct" And I should see "Mark 1.00 out of 1.00" - And I press "Close preview" @javascript Scenario: Preview a infinite question. - When I choose "Preview" action for "Drag to text infinite" in the question bank + When I am on the "Drag to text infinite" "core_question > preview" page logged in as teacher And I press "Fill in correct responses" Then I should see "Option1" in the home area of drag and drop into text question And I should see "Option2" in the home area of drag and drop into text question And I should see "Option3" in the home area of drag and drop into text question - And I press "Close preview" diff --git a/question/type/description/tests/behat/add.feature b/question/type/description/tests/behat/add.feature index bc5538f4ecb..91fb8208c27 100644 --- a/question/type/description/tests/behat/add.feature +++ b/question/type/description/tests/behat/add.feature @@ -6,20 +6,18 @@ Feature: Test creating a Description question Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@moodle.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | - And I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Question bank" in current page administration + | user | course | role | + | teacher | C1 | editingteacher | Scenario: Create a Description question with Correct answer as False - When I add a "Description" question filling the form with: + When I am on the "Course 1" "core_question > course question bank" page logged in as teacher + And I add a "Description" question filling the form with: | Question name | description-001 | | Question text | Instructions about the following questions. | | General feedback | Why actually the field 'General feedback' used in this qytype? | diff --git a/question/type/description/tests/behat/backup_and_restore.feature b/question/type/description/tests/behat/backup_and_restore.feature index 6e9178e6733..3d64c2e196e 100644 --- a/question/type/description/tests/behat/backup_and_restore.feature +++ b/question/type/description/tests/behat/backup_and_restore.feature @@ -19,16 +19,16 @@ Feature: Test duplicating a quiz containing a Description question | quiz | Test quiz | C1 | quiz1 | And quiz "Test quiz" contains the following questions: | description-001 | 1 | - And I log in as "admin" - And I am on "Course 1" course homepage @javascript Scenario: Backup and restore a course containing a Description question - When I backup "Course 1" course using this options: + When I am on the "Course 1" course page logged in as admin + And I backup "Course 1" course using this options: | Confirmation | Filename | test_backup.mbz | 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 + | Schema | Course name | Course 2 | + | Schema | Course short name | C2 | + And I am on the "Course 2" "core_question > course question bank" page And I choose "Edit question" action for "description-001" in the question bank Then the following fields match these values: | Question name | description-001 | diff --git a/question/type/description/tests/behat/edit.feature b/question/type/description/tests/behat/edit.feature index 0aa144e60eb..81cad236109 100644 --- a/question/type/description/tests/behat/edit.feature +++ b/question/type/description/tests/behat/edit.feature @@ -6,26 +6,23 @@ Feature: Test editing a Description question Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@example.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | + | user | course | role | + | teacher | C1 | editingteacher | And the following "question categories" exist: | contextlevel | reference | name | | Course | C1 | Test questions | And the following "questions" exist: | questioncategory | qtype | name | template | | Test questions | description | description-001 | info | - And I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Question bank" in current page administration Scenario: Edit a Description question - When I choose "Edit question" action for "description-001" in the question bank + When I am on the "description-001" "core_question > edit" page logged in as teacher And I set the following fields to these values: | Question name | | And I press "id_submitbutton" diff --git a/question/type/description/tests/behat/export.feature b/question/type/description/tests/behat/export.feature index 619dfcd8ac4..28cc5cda094 100644 --- a/question/type/description/tests/behat/export.feature +++ b/question/type/description/tests/behat/export.feature @@ -6,26 +6,23 @@ Feature: Test exporting Description questions Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@example.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | + | user | course | role | + | teacher | C1 | editingteacher | And the following "question categories" exist: | contextlevel | reference | name | | Course | C1 | Test questions | And the following "questions" exist: | questioncategory | qtype | name | template | | Test questions | description | description-001 | info | - And I log in as "teacher1" - And I am on "Course 1" course homepage Scenario: Export a Description question - 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 press "Export questions to file" Then following "click here" should download between "650" and "900" bytes diff --git a/question/type/description/tests/behat/import.feature b/question/type/description/tests/behat/import.feature index 59855e7cec7..0f54b9c44b0 100644 --- a/question/type/description/tests/behat/import.feature +++ b/question/type/description/tests/behat/import.feature @@ -6,21 +6,18 @@ Feature: Test importing Description questions Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@example.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | - And I log in as "teacher1" - And I am on "Course 1" course homepage + | user | course | role | + | teacher | C1 | editingteacher | @javascript @_file_upload Scenario: import a Description question. - 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/type/description/tests/fixtures/testquestion.moodle.xml" file to "Import" filemanager And I press "id_submitbutton" diff --git a/question/type/description/tests/behat/preview.feature b/question/type/description/tests/behat/preview.feature index c1e548fc4df..f278a65abfe 100644 --- a/question/type/description/tests/behat/preview.feature +++ b/question/type/description/tests/behat/preview.feature @@ -6,29 +6,25 @@ Feature: Preview a Description question Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@moodle.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | + | user | course | role | + | teacher | C1 | editingteacher | And the following "question categories" exist: | contextlevel | reference | name | | Course | C1 | Test questions | And the following "questions" exist: | questioncategory | qtype | name | template | | Test questions | description | description-001 | info | - Given I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Question bank" in current page administration @javascript @_switch_window Scenario: Preview a Description question and submit a correct response. - When I choose "Preview" action for "description-001" in the question bank - And I press "Preview options" + When I am on the "description-001" "core_question > preview" page logged in as teacher + And I expand all fieldsets And I set the field "How questions behave" to "Immediate feedback" And I press "Start again with these options" And I should see "Here is some information about the questions you are about to attempt." - And I press "Close preview" diff --git a/question/type/essay/tests/behat/add.feature b/question/type/essay/tests/behat/add.feature index d87c9e4c0fb..be073e4024e 100644 --- a/question/type/essay/tests/behat/add.feature +++ b/question/type/essay/tests/behat/add.feature @@ -6,20 +6,18 @@ Feature: Test creating an Essay question Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@moodle.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | - And I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Question bank" in current page administration + | user | course | role | + | teacher | C1 | editingteacher | Scenario: Create an Essay question with Response format set to 'HTML editor' - When I add a "Essay" question filling the form with: + When I am on the "Course 1" "core_question > course question bank" page logged in as teacher + And I add a "Essay" question filling the form with: | Question name | essay-001 | | Question text | Write an essay with 500 words. | | General feedback | This is general feedback | @@ -27,7 +25,8 @@ Feature: Test creating an Essay question Then I should see "essay-001" Scenario: Create an Essay question with Response format set to 'HTML editor with the file picker' - When I add a "Essay" question filling the form with: + When I am on the "Course 1" "core_question > course question bank" page logged in as teacher + And I add a "Essay" question filling the form with: | Question name | essay-002 | | Question text | Write an essay with 500 words. | | General feedback | This is general feedback | @@ -36,7 +35,8 @@ Feature: Test creating an Essay question @javascript Scenario: Create an Essay question for testing some default options - When I add a "Essay" question filling the form with: + When I am on the "Course 1" "core_question > course question bank" page logged in as teacher + And I add a "Essay" question filling the form with: | Question name | essay-003 | | Question text | Write an essay with 500 words. | | General feedback | This is general feedback | @@ -48,10 +48,10 @@ Feature: Test creating an Essay question | id_maxbytes | 10240 | Then I should see "essay-003" # Checking that the next new question form displays user preferences settings. - When I press "Create a new question ..." + And I press "Create a new question ..." And I set the field "item_qtype_essay" to "1" And I click on "Add" "button" in the "Choose a question type to add" "dialogue" - Then the following fields match these values: + And the following fields match these values: | id_responseformat | editorfilepicker | | id_responserequired | 0 | | id_responsefieldlines | 15 | diff --git a/question/type/essay/tests/behat/backup_and_restore.feature b/question/type/essay/tests/behat/backup_and_restore.feature index fa540062cdb..2258c548353 100644 --- a/question/type/essay/tests/behat/backup_and_restore.feature +++ b/question/type/essay/tests/behat/backup_and_restore.feature @@ -23,17 +23,17 @@ Feature: Test duplicating a quiz containing an Essay question | essay-001 | 1 | | essay-002 | 1 | | essay-003 | 1 | - And I log in as "admin" - And I am on "Course 1" course homepage @javascript Scenario: Backup and restore a course containing 3 Essay questions - When I backup "Course 1" course using this options: + When I am on the "Course 1" course page logged in as admin + And I backup "Course 1" course using this options: | Confirmation | Filename | test_backup.mbz | 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 should see "essay-001" + | Schema | Course name | Course 2 | + | Schema | Course short name | C2 | + And I am on the "Course 2" "core_question > course question bank" page + Then I should see "essay-001" And I should see "essay-002" And I should see "essay-003" And I choose "Edit question" action for "essay-001" in the question bank diff --git a/question/type/essay/tests/behat/edit.feature b/question/type/essay/tests/behat/edit.feature index dd25a99dde8..8c2dc02ed05 100644 --- a/question/type/essay/tests/behat/edit.feature +++ b/question/type/essay/tests/behat/edit.feature @@ -6,14 +6,14 @@ Feature: Test editing an Essay question Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@example.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | + | user | course | role | + | teacher | C1 | editingteacher | And the following "question categories" exist: | contextlevel | reference | name | | Course | C1 | Test questions | @@ -22,22 +22,20 @@ Feature: Test editing an Essay question | Test questions | essay | essay-001 | editor | | Test questions | essay | essay-002 | editorfilepicker | | Test questions | essay | essay-003 | plain | - And I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Question bank" in current page administration Scenario: Edit an Essay question - When I choose "Edit question" action for "essay-001" in the question bank + When I am on the "Course 1" "core_question > course question bank" page logged in as teacher + And 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" - Then I should see "You must supply a value here." - When I set the following fields to these values: + And I should see "You must supply a value here." + And I set the following fields to these values: | Question name | Edited essay-001 name | | Response format | No online text | And I press "id_submitbutton" - Then I should see "When \"No online text\" is selected, or responses are optional, you must allow at least one attachment." - When I set the following fields to these values: + And I should see "When \"No online text\" is selected, or responses are optional, you must allow at least one attachment." + And I set the following fields to these values: | Response format | Plain text | And I press "id_submitbutton" Then I should see "Edited essay-001 name" diff --git a/question/type/essay/tests/behat/edit_min_max_fields.feature b/question/type/essay/tests/behat/edit_min_max_fields.feature index e3e7fbe213b..384d3db989b 100644 --- a/question/type/essay/tests/behat/edit_min_max_fields.feature +++ b/question/type/essay/tests/behat/edit_min_max_fields.feature @@ -1,66 +1,64 @@ @qtype @qtype_essay Feature: In an essay question, let the question author choose the min/max number of words for input text -In order to constrain student submissions for marking -As a teacher -I need to choose the appropriate minimum and/or maximum number of words for input text + In order to constrain student submissions for marking + As a teacher + I need to choose the appropriate minimum and/or maximum number of words for input text + Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@moodle.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | + | user | course | role | + | teacher | C1 | editingteacher | And the following "question categories" exist: | contextlevel | reference | name | | Course | C1 | Test questions | And the following "questions" exist: | questioncategory | qtype | name | template | minwordlimit | maxwordlimit | | Test questions | essay | essay-min-max | editor | 0 | 0 | - Given I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Question bank" in current page administration @javascript Scenario: Minimum/Maximum word limit are enabled but not set. - Given I choose "Edit question" action for "essay-min-max" in the question bank - When I set the field "minwordenabled" to "1" + When I am on the "essay-min-max" "core_question > edit" page logged in as teacher + And I set the field "minwordenabled" to "1" And I click on "Save changes" "button" Then I should see "Minimum word limit is enabled but is not set" @javascript Scenario: Minimum/Maximum word limit cannot be set to a negative number. - Given I choose "Edit question" action for "essay-min-max" in the question bank + When I am on the "essay-min-max" "core_question > edit" page logged in as teacher And I set the field "minwordenabled" to "1" - When I set the field "id_minwordlimit" to "-10" + And I set the field "id_minwordlimit" to "-10" And I click on "Save changes" "button" Then I should see "Minimum word limit cannot be a negative number" @javascript Scenario: Maximum word limit cannot be greater than minimum word limit. - Given I choose "Edit question" action for "essay-min-max" in the question bank + When I am on the "essay-min-max" "core_question > edit" page logged in as teacher And I set the field "minwordenabled" to "1" And I set the field "id_minwordlimit" to "500" And I set the field "maxwordenabled" to "1" - When I set the field "id_maxwordlimit" to "450" + And I set the field "id_maxwordlimit" to "450" And I click on "Save changes" "button" Then I should see "Maximum word limit must be greater than minimum word limit" @javascript Scenario: Modify the question to see 'Minimum word limit' and 'Maximum word limit' are hidden when 'Require text' field is set to 'Text input is optional' - Given I choose "Edit question" action for "essay-min-max" in the question bank + When I am on the "essay-min-max" "core_question > edit" page logged in as teacher And I should see "Minimum word limit" And I should see "Maximum word limit" - When I set the field "Require text" to "Text input is optional" + And I set the field "Require text" to "Text input is optional" Then I should not see "Minimum word limit" And I should not see "Minimum word limit" @javascript Scenario: Minimum/Maximum word limit can be unset after being set. - Given I choose "Edit question" action for "essay-min-max" in the question bank - When I set the following fields to these values: + When I am on the "essay-min-max" "core_question > edit" page logged in as teacher + And I set the following fields to these values: | minwordenabled | 1 | | id_minwordlimit | 100 | | maxwordenabled | 1 | diff --git a/question/type/essay/tests/behat/export.feature b/question/type/essay/tests/behat/export.feature index 2fb531197b2..e319fcdff44 100644 --- a/question/type/essay/tests/behat/export.feature +++ b/question/type/essay/tests/behat/export.feature @@ -6,14 +6,14 @@ Feature: Test exporting Essay questions Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@example.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | + | user | course | role | + | teacher | C1 | editingteacher | And the following "question categories" exist: | contextlevel | reference | name | | Course | C1 | Test questions | @@ -22,12 +22,9 @@ Feature: Test exporting Essay questions | Test questions | essay | essay-001 | editor | | Test questions | essay | essay-002 | editorfilepicker | | Test questions | essay | essay-003 | plain | - And I log in as "teacher1" - And I am on "Course 1" course homepage Scenario: Export 3 Essay questions - 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 press "Export questions to file" Then following "click here" should download between "3000" and "3500" bytes diff --git a/question/type/essay/tests/behat/file_type_restriction.feature b/question/type/essay/tests/behat/file_type_restriction.feature index b0351fb6677..9868575de3f 100644 --- a/question/type/essay/tests/behat/file_type_restriction.feature +++ b/question/type/essay/tests/behat/file_type_restriction.feature @@ -1,21 +1,21 @@ @qtype @qtype_essay Feature: In a essay question, limit submittable file types -In order to constrain student submissions for marking -As a teacher -I need to limit the submittable file types + In order to constrain student submissions for marking + As a teacher + I need to limit the submittable file types Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | Teacher | 1 | teacher1@example.com | - | student1 | Student | 1 | student0@example.com | + | username | + | teacher | + | student | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | - | student1 | C1 | student | + | user | course | role | + | teacher | C1 | editingteacher | + | student | C1 | student | And the following "question categories" exist: | contextlevel | reference | name | | Course | C1 | Test questions | @@ -31,20 +31,20 @@ I need to limit the submittable file types And the following "blocks" exist: | blockname | contextlevel | reference | pagetypepattern | defaultregion | | private_files | System | 1 | my-index | side-post | - Given I am on the "Quiz 1" "mod_quiz > edit" page logged in as teacher1 + Given I am on the "Quiz 1" "mod_quiz > edit" page logged in as teacher And I click on "Edit question TF1" "link" And I set the field "Allow attachments" to "1" And I set the field "Response format" to "No online text" And I set the field "Require attachments" to "1" And I set the field "filetypeslist[filetypes]" to ".txt" And I press "Save changes" - And I am on the "Quiz 1" "mod_quiz > edit" page logged in as teacher1 + And I am on the "Quiz 1" "mod_quiz > edit" page And I set the field "version" to "Always latest" Then I log out @javascript @_file_upload Scenario: Preview an Essay question and submit a response with a correct filetype. - When I log in as "student1" + When I log in as "student" And I follow "Manage private files" And I upload "lib/tests/fixtures/empty.txt" file to "Files" filemanager And I press "Save changes" @@ -62,7 +62,7 @@ I need to limit the submittable file types @javascript @_file_upload Scenario: Preview an Essay question and try to submit a response with an incorrect filetype. - When I log in as "student1" + When I log in as "student" And I follow "Manage private files" And I upload "lib/tests/fixtures/upload_users.csv" file to "Files" filemanager And I press "Save changes" diff --git a/question/type/essay/tests/behat/import.feature b/question/type/essay/tests/behat/import.feature index ea18fc8c88f..da3ed8b2139 100644 --- a/question/type/essay/tests/behat/import.feature +++ b/question/type/essay/tests/behat/import.feature @@ -6,21 +6,18 @@ Feature: Test importing Essay questions Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@example.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | - And I log in as "teacher1" - And I am on "Course 1" course homepage + | user | course | role | + | teacher | C1 | editingteacher | @javascript @_file_upload Scenario: import Essay question. - 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/type/essay/tests/fixtures/testquestion.moodle.xml" file to "Import" filemanager And I press "id_submitbutton" diff --git a/question/type/essay/tests/behat/max_file_size.feature b/question/type/essay/tests/behat/max_file_size.feature index 3d9d9d40de2..d7a2037c66b 100644 --- a/question/type/essay/tests/behat/max_file_size.feature +++ b/question/type/essay/tests/behat/max_file_size.feature @@ -1,18 +1,19 @@ @qtype @qtype_essay Feature: In an essay question, let the question author choose the maxbytes for attachments -In order to constrain student submissions for marking -As a teacher -I need to choose the appropriate maxbytes for attachments + In order to constrain student submissions for marking + As a teacher + I need to choose the appropriate maxbytes for attachments + Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@moodle.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | maxbytes | | Course 1 | C1 | 0 | 1048576 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | + | user | course | role | + | teacher | C1 | editingteacher | And the following "question categories" exist: | contextlevel | reference | name | | Course | C1 | Test questions | @@ -20,20 +21,15 @@ I need to choose the appropriate maxbytes for attachments | questioncategory | qtype | name | template | attachments | maxbytes | | Test questions | essay | essay-1-512KB | editor | 1 | 524288 | | Test questions | essay | essay-1-max | editor | 1 | 0 | - And I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Question bank" in current page administration @javascript @_switch_window Scenario: Preview an Essay question and see the allowed maximum file sizes and number of attachments. - When I choose "Preview" action for "essay-1-512KB" in the question bank + When I am on the "essay-1-512KB" "core_question > preview" page logged in as teacher Then I should see "Please write a story about a frog." And I should see "Maximum file size: 512 KB, maximum number of files: 1" - And I press "Close preview" @javascript @_switch_window Scenario: Preview an Essay question with Course upload limit and see the allowed maximum file size. - When I choose "Preview" action for "essay-1-max" in the question bank + When I am on the "essay-1-max" "core_question > preview" page logged in as teacher Then I should see "Please write a story about a frog." And I should see "Maximum file size: 1 MB, maximum number of files: 1" - And I press "Close preview" diff --git a/question/type/essay/tests/behat/preview.feature b/question/type/essay/tests/behat/preview.feature index 5c1f85d1a98..c71f983e5a0 100644 --- a/question/type/essay/tests/behat/preview.feature +++ b/question/type/essay/tests/behat/preview.feature @@ -6,14 +6,14 @@ Feature: Preview Essay questions Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@moodle.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | + | user | course | role | + | teacher | C1 | editingteacher | And the following "question categories" exist: | contextlevel | reference | name | | Course | C1 | Test questions | @@ -22,34 +22,28 @@ Feature: Preview Essay questions | Test questions | essay | essay-001 | editor | | Test questions | essay | essay-002 | editorfilepicker | | Test questions | essay | essay-003 | plain | - Given I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Question bank" in current page administration @javascript @_switch_window Scenario: Preview an Essay question that uses the HTML editor. - When I choose "Preview" action for "essay-001" in the question bank - And I press "Preview options" + When I am on the "essay-001" "core_question > preview" page logged in as teacher + And I expand all fieldsets And I set the field "How questions behave" to "Immediate feedback" And I press "Start again with these options" And I should see "Please write a story about a frog." - And I press "Close preview" @javascript @_switch_window Scenario: Preview an Essay question that uses the HTML editor with embedded files. - When I choose "Preview" action for "essay-002" in the question bank - And I press "Preview options" + When I am on the "essay-002" "core_question > preview" page logged in as teacher + And I expand all fieldsets And I set the field "How questions behave" to "Immediate feedback" And I press "Start again with these options" And I should see "Please write a story about a frog." And I should see "You can drag and drop files here to add them." - And I press "Close preview" @javascript @_switch_window Scenario: Preview an Essay question that uses a plain text area. - When I choose "Preview" action for "essay-003" in the question bank - And I press "Preview options" + When I am on the "essay-003" "core_question > preview" page logged in as teacher + And I expand all fieldsets And I set the field "How questions behave" to "Immediate feedback" And I press "Start again with these options" And I should see "Please write a story about a frog." - And I press "Close preview" diff --git a/question/type/gapselect/tests/behat/add.feature b/question/type/gapselect/tests/behat/add.feature index 0b6d50a5a8a..95fa34ac554 100644 --- a/question/type/gapselect/tests/behat/add.feature +++ b/question/type/gapselect/tests/behat/add.feature @@ -6,21 +6,19 @@ Feature: Test creating a Select missing words question Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@moodle.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | - And I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Question bank" in current page administration + | user | course | role | + | teacher | C1 | editingteacher | @javascript Scenario: Create a Select missing words question - Given I add a "Select missing words" question filling the form with: + When I am on the "Course 1" "core_question > course question bank" page logged in as teacher + And I add a "Select missing words" question filling the form with: | Question name | Select missing words 001 | | Question text | The [[1]] [[2]] on the [[3]]. | | General feedback | The cat sat on the mat. | @@ -32,10 +30,10 @@ Feature: Test creating a Select missing words question | id_choices_4_answer | table | | Hint 1 | First hint | | Hint 2 | Second hint | - And I should see "Select missing words 001" + Then I should see "Select missing words 001" # Checking that the next new question form displays user preferences settings. - When I press "Create a new question ..." + And I press "Create a new question ..." And I set the field "item_qtype_gapselect" to "1" And I click on "Add" "button" in the "Choose a question type to add" "dialogue" - Then the following fields match these values: + And the following fields match these values: | id_shuffleanswers | 1 | diff --git a/question/type/gapselect/tests/behat/basic_test.feature b/question/type/gapselect/tests/behat/basic_test.feature index 6b6a4acacc5..1f2df5eef0d 100644 --- a/question/type/gapselect/tests/behat/basic_test.feature +++ b/question/type/gapselect/tests/behat/basic_test.feature @@ -5,20 +5,18 @@ Feature: Test all the basic functionality of this question type Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@moodle.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | + | user | course | role | + | teacher | C1 | editingteacher | @javascript Scenario: Create, edit then preview a gapselect question. - Given 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 teacher # Create a new question. And I add a "Select missing words" question filling the form with: @@ -38,7 +36,7 @@ Feature: Test all the basic functionality of this question type Then I should see "Select missing words 001" # Preview it. - When I choose "Preview" action for "Select missing words 001" in the question bank + And I choose "Preview" action for "Select missing words 001" in the question bank # Gaps (drop-down menus) do not have labels. ids and names are generated # dynamically and therefore not reliable, i.e. this is an accessibility bug @@ -59,7 +57,7 @@ Feature: Test all the basic functionality of this question type And I set space "2" to "sat" in the select missing words question And I set space "3" to "mat" in the select missing words question And I press "Check" - Then I should see "Your answer is correct" + And I should see "Your answer is correct" And I should see "The cat sat on the mat" And I should see "The correct answer is: The [cat] [sat] on the [mat]." And I press "Start again" @@ -69,19 +67,19 @@ Feature: Test all the basic functionality of this question type And I set space "2" to "sat" in the select missing words question And I set space "3" to "dog" in the select missing words question And I press "Check" - Then I should see "Your answer is partially correct" + And I should see "Your answer is partially correct" And I should see "First hint" - When I press "Try again" + And I press "Try again" And I set space "3" to "table" in the select missing words question And I press "Check" - Then I should see "Your answer is partially correct" + And I should see "Your answer is partially correct" And I should see "Second hint" - When I press "Try again" + And I press "Try again" And I set space "3" to "mat" in the select missing words question And I press "Check" - Then I should see "Your answer is correct" + And I should see "Your answer is correct" And I should see "The cat sat on the mat" And I should see "The correct answer is: The [cat] [sat] on the [mat]." @@ -91,8 +89,8 @@ Feature: Test all the basic functionality of this question type And I press "Start again with these options" # Answer question correctly - When I press "Check" - Then I should see "Please put an answer in each box." + And I press "Check" + And I should see "Please put an answer in each box." And I set space "1" to "cat" in the select missing words question And I set space "2" to "sat" in the select missing words question And I set space "3" to "mat" in the select missing words question @@ -107,7 +105,7 @@ Feature: Test all the basic functionality of this question type And I set space "2" to "sat" in the select missing words question And I set space "3" to "cat" in the select missing words question And I press "Check" - Then I should see "Your answer is partially correct" + And I should see "Your answer is partially correct" And I should see "You have correctly selected 1." And I should see "The cat sat on the mat" And I should see "The correct answer is: The [cat] [sat] on the [mat]." @@ -118,25 +116,25 @@ Feature: Test all the basic functionality of this question type And I set space "2" to "ran" in the select missing words question And I set space "3" to "table" in the select missing words question And I press "Check" - Then I should see "Your answer is incorrect" + And I should see "Your answer is incorrect" And I should see "The cat sat on the mat" And I should see "The correct answer is: The [cat] [sat] on the [mat]." And I press "Close preview" # Backup the course and restore it. - When I log out + And I log out And I log in as "admin" - When I backup "Course 1" course using this options: + And I backup "Course 1" course using this options: | Confirmation | Filename | test_backup.mbz | - When I restore "test_backup.mbz" backup into a new course using this options: + And I restore "test_backup.mbz" backup into a new course using this options: | Schema | Course name | Course 2 | - Then I should see "Course 2" - When I navigate to "Question bank" in current page administration - Then I should see "Select missing words 001" + And I should see "Course 2" + And I navigate to "Question bank" in current page administration + And I should see "Select missing words 001" # Edit the copy and verify the form field contents. - When I choose "Edit question" action for "Select missing words 001" in the question bank - Then the following fields match these values: + And I choose "Edit question" action for "Select missing words 001" in the question bank + And the following fields match these values: | Question name | Select missing words 001 | | Question text | The [[1]] [[2]] on the [[3]]. | | General feedback | The cat sat on the mat. | @@ -153,4 +151,4 @@ Feature: Test all the basic functionality of this question type And I set the following fields to these values: | Question name | Edited question name | And I press "id_submitbutton" - Then I should see "Edited question name" + And I should see "Edited question name" diff --git a/question/type/gapselect/tests/behat/import_test.feature b/question/type/gapselect/tests/behat/import_test.feature index 6ef2c81b1c0..af9104c9b84 100644 --- a/question/type/gapselect/tests/behat/import_test.feature +++ b/question/type/gapselect/tests/behat/import_test.feature @@ -6,22 +6,19 @@ Feature: Import and export select missing words questions Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@moodle.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | - And I log in as "teacher1" - And I am on "Course 1" course homepage + | user | course | role | + | teacher | C1 | editingteacher | @javascript @_file_upload Scenario: Import and export select missing words questions # Import sample file. - 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/type/gapselect/tests/fixtures/testquestion.moodle.xml" file to "Import" filemanager And I press "id_submitbutton" @@ -32,12 +29,10 @@ Feature: Import and export select missing words questions And I should see "Imported Select missing words 001" # 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 + And 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 press "Export questions to file" - Then following "click here" should download between "1650" and "1800" bytes + And following "click here" should download between "1650" and "1800" bytes # If the download step is the last in the scenario then we can sometimes run # into the situation where the download page causes a http redirect but behat # has already conducted its reset (generating an error). By putting a logout diff --git a/question/type/match/tests/behat/add.feature b/question/type/match/tests/behat/add.feature index adb847a1598..fcccc363a1a 100644 --- a/question/type/match/tests/behat/add.feature +++ b/question/type/match/tests/behat/add.feature @@ -6,21 +6,19 @@ Feature: Test creating a Matching question Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@moodle.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | - And I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Question bank" in current page administration + | user | course | role | + | teacher | C1 | editingteacher | @javascript Scenario: Create a Matching question with 3 subquestions - When I add a "Matching" question filling the form with: + When I am on the "Course 1" "core_question > course question bank" page logged in as teacher + And I add a "Matching" question filling the form with: | Question name | match-001 | | Question text | Match the country with the capital city. | | General feedback | England=London, France=Paris and Spain=Madrid. | @@ -38,8 +36,8 @@ Feature: Test creating a Matching question | Hint 2 | This is your second hint | Then I should see "match-001" # Checking that the next new question form displays user preferences settings. - When I press "Create a new question ..." + And I press "Create a new question ..." And I set the field "item_qtype_match" to "1" And I click on "Add" "button" in the "Choose a question type to add" "dialogue" - Then the following fields match these values: + And the following fields match these values: | id_shuffleanswers | 0 | diff --git a/question/type/match/tests/behat/backup_and_restore.feature b/question/type/match/tests/behat/backup_and_restore.feature index 5b9841b3d0d..da3365a1a55 100644 --- a/question/type/match/tests/behat/backup_and_restore.feature +++ b/question/type/match/tests/behat/backup_and_restore.feature @@ -19,16 +19,16 @@ Feature: Test duplicating a quiz containing a Matching question | quiz | Test quiz | C1 | quiz1 | And quiz "Test quiz" contains the following questions: | matching-001 | 1 | - And I log in as "admin" - And I am on "Course 1" course homepage @javascript Scenario: Backup and restore a course containing a Matching question - When I backup "Course 1" course using this options: + When I am on the "Course 1" course page logged in as admin + And I backup "Course 1" course using this options: | Confirmation | Filename | test_backup.mbz | 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 + | Schema | Course name | Course 2 | + | Schema | Course short name | C2 | + And I am on the "Course 2" "core_question > course question bank" page And I choose "Edit question" action for "matching-001" in the question bank Then the following fields match these values: | Question name | matching-001 | diff --git a/question/type/match/tests/behat/edit.feature b/question/type/match/tests/behat/edit.feature index 0033ab46ae2..70a10faa9f1 100644 --- a/question/type/match/tests/behat/edit.feature +++ b/question/type/match/tests/behat/edit.feature @@ -6,44 +6,41 @@ Feature: Test editing a Matching question Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@example.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | + | user | course | role | + | teacher | C1 | editingteacher | And the following "question categories" exist: | contextlevel | reference | name | | Course | C1 | Test questions | And the following "questions" exist: | questioncategory | qtype | name | template | | Test questions | match | Matching for editing | foursubq | - And I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Question bank" in current page administration @javascript @_switch_window Scenario: Edit a Matching question - When I choose "Edit question" action for "Matching for editing" in the question bank + When I am on the "Matching for editing" "core_question > edit" page logged in as teacher And I set the following fields to these values: | Question name | | And I press "id_submitbutton" - Then I should see "You must supply a value here." - When I set the following fields to these values: + And I should see "You must supply a value here." + And I set the following fields to these values: | Question name | Edited Matching name | And I press "id_submitbutton" - Then I should see "Edited Matching name" - When I choose "Edit question" action for "Edited Matching name" in the question bank + And I should see "Edited Matching name" + And 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 choose "Preview" action for "Edited Matching name" in the question bank - Then I should see "frog" + And I choose "Preview" action for "Edited Matching name" in the question bank + And I should see "frog" And I should see "dog" And I should see "newt" And I should see "fly" diff --git a/question/type/match/tests/behat/export.feature b/question/type/match/tests/behat/export.feature index aba921421fd..6d28231d648 100644 --- a/question/type/match/tests/behat/export.feature +++ b/question/type/match/tests/behat/export.feature @@ -6,26 +6,23 @@ Feature: Test exporting Matching questions Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@example.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | + | user | course | role | + | teacher | C1 | editingteacher | And the following "question categories" exist: | contextlevel | reference | name | | Course | C1 | Test questions | And the following "questions" exist: | questioncategory | qtype | name | template | | Test questions | match | matching-001 | foursubq | - And I log in as "teacher1" - And I am on "Course 1" course homepage Scenario: Export a Matching question - 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 press "Export questions to file" Then following "click here" should download between "1600" and "1750" bytes diff --git a/question/type/match/tests/behat/import.feature b/question/type/match/tests/behat/import.feature index 75fe19338fe..644e71d9357 100644 --- a/question/type/match/tests/behat/import.feature +++ b/question/type/match/tests/behat/import.feature @@ -6,21 +6,18 @@ Feature: Test importing Matching questions Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@example.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | - And I log in as "teacher1" - And I am on "Course 1" course homepage + | user | course | role | + | teacher | C1 | editingteacher | @javascript @_file_upload Scenario: import Matching question. - 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/type/match/tests/fixtures/testquestion.moodle.xml" file to "Import" filemanager And I press "id_submitbutton" diff --git a/question/type/match/tests/behat/preview.feature b/question/type/match/tests/behat/preview.feature index 3b60dc3a5f2..d9a2ff1a6a4 100644 --- a/question/type/match/tests/behat/preview.feature +++ b/question/type/match/tests/behat/preview.feature @@ -6,74 +6,56 @@ Feature: Preview a Matching question Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@moodle.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | + | user | course | role | + | teacher | C1 | editingteacher | And the following "question categories" exist: | contextlevel | reference | name | | Course | C1 | Test questions | And the following "questions" exist: - | questioncategory | qtype | name | template | - | Test questions | match | matching-001 | foursubq | - Given I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Question bank" in current page administration + | questioncategory | qtype | name | template | shuffleanswers | + | Test questions | match | matching-001 | foursubq | 0 | @javascript @_switch_window Scenario: Preview a Matching question and submit a correct response. - 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 choose "Preview" action for "matching-001" in the question bank - And I press "Preview options" + When I am on the "matching-001" "core_question > preview" page logged in as teacher + And I expand all fieldsets And I set the field "How questions behave" to "Immediate feedback" And I press "Start again with these options" - And I set the field with xpath "//table[@class='answer']//td[@class='control']//select[contains(@id, '1_sub0')]" to "amphibian" - And I set the field with xpath "//table[@class='answer']//td[@class='control']//select[contains(@id, '1_sub1')]" to "mammal" - And I set the field with xpath "//table[@class='answer']//td[@class='control']//select[contains(@id, '1_sub2')]" to "amphibian" + And I set the field "Answer 1" to "amphibian" + And I set the field "Answer 2" to "mammal" + And I set the field "Answer 3" to "amphibian" And I press "Check" Then I should see "Well done!" And I should see "General feedback." - And I press "Close preview" @javascript @_switch_window Scenario: Preview a Matching question and submit a partially correct response. - 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 choose "Preview" action for "matching-001" in the question bank - And I press "Preview options" + When I am on the "matching-001" "core_question > preview" page logged in as teacher + And I expand all fieldsets And I set the field "How questions behave" to "Immediate feedback" And I press "Start again with these options" - And I set the field with xpath "//table[@class='answer']//td[@class='control']//select[contains(@id, '1_sub0')]" to "amphibian" - And I set the field with xpath "//table[@class='answer']//td[@class='control']//select[contains(@id, '1_sub1')]" to "insect" - And I set the field with xpath "//table[@class='answer']//td[@class='control']//select[contains(@id, '1_sub2')]" to "amphibian" + And I set the field "Answer 1" to "amphibian" + And I set the field "Answer 2" to "insect" + And I set the field "Answer 3" to "amphibian" And I press "Check" Then I should see "Parts, but only parts, of your response are correct." And I should see "General feedback." - And I press "Close preview" @javascript @_switch_window Scenario: Preview a Matching question and submit an incorrect response. - 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 choose "Preview" action for "matching-001" in the question bank - And I press "Preview options" + When I am on the "matching-001" "core_question > preview" page logged in as teacher + And I expand all fieldsets And I set the field "How questions behave" to "Immediate feedback" And I press "Start again with these options" - And I set the field with xpath "//table[@class='answer']//td[@class='control']//select[contains(@id, '1_sub0')]" to "mammal" - And I set the field with xpath "//table[@class='answer']//td[@class='control']//select[contains(@id, '1_sub1')]" to "insect" - And I set the field with xpath "//table[@class='answer']//td[@class='control']//select[contains(@id, '1_sub2')]" to "insect" + And I set the field "Answer 1" to "mammal" + And I set the field "Answer 2" to "insect" + And I set the field "Answer 3" to "insect" And I press "Check" Then I should see "That is not right at all." And I should see "General feedback." - And I press "Close preview" diff --git a/question/type/multianswer/tests/behat/add.feature b/question/type/multianswer/tests/behat/add.feature index f371d7e3ac0..b4b863e7254 100644 --- a/question/type/multianswer/tests/behat/add.feature +++ b/question/type/multianswer/tests/behat/add.feature @@ -6,33 +6,32 @@ Feature: Test creating a Multianswer (Cloze) question Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@moodle.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | - And I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Question bank" in current page administration + | user | course | role | + | teacher | C1 | editingteacher | Scenario: Create a Cloze question - When I add a "Embedded answers (Cloze)" question filling the form with: + When I am on the "Course 1" "core_question > course question bank" page logged in as teacher + And I add a "Embedded answers (Cloze)" question filling the form with: | Question name | multianswer-001 | | Question text | {1:SHORTANSWER:=Berlin} is the capital of Germany. | | General feedback | The capital of Germany is Berlin. | Then I should see "multianswer-001" in the "categoryquestions" "table" Scenario: Create a broken Cloze question and correct it - Given I press "Create a new question ..." + When I am on the "Course 1" "core_question > course question bank" page logged in as teacher + And I press "Create a new question ..." And I set the field "Embedded answers (Cloze)" to "1" And I press "Add" And I set the field "Question name" to "multianswer-002" And I set the field "Question text" to "Please select the fruits {1:MULTICHOICE:=Apple#Correct}" And I set the field "General feedback" to "Apple are delicious." - When I press "id_submitbutton" + And I press "id_submitbutton" Then I should see "This type of question requires at least 2 choices" And I set the following fields to these values: | Question text | Please select the fruits {1:MULTICHOICE:=Apple#Correct~Banana#Wrong} | @@ -40,11 +39,12 @@ Feature: Test creating a Multianswer (Cloze) question And I should see "multianswer-002" in the "categoryquestions" "table" Scenario: Try to create a Cloze question that has no answer - Given I press "Create a new question ..." + When I am on the "Course 1" "core_question > course question bank" page logged in as teacher + And I press "Create a new question ..." And I set the field "Embedded answers (Cloze)" to "1" And I press "Add" And I set the following fields to these values: | Question name | multianswer-003 | | Question text | {1:SHORTANSWER:= } is the capital of Germany. | And I press "id_submitbutton" - And I should see "This type of question requires at least 1 answers" + Then I should see "This type of question requires at least 1 answers" diff --git a/question/type/multichoice/tests/behat/add.feature b/question/type/multichoice/tests/behat/add.feature index ebd8467eff2..75adf64c836 100644 --- a/question/type/multichoice/tests/behat/add.feature +++ b/question/type/multichoice/tests/behat/add.feature @@ -6,20 +6,18 @@ Feature: Test creating a Multiple choice question Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@moodle.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | - And I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Question bank" in current page administration + | user | course | role | + | teacher | C1 | editingteacher | Scenario: Create a Multiple choice question with multiple response - When I add a "Multiple choice" question filling the form with: + When I am on the "Course 1" "core_question > course question bank" page logged in as teacher + And I add a "Multiple choice" question filling the form with: | Question name | Multi-choice-001 | | Question text | Find the capital cities in Europe. | | General feedback | Paris and London | @@ -40,7 +38,8 @@ Feature: Test creating a Multiple choice question @javascript Scenario: Create a Multiple choice question with single response - Given I add a "Multiple choice" question filling the form with: + When I am on the "Course 1" "core_question > course question bank" page logged in as teacher + And I add a "Multiple choice" question filling the form with: | Question name | Multi-choice-002 | | Question text | Find the capital city of England. | | General feedback | London is the capital city of England. | @@ -61,12 +60,12 @@ Feature: Test creating a Multiple choice question | id_fraction_4 | None | | Hint 1 | First hint | | Hint 2 | Second hint | - And I should see "Multi-choice-002" + Then I should see "Multi-choice-002" # Checking that the next new question form displays user preferences settings. - When I press "Create a new question ..." + And I press "Create a new question ..." And I set the field "Multiple choice" to "1" And I click on "Add" "button" in the "Choose a question type to add" "dialogue" - Then the following fields match these values: + And the following fields match these values: | Default mark | 5 | | One or multiple answers? | One answer only | | Shuffle the choices? | 0 | diff --git a/question/type/multichoice/tests/behat/backup_and_restore.feature b/question/type/multichoice/tests/behat/backup_and_restore.feature index afc1c2ad268..2a7efb17899 100644 --- a/question/type/multichoice/tests/behat/backup_and_restore.feature +++ b/question/type/multichoice/tests/behat/backup_and_restore.feature @@ -19,16 +19,16 @@ Feature: Test duplicating a quiz containing a Multiple choice question | quiz | Test quiz | C1 | quiz1 | And quiz "Test quiz" contains the following questions: | Multi-choice-001 | 1 | - And I log in as "admin" - And I am on "Course 1" course homepage @javascript Scenario: Backup and restore a course containing a Multiple choice question - When I backup "Course 1" course using this options: + When I am on the "Course 1" course page logged in as admin + And I backup "Course 1" course using this options: | Confirmation | Filename | test_backup.mbz | 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 + | Schema | Course name | Course 2 | + | Schema | Course short name | C2 | + And I am on the "Course 2" "core_question > course question bank" page 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 | diff --git a/question/type/multichoice/tests/behat/clearanswers.feature b/question/type/multichoice/tests/behat/clearanswers.feature index 75f2f4c6152..d63cb068eed 100644 --- a/question/type/multichoice/tests/behat/clearanswers.feature +++ b/question/type/multichoice/tests/behat/clearanswers.feature @@ -6,15 +6,15 @@ Feature: Clear my answers Background: Given the following "users" exist: - | username | firstname | lastname | email | - | student1 | S1 | Student1 | student1@moodle.com | + | username | + | student | And the following "course" exists: | fullname | Course 1 | | shortname | C1 | | category | 0 | And the following "course enrolments" exist: - | user | course | role | - | student1 | C1 | student | + | user | course | role | + | student | C1 | student | And the following "question category" exists: | contextlevel | Course | | reference | C1 | @@ -39,7 +39,7 @@ Feature: Clear my answers @javascript Scenario: Attempt a quiz and reset my chosen answer. - Given I am on the "Quiz 1" "quiz activity" page logged in as student1 + Given I am on the "Quiz 1" "quiz activity" page logged in as student When I press "Attempt quiz" And I should see "Question One" And I click on "Four" "qtype_multichoice > Answer" in the "Question One" "question" @@ -51,7 +51,7 @@ Feature: Clear my answers @javascript Scenario: Attempt a quiz and revisit a cleared answer. - Given I am on the "Quiz 1" "quiz activity" page logged in as student1 + Given I am on the "Quiz 1" "quiz activity" page logged in as student When I press "Attempt quiz" And I should see "Question One" And I click on "Four" "qtype_multichoice > Answer" in the "Question One" "question" diff --git a/question/type/multichoice/tests/behat/edit.feature b/question/type/multichoice/tests/behat/edit.feature index ad50bee4b0a..e7b052576fb 100644 --- a/question/type/multichoice/tests/behat/edit.feature +++ b/question/type/multichoice/tests/behat/edit.feature @@ -6,14 +6,14 @@ Feature: Test editing a Multiple choice question Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@example.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | + | user | course | role | + | teacher | C1 | editingteacher | And the following "question categories" exist: | contextlevel | reference | name | | Course | C1 | Test questions | @@ -21,23 +21,20 @@ Feature: Test editing a Multiple choice question | questioncategory | qtype | name | template | | Test questions | multichoice | Multiple choice for editing | two_of_four | | Test questions | multichoice | Single choice for editing | one_of_four | - And I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Question bank" in current page administration Scenario: Edit a Multiple choice question with multiple response (checkboxes) - When I choose "Edit question" action for "Multiple choice for editing" in the question bank + When I am on the "Multiple choice for editing" "core_question > edit" page logged in as teacher And I set the following fields to these values: | Question name | | And I press "id_submitbutton" - Then I should see "You must supply a value here." - When I set the following fields to these values: + And I should see "You must supply a value here." + And I set the following fields to these values: | Question name | Edited Multiple choice name | And I press "id_submitbutton" Then I should see "Edited Multiple choice name" Scenario: Edit a Multiple choice question with single response (radio buttons) - When I choose "Edit question" action for "Single choice for editing" in the question bank + When I am on the "Single choice for editing" "core_question > edit" page logged in as teacher 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/export.feature b/question/type/multichoice/tests/behat/export.feature index aa48ea4526e..46fd6fec542 100644 --- a/question/type/multichoice/tests/behat/export.feature +++ b/question/type/multichoice/tests/behat/export.feature @@ -6,14 +6,14 @@ Feature: Test exporting Multiple choice questions Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@example.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | + | user | course | role | + | teacher | C1 | editingteacher | And the following "question categories" exist: | contextlevel | reference | name | | Course | C1 | Test questions | @@ -21,12 +21,9 @@ Feature: Test exporting Multiple choice questions | 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: Export a Multiple choice question - 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 press "Export questions to file" Then following "click here" should download between "3900" and "4100" bytes diff --git a/question/type/multichoice/tests/behat/import.feature b/question/type/multichoice/tests/behat/import.feature index 31482f1d533..71dfcb79c99 100644 --- a/question/type/multichoice/tests/behat/import.feature +++ b/question/type/multichoice/tests/behat/import.feature @@ -6,21 +6,18 @@ Feature: Test importing Multiple choice questions Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@example.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | - And I log in as "teacher1" - And I am on "Course 1" course homepage + | user | course | role | + | teacher | C1 | editingteacher | @javascript @_file_upload Scenario: import Multiple choice question. - 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/type/multichoice/tests/fixtures/testquestion.moodle.xml" file to "Import" filemanager And I press "id_submitbutton" diff --git a/question/type/multichoice/tests/behat/preview.feature b/question/type/multichoice/tests/behat/preview.feature index b49c2a30501..649241b76ae 100644 --- a/question/type/multichoice/tests/behat/preview.feature +++ b/question/type/multichoice/tests/behat/preview.feature @@ -6,14 +6,14 @@ Feature: Preview a Multiple choice question Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@moodle.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | + | user | course | role | + | teacher | C1 | editingteacher | And the following "question categories" exist: | contextlevel | reference | name | | Course | C1 | Test questions | @@ -21,14 +21,11 @@ Feature: Preview a Multiple choice question | questioncategory | qtype | name | template | | Test questions | multichoice | Multi-choice-001 | two_of_four | | Test questions | multichoice | Multi-choice-002 | one_of_four | - Given I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Question bank" in current page administration @javascript @_switch_window Scenario: Preview a Multiple choice question and submit a partially correct response. - When I choose "Preview" action for "Multi-choice-001" in the question bank - And I press "Preview options" + When I am on the "Multi-choice-001" "core_question > preview" page logged in as teacher + And I expand all fieldsets And I set the field "How questions behave" to "Immediate feedback" And I press "Start again with these options" And I click on "One" "qtype_multichoice > Answer" @@ -38,12 +35,11 @@ Feature: Preview a Multiple choice question And I should see "Two is even" And I should see "Mark 0.50 out of 1.00" And I should see "Parts, but only parts, of your response are correct." - And I press "Close preview" @javascript @_switch_window Scenario: Preview a Multiple choice question and submit a correct response. - When I choose "Preview" action for "Multi-choice-001" in the question bank - And I press "Preview options" + When I am on the "Multi-choice-001" "core_question > preview" page logged in as teacher + And I expand all fieldsets And I set the field "How questions behave" to "Immediate feedback" And I press "Start again with these options" And I click on "One" "qtype_multichoice > Answer" @@ -55,12 +51,11 @@ Feature: Preview a Multiple choice question And I should see "Well done!" And I should see "The odd numbers are One and Three." And I should see "The correct answers are: One, Three" - And I press "Close preview" @javascript @_switch_window Scenario: Preview a Multiple choice question and submit a correct response. - When I choose "Preview" action for "Multi-choice-002" in the question bank - And I press "Preview options" + When I am on the "Multi-choice-002" "core_question > preview" page logged in as teacher + And I expand all fieldsets And I set the field "How questions behave" to "Immediate feedback" And I press "Start again with these options" And I click on "One" "qtype_multichoice > Answer" @@ -69,16 +64,14 @@ Feature: Preview a Multiple choice question And I should see "Mark 1.00 out of 1.00" And I should see "Well done!" And I should see "The correct answer is: One" - And I press "Close preview" @javascript @_switch_window Scenario: Preview a multiple choice question (single response) and clear a previous selected option. - When I choose "Preview" action for "Multi-choice-002" in the question bank - And I press "Preview options" + When I am on the "Multi-choice-002" "core_question > preview" page logged in as teacher + And I expand all fieldsets And I set the field "How questions behave" to "Immediate feedback" And I press "Start again with these options" And I click on "One" "qtype_multichoice > Answer" Then I should see "Clear my choice" And I click on "Clear my choice" "text" And I should not see "Clear my choice" - And I press "Close preview" diff --git a/question/type/numerical/tests/behat/add.feature b/question/type/numerical/tests/behat/add.feature index 83da6e3861f..6444da83c6a 100644 --- a/question/type/numerical/tests/behat/add.feature +++ b/question/type/numerical/tests/behat/add.feature @@ -6,23 +6,21 @@ Feature: Test creating a Numerical question Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@example.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | + | user | course | role | + | teacher | C1 | editingteacher | And the following "language customisations" exist: | component | stringid | value | | core_langconfig | decsep | # | - And I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Question bank" in current page administration Scenario: Create a Numerical question - When I add a "Numerical" question filling the form with: + When I am on the "Course 1" "core_question > course question bank" page logged in as teacher + And I add a "Numerical" question filling the form with: | Question name | Numerical-001 | | Question text | What is the average of 4, 5, 6 and 10? | | Default mark | 1 | @@ -40,7 +38,8 @@ Feature: Test creating a Numerical question @javascript Scenario: Create a Numerical question with units - Given I add a "Numerical" question filling the form with: + When I am on the "Course 1" "core_question > course question bank" page logged in as teacher + And I add a "Numerical" question filling the form with: | Question name | Numerical-002 | | Question text | How many meter is 1m + 20cm + 50mm? | | Default mark | 1 | @@ -60,12 +59,12 @@ Feature: Test creating a Numerical question | id_unitsleft | on the right, for example 1.00cm or 1.00km | | id_multichoicedisplay | a drop-down menu | | id_unit_0 | m | - And I should see "Numerical-002" + Then I should see "Numerical-002" # Checking that the next new question form displays user preferences settings. - When I press "Create a new question ..." + And I press "Create a new question ..." And I set the field "item_qtype_numerical" to "1" And I click on "Add" "button" in the "Choose a question type to add" "dialogue" - Then the following fields match these values: + And the following fields match these values: | id_unitrole | The unit must be given, and will be graded. | | id_unitpenalty | 0#15 | | id_unitgradingtypes | as a fraction (0-1) of the question grade | diff --git a/question/type/numerical/tests/behat/backup_and_restore.feature b/question/type/numerical/tests/behat/backup_and_restore.feature index 293a942782b..291c5e9355d 100644 --- a/question/type/numerical/tests/behat/backup_and_restore.feature +++ b/question/type/numerical/tests/behat/backup_and_restore.feature @@ -19,16 +19,16 @@ Feature: Test duplicating a quiz containing a Numerical question | quiz | Test quiz | C1 | quiz1 | And quiz "Test quiz" contains the following questions: | Numerical-001 | 1 | - And I log in as "admin" - And I am on "Course 1" course homepage @javascript Scenario: Backup and restore a course containing a Numerical question - When I backup "Course 1" course using this options: + When I am on the "Course 1" course page logged in as admin + And I backup "Course 1" course using this options: | Confirmation | Filename | test_backup.mbz | 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 + | Schema | Course name | Course 2 | + | Schema | Course short name | C2 | + And I am on the "Course 2" "core_question > course question bank" page And I choose "Edit question" action for "Numerical-001" in the question bank Then the following fields match these values: | Question name | Numerical-001 | diff --git a/question/type/numerical/tests/behat/edit.feature b/question/type/numerical/tests/behat/edit.feature index ea9691983a3..a70da10c6ed 100644 --- a/question/type/numerical/tests/behat/edit.feature +++ b/question/type/numerical/tests/behat/edit.feature @@ -6,39 +6,36 @@ Feature: Test editing a Numerical question Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@example.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | + | user | course | role | + | teacher | C1 | editingteacher | And the following "question categories" exist: | contextlevel | reference | name | | Course | C1 | Test questions | And the following "questions" exist: | questioncategory | qtype | name | template | - | Test questions | numerical | Numerical for editing | pi | + | Test questions | numerical | Numerical for editing | pi | Scenario: Edit a Numerical question when using a custom decimal separator Given the following "language customisations" exist: | component | stringid | value | | core_langconfig | decsep | # | - And 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 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: + When I am on the "Numerical for editing" "core_question > edit" page logged in as teacher + And the field "id_answer_0" matches value "3#14" + And I set the following fields to these values: | Question name | | And I press "id_submitbutton" - Then I should see "You must supply a value here." - When I set the following fields to these values: + And I should see "You must supply a value here." + And I set the following fields to these values: | Question name | Edited Numerical name | And I press "id_submitbutton" Then I should see "Edited Numerical name" - When I choose "Edit question" action for "Edited Numerical name" in the question bank + And 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 | @@ -46,13 +43,10 @@ Feature: Test editing a Numerical question | id_tolerance_2 | 0.005 | | id_answer_3 | 3,01 | And I press "id_submitbutton" - Then I should see "Edited Numerical name" + And I should see "Edited Numerical name" Scenario: Edit a Numerical question with very small answer - Given 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 choose "Edit question" action for "Numerical for editing" in the question bank + When I am on the "Numerical for editing" "core_question > edit" page logged in as teacher And I set the following fields to these values: | id_answer_0 | 0.00000123456789 | | id_tolerance_1 | 0.0000123456789 | diff --git a/question/type/numerical/tests/behat/export.feature b/question/type/numerical/tests/behat/export.feature index ee700662eda..df9728ab09f 100644 --- a/question/type/numerical/tests/behat/export.feature +++ b/question/type/numerical/tests/behat/export.feature @@ -6,14 +6,14 @@ Feature: Test exporting Numerical questions Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@example.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | + | user | course | role | + | teacher | C1 | editingteacher | And the following "question categories" exist: | contextlevel | reference | name | | Course | C1 | Test questions | @@ -21,12 +21,9 @@ Feature: Test exporting Numerical questions | questioncategory | qtype | name | template | | Test questions | numerical | Numerical-001 | pi | | Test questions | numerical | Numerical-002 | pi3tries | - And I log in as "teacher1" - And I am on "Course 1" course homepage Scenario: Export a Numerical question - 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 press "Export questions to file" Then following "click here" should download between "3650" and "3750" bytes diff --git a/question/type/numerical/tests/behat/import.feature b/question/type/numerical/tests/behat/import.feature index 9135e85c20a..53ccb7c5624 100644 --- a/question/type/numerical/tests/behat/import.feature +++ b/question/type/numerical/tests/behat/import.feature @@ -6,21 +6,18 @@ Feature: Test importing Numerical questions Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@example.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | - And I log in as "teacher1" - And I am on "Course 1" course homepage + | user | course | role | + | teacher | C1 | editingteacher | @javascript @_file_upload Scenario: import Numerical question. - 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/type/numerical/tests/fixtures/testquestion.moodle.xml" file to "Import" filemanager And I press "id_submitbutton" diff --git a/question/type/numerical/tests/behat/preview.feature b/question/type/numerical/tests/behat/preview.feature index ca8b5a4c07a..d6c595a9a9f 100644 --- a/question/type/numerical/tests/behat/preview.feature +++ b/question/type/numerical/tests/behat/preview.feature @@ -6,14 +6,14 @@ Feature: Preview a Numerical question Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@example.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | + | user | course | role | + | teacher | C1 | editingteacher | And the following "question categories" exist: | contextlevel | reference | name | | Course | C1 | Test questions | @@ -24,28 +24,24 @@ Feature: Preview a Numerical question And the following "language customisations" exist: | component | stringid | value | | core_langconfig | decsep | # | - Given I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Question bank" in current page administration @javascript @_switch_window Scenario: Preview a Numerical question and submit a correct response. - When I choose "Preview" action for "Numerical-001" in the question bank - Then I should see "What is pi to two d.p.?" - And I press "Preview options" - When I set the field "How questions behave" to "Immediate feedback" + When I am on the "Numerical-001" "core_question > preview" page logged in as teacher + And I should see "What is pi to two d.p.?" + And I expand all fieldsets + And I set the field "How questions behave" to "Immediate feedback" And I press "Start again with these options" And I set the field with xpath "//span[@class='answer']//input[contains(@id, '1_answer')]" to "3.14" And I press "Check" Then I should see "Very good." And I should see "Mark 1#00 out of 1#00" - When I press "Start again" + And I press "Start again" And I set the field with xpath "//span[@class='answer']//input[contains(@id, '1_answer')]" to "3,14" And I press "Check" - Then I should see "Please enter your answer without using the thousand separator (,)." - When I press "Start again" + And I should see "Please enter your answer without using the thousand separator (,)." + And I press "Start again" And I set the field with xpath "//span[@class='answer']//input[contains(@id, '1_answer')]" to "3#14" And I press "Check" - Then I should see "Very good." + And I should see "Very good." And I should see "Mark 1#00 out of 1#00" - And I press "Close preview" diff --git a/question/type/shortanswer/tests/behat/add.feature b/question/type/shortanswer/tests/behat/add.feature index 100ae4425e8..17e547bcd2f 100644 --- a/question/type/shortanswer/tests/behat/add.feature +++ b/question/type/shortanswer/tests/behat/add.feature @@ -6,21 +6,19 @@ Feature: Test creating a Short answer question Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@moodle.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | - And I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Question bank" in current page administration + | user | course | role | + | teacher | C1 | editingteacher | @javascript Scenario: Create a Short answer question - Given I add a "Short answer" question filling the form with: + When I am on the "Course 1" "core_question > course question bank" page logged in as teacher + And I add a "Short answer" question filling the form with: | Question name | shortanswer-001 | | Question text | What is the national langauge in France? | | General feedback | The national langauge in France is French | @@ -32,10 +30,10 @@ Feature: Test creating a Short answer question | id_answer_1 | * | | id_fraction_1 | None | | id_feedback_1 | Your answer is incorrect. | - And I should see "shortanswer-001" + Then I should see "shortanswer-001" # Checking that the next new question form displays user preferences settings. - When I press "Create a new question ..." + And I press "Create a new question ..." And I set the field "Short answer" to "1" And I click on "Add" "button" in the "Choose a question type to add" "dialogue" - Then the following fields match these values: + And the following fields match these values: | Case sensitivity | Yes, case must match | diff --git a/question/type/shortanswer/tests/behat/backup_and_restore.feature b/question/type/shortanswer/tests/behat/backup_and_restore.feature index d8f2c606e00..cba24f0d8e9 100644 --- a/question/type/shortanswer/tests/behat/backup_and_restore.feature +++ b/question/type/shortanswer/tests/behat/backup_and_restore.feature @@ -19,16 +19,16 @@ Feature: Test duplicating a quiz containing a Short answer question | quiz | Test quiz | C1 | quiz1 | And quiz "Test quiz" contains the following questions: | shortanswer-001 | 1 | - And I log in as "admin" - And I am on "Course 1" course homepage @javascript Scenario: Backup and restore a course containing a Short answer question - When I backup "Course 1" course using this options: + When I am on the "Course 1" course page logged in as admin + And I backup "Course 1" course using this options: | Confirmation | Filename | test_backup.mbz | 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 + | Schema | Course name | Course 2 | + | Schema | Course short name | C2 | + And I am on the "Course 2" "core_question > course question bank" page And I choose "Edit question" action for "shortanswer-001" in the question bank Then the following fields match these values: | Question name | shortanswer-001 | diff --git a/question/type/shortanswer/tests/behat/edit.feature b/question/type/shortanswer/tests/behat/edit.feature index ccca1e979fa..b41be8a7bcd 100644 --- a/question/type/shortanswer/tests/behat/edit.feature +++ b/question/type/shortanswer/tests/behat/edit.feature @@ -6,50 +6,47 @@ Feature: Test editing a Short answer question Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@example.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | + | user | course | role | + | teacher | C1 | editingteacher | And the following "question categories" exist: | contextlevel | reference | name | | Course | C1 | Test questions | And the following "questions" exist: | questioncategory | qtype | name | template | | Test questions | shortanswer | shortanswer-001 for editing | frogtoad | - And I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Question bank" in current page administration @javascript @_switch_window Scenario: Edit a Short answer question - When I choose "Edit question" action for "shortanswer-001" in the question bank + When I am on the "shortanswer-001 for editing" "core_question > edit" page logged in as teacher And I set the following fields to these values: | Question name | | And I press "id_submitbutton" - Then I should see "You must supply a value here." - When I set the following fields to these values: + And I should see "You must supply a value here." + And I set the following fields to these values: | Question name | Edited shortanswer-001 name | And I press "id_submitbutton" Then I should see "Edited shortanswer-001 name" - When I choose "Edit question" action for "Edited shortanswer-001" in the question bank + And 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 choose "Preview" action for "Edited shortanswer-001" in the question bank - Then I should see "Name an amphibian:" + And I should see "Edited shortanswer-001 name" + And I choose "Preview" action for "Edited shortanswer-001" in the question bank + And I should see "Name an amphibian:" # Set behaviour options And I set the following fields to these values: | behaviour | immediatefeedback | And I press "Start again with these options" And I set the field with xpath "//div[@class='qtext']//input[contains(@id, '1_answer')]" to "newt" And I press "Check" - Then I should see "Newt is an OK good answer." + And I should see "Newt is an OK good answer." And I should see "Generalfeedback: frog or toad would have been OK." And I should see "The correct answer is: frog" diff --git a/question/type/shortanswer/tests/behat/export.feature b/question/type/shortanswer/tests/behat/export.feature index 4cc9edefc7a..04f4a5fb262 100644 --- a/question/type/shortanswer/tests/behat/export.feature +++ b/question/type/shortanswer/tests/behat/export.feature @@ -6,26 +6,23 @@ Feature: Test exporting Short answer questions Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@example.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | + | user | course | role | + | teacher | C1 | editingteacher | And the following "question categories" exist: | contextlevel | reference | name | | Course | C1 | Test questions | And the following "questions" exist: | questioncategory | qtype | name | template | | Test questions | shortanswer | shortanswer-001 | frogtoad | - And I log in as "teacher1" - And I am on "Course 1" course homepage Scenario: Export a Short answer question - 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 press "Export questions to file" Then following "click here" should download between "1200" and "1450" bytes diff --git a/question/type/shortanswer/tests/behat/import.feature b/question/type/shortanswer/tests/behat/import.feature index c0c8378b8ac..2e045647d8d 100644 --- a/question/type/shortanswer/tests/behat/import.feature +++ b/question/type/shortanswer/tests/behat/import.feature @@ -6,21 +6,18 @@ Feature: Test importing Short answer questions Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@example.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | - And I log in as "teacher1" - And I am on "Course 1" course homepage + | user | course | role | + | teacher | C1 | editingteacher | @javascript @_file_upload Scenario: import Matching question. - 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/type/shortanswer/tests/fixtures/testquestion.moodle.xml" file to "Import" filemanager And I press "id_submitbutton" diff --git a/question/type/shortanswer/tests/behat/preview.feature b/question/type/shortanswer/tests/behat/preview.feature index b0e7d63ca1e..2ead8338ff9 100644 --- a/question/type/shortanswer/tests/behat/preview.feature +++ b/question/type/shortanswer/tests/behat/preview.feature @@ -6,28 +6,25 @@ Feature: Preview a Short answer question Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@moodle.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | + | user | course | role | + | teacher | C1 | editingteacher | And the following "question categories" exist: | contextlevel | reference | name | | Course | C1 | Test questions | And the following "questions" exist: | questioncategory | qtype | name | template | | Test questions | shortanswer | shortanswer-001 | frogtoad | - Given I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Question bank" in current page administration @javascript @_switch_window Scenario: Preview a Short answer question with correct answer - When I choose "Preview" action for "shortanswer-001" in the question bank - Then I should see "Name an amphibian:" + When I am on the "shortanswer-001" "core_question > preview" page logged in as teacher + And I should see "Name an amphibian:" # Set behaviour options And I set the following fields to these values: | behaviour | immediatefeedback | @@ -40,8 +37,8 @@ Feature: Preview a Short answer question @javascript @_switch_window Scenario: Preview a Short answer question with almost correct answer - When I choose "Preview" action for "shortanswer-001" in the question bank - Then I should see "Name an amphibian:" + When I am on the "shortanswer-001" "core_question > preview" page logged in as teacher + And I should see "Name an amphibian:" # Set behaviour options And I set the following fields to these values: | behaviour | immediatefeedback | @@ -54,8 +51,8 @@ Feature: Preview a Short answer question @javascript @_switch_window Scenario: Preview a Short answer question with incorrect answer - When I choose "Preview" action for "shortanswer-001" in the question bank - Then I should see "Name an amphibian:" + When I am on the "shortanswer-001" "core_question > preview" page logged in as teacher + And I should see "Name an amphibian:" # Set behaviour options And I set the following fields to these values: | behaviour | immediatefeedback | diff --git a/question/type/truefalse/tests/behat/add.feature b/question/type/truefalse/tests/behat/add.feature index 345422ffc17..fc2f133e340 100644 --- a/question/type/truefalse/tests/behat/add.feature +++ b/question/type/truefalse/tests/behat/add.feature @@ -6,20 +6,18 @@ Feature: Test creating a True/False question Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@moodle.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | - And I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Question bank" in current page administration + | user | course | role | + | teacher | C1 | editingteacher | Scenario: Create a True/False question with Correct answer as False - When I add a "True/False" question filling the form with: + When I am on the "Course 1" "core_question > course question bank" page logged in as teacher + And I add a "True/False" question filling the form with: | Question name | true-false-001 | | Question text | Manchester is the capital city of England. | | Default mark | 1 | @@ -30,7 +28,8 @@ Feature: Test creating a True/False question Then I should see "true-false-001" Scenario: Create a True/False question with Correct answer as True - When I add a "True/False" question filling the form with: + When I am on the "Course 1" "core_question > course question bank" page logged in as teacher + And I add a "True/False" question filling the form with: | Question name | true-false-002 | | Question text | London is the capital city of England. | | Default mark | 1 | diff --git a/question/type/truefalse/tests/behat/backup_and_restore.feature b/question/type/truefalse/tests/behat/backup_and_restore.feature index dce13d6493e..e10660f107d 100644 --- a/question/type/truefalse/tests/behat/backup_and_restore.feature +++ b/question/type/truefalse/tests/behat/backup_and_restore.feature @@ -19,16 +19,16 @@ Feature: Test duplicating a quiz containing a True/False question | quiz | Test quiz | C1 | quiz1 | And quiz "Test quiz" contains the following questions: | true-false-001 | 1 | - And I log in as "admin" - And I am on "Course 1" course homepage @javascript Scenario: Backup and restore a course containing a True/False question - When I backup "Course 1" course using this options: + When I am on the "Course 1" course page logged in as admin + And I backup "Course 1" course using this options: | Confirmation | Filename | test_backup.mbz | 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 + | Schema | Course name | Course 2 | + | Schema | Course short name | C2 | + And I am on the "Course 2" "core_question > course question bank" page 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 | diff --git a/question/type/truefalse/tests/behat/edit.feature b/question/type/truefalse/tests/behat/edit.feature index 7fa05952dce..fa60e47b541 100644 --- a/question/type/truefalse/tests/behat/edit.feature +++ b/question/type/truefalse/tests/behat/edit.feature @@ -6,31 +6,28 @@ Feature: Test editing a True/False question Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@example.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | + | user | course | role | + | teacher | C1 | editingteacher | And the following "question categories" exist: | contextlevel | reference | name | | Course | C1 | Test questions | And the following "questions" exist: | questioncategory | qtype | name | template | | Test questions | truefalse | true-false-001 | true | - And I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Question bank" in current page administration Scenario: Edit a True/False question - When I choose "Edit question" action for "true-false-001" in the question bank + When I am on the "true-false-001" "core_question > edit" page logged in as teacher And I set the following fields to these values: | Question name | | And I press "id_submitbutton" Then I should see "You must supply a value here." - When I set the following fields to these values: + And I set the following fields to these values: | Question name | Edited true-false-001 name | And I press "id_submitbutton" - Then I should see "Edited true-false-001 name" + And I should see "Edited true-false-001 name" diff --git a/question/type/truefalse/tests/behat/export.feature b/question/type/truefalse/tests/behat/export.feature index f628e540faf..fb9f4005a29 100644 --- a/question/type/truefalse/tests/behat/export.feature +++ b/question/type/truefalse/tests/behat/export.feature @@ -6,26 +6,23 @@ Feature: Test exporting True/False questions Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@example.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | + | user | course | role | + | teacher | C1 | editingteacher | And the following "question categories" exist: | contextlevel | reference | name | | Course | C1 | Test questions | And the following "questions" exist: | questioncategory | qtype | name | template | | Test questions | truefalse | true-false-001 | true | - And I log in as "teacher1" - And I am on "Course 1" course homepage Scenario: Export a True/False question - 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 press "Export questions to file" Then following "click here" should download between "1000" and "1200" bytes diff --git a/question/type/truefalse/tests/behat/import.feature b/question/type/truefalse/tests/behat/import.feature index 10ad32dd00f..a255c7a4d05 100644 --- a/question/type/truefalse/tests/behat/import.feature +++ b/question/type/truefalse/tests/behat/import.feature @@ -6,21 +6,18 @@ Feature: Test importing True/False questions Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@example.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | - And I log in as "teacher1" - And I am on "Course 1" course homepage + | user | course | role | + | teacher | C1 | editingteacher | @javascript @_file_upload Scenario: import a True/False question. - 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/type/truefalse/tests/fixtures/testquestion.moodle.xml" file to "Import" filemanager And I press "id_submitbutton" diff --git a/question/type/truefalse/tests/behat/preview.feature b/question/type/truefalse/tests/behat/preview.feature index 874a61f7945..e70faaeadcd 100644 --- a/question/type/truefalse/tests/behat/preview.feature +++ b/question/type/truefalse/tests/behat/preview.feature @@ -6,40 +6,36 @@ Feature: Preview a Trtue/False question Background: Given the following "users" exist: - | username | firstname | lastname | email | - | teacher1 | T1 | Teacher1 | teacher1@moodle.com | + | username | + | teacher | And the following "courses" exist: | fullname | shortname | category | | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | + | user | course | role | + | teacher | C1 | editingteacher | And the following "question categories" exist: | contextlevel | reference | name | | Course | C1 | Test questions | And the following "questions" exist: | questioncategory | qtype | name | template | | Test questions | truefalse | true-false-001 | true | - Given I log in as "teacher1" - And I am on "Course 1" course homepage - And I navigate to "Question bank" in current page administration @javascript @_switch_window Scenario: Preview a True/False question and submit a correct response. - When I choose "Preview" action for "true-false-001" in the question bank - And I press "Preview options" + When I am on the "true-false-001" "core_question > preview" page logged in as teacher + And I expand all fieldsets And I set the field "How questions behave" to "Immediate feedback" And I press "Start again with these options" And I click on "True" "radio" And I press "Check" And I should see "This is the right answer." And I should see "The correct answer is 'True'." - And I press "Close preview" @javascript @_switch_window Scenario: Preview a True/False question and submit an incorrect response. - When I choose "Preview" action for "true-false-001" in the question bank - And I press "Preview options" + When I am on the "true-false-001" "core_question > preview" page logged in as teacher + And I expand all fieldsets And I set the field "How questions behave" to "Immediate feedback" And I press "Start again with these options" And I click on "False" "radio" @@ -47,4 +43,3 @@ Feature: Preview a Trtue/False question And I should see "This is the wrong answer." And I should see "You should have selected true." And I should see "The correct answer is 'True'." - And I press "Close preview" diff --git a/question/upgrade.txt b/question/upgrade.txt index 1afbdfb4f46..36a40e88657 100644 --- a/question/upgrade.txt +++ b/question/upgrade.txt @@ -78,6 +78,12 @@ This files describes API changes for code that uses the question API. anymore as the api is now self sufficient, calling the api will fetch all the features: process_actions(), process_actions_needing_ui(). +12) The Behat class for question-related steps has been renamed to behat_core_question + to match the expected naming convention. In the unlikely event that you are directly + referring to the behat_question class name (nothing in the standard Moodle code was) + then you will have to update your reference. + + === 3.9 == 1) For years, the ..._questions_in_use callback has been the right way for plugins to diff --git a/theme/classic/tests/behat/behat_theme_classic_behat_question.php b/theme/classic/tests/behat/behat_theme_classic_behat_core_question.php similarity index 95% rename from theme/classic/tests/behat/behat_theme_classic_behat_question.php rename to theme/classic/tests/behat/behat_theme_classic_behat_core_question.php index f5b93c2ab9b..e0885ef989b 100644 --- a/theme/classic/tests/behat/behat_theme_classic_behat_question.php +++ b/theme/classic/tests/behat/behat_theme_classic_behat_core_question.php @@ -16,7 +16,7 @@ // NOTE: no MOODLE_INTERNAL test here, this file may be required by behat before including /config.php. -require_once(__DIR__ . '/../../../../question/tests/behat/behat_question.php'); +require_once(__DIR__ . '/../../../../question/tests/behat/behat_core_question.php'); use Behat\Gherkin\Node\TableNode as TableNode; /** @@ -27,7 +27,7 @@ use Behat\Gherkin\Node\TableNode as TableNode; * @copyright 2021 Mathew May * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class behat_theme_classic_behat_question extends behat_question { +class behat_theme_classic_behat_core_question extends behat_core_question { /** * Creates a question in the current course questions bank with the provided data. * This step can only be used when creating question types composed by a single form.