Moodle APIs
3.8
Moodle 3.8.6 (Build: 20201109)
|
Public Member Functions | |
__call ($name, $arguments) | |
Finds DOM nodes in the page using named selectors. More... | |
escape ($string) | |
Escapes the double quote character. More... | |
evaluate_script (string $script) | |
Evaluate the supplied script in the current session, returning the result. More... | |
execute_script (string $script) | |
Execute the supplied script in the current session. More... | |
get_sesskey () | |
Get the session key for the current session via Javascript. More... | |
has_tag (string $tag) | |
Checks if the current scenario, or its feature, has a specified tag. More... | |
i_add_question_to_the_quiz_with ($questiontype, $quizname, TableNode $questiondata) | |
Adds a question to the existing quiz with filling the form. More... | |
i_click_on_shuffle_for_section ($heading) | |
Set Shuffle for shuffling questions within sections. More... | |
i_click_on_the_page_break_icon_after_question ($addorremoves, $questionname) | |
Click the add or remove page-break icon after a particular question. More... | |
i_delete_question_by_clicking_the_delete_icon ($questionname) | |
Delete a question on the Edit quiz page by first clicking on the Delete icon, then clicking one of the "After ..." links. More... | |
i_move_question_after_item_by_clicking_the_move_icon ($questionname, $target) | |
Move a question on the Edit quiz page by first clicking on the Move icon, then clicking one of the "After ..." links. More... | |
i_move_question_after_item_by_dragging ($questionname, $target) | |
Move a question on the Edit quiz page by dragging a given question on top of another item. More... | |
i_open_the_add_to_quiz_menu_for ($pageorlast) | |
Open the add menu on a given page, or at the end of the Edit quiz page. More... | |
i_set_the_max_mark_for_quiz_question ($questionname, $newmark) | |
Set the max mark for a question on the Edit quiz page. More... | |
i_set_the_section_heading_for ($sectionname, $sectionheading) | |
Set the section heading for a given section on the Edit quiz page. More... | |
i_should_not_see_on_quiz_page ($questionname, $pagenumber) | |
Check whether a particular question is not on a particular page of the quiz on the Edit quiz page. More... | |
i_should_see_before_on_the_edit_quiz_page ($firstquestionname, $secondquestionname) | |
Check whether one question comes before another on the Edit quiz page. More... | |
i_should_see_on_quiz_page ($questionname, $pagenumber) | |
Check whether a particular question is on a particular page of the quiz on the Edit quiz page. More... | |
i_should_see_question_in_section_in_the_quiz_navigation ($questionnumber, $sectionheading) | |
Check that a given question comes after a given section heading in the quiz navigation block. More... | |
look_for_exceptions () | |
Internal step definition to find exceptions, debugging() messages and PHP debug messages. More... | |
normalise_selector (string $selector, $locator, Element $container) | |
Normalise the locator and selector. More... | |
quiz_contains_the_following_questions ($quizname, TableNode $data) | |
Put the specified questions on the specified pages of a given quiz. More... | |
quiz_contains_the_following_sections ($quizname, TableNode $data) | |
Put the specified section headings to start at specified pages of a given quiz. More... | |
should_have_number_on_the_edit_quiz_page ($questionname, $number) | |
Check the number displayed alongside a question on the Edit quiz page. More... | |
shuffle_for_section_should_be ($heading, $value) | |
Check the shuffle checkbox for a particular section. More... | |
the_page_break_icon_after_question_should_exist ($addorremoves, $questionname) | |
Assert the add or remove page-break icon after a particular question exists. More... | |
the_page_break_icon_after_question_should_not_exist ($addorremoves, $questionname) | |
Assert the add or remove page-break icon after a particular question does not exist. More... | |
the_page_break_link_after_question_should_contain ($addorremoves, $questionname, $paramdata) | |
Check the add or remove page-break link after a particular question contains the given parameters in its url. More... | |
user_has_attempted_with_responses ($username, $quizname, TableNode $attemptinfo) | |
Attempt a quiz. More... | |
user_has_checked_answers_in_their_attempt_at_quiz ($username, $quizname, TableNode $attemptinfo) | |
Submit answers to questions an existing quiz attempt, with a simulated click on the 'Check' button. More... | |
user_has_finished_an_attempt_at_quiz ($username, $quizname) | |
Finish an existing quiz attempt. More... | |
user_has_input_answers_in_their_attempt_at_quiz ($username, $quizname, TableNode $attemptinfo) | |
Input answers to particular questions an existing quiz attempt, without simulating a click of the 'Check' button, if any. More... | |
user_has_started_an_attempt_at_quiz ($username, $quizname) | |
Start a quiz attempt without answers. More... | |
user_has_started_an_attempt_at_quiz_with_details ($username, $quizname, TableNode $attemptinfo) | |
Start a quiz attempt without answers. More... | |
wait_for_pending_js () | |
Waits for all the JS to be loaded. More... | |
Static Public Member Functions | |
static | evaluate_script_in_session (Session $session, string $script) |
Evaluate the supplied script in the specified session, returning the result. More... | |
static | execute_script_in_session (Session $session, string $script) |
Excecute the supplied script in the specified session. More... | |
static | get_exact_named_selectors () |
Return a list of the exact named selectors for the component. More... | |
static | get_extended_timeout () |
Gets the extended timeout. More... | |
static | get_named_replacements () |
Return a list of the Mink named replacements for the component. More... | |
static | get_partial_named_selectors () |
Return a list of the partial named selectors for the component. More... | |
static | get_reduced_timeout () |
Gets the reduced timeout. More... | |
static | get_timeout () |
Gets the default timeout. More... | |
static | set_user ($user=null) |
Set current $USER, reset access cache. More... | |
static | wait_for_pending_js_in_session (Session $session) |
Waits for all the JS to be loaded. More... | |
Public Attributes | |
const | EXTENDED_TIMEOUT = 10 |
And extended timeout for specific cases. More... | |
const | PAGE_READY_JS |
The JS code to check that the page is ready. More... | |
const | REDUCED_TIMEOUT = 2 |
Small timeout. More... | |
const | TIMEOUT = 6 |
The timeout for each Behat step (load page, wait for an element to load...). More... | |
Protected Member Functions | |
ensure_editors_are_loaded () | |
Ensures that all the page's editors are loaded. More... | |
ensure_element_does_not_exist ($locator, $selectortype) | |
Spins until the element does not exist. More... | |
ensure_element_exists ($locator, $selectortype) | |
Spins around an element until it exists. More... | |
ensure_element_is_visible ($element, $selectortype) | |
Ensures that the provided element is visible and we can interact with it. More... | |
ensure_node_attribute_is_set ($node, $attribute, $attributevalue) | |
Ensures that the provided node has a attribute value set. More... | |
ensure_node_is_visible ($node) | |
Ensures that the provided node is visible and we can interact with it. More... | |
execute ($contextapi, $params=array()) | |
Helper function to execute api in a given context. More... | |
extract_forced_randomisation_from_attempt_info (TableNode $attemptinfo) | |
Helper used by user_has_attempted_with_responses, user_has_started_an_attempt_at_quiz_with_details, etc. More... | |
extract_responses_from_attempt_info (TableNode $attemptinfo) | |
Helper used by user_has_attempted_with_responses, user_has_checked_answers_in_their_attempt_at_quiz, user_has_input_answers_in_their_attempt_at_quiz, etc. More... | |
find ($selector, $locator, $exception=false, $node=false, $timeout=false) | |
Returns the first matching element. More... | |
find_all ($selector, $locator, $exception=false, $container=false, $timeout=false) | |
Returns all matching elements. More... | |
finish_adding_question ($questiontypename, TableNode $questiondata) | |
Helper used by } and * behat_mod_quiz::i_add_question_to_the_quiz_with to finish creating(). More... | |
get_cm_by_quiz_name (string $name) | |
Get a quiz cmid from the quiz name. More... | |
get_debug_text ($html) | |
Converts HTML tags to line breaks to display the info in CLI. More... | |
get_node_in_container ($selectortype, $element, $containerselectortype, $containerelement) | |
Gets the requested element inside the specified container. More... | |
get_quiz_by_name (string $name) | |
Get a quiz by name. More... | |
get_selected_node ($selectortype, $element) | |
Gets a NodeElement based on the locator and selector type received as argument from steps definitions. More... | |
get_session_user () | |
Get the actual user in the behat session (note $USER does not correspond to the behat session's user). More... | |
get_text_selector_node ($selectortype, $element) | |
Gets a NodeElement based on the locator and selector type received as argument from steps definitions. More... | |
get_xpath_for_shuffle_checkbox ($heading) | |
Return the xpath for shuffle checkbox in section heading. More... | |
get_xpath_page_break_icon_after_question ($addorremoves, $questionname) | |
Get the xpath for a partcular add/remove page-break icon. More... | |
is_in_app () | |
Checks if the current page is part of the mobile app. More... | |
js_trigger_click ($node) | |
Trigger click on node via javascript instead of actually clicking on it via pointer. More... | |
locate_path ($path) | |
Locates url, based on provided path. More... | |
require_javascript () | |
Require that javascript be available in the current Session. More... | |
resize_window ($windowsize, $viewport=false) | |
Change browser window size. More... | |
resolve_page_instance_url (string $type, string $identifier) | |
Convert page names to URLs for steps like 'When I am on the "[identifier]" "[page type]" page'. More... | |
resolve_page_url (string $page) | |
Convert page names to URLs for steps like 'When I am on the "[page name]" page'. More... | |
running_javascript () | |
Whether Javascript is available in the current Session. More... | |
spin ($lambda, $args=false, $timeout=false, $exception=false, $microsleep=false) | |
Executes the passed closure until returns true or time outs. More... | |
transform_selector ($selectortype, $element) | |
Transforms from step definition's argument style to Mink format. More... | |
transform_text_selector ($selectortype, $element) | |
Transforms from step definition's argument style to Mink format. More... | |
Static Protected Member Functions | |
static | get_real_timeout (int $timeout) |
Gets the required timeout in seconds. More... | |
static | require_javascript_in_session (Session $session) |
Require that javascript be available for the specified Session. More... | |
static | running_javascript_in_session (Session $session) |
Whether Javascript is available in the specified Session. More... | |
|
inherited |
Finds DOM nodes in the page using named selectors.
The point of using this method instead of Mink ones is the spin method of behat_base::find() that looks for the element until it is available or it timeouts, this avoids the false failures received when selenium tries to execute commands on elements that are not ready to be used.
All steps that requires elements to be available before interact with them should use one of the find* methods.
The methods calls requires a {'find_' . $elementtype}($locator) format, like find_link($locator), find_select($locator), find_button($locator)...
@externalurl http://mink.behat.org/#named-selectors
coding_exception |
string | $name | The name of the called method |
mixed | $arguments |
NodeElement |
|
protectedinherited |
Ensures that all the page's editors are loaded.
ElementNotFoundException | |
ExpectationException |
void |
|
protectedinherited |
Spins until the element does not exist.
ExpectationException |
string | $locator | |
string | $selectortype |
void |
|
protectedinherited |
Spins around an element until it exists.
ExpectationException |
string | $locator | |
string | $selectortype |
void |
|
protectedinherited |
Ensures that the provided element is visible and we can interact with it.
Returns the node in case other actions are interested in using it.
ExpectationException |
string | $element | |
string | $selectortype |
NodeElement | Throws an exception if it times out without being visible |
|
protectedinherited |
Ensures that the provided node has a attribute value set.
This step can be used to check if specific JS has finished modifying the node.
ExpectationException |
NodeElement | $node | |
string | $attribute | attribute name |
string | $attributevalue | attribute value to check. |
void | Throws an exception if it times out without the element being visible |
|
protectedinherited |
Ensures that the provided node is visible and we can interact with it.
ExpectationException |
NodeElement | $node |
void | Throws an exception if it times out without the element being visible |
|
inherited |
Escapes the double quote character.
Double quote is the argument delimiter, it can be escaped with a backslash, but we auto-remove this backslashes before the step execution, this method is useful when using arguments as arguments for other steps.
string | $string |
string |
|
inherited |
Evaluate the supplied script in the current session, returning the result.
string | $script |
mixed |
|
staticinherited |
Evaluate the supplied script in the specified session, returning the result.
Session | $session | |
string | $script |
mixed |
|
protectedinherited |
Helper function to execute api in a given context.
string | $contextapi | context in which api is defined. |
array | $params | list of params to pass. |
Exception |
|
inherited |
Execute the supplied script in the current session.
No result will be returned.
string | $script |
|
staticinherited |
Excecute the supplied script in the specified session.
No result will be returned.
Session | $session | |
string | $script |
|
protectedinherited |
Helper used by user_has_attempted_with_responses, user_has_started_an_attempt_at_quiz_with_details, etc.
TableNode | $attemptinfo | data table from the Behat step |
array | with two elements, $forcedrandomquestions, $forcedvariants, that can be passed to $quizgenerator->create_attempt. |
|
protectedinherited |
Helper used by user_has_attempted_with_responses, user_has_checked_answers_in_their_attempt_at_quiz, user_has_input_answers_in_their_attempt_at_quiz, etc.
TableNode | $attemptinfo | data table from the Behat step |
array | of responses that can be passed to $quizgenerator->submit_responses. |
|
protectedinherited |
Returns the first matching element.
@externalurl http://mink.behat.org/#traverse-the-page-selectors
string | $selector | The selector type (css, xpath, named...) |
mixed | $locator | It depends on the $selector, can be the xpath, a name, a css locator... |
Exception | $exception | Otherwise we throw exception with generic info |
NodeElement | $node | Spins around certain DOM node instead of the whole page |
int | $timeout | Forces a specific time out (in seconds). |
NodeElement |
|
protectedinherited |
Returns all matching elements.
Adapter to Behat\Mink\Element\Element::findAll() using the spin() method.
@externalurl http://mink.behat.org/#traverse-the-page-selectors
string | $selector | The selector type (css, xpath, named...) |
mixed | $locator | It depends on the $selector, can be the xpath, a name, a css locator... |
Exception | $exception | Otherwise we throw expcetion with generic info |
NodeElement | $container | Restrict the search to just children of the specified container |
int | $timeout | Forces a specific time out (in seconds). If 0 is provided the default timeout will be applied. |
array | NodeElements list |
|
protectedinherited |
Helper used by } and * behat_mod_quiz::i_add_question_to_the_quiz_with to finish creating().
string | $questiontypename | The question type name |
TableNode | $questiondata | The data to fill the question type form |
|
protectedinherited |
Get a quiz cmid from the quiz name.
string | $name | quiz name. |
stdClass | cm from get_coursemodule_from_instance. |
|
protectedinherited |
Converts HTML tags to line breaks to display the info in CLI.
string | $html |
string |
|
staticinherited |
Return a list of the exact named selectors for the component.
Named selectors are what make Behat steps like Then I should see "Useful text" in the "General" "fieldset" work. Here, "fieldset" is the named selector, and "General" is the locator.
If you override this method in your plugin (e.g. mod_mymod), to define new selectors specific to your plugin. For example, if you returned new behat_component_named_selector('Thingy', [".//some/xpath//img[contains(@alt, %locator%)]/.."]) then Then I should see "Useful text" in the "Whatever" "mod_mymod > Thingy" would work.
This method should return a list of behat_component_named_selector and the docs on that class explain how it works.
behat_component_named_selector[] |
|
staticinherited |
Gets the extended timeout.
A longer timeout for cases where the normal timeout is not enough.
int | Timeout in seconds |
|
staticinherited |
Return a list of the Mink named replacements for the component.
Named replacements allow you to define parts of an xpath that can be reused multiple times, or in multiple xpaths.
This method should return a list of behat_component_named_replacement and the docs on that class explain how it works.
behat_component_named_replacement[] |
Reimplemented in behat_message.
|
protectedinherited |
Gets the requested element inside the specified container.
ElementNotFoundException | Thrown by behat_base::find |
mixed | $selectortype | The element selector type. |
mixed | $element | The element locator. |
mixed | $containerselectortype | The container selector type. |
mixed | $containerelement | The container locator. |
NodeElement |
|
staticinherited |
Return a list of the partial named selectors for the component.
Like the exact named selectors above, but the locator only needs to match part of the text. For example, the standard "button" is a partial selector, so: When I click "Save" "button" will activate "Save changes".
behat_component_named_selector[] |
Reimplemented in behat_message.
|
protectedinherited |
Get a quiz by name.
string | $name | quiz name. |
stdClass | the corresponding DB row. |
|
staticprotectedinherited |
Gets the required timeout in seconds.
int | $timeout | One of the TIMEOUT constants |
int | Actual timeout (in seconds) |
|
staticinherited |
Gets the reduced timeout.
A reduced timeout for cases where self::get_timeout() is too much and a simple $this->getSession()->getPage()->find() could not be enough.
int | Timeout in seconds |
|
protectedinherited |
Gets a NodeElement based on the locator and selector type received as argument from steps definitions.
Use behat_base::get_text_selector_node() for text-based selectors.
ElementNotFoundException | Thrown by behat_base::find |
string | $selectortype | |
string | $element |
NodeElement |
|
protectedinherited |
Get the actual user in the behat session (note $USER does not correspond to the behat session's user).
mixed |
coding_exception |
|
inherited |
Get the session key for the current session via Javascript.
string |
|
protectedinherited |
Gets a NodeElement based on the locator and selector type received as argument from steps definitions.
ElementNotFoundException | Thrown by behat_base::find |
string | $selectortype | |
string | $element |
NodeElement |
|
staticinherited |
Gets the default timeout.
The timeout for each Behat step (load page, wait for an element to load...).
int | Timeout in seconds |
|
protectedinherited |
Return the xpath for shuffle checkbox in section heading.
string | $heading |
string |
|
protectedinherited |
Get the xpath for a partcular add/remove page-break icon.
string | $addorremoves | 'Add' or 'Remove'. |
string | $questionname | the name of the question before the icon. |
string | the requried xpath. |
|
inherited |
Checks if the current scenario, or its feature, has a specified tag.
string | $tag | Tag to check |
bool | True if the tag exists in scenario or feature |
behat_theme_classic_behat_mod_quiz::i_add_question_to_the_quiz_with | ( | $questiontype, | |
$quizname, | |||
TableNode | $questiondata | ||
) |
Adds a question to the existing quiz with filling the form.
The form for creating a question should be on one page.
string | $questiontype | |
string | $quizname | |
TableNode | $questiondata | with data for filling the add question form |
Reimplemented from behat_mod_quiz.
|
inherited |
Set Shuffle for shuffling questions within sections.
string | $heading | the heading of the section to change shuffle for. |
@Given /^I click on shuffle for section "([^"]*)" on the quiz edit page$/
|
inherited |
Click the add or remove page-break icon after a particular question.
@When /^I click on the "(Add|Remove)" page break icon after question "(?P<question_name>(?:[^"]|")*)"$/
string | $addorremoves | 'Add' or 'Remove'. |
string | $questionname | the name of the question before the icon to click. |
|
inherited |
Delete a question on the Edit quiz page by first clicking on the Delete icon, then clicking one of the "After ..." links.
@When /^I delete "(?P<question_name>(?:[^"]|")*)" in the quiz by clicking the delete icon$/
string | $questionname | the name of the question we are looking for. |
array | of steps. |
|
inherited |
Move a question on the Edit quiz page by first clicking on the Move icon, then clicking one of the "After ..." links.
@When /^I move "(?P<question_name>(?:[^"]|")*)" to "(?P<target>(?:[^"]|\")*)" in the quiz by clicking the move icon$/
string | $questionname | the name of the question we are looking for. |
string | $target | the target place to move to. One of the links in the pop-up like "After Page 1" or "After Question N". |
|
inherited |
Move a question on the Edit quiz page by dragging a given question on top of another item.
@When /^I move "(?P<question_name>(?:[^"]|")*)" to "(?P<target>(?:[^"]|\")*)" in the quiz by dragging$/
string | $questionname | the name of the question we are looking for. |
string | $target | the target place to move to. Ether a question name, or "Page N" |
|
inherited |
Open the add menu on a given page, or at the end of the Edit quiz page.
@Given /^I open the "(?P<page_n_or_last_string>(?:[^"]|")*)" add to quiz menu$/ @param string $pageorlast either "Page n" or "last".
|
inherited |
Set the max mark for a question on the Edit quiz page.
@When /^I set the max mark for question "(?P<question_name_string>(?:[^"]|")*)" to "(?P<new_mark_string>(?:[^"]|\")*)"$/
string | $questionname | the name of the question to set the max mark for. |
string | $newmark | the mark to set |
|
inherited |
Set the section heading for a given section on the Edit quiz page.
@When /^I change quiz section heading "(?P<section_name_string>(?:[^"]|")*)" to "(?P<new_section_heading_string>(?:[^"]|\")*)"$/
string | $sectionname | the heading to change. |
string | $sectionheading | the new heading to set. |
|
inherited |
Check whether a particular question is not on a particular page of the quiz on the Edit quiz page.
@Given /^I should not see "(?P<question_name>(?:[^"]|")*)" on quiz page "(?P<page_number>\d+)"$/
string | $questionname | the name of the question we are looking for. |
number | $pagenumber | the page it should be found on. |
|
inherited |
Check whether one question comes before another on the Edit quiz page.
The two questions must be on the same page. @Given /^I should see "(?P<first_q_name>(?:[^"]|")*)" before "(?P<second_q_name>(?:[^"]|\")*)" on the edit quiz page$/
string | $firstquestionname | the name of the question that should come first in order. |
string | $secondquestionname | the name of the question that should come immediately after it in order. |
|
inherited |
Check whether a particular question is on a particular page of the quiz on the Edit quiz page.
@Given /^I should see "(?P<question_name>(?:[^"]|")*)" on quiz page "(?P<page_number>\d+)"$/
string | $questionname | the name of the question we are looking for. |
number | $pagenumber | the page it should be found on. |
|
inherited |
Check that a given question comes after a given section heading in the quiz navigation block.
@Then /^I should see question "(?P<questionnumber>\d+)" in section "(?P<section_heading_string>(?:[^"]|")*)" in the quiz navigation$/
int | $questionnumber | the number of the question to check. |
string | $sectionheading | which section heading it should appear after. |
|
protectedinherited |
Checks if the current page is part of the mobile app.
bool | True if it's in the app |
|
protectedinherited |
Trigger click on node via javascript instead of actually clicking on it via pointer.
This function resolves the issue of nested elements with click listeners or links - in these cases clicking via the pointer may accidentally cause a click on the wrong element. Example of issue: clicking to expand navigation nodes when the config value linkadmincategories is enabled.
NodeElement | $node |
|
protectedinherited |
Locates url, based on provided path.
Override to provide custom routing mechanism.
string | $path |
string |
|
inherited |
Internal step definition to find exceptions, debugging() messages and PHP debug messages.
Part of behat_hooks class as is part of the testing framework, is auto-executed after each step so no features will splicitly use it.
Exception | Unknown type, depending on what we caught in the hook or basic Exception. |
|
inherited |
Normalise the locator and selector.
string | $selector | The type of thing to search |
mixed | $locator | The locator value. Can be an array, but is more likely a string. |
Element | $container | An optional container to search within |
array | The selector, locator, and container to search within |
|
inherited |
Put the specified questions on the specified pages of a given quiz.
The first row should be column names: | question | page | maxmark | requireprevious | The first two of those are required. The others are optional.
question needs to uniquely match a question name. page is a page number. Must start at 1, and on each following row should be the same as the previous, or one more. maxmark What the question is marked out of. Defaults to question.defaultmark. requireprevious The question can only be attempted after the previous one was completed.
Then there should be a number of rows of data, one for each question you want to add.
For backwards-compatibility reasons, specifying the column names is optional (but strongly encouraged). If not specified, the columns are asseumed to be | question | page | maxmark |.
string | $quizname | the name of the quiz to add questions to. |
TableNode | $data | information about the questions to add. |
@Given /^quiz "([^"]*)" contains the following questions:$/
|
inherited |
Put the specified section headings to start at specified pages of a given quiz.
The first row should be column names: | heading | firstslot | shufflequestions |
heading is the section heading text firstslot is the slot number where the section starts shuffle whether this section is shuffled (0 or 1)
Then there should be a number of rows of data, one for each section you want to add.
string | $quizname | the name of the quiz to add sections to. |
TableNode | $data | information about the sections to add. |
@Given /^quiz "([^"]*)" contains the following sections:$/
|
protectedinherited |
Require that javascript be available in the current Session.
DriverException |
|
staticprotectedinherited |
Require that javascript be available for the specified Session.
Session | $session |
DriverException |
|
protectedinherited |
Change browser window size.
string | $windowsize | size of window. |
bool | $viewport | If true, changes viewport rather than window size |
ExpectationException |
|
protectedinherited |
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) |
string | $type | identifies which type of page this is, e.g. 'Attempt review'. |
string | $identifier | identifies the particular page, e.g. 'Test quiz > student > Attempt 1'. |
moodle_url | the corresponding URL. |
Exception | with a meaningful error message if the specified page cannot be found. |
Reimplemented from behat_base.
|
protectedinherited |
Convert page names to URLs for steps like 'When I am on the "[page name]" page'.
Recognised page names are: | None so far! | |
string | $page | name of the page, with the component name removed e.g. 'Admin notification'. |
moodle_url | the corresponding URL. |
Exception | with a meaningful error message if the specified page cannot be found. |
Reimplemented from behat_base.
|
protectedinherited |
Whether Javascript is available in the current Session.
boolean |
|
staticprotectedinherited |
Whether Javascript is available in the specified Session.
Session | $session |
boolean |
|
staticinherited |
Set current $USER, reset access cache.
In some cases, behat will execute the code as admin but in many cases we need to set an specific user as some API's might rely on the logged user to take some action.
null | int | stdClass | $user | user record, null or 0 means non-logged-in, positive integer means userid |
|
inherited |
Check the number displayed alongside a question on the Edit quiz page.
@Given /^"(?P<question_name>(?:[^"]|")*)" should have number "(?P<number>(?:[^"]|\")*)" on the edit quiz page$/
string | $questionname | the name of the question we are looking for. |
number | $number | the number (or 'i') that should be displayed beside that question. |
|
inherited |
Check the shuffle checkbox for a particular section.
string | $heading | the heading of the section to check shuffle for |
int | $value | whether the shuffle checkbox should be on or off. |
@Given /^shuffle for section "([^"]*)" should be "(On|Off)" on the quiz edit page$/
|
protectedinherited |
Executes the passed closure until returns true or time outs.
In most cases the document.readyState === 'complete' will be enough, but sometimes JS requires more time to be completely loaded or an element to be visible or whatever is required to perform some action on an element; this method receives a closure which should contain the required statements to ensure the step definition actions and assertions have all their needs satisfied and executes it until they are satisfied or it timeouts. Redirects the return of the closure to the caller.
The closures requirements to work well with this spin method are:
The arguments of the closure are mixed, use $args depending on your needs.
You can provide an exception to give more accurate feedback to tests writers, otherwise the closure exception will be used, but you must provide an exception if the closure does not throw an exception.
Exception | If it timeouts without receiving something != false from the closure |
Function | array | string | $lambda | The function to execute or an array passed to call_user_func (maps to a class method) |
mixed | $args | Arguments to pass to the closure |
int | $timeout | Timeout in seconds |
Exception | $exception | The exception to throw in case it time outs. |
bool | $microsleep | If set to true it'll sleep micro seconds rather than seconds. |
mixed | The value returned by the closure |
|
inherited |
Assert the add or remove page-break icon after a particular question exists.
@When /^the "(Add|Remove)" page break icon after question "(?P<question_name>(?:[^"]|")*)" should exist$/
string | $addorremoves | 'Add' or 'Remove'. |
string | $questionname | the name of the question before the icon to click. |
array | of steps. |
|
inherited |
Assert the add or remove page-break icon after a particular question does not exist.
@When /^the "(Add|Remove)" page break icon after question "(?P<question_name>(?:[^"]|")*)" should not exist$/
string | $addorremoves | 'Add' or 'Remove'. |
string | $questionname | the name of the question before the icon to click. |
array | of steps. |
|
inherited |
Check the add or remove page-break link after a particular question contains the given parameters in its url.
@When /^the "(Add|Remove)" page break link after question "(?P<question_name>(?:[^"]|")*) should contain:"$/
string | $addorremoves | 'Add' or 'Remove'. |
string | $questionname | the name of the question before the icon to click. |
TableNode | $paramdata | with data for checking the page break url |
array | of steps. |
|
protectedinherited |
Transforms from step definition's argument style to Mink format.
Mink has 3 different selectors css, xpath and named, where named selectors includes link, button, field... to simplify and group multiple steps in one we use the same interface, considering all link, buttons... at the same level as css selectors and xpath; this method makes the conversion from the arguments received by the steps to the selectors and locators required to interact with Mink.
ExpectationException |
string | $selectortype | It can be css, xpath or any of the named selectors. |
string | $element | The locator (or string) we are looking for. |
array | Contains the selector and the locator expected by Mink. |
|
protectedinherited |
Transforms from step definition's argument style to Mink format.
Delegates all the process to behat_base::transform_selector() checking the provided $selectortype.
ExpectationException |
string | $selectortype | It can be css, xpath or any of the named selectors. |
string | $element | The locator (or string) we are looking for. |
array | Contains the selector and the locator expected by Mink. |
|
inherited |
Attempt a quiz.
The first row should be column names: | slot | actualquestion | variant | response | The first two of those are required. The others are optional.
slot The slot actualquestion This column is optional, and is only needed if the quiz contains random questions. If so, this will let you control which actual question gets picked when this slot is 'randomised' at the start of the attempt. If you don't specify, then one will be picked at random (which might make the response meaningless). Give the question name. variant This column is similar, and also options. It is only needed if the question that ends up in this slot returns something greater than 1 for $question->get_num_variants(). Like with actualquestion, if you specify a value here it is used the fix the 'random' choice made when the quiz is started. response The response that was submitted. How this is interpreted depends on the question type. It gets passed to core_question_generator::get_simulated_post_data_for_question_attempt() and therefore to the un_summarise_response method of the question to decode.
Then there should be a number of rows of data, one for each question you want to add. There is no need to supply answers to all questions. If so, other qusetions will be left unanswered.
string | $username | the username of the user that will attempt. |
string | $quizname | the name of the quiz the user will attempt. |
TableNode | $attemptinfo | information about the questions to add, as above. @Given /^user "([^"]*)" has attempted "([^"]*)" with responses:$/ |
|
inherited |
Submit answers to questions an existing quiz attempt, with a simulated click on the 'Check' button.
This step should only be used with question behaviours that have have a 'Check' button. Those include Interactive with multiple tires, Immediate feedback and Immediate feedback with CBM.
Then there should be a number of rows of data, with two columns slot and response, as for user_has_attempted_with_responses() above. There is no need to supply answers to all questions. If so, other questions will be left unanswered.
string | $username | the username of the user that will attempt. |
string | $quizname | the name of the quiz the user will attempt. |
TableNode | $attemptinfo | information about the questions to add, as above. |
Behat |
|
inherited |
Finish an existing quiz attempt.
string | $username | the username of the user that will attempt. |
string | $quizname | the name of the quiz the user will attempt. @Given /^user "([^"]*)" has finished an attempt at quiz "([^"]*)"$/ |
|
inherited |
Input answers to particular questions an existing quiz attempt, without simulating a click of the 'Check' button, if any.
Then there should be a number of rows of data, with two columns slot and response, as for user_has_attempted_with_responses() above. There is no need to supply answers to all questions. If so, other questions will be left unanswered.
string | $username | the username of the user that will attempt. |
string | $quizname | the name of the quiz the user will attempt. |
TableNode | $attemptinfo | information about the questions to add, as above. |
Behat |
|
inherited |
Start a quiz attempt without answers.
Then there should be a number of rows of data, one for each question you want to add. There is no need to supply answers to all questions. If so, other qusetions will be left unanswered.
string | $username | the username of the user that will attempt. |
string | $quizname | the name of the quiz the user will attempt. @Given /^user "([^"]*)" has started an attempt at quiz "([^"]*)"$/ |
|
inherited |
Start a quiz attempt without answers.
The supplied data table for have a row for each slot where you want to force either which random question was chose, or which random variant was used, as for user_has_attempted_with_responses() above.
string | $username | the username of the user that will attempt. |
string | $quizname | the name of the quiz the user will attempt. |
TableNode | $attemptinfo | information about the questions to add, as above. @Given /^user "([^"]*)" has started an attempt at quiz "([^"]*)" randomised as follows:$/ |
|
inherited |
Waits for all the JS to be loaded.
bool | Whether any JS is still pending completion. |
|
staticinherited |
Waits for all the JS to be loaded.
Session | $session | The Mink Session where JS can be run |
bool | Whether any JS is still pending completion. |
|
inherited |
And extended timeout for specific cases.
|
inherited |
The JS code to check that the page is ready.
The document must be complete and either M.util.pending_js must be empty, or it must not be defined at all.
|
inherited |
Small timeout.
A reduced timeout for cases where self::TIMEOUT is too much and a simple $this->getSession()->getPage()->find() could not be enough.
|
inherited |
The timeout for each Behat step (load page, wait for an element to load...).