Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

Class: behat_core_question  - X-Ref

Steps definitions related with the question bank management.

resolve_page_url(string $page)   X-Ref
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.

resolve_page_instance_url(string $type, string $identifier)   X-Ref
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            |

param: string $type identifies which type of page this is, e.g. 'Preview'.
param: string $identifier identifies the particular page, e.g. 'My question'.
return: moodle_url the corresponding URL.

find_question_by_name(string $questionname)   X-Ref
Find a question, and where it is, from the question name.

This is a helper used by resolve_page_instance_url.

param: string $questionname
return: array with three elemnets, int question id, a string 'cmid' or 'courseid',

i_add_a_question_filling_the_form_with($questiontypename, TableNode $questiondata)   X-Ref
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.

param: string $questiontypename The question type name
param: TableNode $questiondata The data to fill the question type form.

the_state_of_question_is_shown_as($questiondescription, $state)   X-Ref
Checks the state of the specified question.

param: string $questiondescription
param: string $state

i_action_the_question($action, $questionname)   X-Ref
Activates a particular action on a particular question in the question bank UI.

param: string $action the label for the action you want to activate.
param: string $questionname the question name.

action_exists($action, $questionname)   X-Ref
Checks that action does exist for a question.

param: string $action the label for the action you want to activate.
param: string $questionname the question name.

action_not_exists($action, $questionname)   X-Ref
Checks that action does not exist for a question.

param: string $action the label for the action you want to activate.
param: string $questionname the question name.

i_should_see_question_bulk_action($action)   X-Ref
A particular bulk action is visible in the question bank UI.

param: string $action the value of the input for the action.

i_should_not_see_question_bulk_action($action)   X-Ref
A particular bulk action should not be visible in the question bank UI.

param: string $action the value of the input for the action.

i_click_on_question_bulk_action($action)   X-Ref
A click on a particular bulk action in the question bank UI.

param: string $action the value of the input for the action.

change_question_to_nonexistant_type($questionname)   X-Ref
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.

param: string $questionname the question name.

remove_question_from_db($questionname)   X-Ref
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.

param: string $questionname the question name.