From 49f8c0213f05cbf5f66517cec82b44b1d60c6382 Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Tue, 8 Mar 2022 16:08:41 +0000 Subject: [PATCH 1/2] MDL-74130 question behat: support I am on ... page or key qbank pages --- question/tests/behat/behat_core_question.php | 120 +++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 question/tests/behat/behat_core_question.php diff --git a/question/tests/behat/behat_core_question.php b/question/tests/behat/behat_core_question.php new file mode 100644 index 00000000000..e056f121a07 --- /dev/null +++ b/question/tests/behat/behat_core_question.php @@ -0,0 +1,120 @@ +. + +// 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; + +/** + * Behat navigation hooks for core_question. + * + * @package core_question + * @category test + * @copyright 2022 The Open University + * @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/import.php', + ['courseid' => $this->get_course_id($identifier)]); + + case 'course question export': + return new moodle_url('/question/export.php', + ['courseid' => $this->get_course_id($identifier)]); + + case 'preview': + [$questionid, $otheridtype, $otherid] = $this->find_question_by_name($identifier); + return new moodle_url('/question/preview.php', + ['id' => $questionid, $otheridtype => $otherid]); + + case 'edit': + [$questionid, $otheridtype, $otherid] = $this->find_question_by_name($identifier); + return new moodle_url('/question/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); + } + } +} From 2b13b00703795aa44858a62ff9a5f3f7b7ed6062 Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Tue, 8 Mar 2022 17:03:57 +0000 Subject: [PATCH 2/2] MDL-74130 question behat: Update tests to use the new navigation steps --- .../ddimageortext/tests/behat/add.feature | 12 ++-- .../tests/behat/backup_and_restore.feature | 10 ++-- .../ddimageortext/tests/behat/edit.feature | 13 ++-- .../ddimageortext/tests/behat/export.feature | 15 ++--- .../ddimageortext/tests/behat/import.feature | 12 ++-- .../ddimageortext/tests/behat/preview.feature | 22 ++----- .../type/ddmarker/tests/behat/add.feature | 14 ++--- .../tests/behat/backup_and_restore.feature | 3 +- .../type/ddmarker/tests/behat/edit.feature | 13 ++-- .../type/ddmarker/tests/behat/export.feature | 15 ++--- .../type/ddmarker/tests/behat/import.feature | 12 ++-- .../type/ddmarker/tests/behat/preview.feature | 37 ++++-------- question/type/ddwtos/tests/behat/add.feature | 14 ++--- .../tests/behat/backup_and_restore.feature | 10 ++-- question/type/ddwtos/tests/behat/edit.feature | 15 ++--- .../type/ddwtos/tests/behat/export.feature | 13 ++-- .../type/ddwtos/tests/behat/import.feature | 12 ++-- .../type/ddwtos/tests/behat/preview.feature | 39 +++--------- .../type/description/tests/behat/add.feature | 14 ++--- .../tests/behat/backup_and_restore.feature | 10 ++-- .../type/description/tests/behat/edit.feature | 13 ++-- .../description/tests/behat/export.feature | 12 ++-- .../description/tests/behat/import.feature | 12 ++-- .../description/tests/behat/preview.feature | 16 ++--- question/type/essay/tests/behat/add.feature | 17 +++--- .../tests/behat/backup_and_restore.feature | 12 ++-- question/type/essay/tests/behat/edit.feature | 22 ++++--- .../type/essay/tests/behat/export.feature | 12 ++-- .../tests/behat/file_type_restriction.feature | 25 ++++---- .../type/essay/tests/behat/import.feature | 12 ++-- .../essay/tests/behat/max_file_size.feature | 26 ++++---- .../type/essay/tests/behat/preview.feature | 32 ++++------ .../gapselect/tests/behat/basic_test.feature | 52 ++++++++-------- .../gapselect/tests/behat/import_test.feature | 16 +++-- question/type/match/tests/behat/add.feature | 14 ++--- .../tests/behat/backup_and_restore.feature | 10 ++-- question/type/match/tests/behat/edit.feature | 25 ++++---- .../type/match/tests/behat/export.feature | 12 ++-- .../type/match/tests/behat/import.feature | 12 ++-- .../type/match/tests/behat/preview.feature | 60 +++++++------------ .../type/multianswer/tests/behat/add.feature | 24 ++++---- .../type/multichoice/tests/behat/add.feature | 17 +++--- .../tests/behat/backup_and_restore.feature | 10 ++-- .../tests/behat/clearanswers.feature | 16 ++--- .../type/multichoice/tests/behat/edit.feature | 19 +++--- .../multichoice/tests/behat/export.feature | 12 ++-- .../multichoice/tests/behat/import.feature | 12 ++-- .../multichoice/tests/behat/preview.feature | 31 ++++------ .../type/numerical/tests/behat/add.feature | 14 ++--- .../tests/behat/backup_and_restore.feature | 10 ++-- .../type/numerical/tests/behat/edit.feature | 32 ++++------ .../type/numerical/tests/behat/export.feature | 12 ++-- .../type/numerical/tests/behat/import.feature | 12 ++-- .../numerical/tests/behat/preview.feature | 28 ++++----- .../type/shortanswer/tests/behat/add.feature | 15 +++-- .../tests/behat/backup_and_restore.feature | 10 ++-- .../type/shortanswer/tests/behat/edit.feature | 27 ++++----- .../shortanswer/tests/behat/export.feature | 12 ++-- .../shortanswer/tests/behat/import.feature | 12 ++-- .../shortanswer/tests/behat/preview.feature | 26 ++++---- .../type/truefalse/tests/behat/add.feature | 17 +++--- .../tests/behat/backup_and_restore.feature | 10 ++-- .../type/truefalse/tests/behat/edit.feature | 17 +++--- .../type/truefalse/tests/behat/export.feature | 12 ++-- .../type/truefalse/tests/behat/import.feature | 12 ++-- .../truefalse/tests/behat/preview.feature | 21 +++---- 66 files changed, 480 insertions(+), 677 deletions(-) diff --git a/question/type/ddimageortext/tests/behat/add.feature b/question/type/ddimageortext/tests/behat/add.feature index 46b95589735..18d8e381f1d 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" diff --git a/question/type/ddimageortext/tests/behat/backup_and_restore.feature b/question/type/ddimageortext/tests/behat/backup_and_restore.feature index 8317809d722..9c54e73f5cc 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 7fecbcfe477..8bab9b1ba46 100644 --- a/question/type/ddimageortext/tests/behat/edit.feature +++ b/question/type/ddimageortext/tests/behat/edit.feature @@ -6,27 +6,24 @@ 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" diff --git a/question/type/ddimageortext/tests/behat/export.feature b/question/type/ddimageortext/tests/behat/export.feature index 61f582f1a5e..06d83e284ea 100644 --- a/question/type/ddimageortext/tests/behat/export.feature +++ b/question/type/ddimageortext/tests/behat/export.feature @@ -6,30 +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 > Export" in current page administration + 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 65c64db824f..828403bb71d 100644 --- a/question/type/ddimageortext/tests/behat/import.feature +++ b/question/type/ddimageortext/tests/behat/import.feature @@ -6,20 +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 > Import" in current page administration + 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 4a286418840..6d5bd421507 100644 --- a/question/type/ddimageortext/tests/behat/preview.feature +++ b/question/type/ddimageortext/tests/behat/preview.feature @@ -6,31 +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 - And I switch to "questionpreview" window - # Increase window size and wait 2 seconds to ensure elements are placed properly by js. - # Keep window large else drag will scroll the window to find element. - 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 @@ -44,12 +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 switch to the main window @javascript Scenario: Preview a question using the keyboard. - When I choose "Preview" action for "Drag onto image" in the question bank - And I switch to "questionpreview" window + 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 change window size to "medium" And I wait "2" seconds @@ -64,4 +55,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 switch to the main window diff --git a/question/type/ddmarker/tests/behat/add.feature b/question/type/ddmarker/tests/behat/add.feature index ec506c2d85b..de8ebc62e4f 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" diff --git a/question/type/ddmarker/tests/behat/backup_and_restore.feature b/question/type/ddmarker/tests/behat/backup_and_restore.feature index 5fde8360817..18721ba4a6c 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 80928780368..edb928239ae 100644 --- a/question/type/ddmarker/tests/behat/export.feature +++ b/question/type/ddmarker/tests/behat/export.feature @@ -6,30 +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 > Export" in current page administration + 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 38ddf880fa4..d822f015dcc 100644 --- a/question/type/ddmarker/tests/behat/import.feature +++ b/question/type/ddmarker/tests/behat/import.feature @@ -6,20 +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 > Import" in current page administration + 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 6697b3bdcd4..528c98e20ad 100644 --- a/question/type/ddmarker/tests/behat/preview.feature +++ b/question/type/ddmarker/tests/behat/preview.feature @@ -6,33 +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 - And I switch to "questionpreview" window - # Increase window size and wait 2 seconds to ensure elements are placed properly by js. - # Keep window large else drag will scroll the window to find element. - And I change window size to "large" - And I wait "2" seconds - # 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 @@ -40,27 +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 switch to the main window @javascript - Scenario: Preview a question using the keyboard. - When I choose "Preview" action for "Drag markers" in the question bank - And I switch to "questionpreview" window - # Increase window size and wait 2 seconds to ensure elements are placed properly by js. - # Keep window large else drag will scroll the window to find element. - And I change window size to "medium" - And I wait "2" seconds + 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 switch to the main window @javascript - Scenario: Preview a question in multiple viewports. - When I choose "Preview" action for "Drag markers" in the question bank - And I switch to "questionpreview" window + 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 46a92386db4..54505fdb9ab 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 - When 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. | 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 03729a1c9eb..a74915b78e5 100644 --- a/question/type/ddwtos/tests/behat/export.feature +++ b/question/type/ddwtos/tests/behat/export.feature @@ -6,27 +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 > Export" in current page administration + 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 9785350456d..0a0aabcc872 100644 --- a/question/type/ddwtos/tests/behat/import.feature +++ b/question/type/ddwtos/tests/behat/import.feature @@ -6,20 +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 > Import" in current page administration + 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 3f2bb01bbe4..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,75 +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 - And I switch to "questionpreview" window - # Increase window size and wait 2 seconds to ensure elements are placed properly by js. - # Keep window large else drag will scroll the window to find element. - And I change window size to "medium" - And I wait "2" seconds + 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 switch to the main window @javascript Scenario: Preview a question using the keyboard & submit incomplete. - When I choose "Preview" action for "Drag to text" in the question bank - And I switch to "questionpreview" window + 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 switch to the main window @javascript Scenario: Preview a question using the keyboard. - When I choose "Preview" action for "Drag to text" in the question bank - And I switch to "questionpreview" window + 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 switch to the main window @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 - And I switch to "questionpreview" window + 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 switch to the main window @javascript Scenario: Preview a infinite question. - When I choose "Preview" action for "Drag to text infinite" in the question bank - And I switch to "questionpreview" window - # Increase window size. - # 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 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 switch to the main window 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 a630926060c..28cc5cda094 100644 --- a/question/type/description/tests/behat/export.feature +++ b/question/type/description/tests/behat/export.feature @@ -6,25 +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 > Export" in current page administration + 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 53bdb1964ea..0f54b9c44b0 100644 --- a/question/type/description/tests/behat/import.feature +++ b/question/type/description/tests/behat/import.feature @@ -6,20 +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 > Import" in current page administration + 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 13b4660369c..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 switch to "questionpreview" window + 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 switch to the main window diff --git a/question/type/essay/tests/behat/add.feature b/question/type/essay/tests/behat/add.feature index a0b57e21eaa..be613516e8c 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 | diff --git a/question/type/essay/tests/behat/backup_and_restore.feature b/question/type/essay/tests/behat/backup_and_restore.feature index e16bbf2ff73..8b271854a43 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 Assay 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/export.feature b/question/type/essay/tests/behat/export.feature index fd8eaae2a20..bdc12202069 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,11 +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 > Export" in current page administration + 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 "2750" and "3250" bytes diff --git a/question/type/essay/tests/behat/file_type_restriction.feature b/question/type/essay/tests/behat/file_type_restriction.feature index de5e78912b7..b6e667db6b5 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 | @@ -28,18 +28,19 @@ I need to limit the submittable file types And quiz "Quiz 1" contains the following questions: | question | page | | TF1 | 1 | - 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 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" @@ -57,7 +58,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 195b78cb244..a053cb4150e 100644 --- a/question/type/essay/tests/behat/import.feature +++ b/question/type/essay/tests/behat/import.feature @@ -6,20 +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 > Import" in current page administration + 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 6f2f75b08da..75a8c99c27c 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,22 +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 - And I switch to "questionpreview" window + 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: 512KB, maximum number of files: 1" - And I switch to the main window @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 - And I switch to "questionpreview" window + 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: 1MB, maximum number of files: 1" - And I switch to the main window diff --git a/question/type/essay/tests/behat/preview.feature b/question/type/essay/tests/behat/preview.feature index 6eb52f327a8..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 and submit a partially correct response. - When I choose "Preview" action for "essay-001" in the question bank - And I switch to "questionpreview" window + Scenario: Preview an Essay question that uses the HTML editor. + 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 switch to the main window @javascript @_switch_window - Scenario: Preview an Essay question and submit a partially correct response. - When I choose "Preview" action for "essay-002" in the question bank - And I switch to "questionpreview" window + Scenario: Preview an Essay question that uses the HTML editor with embedded files. + 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 switch to the main window @javascript @_switch_window - Scenario: Preview an Essay question and submit a partially correct response. - When I choose "Preview" action for "essay-003" in the question bank - And I switch to "questionpreview" window + Scenario: Preview an Essay question that uses a plain text area. + 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 switch to the main window diff --git a/question/type/gapselect/tests/behat/basic_test.feature b/question/type/gapselect/tests/behat/basic_test.feature index b2301ad35f0..b586fefbf18 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 And I switch to "questionpreview" window # Gaps (drop-down menus) do not have labels. ids and names are generated @@ -60,7 +58,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" @@ -70,19 +68,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]." @@ -92,8 +90,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 @@ -108,7 +106,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]." @@ -119,25 +117,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 switch to the main window # 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. | @@ -154,4 +152,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 a7d5018de8e..af9104c9b84 100644 --- a/question/type/gapselect/tests/behat/import_test.feature +++ b/question/type/gapselect/tests/behat/import_test.feature @@ -6,21 +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 > Import" in current page administration + 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" @@ -31,10 +29,10 @@ Feature: Import and export select missing words questions And I should see "Imported Select missing words 001" # Now export again. - When I follow "Export" + 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 9e7a9f690d8..d05bc321f2b 100644 --- a/question/type/match/tests/behat/add.feature +++ b/question/type/match/tests/behat/add.feature @@ -6,20 +6,18 @@ 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 | 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. | 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 3f6e383d12c..64ae90f4ed2 100644 --- a/question/type/match/tests/behat/edit.feature +++ b/question/type/match/tests/behat/edit.feature @@ -6,45 +6,42 @@ 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 + And I choose "Preview" action for "Edited Matching name" in the question bank And I switch to "questionpreview" window - Then I should see "frog" + And I should see "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 4b1b08db9ae..6d28231d648 100644 --- a/question/type/match/tests/behat/export.feature +++ b/question/type/match/tests/behat/export.feature @@ -6,25 +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 > Export" in current page administration + 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 99308528b2e..644e71d9357 100644 --- a/question/type/match/tests/behat/import.feature +++ b/question/type/match/tests/behat/import.feature @@ -6,20 +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 > Import" in current page administration + 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 fc2b90c0d1f..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 switch to "questionpreview" window + 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 switch to the main window @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 switch to "questionpreview" window + 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 switch to the main window @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 switch to "questionpreview" window + 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 switch to the main window 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 6aa59eeaa51..5d2c0f89216 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 | @@ -39,7 +37,8 @@ Feature: Test creating a Multiple choice question Then I should see "Multi-choice-001" Scenario: Create a Multiple choice question with single 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-002 | | Question text | Find the capital city of England. | | General feedback | London is the capital city of England. | 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 95c7c5d27df..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,8 +39,8 @@ 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 - When I press "Attempt quiz now" + 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" And I should see "Clear my choice" @@ -51,8 +51,8 @@ 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 - When I press "Attempt quiz now" + 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" And I follow "Finish attempt ..." 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 27fd30eb613..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,11 +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 > Export" in current page administration + 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 53744321b2e..71dfcb79c99 100644 --- a/question/type/multichoice/tests/behat/import.feature +++ b/question/type/multichoice/tests/behat/import.feature @@ -6,20 +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 > Import" in current page administration + 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 39e5a1775b5..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 switch to "questionpreview" window + 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 switch to the main window @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 switch to "questionpreview" window + 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 switch to the main window @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 switch to "questionpreview" window + 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 switch to the main window @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 switch to "questionpreview" window + 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 switch to the main window diff --git a/question/type/numerical/tests/behat/add.feature b/question/type/numerical/tests/behat/add.feature index 8133a892b6d..b6433bd87c6 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 | 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 7d3f920819c..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,11 +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 > Export" in current page administration + 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 6995a63dc0f..53ccb7c5624 100644 --- a/question/type/numerical/tests/behat/import.feature +++ b/question/type/numerical/tests/behat/import.feature @@ -6,20 +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 > Import" in current page administration + 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 747b9c360c2..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 - And I switch to "questionpreview" window - Then I should see "What is pi to two d.p.?" - When I set the field "How questions behave" to "Immediate feedback" + 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 switch to the main window diff --git a/question/type/shortanswer/tests/behat/add.feature b/question/type/shortanswer/tests/behat/add.feature index a84b3aab4e7..31ec38cba5f 100644 --- a/question/type/shortanswer/tests/behat/add.feature +++ b/question/type/shortanswer/tests/behat/add.feature @@ -6,20 +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 - When 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 | 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 996eb12003e..95c8f44dc43 100644 --- a/question/type/shortanswer/tests/behat/edit.feature +++ b/question/type/shortanswer/tests/behat/edit.feature @@ -6,51 +6,48 @@ 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 + And I should see "Edited shortanswer-001 name" + And I choose "Preview" action for "Edited shortanswer-001" in the question bank And I switch to "questionpreview" window - Then I should see "Name an amphibian:" + 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 e80449a994c..04f4a5fb262 100644 --- a/question/type/shortanswer/tests/behat/export.feature +++ b/question/type/shortanswer/tests/behat/export.feature @@ -6,25 +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 > Export" in current page administration + 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 48908094429..2e045647d8d 100644 --- a/question/type/shortanswer/tests/behat/import.feature +++ b/question/type/shortanswer/tests/behat/import.feature @@ -6,20 +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 > Import" in current page administration + 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 2772c38cfc5..2ead8338ff9 100644 --- a/question/type/shortanswer/tests/behat/preview.feature +++ b/question/type/shortanswer/tests/behat/preview.feature @@ -6,29 +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 - And I switch to "questionpreview" window - 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 | @@ -41,9 +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 - And I switch to "questionpreview" window - 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 | @@ -56,9 +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 - And I switch to "questionpreview" window - 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 1f0f4ad9c66..fb9f4005a29 100644 --- a/question/type/truefalse/tests/behat/export.feature +++ b/question/type/truefalse/tests/behat/export.feature @@ -6,25 +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 > Export" in current page administration + 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 7a3bd4c1174..a255c7a4d05 100644 --- a/question/type/truefalse/tests/behat/import.feature +++ b/question/type/truefalse/tests/behat/import.feature @@ -6,20 +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 > Import" in current page administration + 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 83baede4749..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 switch to "questionpreview" window + 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 switch to the main window @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 switch to "questionpreview" window + 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 switch to the main window