This commit is contained in:
Eloy Lafuente (stronk7) 2019-10-14 18:53:44 +02:00
commit 82d71a5c83
27 changed files with 492 additions and 297 deletions

View File

@ -42,16 +42,23 @@ class behat_auth extends behat_base {
* Logs in the user. There should exist a user with the same value as username and password.
*
* @Given /^I log in as "(?P<username_string>(?:[^"]|\\")*)"$/
* @param string $username the user to log in as.
* @param moodle_url|null $wantsurl optional, URL to go to after logging in.
*/
public function i_log_in_as($username) {
// In the mobile app the required tasks are different.
public function i_log_in_as(string $username, moodle_url $wantsurl = null) {
// In the mobile app the required tasks are different (does not support $wantsurl).
if ($this->is_in_app()) {
$this->execute('behat_app::login', [$username]);
return;
}
$loginurl = new moodle_url('/login/index.php');
if ($wantsurl !== null) {
$loginurl->param('wantsurl', $wantsurl->out_as_local_url());
}
// Visit login page.
$this->getSession()->visit($this->locate_path('login/index.php'));
$this->getSession()->visit($this->locate_path($loginurl->out_as_local_url()));
// Enter username and password.
$this->execute('behat_forms::i_set_the_field_to', array('Username', $this->escape($username)));

View File

@ -1058,6 +1058,56 @@ class behat_base extends Behat\MinkExtension\Context\RawMinkContext {
}
}
/**
* Convert page names to URLs for steps like 'When I am on the "[page name]" page'.
*
* You should override this as appropriate for your plugin. The method
* {@link behat_navigation::resolve_core_page_url()} is a good example.
*
* Your overridden method should document the recognised page types with
* a table like this:
*
* Recognised page names are:
* | Page | Description |
*
* @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 {
throw new Exception('Component "' . get_class($this) .
'" does not support the generic \'When I am on the "' . $page .
'" page\' navigation step.');
}
/**
* Convert page names to URLs for steps like 'When I am on the "[identifier]" "[page type]" page'.
*
* A typical example might be:
* When I am on the "Test quiz" "mod_quiz > Responses report" page
* which would cause this method in behat_mod_quiz to be called with
* arguments 'Responses report', 'Test quiz'.
*
* You should override this as appropriate for your plugin. The method
* {@link behat_navigation::resolve_core_page_instance_url()} is a good example.
*
* Your overridden method should document the recognised page types with
* a table like this:
*
* Recognised page names are:
* | Type | identifier meaning | Description |
*
* @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 {
throw new Exception('Component "' . get_class($this) .
'" does not support the generic \'When I am on the "' . $identifier .
'" "' . $type . '" page\' navigation step.');
}
/**
* Gets the required timeout in seconds.
*

View File

@ -533,6 +533,197 @@ class behat_navigation extends behat_base {
$USER = $globuser;
}
/**
* Open a given page, belonging to a plugin or core component.
*
* The page-type are interpreted by each plugin to work out the
* corresponding URL. See the resolve_url method in each class like
* behat_mod_forum. That method should document which page types are
* recognised, and how the name identifies them.
*
* For pages belonging to core, the 'core > ' bit is omitted.
*
* @When I am on the :page page
* @param string $page the component and page name.
* E.g. 'Admin notifications' or 'core_user > Preferences'.
* @throws Exception if the specified page cannot be determined.
*/
public function i_am_on_page(string $page) {
$this->getSession()->visit($this->locate_path(
$this->resolve_page_helper($page)->out_as_local_url()));
}
/**
* Open a given page logged in as a given user.
*
* This is like the combination
* When I log in as "..."
* And I am on the "..." page
* but with the advantage that you go straight to the desired page, without
* having to wait for the Dashboard to load.
*
* @When I am on the :page page logged in as :username
* @param string $page the type of page. E.g. 'Admin notifications' or 'core_user > Preferences'.
* @param string $username the name of the user to log in as. E.g. 'admin'.
* @throws Exception if the specified page cannot be determined.
*/
public function i_am_on_page_logged_in_as(string $page, string $username) {
self::execute('behat_auth::i_log_in_as', [$username, $this->resolve_page_helper($page)]);
}
/**
* Helper used by i_am_on_page() and i_am_on_page_logged_in_as().
*
* @param string $page the type of page. E.g. 'Admin notifications' or 'core_user > Preferences'.
* @return moodle_url the corresponding URL.
*/
protected function resolve_page_helper(string $page): moodle_url {
list($component, $name) = $this->parse_page_name($page);
if ($component === 'core') {
return $this->resolve_core_page_url($name);
} else {
$context = behat_context_helper::get('behat_' . $component);
return $context->resolve_page_url($name);
}
}
/**
* Parse a full page name like 'Admin notifications' or 'core_user > Preferences'.
*
* E.g. parsing 'mod_quiz > View' gives ['mod_quiz', 'View'].
*
* @param string $page the full page name
* @return array with two elements, component and page name.
*/
protected function parse_page_name(string $page): array {
$dividercount = substr_count($page, ' > ');
if ($dividercount === 0) {
return ['core', $page];
} else if ($dividercount === 1) {
list($component, $name) = explode(' > ', $page);
if ($component === 'core') {
throw new coding_exception('Do not specify the component "core > ..." for core pages.');
}
return [$component, $name];
} else {
throw new coding_exception('The page name most be in the form ' .
'"{page-name}" for core pages, or "{component} > {page-name}" ' .
'for pages belonging to other components. ' .
'For example "Admin notifications" or "mod_quiz > View".');
}
}
/**
* Open a given instance of a page, belonging to a plugin or core component.
*
* The instance identifier and page-type are interpreted by each plugin to
* work out the corresponding URL. See the resolve_page_instance_url method
* in each class like behat_mod_forum. That method should document which page
* types are recognised, and how the name identifies them.
*
* For pages belonging to core, the 'core > ' bit is omitted.
*
* @When I am on the :identifier :type page
* @param string $identifier identifies the particular page. E.g. 'Test quiz'.
* @param string $type the component and page type. E.g. 'mod_quiz > View'.
* @throws Exception if the specified page cannot be determined.
*/
public function i_am_on_page_instance(string $identifier, string $type) {
list($component, $type) = $this->parse_page_name($type);
$this->getSession()->visit($this->locate_path(
$this->resolve_page_instance_helper($identifier, $type)->out_as_local_url()));
}
/**
* Open a given page logged in as a given user.
*
* This is like the combination
* When I log in as "..."
* And I am on the "..." "..." page
* but with the advantage that you go straight to the desired page, without
* having to wait for the Dashboard to load.
*
* @When I am on the :identifier :type page logged in as :username
* @param string $identifier identifies the particular page. E.g. 'Test quiz'.
* @param string $type the component and page type. E.g. 'mod_quiz > View'.
* @param string $username the name of the user to log in as. E.g. 'student'.
* @throws Exception if the specified page cannot be determined.
*/
public function i_am_on_page_instance_logged_in_as(string $identifier,
string $type, string $username) {
self::execute('behat_auth::i_log_in_as',
[$username, $this->resolve_page_instance_helper($identifier, $type)]);
}
/**
* Helper used by i_am_on_page() and i_am_on_page_logged_in_as().
*
* @param string $identifier identifies the particular page. E.g. 'Test quiz'.
* @param string $pagetype the component and page type. E.g. 'mod_quiz > View'.
* @return moodle_url the corresponding URL.
*/
protected function resolve_page_instance_helper(string $identifier, string $pagetype): moodle_url {
list($component, $type) = $this->parse_page_name($pagetype);
if ($component === 'core') {
return $this->resolve_core_page_instance_url($type, $identifier);
} else {
$context = behat_context_helper::get('behat_' . $component);
return $context->resolve_page_instance_url($type, $identifier);
}
}
/**
* Convert core page names to URLs for steps like 'When I am on the "[page name]" page'.
*
* Recognised page names are:
* | Homepage | Homepage (normally dashboard). |
* | Admin notifications | Admin notification screen. |
*
* @param string $name identifies which identifies this page, e.g. 'Homepage', 'Admin notifications'.
* @return moodle_url the corresponding URL.
* @throws Exception with a meaningful error message if the specified page cannot be found.
*/
protected function resolve_core_page_url(string $name): moodle_url {
switch ($name) {
case 'Homepage':
return new moodle_url('/');
case 'Admin notifications':
return new moodle_url('/admin/');
default:
throw new Exception('Unrecognised core page type "' . $name . '."');
}
}
/**
* Convert page names to URLs for steps like 'When I am on the "[identifier]" "[page type]" page'.
*
* Recognised page names are:
* | Page type | Identifier meaning | description |
* | Category page | category idnumber | List of courses in that category. |
*
* @param string $type identifies which type of page this is, e.g. 'Category page'.
* @param string $identifier identifies the particular page, e.g. 'test-cat'.
* @return moodle_url the corresponding URL.
* @throws Exception with a meaningful error message if the specified page cannot be found.
*/
protected function resolve_core_page_instance_url(string $type, string $identifier): moodle_url {
global $DB;
switch ($type) {
case 'Category page':
$categoryid = $DB->get_field('course_categories', 'id', ['idnumber' => $identifier]);
if (!$categoryid) {
throw new Exception('The specified category with idnumber "' . $identifier . '" does not exist');
}
return new moodle_url('/course/category.php', ['id' => $categoryid]);
default:
throw new Exception('Unrecognised core page type "' . $type . '."');
}
}
/**
* Opens the course homepage.
*

View File

@ -30,10 +30,21 @@ require_once('lib.php');
redirect_if_major_upgrade_required();
$testsession = optional_param('testsession', 0, PARAM_INT); // test session works properly
$anchor = optional_param('anchor', '', PARAM_RAW); // Used to restore hash anchor to wantsurl.
$anchor = optional_param('anchor', '', PARAM_RAW); // Used to restore hash anchor to wantsurl.
$resendconfirmemail = optional_param('resendconfirmemail', false, PARAM_BOOL);
// It might be safe to do this for non-Behat sites, or there might
// be a security risk. For now we only allow it on Behat sites.
// If you wants to do the analysis, you may be able to remove the
// if (BEHAT_SITE_RUNNING).
if (defined('BEHAT_SITE_RUNNING') && BEHAT_SITE_RUNNING) {
$wantsurl = optional_param('wantsurl', '', PARAM_LOCALURL); // Overrides $SESSION->wantsurl if given.
if ($wantsurl !== '') {
$SESSION->wantsurl = (new moodle_url($wantsurl))->out(false);
}
}
$context = context_system::instance();
$PAGE->set_url("$CFG->wwwroot/login/index.php");
$PAGE->set_context($context);

View File

@ -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:

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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);

View File

@ -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

View File

@ -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"
Then I should see "foo" in the "question 01 name" "table_row"
@ -74,9 +72,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"
@ -97,10 +93,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"

View File

@ -38,9 +38,7 @@ Feature: Adding random questions to a quiz based on category and tags
And I set the following fields in the "Question tags" "dialogue" 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"

View File

@ -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.

View File

@ -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"

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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 |

View File

@ -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"