| 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:
| 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"
| | 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"
| 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"
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"
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"
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"
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"
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"
@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"
@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 ..."
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"
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"
@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"
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"
| 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"
| 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"
| 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"
| 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"
| 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"
| 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"
| 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"
| 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"
| 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"
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"
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"
*/
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.
*
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);
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"
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"
# 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
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"
| 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"
| 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"
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
| 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"
| 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.
| 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.
| 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"
| 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"
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"
| 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"
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"
| 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"
| 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"
| 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"
| 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.
| 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"
| 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
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"
| 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
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.
| 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
| 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
| 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
| 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
| 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
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
| 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
| 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
| 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
| 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
| 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
| 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
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 |
| | 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"
| 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"
| 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"
| 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
| 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"
| 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"
| 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
| 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
| 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
| 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
| 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
| 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
| 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"
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.
| 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"
| 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"
@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"
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"
@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"
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"
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 |
| 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"
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 |
| 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"
| 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 |
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"