Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
behat_theme_classic_behat_core_question Class Reference
Inheritance diagram for behat_theme_classic_behat_core_question:
behat_core_question behat_question_base behat_base behat_session_interface

Public Member Functions

 action_exists ($action, $questionname)
 Checks that action does exist for a question.
 
 action_not_exists ($action, $questionname)
 Checks that action does not exist for a question.
 
 change_question_to_nonexistant_type ($questionname)
 Change the question type of the give question to a type that does not exist.
 
 getSession ($name=null)
 Returns the Mink session.
 
 i_action_the_question ($action, $questionname)
 Activates a particular action on a particular question in the question bank UI.
 
 i_add_a_question_filling_the_form_with ($questiontypename, TableNode $questiondata)
 Creates a question in the current course questions bank with the provided data.
 
 i_add_question_bank_filter (string $filtertype)
 Add a question bank filter.
 
 i_apply_question_bank_filter (string $filtertype, string $value)
 Apply question bank filter.
 
 i_click_on_question_bulk_action ($action)
 A click on a particular bulk action in the question bank UI.
 
 i_should_not_see_question_bulk_action ($action)
 A particular bulk action should not be visible in the question bank UI.
 
 i_should_see_question_bulk_action ($action)
 A particular bulk action is visible in the question bank UI.
 
 remove_question_from_db ($questionname)
 Forcibly delete a question from the database.
 
 the_state_of_question_is_shown_as ($questiondescription, $state)
 Checks the state of the specified question.
 

Public Attributes

const PAGE_READY_JS
 The JS code to check that the page is ready.
 

Protected Member Functions

 find_question_by_name (string $questionname)
 Find a question, and where it is, from the question name.
 
 finish_adding_question ($questiontypename, TableNode $questiondata)
 Helper used by i_add_a_question_filling_the_form_with() and to finish creating().
 
 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'.
 
 resolve_page_url (string $page)
 Convert page names to URLs for steps like 'When I am on the "[page name]" page'.
 

Detailed Description

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Member Function Documentation

◆ action_exists()

behat_core_question::action_exists ( $action,
$questionname )
inherited

Checks that action does exist for a question.

@Then the :action action should exist for the :questionname question in the question bank

Parameters
string$actionthe label for the action you want to activate.
string$questionnamethe question name.

◆ action_not_exists()

behat_core_question::action_not_exists ( $action,
$questionname )
inherited

Checks that action does not exist for a question.

@Then the :action action should not exist for the :questionname question in the question bank

Parameters
string$actionthe label for the action you want to activate.
string$questionnamethe question name.

◆ change_question_to_nonexistant_type()

behat_core_question::change_question_to_nonexistant_type ( $questionname)
inherited

Change the question type of the give question to a type that does not exist.

This is useful for testing robustness of the code when a question type has been uninstalled, even though there are still questions of that type or attempts at them.

In order to set things up, you probably need to start by generating questions of a valid type, then using this to change the type once the data is created.

@Given question :questionname is changed to simulate being of an uninstalled type

Parameters
string$questionnamethe question name.

◆ find_question_by_name()

behat_core_question::find_question_by_name ( string $questionname)
protectedinherited

Find a question, and where it is, from the question name.

This is a helper used by resolve_page_instance_url.

Parameters
string$questionname
Return values
arraywith three elemnets, int question id, a string 'cmid' or 'courseid', and int either cmid or courseid as applicable.

◆ finish_adding_question()

behat_question_base::finish_adding_question ( $questiontypename,
TableNode $questiondata )
protectedinherited

Helper used by i_add_a_question_filling_the_form_with() and to finish creating().

Parameters
string$questiontypenameThe question type name
TableNode$questiondataThe data to fill the question type form

◆ getSession()

behat_session_interface::getSession ( $name = null)
inherited

Returns the Mink session.

Parameters
string | null$namename of the session OR active session will be used
Return values
Behat\Mink\Session

Implemented in behat_form_field.

◆ i_action_the_question()

behat_core_question::i_action_the_question ( $action,
$questionname )
inherited

Activates a particular action on a particular question in the question bank UI.

@When I choose :action action for :questionname in the question bank

Parameters
string$actionthe label for the action you want to activate.
string$questionnamethe question name.

◆ i_add_a_question_filling_the_form_with()

