From 4e1ebf8cde12e8ea5abd615e3e9d1f26283e026a Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Wed, 7 Aug 2019 15:18:45 +0100 Subject: [PATCH] MDL-66335 quiz behat: using the new generic navigation steps This converts all the navigation to quiz pages when that is not the thing under test. Also, I decided that the Quiz settings form belonged to the course, so did not do that here. --- mod/quiz/tests/behat/add_quiz.feature | 8 +- mod/quiz/tests/behat/attempt_basic.feature | 12 +- mod/quiz/tests/behat/attempt_begin.feature | 20 +--- .../behat/attempt_redo_questions.feature | 46 +++----- .../behat/attempt_require_previous.feature | 42 ++----- mod/quiz/tests/behat/backup.feature | 6 +- mod/quiz/tests/behat/behat_mod_quiz.php | 111 +++++++++++++++++- mod/quiz/tests/behat/editing_add.feature | 15 +-- .../editing_add_from_question_bank.feature | 14 +-- .../tests/behat/editing_add_random.feature | 8 +- .../tests/behat/editing_move_by_click.feature | 4 +- .../editing_remove_multiple_questions.feature | 22 ++-- .../behat/editing_remove_question.feature | 10 +- .../tests/behat/editing_repaginate.feature | 4 +- .../behat/editing_require_previous.feature | 48 ++------ .../behat/editing_section_headings.feature | 58 +++------ .../editing_set_marks_no_attempts.feature | 2 +- .../editing_set_marks_with_attempts.feature | 6 +- .../behat/manually_mark_question.feature | 12 +- mod/quiz/tests/behat/preview.feature | 4 +- .../tests/behat/quiz_group_override.feature | 30 +---- .../quiz_no_calendar_capabilities.feature | 4 +- mod/quiz/tests/behat/quiz_reset.feature | 36 ++---- 23 files changed, 229 insertions(+), 293 deletions(-) diff --git a/mod/quiz/tests/behat/add_quiz.feature b/mod/quiz/tests/behat/add_quiz.feature index a35e68f4302..7344a0a149c 100644 --- a/mod/quiz/tests/behat/add_quiz.feature +++ b/mod/quiz/tests/behat/add_quiz.feature @@ -11,11 +11,11 @@ Feature: Add a quiz | student1 | Sam1 | Student1 | student1@example.com | And the following "courses" exist: | fullname | shortname | category | - | Course 1 | C1 | 0 | + | Course 1 | C1 | 0 | And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | - | student1 | C1 | student | + | user | course | role | + | teacher1 | C1 | editingteacher | + | student1 | C1 | student | When I log in as "teacher1" And I am on "Course 1" course homepage with editing mode on And I add a "Quiz" to section "1" and I fill the form with: diff --git a/mod/quiz/tests/behat/attempt_basic.feature b/mod/quiz/tests/behat/attempt_basic.feature index b38f227d8aa..f946e525495 100644 --- a/mod/quiz/tests/behat/attempt_basic.feature +++ b/mod/quiz/tests/behat/attempt_basic.feature @@ -35,9 +35,7 @@ Feature: Attempt a quiz | slot | response | | 1 | True | | 2 | False | - When I log in as "student" - And I am on "Course 1" course homepage - And I follow "Quiz 1" + When I am on the "Quiz 1" "mod_quiz > View" page logged in as "student" And I follow "Review" Then I should see "25.00 out of 100.00" @@ -66,9 +64,7 @@ Feature: Attempt a quiz | | 4 | 1 | | Section 3 | 5 | 0 | - When I log in as "student" - And I am on "Course 1" course homepage - And I follow "Quiz 1" + When I am on the "Quiz 1" "mod_quiz > View" page logged in as "student" And I press "Attempt quiz now" Then I should see "Section 1" in the "Quiz navigation" "block" @@ -109,9 +105,7 @@ Feature: Attempt a quiz | question | page | | TF1 | 1 | | TF2 | 2 | - When I log in as "student" - And I am on "Course 1" course homepage - And I follow "Quiz 1" + When I am on the "Quiz 1" "mod_quiz > View" page logged in as "student" And I press "Attempt quiz now" Then I should see "Text of the first question" And I should not see "Text of the second question" diff --git a/mod/quiz/tests/behat/attempt_begin.feature b/mod/quiz/tests/behat/attempt_begin.feature index ab48d67dd06..5ce5fb2d632 100644 --- a/mod/quiz/tests/behat/attempt_begin.feature +++ b/mod/quiz/tests/behat/attempt_begin.feature @@ -29,9 +29,7 @@ Feature: The various checks that may happen when an attept is started And quiz "Quiz 1" contains the following questions: | question | page | | TF1 | 1 | - When I log in as "student" - And I am on "Course 1" course homepage - And I follow "Quiz 1" + When I am on the "Quiz 1" "mod_quiz > View" page logged in as "student" And I press "Attempt quiz now" Then I should see "Text of the first question" @@ -43,9 +41,7 @@ Feature: The various checks that may happen when an attept is started And quiz "Quiz 1" contains the following questions: | question | page | | TF1 | 1 | - When I log in as "student" - And I am on "Course 1" course homepage - And I follow "Quiz 1" + When I am on the "Quiz 1" "mod_quiz > View" page logged in as "student" And I press "Attempt quiz now" Then I should see "To attempt this quiz you need to know the quiz password" in the "Start attempt" "dialogue" And I should see "The quiz has a time limit of 1 hour. Time will " in the "Start attempt" "dialogue" @@ -61,9 +57,7 @@ Feature: The various checks that may happen when an attept is started And quiz "Quiz 1" contains the following questions: | question | page | | TF1 | 1 | - When I log in as "student" - And I am on "Course 1" course homepage - And I follow "Quiz 1" + When I am on the "Quiz 1" "mod_quiz > View" page logged in as "student" And I press "Attempt quiz now" And I click on "Cancel" "button" in the "Start attempt" "dialogue" Then I should see "Quiz 1 description" @@ -77,9 +71,7 @@ Feature: The various checks that may happen when an attept is started And quiz "Quiz 1" contains the following questions: | question | page | | TF1 | 1 | - When I log in as "student" - And I am on "Course 1" course homepage - And I follow "Quiz 1" + When I am on the "Quiz 1" "mod_quiz > View" page logged in as "student" And I press "Attempt quiz now" And I set the field "Quiz password" to "Toad" And I click on "Start attempt" "button" in the "Start attempt" "dialogue" @@ -101,9 +93,7 @@ Feature: The various checks that may happen when an attept is started And quiz "Quiz 1" contains the following questions: | question | page | | TF1 | 1 | - When I log in as "student" - And I am on "Course 1" course homepage - And I follow "Quiz 1" + When I am on the "Quiz 1" "mod_quiz > View" page logged in as "student" And I press "Attempt quiz now" And I set the field "Quiz password" to "Toad" And I click on "Start attempt" "button" in the "Start attempt" "dialogue" diff --git a/mod/quiz/tests/behat/attempt_redo_questions.feature b/mod/quiz/tests/behat/attempt_redo_questions.feature index 4398197f23f..2e63a893f35 100644 --- a/mod/quiz/tests/behat/attempt_redo_questions.feature +++ b/mod/quiz/tests/behat/attempt_redo_questions.feature @@ -33,10 +33,8 @@ Feature: Allow students to redo questions in a practice quiz, without starting a @javascript Scenario: After completing a question, there is a redo question button that restarts the question - Given I log in as "student" - And I am on "Course 1" course homepage - When I follow "Quiz 1" - And I press "Attempt quiz now" + Given I am on the "Quiz 1" "mod_quiz > View" page logged in as "student" + When I press "Attempt quiz now" And I click on "False" "radio" in the "First question" "question" And I click on "Check" "button" in the "First question" "question" And I press "Try another question like this one" @@ -45,26 +43,20 @@ Feature: Allow students to redo questions in a practice quiz, without starting a @javascript Scenario: The redo question button is visible but disabled for teachers - Given I log in as "student" - And I am on "Course 1" course homepage - When I follow "Quiz 1" - And I press "Attempt quiz now" + Given I am on the "Quiz 1" "mod_quiz > View" page logged in as "student" + When I press "Attempt quiz now" And I click on "False" "radio" in the "First question" "question" And I click on "Check" "button" in the "First question" "question" And I log out - And I log in as "teacher" - And I am on "Course 1" course homepage - And I follow "Quiz 1" + And I am on the "Quiz 1" "mod_quiz > View" page logged in as "teacher" And I follow "Attempts: 1" And I follow "Review attempt" Then the "Try another question like this one" "button" should be disabled @javascript Scenario: The redo question buttons are no longer visible after the attempt is submitted. - Given I log in as "student" - And I am on "Course 1" course homepage - When I follow "Quiz 1" - And I press "Attempt quiz now" + Given I am on the "Quiz 1" "mod_quiz > View" page logged in as "student" + When I press "Attempt quiz now" And I click on "False" "radio" in the "First question" "question" And I click on "Check" "button" in the "First question" "question" And I press "Finish attempt ..." @@ -73,11 +65,9 @@ Feature: Allow students to redo questions in a practice quiz, without starting a Then "Try another question like this one" "button" should not exist @javascript @_switch_window - Scenario: Teachers reviewing can see all the qestions attempted in a slot - Given I log in as "student" - And I am on "Course 1" course homepage - When I follow "Quiz 1" - And I press "Attempt quiz now" + Scenario: Teachers reviewing can see all the questions attempted in a slot + Given I am on the "Quiz 1" "mod_quiz > View" page logged in as "student" + When I press "Attempt quiz now" And I click on "False" "radio" in the "First question" "question" And I click on "Check" "button" in the "First question" "question" And I press "Try another question like this one" @@ -85,9 +75,7 @@ Feature: Allow students to redo questions in a practice quiz, without starting a And I press "Submit all and finish" And I click on "Submit all and finish" "button" in the "Confirmation" "dialogue" And I log out - And I log in as "teacher" - And I am on "Course 1" course homepage - And I follow "Quiz 1" + And I am on the "Quiz 1" "mod_quiz > View" page logged in as "teacher" And I follow "Attempts: 1" And I follow "Review attempt" And I click on "1" "link" in the "First question" "question" @@ -106,10 +94,8 @@ Feature: Allow students to redo questions in a practice quiz, without starting a @javascript Scenario: Redoing question 1 should save any changes to question 2 on the same page - Given I log in as "student" - And I am on "Course 1" course homepage - When I follow "Quiz 1" - And I press "Attempt quiz now" + Given I am on the "Quiz 1" "mod_quiz > View" page logged in as "student" + When I press "Attempt quiz now" And I click on "False" "radio" in the "First question" "question" And I click on "Check" "button" in the "First question" "question" And I click on "True" "radio" in the "Second question" "question" @@ -131,10 +117,8 @@ Feature: Allow students to redo questions in a practice quiz, without starting a And user "student" has started an attempt at quiz "Quiz 2" randomised as follows: | slot | actualquestion | | 1 | TF1 | - And I log in as "student" - And I am on "Course 1" course homepage - When I follow "Quiz 2" - And I press "Continue the last attempt" + And I am on the "Quiz 2" "mod_quiz > View" page logged in as "student" + When I press "Continue the last attempt" And I should see "First question" And I click on "False" "radio" And I click on "Check" "button" diff --git a/mod/quiz/tests/behat/attempt_require_previous.feature b/mod/quiz/tests/behat/attempt_require_previous.feature index 6155408b6b0..0caf8aff346 100644 --- a/mod/quiz/tests/behat/attempt_require_previous.feature +++ b/mod/quiz/tests/behat/attempt_require_previous.feature @@ -34,20 +34,14 @@ Feature: Attempt a quiz where some questions require that the previous question | TF1 | 1 | 0 | | TF2 | 1 | 1 | - When I log in as "student" - And I am on "Course 1" course homepage - And I follow "Quiz 1" + When I am on the "Quiz 1" "mod_quiz > View" page logged in as "student" And I press "Attempt quiz now" Then I should see "First question" And I should see "This question cannot be attempted until the previous question has been completed." And I should not see "Second question" And I log out - And I log in as "teacher" - And I am on "Course 1" course homepage - And I follow "Quiz 1" - And I follow "Attempts: 1" - And I follow "Review attempt" + And I am on the "Quiz 1 > student > Attempt 1" "mod_quiz > Attempt review" page logged in as "teacher" And I should see "First question" And I should see "This question cannot be attempted until the previous question has been completed." And I should not see "Second question" @@ -68,9 +62,7 @@ Feature: Attempt a quiz where some questions require that the previous question | TF1 | 1 | 0 | | TF2 | 1 | 1 | - When I log in as "student" - And I am on "Course 1" course homepage - And I follow "Quiz 1" + When I am on the "Quiz 1" "mod_quiz > View" page logged in as "student" And I press "Attempt quiz now" And I click on "True" "radio" in the "First question" "question" And I press "Check" @@ -95,9 +87,7 @@ Feature: Attempt a quiz where some questions require that the previous question | TF1 | 1 | 0 | | TF2 | 1 | 1 | - When I log in as "student" - And I am on "Course 1" course homepage - And I follow "Quiz 1" + When I am on the "Quiz 1" "mod_quiz > View" page logged in as "student" And I press "Attempt quiz now" And I press "Finish attempt ..." And I press "Submit all and finish" @@ -120,9 +110,7 @@ Feature: Attempt a quiz where some questions require that the previous question | TF1 | 1 | 0 | | TF2 | 1 | 1 | - When I log in as "student" - And I am on "Course 1" course homepage - And I follow "Quiz 1" + When I am on the "Quiz 1" "mod_quiz > View" page logged in as "student" And I press "Attempt quiz now" Then I should see "First question" @@ -146,9 +134,7 @@ Feature: Attempt a quiz where some questions require that the previous question | heading | firstslot | shuffle | | Section 1 | 1 | 1 | - When I log in as "student" - And I am on "Course 1" course homepage - And I follow "Quiz 1" + When I am on the "Quiz 1" "mod_quiz > View" page logged in as "student" And I press "Attempt quiz now" Then I should see "First question" @@ -173,9 +159,7 @@ Feature: Attempt a quiz where some questions require that the previous question | Section 1 | 1 | 1 | | Section 2 | 2 | 0 | - When I log in as "student" - And I am on "Course 1" course homepage - And I follow "Quiz 1" + When I am on the "Quiz 1" "mod_quiz > View" page logged in as "student" And I press "Attempt quiz now" And I press "Next page" @@ -196,9 +180,7 @@ Feature: Attempt a quiz where some questions require that the previous question | TF1 | 1 | 1 | | TF2 | 1 | 1 | - When I log in as "student" - And I am on "Course 1" course homepage - And I follow "Quiz 1" + When I am on the "Quiz 1" "mod_quiz > View" page logged in as "student" And I press "Attempt quiz now" Then I should see "First question" @@ -219,9 +201,7 @@ Feature: Attempt a quiz where some questions require that the previous question | Story | 1 | 0 | | TF2 | 1 | 1 | - When I log in as "student" - And I am on "Course 1" course homepage - And I follow "Quiz 1" + When I am on the "Quiz 1" "mod_quiz > View" page logged in as "student" And I press "Attempt quiz now" Then I should see "First question" @@ -242,9 +222,7 @@ Feature: Attempt a quiz where some questions require that the previous question | Info | 1 | 0 | | TF1 | 1 | 1 | - When I log in as "student" - And I am on "Course 1" course homepage - And I follow "Quiz 1" + When I am on the "Quiz 1" "mod_quiz > View" page logged in as "student" And I press "Attempt quiz now" Then I should see "Read me" diff --git a/mod/quiz/tests/behat/backup.feature b/mod/quiz/tests/behat/backup.feature index eaa8b44c744..9eefeff05ac 100644 --- a/mod/quiz/tests/behat/backup.feature +++ b/mod/quiz/tests/behat/backup.feature @@ -29,8 +29,7 @@ Feature: Backup and restore of quizzes When I am on "Course 1" course homepage with editing mode on And I duplicate "Quiz 1" activity editing the new copy with: | Name | Quiz 2 | - And I follow "Quiz 2" - And I navigate to "Edit quiz" in current page administration + And I am on the "Quiz 1" "mod_quiz > Edit" page Then I should see "TF1" And I should see "TF2" @@ -73,7 +72,6 @@ Feature: Backup and restore of quizzes And I upload "mod/quiz/tests/fixtures/moodle_28_quiz.mbz" file to "Files" filemanager And I press "Save changes" And I restore "moodle_28_quiz.mbz" backup into "Course 1" course using this options: - And I follow "Restored Moodle 2.8 quiz" - And I navigate to "Edit quiz" in current page administration + And I am on the "Restored Moodle 2.8 quiz" "mod_quiz > Edit" page Then I should see "TF1" And I should see "TF2" diff --git a/mod/quiz/tests/behat/behat_mod_quiz.php b/mod/quiz/tests/behat/behat_mod_quiz.php index 0269b75736b..563ffbe4681 100644 --- a/mod/quiz/tests/behat/behat_mod_quiz.php +++ b/mod/quiz/tests/behat/behat_mod_quiz.php @@ -40,6 +40,115 @@ use Behat\Mink\Exception\ExpectationException as ExpectationException; */ class behat_mod_quiz 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 ($page) { + default: + throw new Exception('Unrecognised quiz 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 | + * | View | Quiz name | The quiz info page (view.php) | + * | Edit | Quiz name | The edit quiz page (edit.php) | + * | Group overrides | Quiz name | The manage group overrides page | + * | User overrides | Quiz name | The manage user overrides page | + * | Grades report | Quiz name | The overview report for a quiz | + * | Responses report | Quiz name | The responses report for a quiz | + * | Statistics report | Quiz name | The statistics report for a quiz | + * | Attempt review | Quiz name > username > [Attempt] attempt no | Review page for a given attempt (review.php) | + * + * @param string $type identifies which type of page this is, e.g. 'Attempt review'. + * @param string $identifier identifies the particular page, e.g. 'Test quiz > student > Attempt 1'. + * @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 { + global $DB; + + switch ($type) { + case 'View': + return new moodle_url('/mod/quiz/view.php', + ['id' => $this->get_cm_by_quiz_name($identifier)->id]); + + case 'Edit': + return new moodle_url('/mod/quiz/edit.php', + ['cmid' => $this->get_cm_by_quiz_name($identifier)->id]); + + case 'Group overrides': + return new moodle_url('/mod/quiz/overrides.php', + ['cmid' => $this->get_cm_by_quiz_name($identifier)->id, 'mode' => 'group']); + + case 'User overrides': + return new moodle_url('/mod/quiz/overrides.php', + ['cmid' => $this->get_cm_by_quiz_name($identifier)->id, 'mode' => 'user']); + + case 'Grades report': + return new moodle_url('/mod/quiz/report.php', + ['id' => $this->get_cm_by_quiz_name($identifier)->id, 'mode' => 'overview']); + + case 'Responses report': + return new moodle_url('/mod/quiz/report.php', + ['id' => $this->get_cm_by_quiz_name($identifier)->id, 'mode' => 'responses']); + + case 'Statistics report': + return new moodle_url('/mod/quiz/report.php', + ['id' => $this->get_cm_by_quiz_name($identifier)->id, 'mode' => 'statistics']); + + case 'Attempt review': + if (substr_count($identifier, ' > ') !== 2) { + throw new coding_exception('For "attempt review", name must be ' . + '"{Quiz name} > {username} > Attempt {attemptnumber}", ' . + 'for example "Quiz 1 > student > Attempt 1".'); + } + list($quizname, $username, $attemptno) = explode(' > ', $identifier); + $attemptno = (int) trim(str_replace ('Attempt', '', $attemptno)); + $quiz = $this->get_quiz_by_name($quizname); + $user = $DB->get_record('user', ['username' => $username], '*', MUST_EXIST); + $attempt = $DB->get_record('quiz_attempts', + ['quiz' => $quiz->id, 'userid' => $user->id, 'attempt' => $attemptno], '*', MUST_EXIST); + return new moodle_url('/mod/quiz/review.php', ['attempt' => $attempt->id]); + + default: + throw new Exception('Unrecognised quiz page type "' . $type . '."'); + } + } + + /** + * Get a quiz by name. + * + * @param string $name quiz name. + * @return stdClass the corresponding DB row. + */ + protected function get_quiz_by_name(string $name): stdClass { + global $DB; + return $DB->get_record('quiz', array('name' => $name), '*', MUST_EXIST); + } + + /** + * Get a quiz cmid from the quiz name. + * + * @param string $name quiz name. + * @return stdClass cm from get_coursemodule_from_instance. + */ + protected function get_cm_by_quiz_name(string $name): stdClass { + $quiz = $this->get_quiz_by_name($name); + return get_coursemodule_from_instance('quiz', $quiz->id, $quiz->course); + } + /** * Put the specified questions on the specified pages of a given quiz. * @@ -67,7 +176,7 @@ class behat_mod_quiz extends behat_question_base { public function quiz_contains_the_following_questions($quizname, TableNode $data) { global $DB; - $quiz = $DB->get_record('quiz', array('name' => $quizname), '*', MUST_EXIST); + $quiz = $this->get_quiz_by_name($quizname); // Deal with backwards-compatibility, optional first row. $firstrow = $data->getRow(0); diff --git a/mod/quiz/tests/behat/editing_add.feature b/mod/quiz/tests/behat/editing_add.feature index 3888204dc8c..41071b64cab 100644 --- a/mod/quiz/tests/behat/editing_add.feature +++ b/mod/quiz/tests/behat/editing_add.feature @@ -17,15 +17,12 @@ Feature: Edit quiz page - adding things And the following "activities" exist: | activity | name | intro | course | idnumber | | quiz | Quiz 1 | Quiz 1 for testing the Add menu | C1 | quiz1 | - And I log in as "teacher1" - And I am on "Course 1" course homepage - And I follow "Quiz 1" - And I navigate to "Edit quiz" in current page administration - Then I should see "Editing quiz: Quiz 1" + And I am on the "Quiz 1" "mod_quiz > Edit" page logged in as "teacher1" + And I should see "Editing quiz: Quiz 1" @javascript Scenario: Add some new question to the quiz using '+ a new question' options of the 'Add' menu. - And I open the "last" add to quiz menu + When I open the "last" add to quiz menu And I follow "a new question" And I set the field "item_qtype_essay" to "1" And I press "submitbutton" @@ -108,7 +105,7 @@ Feature: Edit quiz page - adding things in various categories and add them to the question bank. # Create a couple of sub categories. - And I am on "Course 1" course homepage + When I am on "Course 1" course homepage And I navigate to "Question bank > Categories" in current page administration Then I should see "Add category" Then I set the field "Parent category" to "Default for C1" @@ -190,9 +187,7 @@ Feature: Edit quiz page - adding things # Add questions from question bank using the Add menu. # Add Essay 03 from question bank. - And I am on "Course 1" course homepage - And I follow "Quiz 1" - And I navigate to "Edit quiz" in current page administration + And I am on the "Quiz 1" "mod_quiz > Edit" page And I open the "last" add to quiz menu And I follow "from question bank" Then the "Add selected questions to the quiz" "button" should be disabled diff --git a/mod/quiz/tests/behat/editing_add_from_question_bank.feature b/mod/quiz/tests/behat/editing_add_from_question_bank.feature index 56e983d5f4c..e5245621642 100644 --- a/mod/quiz/tests/behat/editing_add_from_question_bank.feature +++ b/mod/quiz/tests/behat/editing_add_from_question_bank.feature @@ -37,9 +37,7 @@ Feature: Adding questions to a quiz from the question bank And I set the following fields to these values: | Tags | bar | And I press "id_submitbutton" - And I am on "Course 1" course homepage - And I follow "Quiz 1" - And I navigate to "Edit quiz" in current page administration + And I am on the "Quiz 1" "mod_quiz > Edit" page And I open the "last" add to quiz menu And I follow "from question bank" And I set the field "Filter by tags..." to "foo" @@ -71,9 +69,7 @@ Feature: Adding questions to a quiz from the question bank | Test questions | essay | question 21 name | teacher1 | Question 21 text | | Test questions | essay | question 22 name | teacher1 | Question 22 text | And I log in as "teacher1" - And I am on "Course 1" course homepage - And I follow "Quiz 1" - And I navigate to "Edit quiz" in current page administration + And I am on the "Quiz 1" "mod_quiz > Edit" page And I open the "last" add to quiz menu And I follow "from question bank" And I click on "2" "link" in the ".pagination" "css_element" @@ -94,10 +90,8 @@ Feature: Adding questions to a quiz from the question bank | Section 1 | 1 | 0 | | Section 2 | 2 | 0 | And I log in as "teacher1" - And I am on "Course 1" course homepage - And I follow "Quiz 1" - When I navigate to "Edit quiz" in current page administration - And I open the "Page 1" add to quiz menu + And I am on the "Quiz 1" "mod_quiz > Edit" page + When I open the "Page 1" add to quiz menu And I follow "from question bank" And I set the field with xpath "//tr[contains(normalize-space(.), 'question 03 name')]//input[@type='checkbox']" to "1" And I click on "Add selected questions to the quiz" "button" diff --git a/mod/quiz/tests/behat/editing_add_random.feature b/mod/quiz/tests/behat/editing_add_random.feature index 2249d113d0e..911bc95e22f 100644 --- a/mod/quiz/tests/behat/editing_add_random.feature +++ b/mod/quiz/tests/behat/editing_add_random.feature @@ -38,9 +38,7 @@ Feature: Adding random questions to a quiz based on category and tags And I set the following fields to these values: | Tags | bar | And I press "Save changes" - And I am on "Course 1" course homepage - And I follow "Quiz 1" - And I navigate to "Edit quiz" in current page administration + And I am on the "Quiz 1" "mod_quiz > Edit" page And I open the "last" add to quiz menu And I follow "a random question" And I open the autocomplete suggestions list @@ -52,8 +50,6 @@ Feature: Adding random questions to a quiz based on category and tags | capability | permission | role | contextlevel | reference | | moodle/question:useall | Prevent | editingteacher | Course | C1 | And I log in as "teacher1" - And I am on "Course 1" course homepage - And I follow "Quiz 1" - And I navigate to "Edit quiz" in current page administration + And I am on the "Quiz 1" "mod_quiz > Edit" page When I open the "last" add to quiz menu Then I should not see "a random question" diff --git a/mod/quiz/tests/behat/editing_move_by_click.feature b/mod/quiz/tests/behat/editing_move_by_click.feature index 6a0d36bc640..7f838d6665b 100644 --- a/mod/quiz/tests/behat/editing_move_by_click.feature +++ b/mod/quiz/tests/behat/editing_move_by_click.feature @@ -31,9 +31,7 @@ Feature: Edit quiz page - drag-and-drop | Question B | 1 | | Question C | 2 | And I log in as "teacher1" - And I am on "Course 1" course homepage - And I follow "Quiz 1" - And I navigate to "Edit quiz" in current page administration + And I am on the "Quiz 1" "mod_quiz > Edit" page @javascript Scenario: Re-order questions by clicking on the move icon. diff --git a/mod/quiz/tests/behat/editing_remove_multiple_questions.feature b/mod/quiz/tests/behat/editing_remove_multiple_questions.feature index 9d9a220cea6..8c402ac685b 100644 --- a/mod/quiz/tests/behat/editing_remove_multiple_questions.feature +++ b/mod/quiz/tests/behat/editing_remove_multiple_questions.feature @@ -21,8 +21,6 @@ Feature: Edit quiz page - remove multiple questions | activity | name | course | idnumber | | quiz | Quiz 1 | C1 | quiz1 | And I log in as "teacher1" - And I am on "Course 1" course homepage - And I follow "Quiz 1" @javascript Scenario: Delete selected question using select multiple items feature. @@ -36,7 +34,7 @@ Feature: Edit quiz page - remove multiple questions | Question A | 1 | | Question B | 1 | | Question C | 2 | - And I navigate to "Edit quiz" in current page administration + And I am on the "Quiz 1" "mod_quiz > Edit" page # Confirm the starting point. Then I should see "Question A" on quiz page "1" @@ -70,7 +68,7 @@ Feature: Edit quiz page - remove multiple questions | Question A | 1 | | Question B | 2 | | Question C | 2 | - And I navigate to "Edit quiz" in current page administration + And I am on the "Quiz 1" "mod_quiz > Edit" page # Confirm the starting point. Then I should see "Question A" on quiz page "1" @@ -100,8 +98,8 @@ Feature: Edit quiz page - remove multiple questions And quiz "Quiz 1" contains the following questions: | question | page | | Question A | 1 | - When I navigate to "Edit quiz" in current page administration - And I click on "Select multiple items" "button" + And I am on the "Quiz 1" "mod_quiz > Edit" page + When I click on "Select multiple items" "button" And I click on "selectquestion-1" "checkbox" And I click on "Delete selected" "button" And I click on "Yes" "button" in the "Confirm" "dialogue" @@ -119,9 +117,9 @@ Feature: Edit quiz page - remove multiple questions | Question A | 1 | | Question B | 1 | | Question C | 2 | - And I navigate to "Edit quiz" in current page administration + And I am on the "Quiz 1" "mod_quiz > Edit" page - # Confirm the starting point. + # Confirm the starting point. Then I should see "Question A" on quiz page "1" And I should see "Question B" on quiz page "1" And I should see "Question C" on quiz page "2" @@ -129,7 +127,7 @@ Feature: Edit quiz page - remove multiple questions And I should see "Questions: 3" And I should see "This quiz is open" - # Delete all questions in page. Page contains multiple questions + # Delete all questions in page. Page contains multiple questions When I click on "Select multiple items" "button" Then I press "Select all" And I click on "Delete selected" "button" @@ -153,7 +151,7 @@ Feature: Edit quiz page - remove multiple questions | Question A | 1 | | Question B | 1 | | Question C | 2 | - And I navigate to "Edit quiz" in current page administration + And I am on the "Quiz 1" "mod_quiz > Edit" page # Confirm the starting point. Then I should see "Question A" on quiz page "1" @@ -191,7 +189,7 @@ Feature: Edit quiz page - remove multiple questions | Section 1 | 1 | 0 | | Section 2 | 2 | 0 | | Section 3 | 4 | 0 | - And I navigate to "Edit quiz" in current page administration + And I am on the "Quiz 1" "mod_quiz > Edit" page When I click on "Select multiple items" "button" And I click on "selectquestion-3" "checkbox" @@ -230,7 +228,7 @@ Feature: Edit quiz page - remove multiple questions | Section 1 | 1 | 0 | | Section 2 | 2 | 0 | | Section 3 | 4 | 0 | - And I navigate to "Edit quiz" in current page administration + And I am on the "Quiz 1" "mod_quiz > Edit" page When I click on "Select multiple items" "button" And I click on "selectquestion-2" "checkbox" diff --git a/mod/quiz/tests/behat/editing_remove_question.feature b/mod/quiz/tests/behat/editing_remove_question.feature index a5d37a153de..1ae73b6e90a 100644 --- a/mod/quiz/tests/behat/editing_remove_question.feature +++ b/mod/quiz/tests/behat/editing_remove_question.feature @@ -21,8 +21,6 @@ Feature: Edit quiz page - remove questions | activity | name | course | idnumber | | quiz | Quiz 1 | C1 | quiz1 | And I log in as "teacher1" - And I am on "Course 1" course homepage - And I follow "Quiz 1" @javascript Scenario: Delete questions by clicking on the delete icon. @@ -36,7 +34,7 @@ Feature: Edit quiz page - remove questions | Question A | 1 | | Question B | 1 | | Question C | 2 | - And I navigate to "Edit quiz" in current page administration + And I am on the "Quiz 1" "mod_quiz > Edit" page # Confirm the starting point. Then I should see "Question A" on quiz page "1" @@ -81,7 +79,7 @@ Feature: Edit quiz page - remove questions | heading | firstslot | shuffle | | Heading 1 | 1 | 1 | | Heading 2 | 2 | 1 | - When I navigate to "Edit quiz" in current page administration + And I am on the "Quiz 1" "mod_quiz > Edit" page Then "Delete" "link" in the "Question A" "list_item" should not be visible Then "Delete" "link" in the "Question B" "list_item" should be visible Then "Delete" "link" in the "Question C" "list_item" should be visible @@ -94,6 +92,6 @@ Feature: Edit quiz page - remove questions And quiz "Quiz 1" contains the following questions: | question | page | | Question A | 1 | - When I navigate to "Edit quiz" in current page administration - And I delete "Question A" in the quiz by clicking the delete icon + And I am on the "Quiz 1" "mod_quiz > Edit" page + When I delete "Question A" in the quiz by clicking the delete icon Then I should see "Questions: 0" diff --git a/mod/quiz/tests/behat/editing_repaginate.feature b/mod/quiz/tests/behat/editing_repaginate.feature index 3fa35745c0b..0fe66564419 100644 --- a/mod/quiz/tests/behat/editing_repaginate.feature +++ b/mod/quiz/tests/behat/editing_repaginate.feature @@ -19,9 +19,7 @@ Feature: Edit quiz page - pagination | quiz | Quiz 1 | Quiz 1 description | C1 | quiz1 | When I log in as "teacher1" - And I am on "Course 1" course homepage - And I follow "Quiz 1" - And I navigate to "Edit quiz" in current page administration + And I am on the "Quiz 1" "mod_quiz > Edit" page @javascript Scenario: Repaginate questions with N question(s) per page as well as clicking diff --git a/mod/quiz/tests/behat/editing_require_previous.feature b/mod/quiz/tests/behat/editing_require_previous.feature index 813ab55b407..079b2120410 100644 --- a/mod/quiz/tests/behat/editing_require_previous.feature +++ b/mod/quiz/tests/behat/editing_require_previous.feature @@ -30,9 +30,7 @@ Feature: Edit quizzes where some questions require the previous one to have been And quiz "Quiz 1" contains the following questions: | question | page | requireprevious | | TF1 | 1 | 1 | - And I am on "Course 1" course homepage - And I follow "Quiz 1" - And I navigate to "Edit quiz" in current page administration + And I am on the "Quiz 1" "mod_quiz > Edit" page Then "be attempted" "link" should not be visible # The text "be attempted" is used as a relatively unique string in both the add and remove links. @@ -49,9 +47,7 @@ Feature: Edit quizzes where some questions require the previous one to have been | question | page | requireprevious | | TF1 | 1 | 0 | | TF2 | 1 | 1 | - And I am on "Course 1" course homepage - And I follow "Quiz 1" - And I navigate to "Edit quiz" in current page administration + And I am on the "Quiz 1" "mod_quiz > Edit" page Then "This question cannot be attempted until the previous question has been completed." "link" should be visible @javascript @@ -67,9 +63,7 @@ Feature: Edit quizzes where some questions require the previous one to have been | question | page | requireprevious | | Random (Test questions) | 1 | 0 | | TF1 | 1 | 1 | - And I am on "Course 1" course homepage - And I follow "Quiz 1" - And I navigate to "Edit quiz" in current page administration + And I am on the "Quiz 1" "mod_quiz > Edit" page Then "This question cannot be attempted until the previous question has been completed." "link" should be visible @javascript @@ -87,9 +81,7 @@ Feature: Edit quizzes where some questions require the previous one to have been | TF1 | 1 | 0 | | TF2 | 1 | 0 | | TF3 | 1 | 0 | - And I am on "Course 1" course homepage - And I follow "Quiz 1" - And I navigate to "Edit quiz" in current page administration + And I am on the "Quiz 1" "mod_quiz > Edit" page When I follow "No restriction on when question 2 can be attempted • Click to change" Then "Question 2 cannot be attempted until the previous question 1 has been completed • Click to change" "link" should be visible And "No restriction on when question 3 can be attempted • Click to change" "link" should be visible @@ -109,9 +101,7 @@ Feature: Edit quizzes where some questions require the previous one to have been | TF1 | 1 | 0 | | TF2 | 1 | 1 | | TF3 | 1 | 1 | - And I am on "Course 1" course homepage - And I follow "Quiz 1" - And I navigate to "Edit quiz" in current page administration + And I am on the "Quiz 1" "mod_quiz > Edit" page When I follow "Question 3 cannot be attempted until the previous question 2 has been completed • Click to change" Then "Question 2 cannot be attempted until the previous question 1 has been completed • Click to change" "link" should be visible And "No restriction on when question 3 can be attempted • Click to change" "link" should be visible @@ -131,9 +121,7 @@ Feature: Edit quizzes where some questions require the previous one to have been | Random (Test questions) | 1 | 0 | | TF1 | 1 | 1 | | TF2 | 1 | 1 | - And I am on "Course 1" course homepage - And I follow "Quiz 1" - And I navigate to "Edit quiz" in current page administration + And I am on the "Quiz 1" "mod_quiz > Edit" page Then "be attempted" "link" in the "TF1" "list_item" should not be visible Then "be attempted" "link" in the "TF2" "list_item" should not be visible @@ -153,9 +141,7 @@ Feature: Edit quizzes where some questions require the previous one to have been And quiz "Quiz 1" contains the following sections: | heading | firstslot | shuffle | | Section 1 | 1 | 1 | - And I am on "Course 1" course homepage - And I follow "Quiz 1" - And I navigate to "Edit quiz" in current page administration + And I am on the "Quiz 1" "mod_quiz > Edit" page Then "be attempted" "link" in the "TF2" "list_item" should not be visible @javascript @@ -175,9 +161,7 @@ Feature: Edit quizzes where some questions require the previous one to have been | heading | firstslot | shuffle | | Section 1 | 1 | 1 | | Section 2 | 2 | 0 | - And I am on "Course 1" course homepage - And I follow "Quiz 1" - And I navigate to "Edit quiz" in current page administration + And I am on the "Quiz 1" "mod_quiz > Edit" page Then "be attempted" "link" in the "TF2" "list_item" should not be visible @javascript @@ -193,9 +177,7 @@ Feature: Edit quizzes where some questions require the previous one to have been | question | page | requireprevious | | TF1 | 1 | 1 | | TF2 | 1 | 1 | - And I am on "Course 1" course homepage - And I follow "Quiz 1" - And I navigate to "Edit quiz" in current page administration + And I am on the "Quiz 1" "mod_quiz > Edit" page Then "be attempted" "link" in the "TF2" "list_item" should not be visible @javascript @@ -211,9 +193,7 @@ Feature: Edit quizzes where some questions require the previous one to have been | question | page | requireprevious | | Story | 1 | 0 | | TF1 | 1 | 0 | - And I am on "Course 1" course homepage - And I follow "Quiz 1" - And I navigate to "Edit quiz" in current page administration + And I am on the "Quiz 1" "mod_quiz > Edit" page Then "be attempted" "link" in the "TF1" "list_item" should not be visible @javascript @@ -229,9 +209,7 @@ Feature: Edit quizzes where some questions require the previous one to have been | question | page | requireprevious | | Info | 1 | 0 | | TF1 | 1 | 0 | - And I am on "Course 1" course homepage - And I follow "Quiz 1" - And I navigate to "Edit quiz" in current page administration + And I am on the "Quiz 1" "mod_quiz > Edit" page Then "be attempted" "link" in the "TF1" "list_item" should not be visible @javascript @@ -249,9 +227,7 @@ Feature: Edit quizzes where some questions require the previous one to have been | TF1 | 1 | 0 | | TF2 | 1 | 1 | | TF3 | 1 | 1 | - And I am on "Course 1" course homepage - And I follow "Quiz 1" - And I navigate to "Edit quiz" in current page administration + And I am on the "Quiz 1" "mod_quiz > Edit" page When I move "Question 1" to "After Question 3" in the quiz by clicking the move icon Then "Question 2 cannot be attempted until the previous question 1 has been completed • Click to change" "link" should be visible And "No restriction on when question 3 can be attempted • Click to change" "link" should be visible diff --git a/mod/quiz/tests/behat/editing_section_headings.feature b/mod/quiz/tests/behat/editing_section_headings.feature index a771b99eefa..fbb0d0eaf7b 100644 --- a/mod/quiz/tests/behat/editing_section_headings.feature +++ b/mod/quiz/tests/behat/editing_section_headings.feature @@ -35,9 +35,7 @@ Feature: Edit quiz page - section headings | TF1 | 1 | | TF2 | 2 | | TF3 | 3 | - When I am on "Course 1" course homepage - And I follow "Quiz 1" - And I navigate to "Edit quiz" in current page administration + When I am on the "Quiz 1" "mod_quiz > Edit" page Then I should see "Shuffle" @javascript @@ -45,13 +43,11 @@ Feature: Edit quiz page - section headings Given the following "activities" exist: | activity | name | intro | course | idnumber | | quiz | Quiz 1 | Quiz 1 description | C1 | quiz1 | - When I am on "Course 1" course homepage - And I follow "Quiz 1" - And I navigate to "Edit quiz" in current page administration + When I am on the "Quiz 1" "mod_quiz > Edit" page And I change quiz section heading "" to "This is section one" Then I should see "This is section one" - @javascript + @javascript Scenario: Modify section headings Given the following "activities" exist: | activity | name | intro | course | idnumber | @@ -74,9 +70,7 @@ Feature: Edit quiz page - section headings | | 1 | 0 | | Heading 2 | 2 | 0 | | Heading 3 | 3 | 1 | - When I am on "Course 1" course homepage - And I follow "Quiz 1" - And I navigate to "Edit quiz" in current page administration + When I am on the "Quiz 1" "mod_quiz > Edit" page And I change quiz section heading "" to "This is section one" And I change quiz section heading "Heading 2" to "This is section two" Then I should see "This is section one" @@ -105,9 +99,7 @@ Feature: Edit quiz page - section headings | Heading 1 | 1 | 0 | | Heading 2 | 2 | 0 | | Heading 3 | 3 | 1 | - When I am on "Course 1" course homepage - And I follow "Quiz 1" - And I navigate to "Edit quiz" in current page administration + And I am on the "Quiz 1" "mod_quiz > Edit" page When I change quiz section heading "Heading 1" to "" Then I should not see "Heading 1" And I should see "Heading 2" @@ -143,9 +135,7 @@ Feature: Edit quiz page - section headings | Heading 1 | 1 | 0 | | Heading 2 | 2 | 0 | | Heading 3 | 3 | 1 | - When I am on "Course 1" course homepage - And I follow "Quiz 1" - And I navigate to "Edit quiz" in current page administration + When I am on the "Quiz 1" "mod_quiz > Edit" page And I follow "Remove heading 'Heading 2'" And I should see "Are you sure you want to remove the 'Heading 2' section heading?" And I click on "Yes" "button" in the "Confirm" "dialogue" @@ -172,9 +162,7 @@ Feature: Edit quiz page - section headings | heading | firstslot | shuffle | | Heading 1 | 1 | 0 | | Heading 2 | 2 | 0 | - When I am on "Course 1" course homepage - And I follow "Quiz 1" - And I navigate to "Edit quiz" in current page administration + When I am on the "Quiz 1" "mod_quiz > Edit" page And I change quiz section heading "Heading 2" to "Edited heading" Then I should see "Edited heading" And "Edit heading 'Edited heading'" "link" should be visible @@ -206,9 +194,7 @@ Feature: Edit quiz page - section headings | Heading 1 | 1 | 0 | | Heading 2 | 3 | 0 | | Heading 3 | 5 | 1 | - When I am on "Course 1" course homepage - And I follow "Quiz 1" - And I navigate to "Edit quiz" in current page administration + When I am on the "Quiz 1" "mod_quiz > Edit" page And I move "TF5" to "After Question 2" in the quiz by clicking the move icon Then I should see "TF5" on quiz page "2" @@ -238,9 +224,7 @@ Feature: Edit quiz page - section headings | Heading 1 | 1 | 0 | | Heading 2 | 3 | 0 | | Heading 3 | 5 | 1 | - When I am on "Course 1" course homepage - And I follow "Quiz 1" - And I navigate to "Edit quiz" in current page administration + When I am on the "Quiz 1" "mod_quiz > Edit" page And I move "TF1" to "After Question 3" in the quiz by clicking the move icon Then I should see "TF1" on quiz page "2" @@ -264,9 +248,7 @@ Feature: Edit quiz page - section headings | Heading 1 | 1 | 0 | | Heading 2 | 2 | 0 | | Heading 3 | 3 | 1 | - When I am on "Course 1" course homepage - And I follow "Quiz 1" - And I navigate to "Edit quiz" in current page administration + When I am on the "Quiz 1" "mod_quiz > Edit" page Then "Remove heading 'Heading 1'" "link" should not exist And "Remove heading 'Heading 2'" "link" should exist And "Remove heading 'Heading 3'" "link" should exist @@ -291,9 +273,7 @@ Feature: Edit quiz page - section headings | Heading 1 | 1 | 0 | | Heading 2 | 2 | 0 | | Heading 3 | 3 | 0 | - When I am on "Course 1" course homepage - And I follow "Quiz 1" - And I navigate to "Edit quiz" in current page administration + When I am on the "Quiz 1" "mod_quiz > Edit" page And I click on shuffle for section "Heading 1" on the quiz edit page And I click on shuffle for section "Heading 2" on the quiz edit page Then shuffle for section "Heading 1" should be "On" on the quiz edit page @@ -319,9 +299,7 @@ Feature: Edit quiz page - section headings | Heading 1 | 1 | 1 | | Heading 2 | 2 | 1 | | Heading 3 | 3 | 1 | - When I am on "Course 1" course homepage - And I follow "Quiz 1" - And I navigate to "Edit quiz" in current page administration + When I am on the "Quiz 1" "mod_quiz > Edit" page And I click on shuffle for section "Heading 1" on the quiz edit page And I click on shuffle for section "Heading 2" on the quiz edit page Then shuffle for section "Heading 1" should be "Off" on the quiz edit page @@ -345,9 +323,7 @@ Feature: Edit quiz page - section headings | TF1 | 1 | | TF2 | 1 | | TF3 | 2 | - When I am on "Course 1" course homepage - And I follow "Quiz 1" - And I navigate to "Edit quiz" in current page administration + When I am on the "Quiz 1" "mod_quiz > Edit" page And I click on the "Add" page break icon after question "TF1" And I open the action menu in "Page 1" "list_item" Then "a new section heading" "link" in the "Page 1" "list_item" should not be visible @@ -380,9 +356,7 @@ Feature: Edit quiz page - section headings | TF3 | 3 | | TF4 | 4 | - When I am on "Course 1" course homepage - And I follow "Quiz 1" - And I navigate to "Edit quiz" in current page administration + When I am on the "Quiz 1" "mod_quiz > Edit" page And I click on the "Remove" page break icon after question "TF1" And I open the "Page 2" add to quiz menu And I choose "a new section heading" in the open action menu @@ -419,9 +393,7 @@ Feature: Edit quiz page - section headings | TF9 | 9 | | TF10 | 10 | | TF11 | 11 | - When I am on "Course 1" course homepage - And I follow "Quiz 1" - And I navigate to "Edit quiz" in current page administration + When I am on the "Quiz 1" "mod_quiz > Edit" page And I click on the "Remove" page break icon after question "TF10" And I open the "Page 10" add to quiz menu And I choose "a new section heading" in the open action menu diff --git a/mod/quiz/tests/behat/editing_set_marks_no_attempts.feature b/mod/quiz/tests/behat/editing_set_marks_no_attempts.feature index 90088eec263..7b4184dcfbb 100644 --- a/mod/quiz/tests/behat/editing_set_marks_no_attempts.feature +++ b/mod/quiz/tests/behat/editing_set_marks_no_attempts.feature @@ -68,7 +68,7 @@ Feature: Edit quiz marks with no attempts | Decimal places in grades | 3 | | Decimal places in question grades | 5 | And I press "Save and display" - And I navigate to "Edit quiz" in current page administration + When I am on the "Quiz 1" "mod_quiz > Edit" page # Then the field "maxgrade" matches value "20.000" -- with exact match on decimal places. Then "//input[@name = 'maxgrade' and @value = '20.000']" "xpath_element" should exist And I should see "2.00000" diff --git a/mod/quiz/tests/behat/editing_set_marks_with_attempts.feature b/mod/quiz/tests/behat/editing_set_marks_with_attempts.feature index 5236cac72b9..a23acfbc58e 100644 --- a/mod/quiz/tests/behat/editing_set_marks_with_attempts.feature +++ b/mod/quiz/tests/behat/editing_set_marks_with_attempts.feature @@ -36,9 +36,7 @@ Feature: Edit quiz marks with attempts And I press "Attempt quiz now" And I log out And I log in as "teacher1" - And I am on "Course 1" course homepage - And I follow "Quiz 1" - And I navigate to "Edit quiz" in current page administration + And I am on the "Quiz 1" "mod_quiz > Edit" page @javascript Scenario: Set the max mark for a question. @@ -80,7 +78,7 @@ Feature: Edit quiz marks with attempts | Decimal places in grades | 3 | | Decimal places in question grades | 5 | And I press "Save and display" - And I navigate to "Edit quiz" in current page administration + And I am on the "Quiz 1" "mod_quiz > Edit" page # Then the field "maxgrade" matches value "20.000" -- with exact match on decimal places. Then "//input[@name = 'maxgrade' and @value = '20.000']" "xpath_element" should exist And I should see "2.00000" diff --git a/mod/quiz/tests/behat/manually_mark_question.feature b/mod/quiz/tests/behat/manually_mark_question.feature index e361b2afdc6..d8218f3d0f5 100644 --- a/mod/quiz/tests/behat/manually_mark_question.feature +++ b/mod/quiz/tests/behat/manually_mark_question.feature @@ -30,7 +30,7 @@ Feature: Teachers can override the grade for any question | TF1 | 1 | And I log in as "student1" And I am on "Course 1" course homepage - And I follow "Quiz 1" + And I am on the "Quiz 1" "mod_quiz > View" page And I press "Attempt quiz now" And I follow "Finish attempt ..." And I press "Submit all and finish" @@ -40,10 +40,7 @@ Feature: Teachers can override the grade for any question @javascript @_switch_window @_bug_phantomjs Scenario: Validating the marking of an essay question attempt. When I log in as "teacher1" - And I am on "Course 1" course homepage - And I follow "Quiz 1" - And I follow "Attempts: 1" - And I follow "Review attempt" + And I am on the "Quiz 1 > student1 > Attempt 1" "mod_quiz > Attempt review" page And I follow "Make comment or override mark" And I switch to "commentquestion" window And I set the field "Mark" to "25" @@ -64,10 +61,7 @@ Feature: Teachers can override the grade for any question And I follow "Manage private files" And I upload "mod/quiz/tests/fixtures/moodle_logo.jpg" file to "Files" filemanager And I click on "Save changes" "button" - And I am on "Course 1" course homepage - And I follow "Quiz 1" - And I follow "Attempts: 1" - And I follow "Review attempt" + And I am on the "Quiz 1 > student1 > Attempt 1" "mod_quiz > Attempt review" page And I follow "Make comment or override mark" And I switch to "commentquestion" window And I set the field "Comment" to "Administrator's comment" diff --git a/mod/quiz/tests/behat/preview.feature b/mod/quiz/tests/behat/preview.feature index a410d0e0c01..d8c8733bba7 100644 --- a/mod/quiz/tests/behat/preview.feature +++ b/mod/quiz/tests/behat/preview.feature @@ -35,9 +35,7 @@ Feature: Preview a quiz as a teacher @javascript Scenario: Preview a quiz - When I log in as "teacher" - And I am on "Course 1" course homepage - When I follow "Quiz 1" + When I am on the "Quiz 1" "mod_quiz > View" page logged in as "teacher" And I follow "Review" Then I should see "25.00 out of 100.00" And I follow "Finish review" diff --git a/mod/quiz/tests/behat/quiz_group_override.feature b/mod/quiz/tests/behat/quiz_group_override.feature index b90b775a726..c20ac9fbffd 100644 --- a/mod/quiz/tests/behat/quiz_group_override.feature +++ b/mod/quiz/tests/behat/quiz_group_override.feature @@ -46,10 +46,7 @@ Feature: Quiz group override Given the following "permission overrides" exist: | capability | permission | role | contextlevel | reference | | moodle/site:accessallgroups | Prevent | editingteacher | Course | C1 | - When I log in as "teacher1" - And I am on "Course 1" course homepage - And I follow "Test quiz" - And I navigate to "Group overrides" in current page administration + When I am on the "Test quiz" "mod_quiz > Group overrides" page logged in as "teacher1" And I press "Add group override" Then the "Override group" select box should contain "Group 1" And the "Override group" select box should not contain "Group 2" @@ -58,18 +55,12 @@ Feature: Quiz group override Given the following "permission overrides" exist: | capability | permission | role | contextlevel | reference | | moodle/site:accessallgroups | Prevent | editingteacher | Course | C1 | - When I log in as "teacher3" - And I am on "Course 1" course homepage - And I follow "Test quiz" - And I navigate to "Group overrides" in current page administration + When I am on the "Test quiz" "mod_quiz > Group overrides" page logged in as "teacher3" Then I should see "No groups you can access." And the "Add group override" "button" should be disabled Scenario: A teacher with accessallgroups permission should see all group overrides - Given I log in as "admin" - And I am on "Course 1" course homepage - And I follow "Test quiz" - And I navigate to "Group overrides" in current page administration + When I am on the "Test quiz" "mod_quiz > Group overrides" page logged in as "admin" And I press "Add group override" And I set the following fields to these values: | Override group | Group 1 | @@ -80,10 +71,7 @@ Feature: Quiz group override | Attempts allowed | 2 | And I press "Save" And I log out - When I log in as "teacher1" - And I am on "Course 1" course homepage - And I follow "Test quiz" - And I navigate to "Group overrides" in current page administration + And I am on the "Test quiz" "mod_quiz > Group overrides" page logged in as "teacher1" Then I should see "Group 1" in the ".generaltable" "css_element" And I should see "Group 2" in the ".generaltable" "css_element" @@ -91,10 +79,7 @@ Feature: Quiz group override Given the following "permission overrides" exist: | capability | permission | role | contextlevel | reference | | moodle/site:accessallgroups | Prevent | editingteacher | Course | C1 | - And I log in as "admin" - And I am on "Course 1" course homepage - And I follow "Test quiz" - And I navigate to "Group overrides" in current page administration + When I am on the "Test quiz" "mod_quiz > Group overrides" page logged in as "admin" And I press "Add group override" And I set the following fields to these values: | Override group | Group 1 | @@ -105,9 +90,6 @@ Feature: Quiz group override | Attempts allowed | 2 | And I press "Save" And I log out - When I log in as "teacher1" - And I am on "Course 1" course homepage - And I follow "Test quiz" - And I navigate to "Group overrides" in current page administration + When I am on the "Test quiz" "mod_quiz > Group overrides" page logged in as "teacher1" Then I should see "Group 1" in the ".generaltable" "css_element" And I should not see "Group 2" in the ".generaltable" "css_element" diff --git a/mod/quiz/tests/behat/quiz_no_calendar_capabilities.feature b/mod/quiz/tests/behat/quiz_no_calendar_capabilities.feature index 52b1f216b70..4bd2b0bc3a0 100644 --- a/mod/quiz/tests/behat/quiz_no_calendar_capabilities.feature +++ b/mod/quiz/tests/behat/quiz_no_calendar_capabilities.feature @@ -37,9 +37,7 @@ Feature: Quiz with no calendar capabilites | id_timeclose_month | 2 | | id_timeclose_year | 2017 | And I log out - When I log in as "teacher1" - And I am on "Course 1" course homepage with editing mode on - And I follow "Test quiz name" + When I am on the "Test quiz name" "mod_quiz > View" page logged in as "teacher1" And I navigate to "Edit settings" in current page administration And I set the following fields to these values: | id_timeopen_year | 2018 | diff --git a/mod/quiz/tests/behat/quiz_reset.feature b/mod/quiz/tests/behat/quiz_reset.feature index 1337e976e00..ade7c7605c0 100644 --- a/mod/quiz/tests/behat/quiz_reset.feature +++ b/mod/quiz/tests/behat/quiz_reset.feature @@ -41,55 +41,43 @@ Feature: Quiz reset And I am on "Course 1" course homepage And I navigate to "Reset" in current page administration And I set the following fields to these values: - | Delete all quiz attempts | 1 | + | Delete all quiz attempts | 1 | And I press "Reset course" And I press "Continue" - And I am on "Course 1" course homepage - And I follow "Test quiz name" - And I navigate to "Results" in current page administration + And I am on the "Test quiz name" "mod_quiz > Grades report" page Then I should see "Attempts: 0" @javascript Scenario: Use course reset to remove user overrides. - When I log in as "teacher1" - And I am on "Course 1" course homepage - And I follow "Test quiz name" - And I navigate to "User overrides" in current page administration + When I am on the "Test quiz name" "mod_quiz > User overrides" page logged in as "teacher1" And I press "Add user override" And I set the following fields to these values: - | Override user | Student1 | - | Attempts allowed | 2 | + | Override user | Student1 | + | Attempts allowed | 2 | And I press "Save" And I should see "Sam1 Student1" And I am on "Course 1" course homepage And I navigate to "Reset" in current page administration And I set the following fields to these values: - | Delete all user overrides | 1 | + | Delete all user overrides | 1 | And I press "Reset course" And I press "Continue" - And I am on "Course 1" course homepage - And I follow "Test quiz name" - And I navigate to "User overrides" in current page administration + And I am on the "Test quiz name" "mod_quiz > User overrides" page Then I should not see "Sam1 Student1" Scenario: Use course reset to remove group overrides. - When I log in as "teacher1" - And I am on "Course 1" course homepage - And I follow "Test quiz name" - And I navigate to "Group overrides" in current page administration + When I am on the "Test quiz name" "mod_quiz > Group overrides" page logged in as "teacher1" And I press "Add group override" And I set the following fields to these values: - | Override group | Group 1 | - | Attempts allowed | 2 | + | Override group | Group 1 | + | Attempts allowed | 2 | And I press "Save" And I should see "Group 1" And I am on "Course 1" course homepage And I navigate to "Reset" in current page administration And I set the following fields to these values: - | Delete all group overrides | 1 | + | Delete all group overrides | 1 | And I press "Reset course" And I press "Continue" - And I am on "Course 1" course homepage - And I follow "Test quiz name" - And I navigate to "Group overrides" in current page administration + And I am on the "Test quiz name" "mod_quiz > Group overrides" page Then I should not see "Group 1"