behat_theme_classic_behat_core_question::i_add_a_question_filling_the_form_with ( $questiontypename,
TableNode $questiondata )

Creates a question in the current course questions bank with the provided data.

This step can only be used when creating question types composed by a single form.

Parameters
string$questiontypenameThe question type name
TableNode$questiondataThe data to fill the question type form.

Reimplemented from behat_core_question.

◆ i_add_question_bank_filter()

behat_core_question::i_add_question_bank_filter ( string $filtertype)
inherited

Add a question bank filter.

This will add the filter if it does not exist, but leave the value empty.

@When I add question bank filter :filtertype

Parameters
string$filtertypeThe filter we are adding

◆ i_apply_question_bank_filter()

behat_core_question::i_apply_question_bank_filter ( string $filtertype,
string $value )
inherited

Apply question bank filter.

This will change the existing value of the specified filter, or add the filter and set its value if it doesn't already exist.

@When I apply question bank filter :filtertype with value :value

Parameters
string$filtertypeThe filter to apply. This should match the get_title() return value from the filter's condition class.
string$valueThe value to set for the condition.

◆ i_click_on_question_bulk_action()

behat_core_question::i_click_on_question_bulk_action ( $action)
inherited

A click on a particular bulk action in the question bank UI.

@When I click on question bulk action :action

Parameters
string$actionthe value of the input for the action.

◆ i_should_not_see_question_bulk_action()

behat_core_question::i_should_not_see_question_bulk_action ( $action)
inherited

A particular bulk action should not be visible in the question bank UI.

@When I should not see question bulk action :action

Parameters
string$actionthe value of the input for the action.

◆ i_should_see_question_bulk_action()

behat_core_question::i_should_see_question_bulk_action ( $action)
inherited

A particular bulk action is visible in the question bank UI.

@When I should see question bulk action :action

Parameters
string$actionthe value of the input for the action.

◆ remove_question_from_db()

behat_core_question::remove_question_from_db ( $questionname)
inherited

Forcibly delete a question from the database.

This is useful for testing robustness of the code when a question record is no longer in the database, even though it is referred to. Obviously, this should never happen, but it has been known to in the past and so we sometimes need to be able to test the code can handle this situation.

In order to set things up, you probably need to start by generating a valid questions, then using this to remove it once the data is created.

@Given question :questionname no longer exists in the database

Parameters
string$questionnamethe question name.

◆ resolve_page_instance_url()

behat_core_question::resolve_page_instance_url ( string $type,
string $identifier )
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 | | course question bank | Course name | The question bank for a course | | course question import | Course name | The import questions screen for a course | | course question export | Course name | The export questions screen for a course | | preview | Question name | The screen to preview a question | | edit | Question name | The screen to edit a question |

Parameters
string$typeidentifies which type of page this is, e.g. 'Preview'.
string$identifieridentifies the particular page, e.g. 'My question'.
Return values
moodle_urlthe corresponding URL.
Exceptions
Exceptionwith a meaningful error message if the specified page cannot be found.

◆ resolve_page_url()

behat_core_question::resolve_page_url ( string $page)
protectedinherited

Convert page names to URLs for steps like 'When I am on the "[page name]" page'.

Recognised page names are: | None so far! | |

Parameters
string$pagename of the page, with the component name removed e.g. 'Admin notification'.
Return values
moodle_urlthe corresponding URL.
Exceptions
Exceptionwith a meaningful error message if the specified page cannot be found.

◆ the_state_of_question_is_shown_as()

behat_core_question::the_state_of_question_is_shown_as ( $questiondescription,
$state )
inherited

Checks the state of the specified question.

@Then /^the state of "(?P<question_description_string>(?:[^"]|::")*)" question is shown as "(?P<state_string>(?:[^"]|")*)"$/

Exceptions
ExpectationException
ElementNotFoundException
Parameters
string$questiondescription
string$state

Member Data Documentation

◆ PAGE_READY_JS

const behat_session_interface::PAGE_READY_JS
inherited
Initial value:
= "document.readyState === 'complete' && " .
"(typeof M !== 'object' || typeof M.util !== 'object' || " .
"typeof M.util.pending_js === 'undefined' || M.util.pending_js.length === 0)"

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.


The documentation for this class was generated from the following file: