Moodle PHP Documentation 5.1
Moodle 5.1dev (Build: 20250711) (9addea9f0ac)
core_question\local\bank\condition Class Reference
Inheritance diagram for core_question\local\bank\condition:
qbank_deletequestion\hidden_condition qbank_editquestion\status_condition qbank_managecategories\category_condition qbank_tagquestion\tag_condition qbank_viewcreator\timemodified_condition qbank_viewcreator\user_condition qbank_viewquestionname\question_idnumber_condition qbank_viewquestionname\question_name_condition qbank_viewquestiontext\questiontext_condition qbank_viewquestiontype\type_condition

Public Member Functions

 __construct (?view $qbank=null)
 Extract the required filter from the provided question bank view and set the initial values.
 
 allow_custom ()
 Whether customisation is allowed.
 
 allow_empty ()
 Whether empty value is allowed.
 
 allow_multiple ()
 Whether multiple values are allowed .
 
 display_options ()
 Display GUI for selecting criteria for this condition.
 
 display_options_adv ()
 Display GUI for selecting criteria for this condition.
 
 filter_invalid_values (array $filterconditions)
 Method to be overridden in condition classes to filter out anything invalid from the filterconditions array.
 
 get_condition_class ()
 Return this condition class.
 
 get_filter_class ()
 Return the Javascript filter class to provide the UI for this condition.
 
 get_filteroptions ()
 Extra data specific to this condition.
 
 get_initial_values ()
 Initial values of the condition.
 
 get_join_list ()
 Get the list of available joins for the filter.
 
 get_title ()
 Return title of the condition.
 
 is_required ()
 Whether this filter is required - if so it cannot be removed from the list of filters.
 
 params ()
 Return parameters to be bound to the above WHERE clause fragment.
 
 where ()
 Return an SQL fragment to be ANDed into the WHERE clause to filter which questions are shown.
 

Static Public Member Functions

static build_query_from_filter (array $filter)
 Return the SQL WHERE condition and parameters to be ANDed with other filter conditions.
 
static get_condition_key ()
 Each condition will need a unique key to be identified and sequenced by the api.
 
static get_filter_from_list (array $filters)
 Given an array of filters, pick the entry that matches the condition key and return it.
 

Public Attributes

array array $filter
 Filter properties for this condition.
 
int const JOINTYPE_DEFAULT = datafilter::JOINTYPE_ANY
 The default filter type.
 

Protected Attributes

array array $params = []
 query param used in where.
 
string string $where = ''
 SQL fragment to add to the where clause.
 

Constructor & Destructor Documentation

◆ __construct()

core_question\local\bank\condition::__construct ( ?view $qbank = null)

Extract the required filter from the provided question bank view and set the initial values.

This will look for the filter matching {

See also
get_condition_key()} in the view's current filter parameter. If the filter is not being initialised to display the question bank UI (for example, to resolve a list of questions matching a set of filters), then the $qbank argument may be null, and any usage of it to set the initial filter state is skipped.
Parameters
?view$qbankThe question bank view the filter is being rendered for. This may only be used for setting the initial state of the filter.

Reimplemented in qbank_managecategories\category_condition.

Member Function Documentation

◆ allow_custom()

core_question\local\bank\condition::allow_custom ( )

Whether customisation is allowed.

Return values
bool

Reimplemented in qbank_managecategories\category_condition, qbank_tagquestion\tag_condition, and qbank_viewquestiontype\type_condition.

◆ allow_empty()

core_question\local\bank\condition::allow_empty ( )

Whether empty value is allowed.

Return values
bool

Reimplemented in qbank_managecategories\category_condition.

◆ allow_multiple()

core_question\local\bank\condition::allow_multiple ( )

Whether multiple values are allowed .

Return values
bool

Reimplemented in qbank_managecategories\category_condition.

◆ build_query_from_filter()

static core_question\local\bank\condition::build_query_from_filter ( array $filter)
staticabstract

Return the SQL WHERE condition and parameters to be ANDed with other filter conditions.

The $filter parameter recieves an array with a 'values' key, containing an array of the filter values selected, and a 'jointype' key containing the selected join type.

Parameters
array$filterfilter properties
Return values
array['SQL where condition', ['param1' => 'value1', 'param2' => 'value2', ...]]

Reimplemented in qbank_deletequestion\hidden_condition, qbank_editquestion\status_condition, qbank_managecategories\category_condition, qbank_tagquestion\tag_condition, qbank_viewcreator\timemodified_condition, qbank_viewcreator\user_condition, qbank_viewquestionname\question_idnumber_condition, qbank_viewquestionname\question_name_condition, qbank_viewquestiontext\questiontext_condition, and qbank_viewquestiontype\type_condition.

◆ display_options()

core_question\local\bank\condition::display_options ( )

Display GUI for selecting criteria for this condition.

Displayed always, whether Show More is open or not.

Compare display_options_adv(), which displays when Show More is open.

Return values
bool|stringHTML form fragment
Deprecated
since Moodle 4.0 MDL-72321 - please do not use this function any more.
Todo
Final deprecation on Moodle 4.1 MDL-72572

Reimplemented in qbank_managecategories\category_condition, and qbank_tagquestion\tag_condition.

◆ display_options_adv()

core_question\local\bank\condition::display_options_adv ( )

Display GUI for selecting criteria for this condition.

Displayed when Show More is open.

Compare display_options(), which displays always, whether Show More is open or not.

Return values
bool|stringHTML form fragment
Deprecated
since Moodle 4.0 MDL-72321 - please do not use this function any more.
Todo
Final deprecation on Moodle 4.1 MDL-72572

Reimplemented in qbank_managecategories\category_condition.

◆ filter_invalid_values()

core_question\local\bank\condition::filter_invalid_values ( array $filterconditions)

Method to be overridden in condition classes to filter out anything invalid from the filterconditions array.

This can be applied anywhere where the $filterconditions array exists, to let condition plugins remove elements from the array, based on their own internal logic/validation. For example, this is used on the /mod/quiz/editrandom.php page to filter out question categories which no longer exist, which previously broke the editrandom page.

Parameters
array$filterconditions
Return values
array

Reimplemented in qbank_managecategories\category_condition.

◆ get_condition_class()

core_question\local\bank\condition::get_condition_class ( )

Return this condition class.

Return values
string

◆ get_condition_key()

static core_question\local\bank\condition::get_condition_key ( )
staticabstract

Each condition will need a unique key to be identified and sequenced by the api.

Use a unique string for the condition identifier, use string directly, dont need to use language pack. Using language pack might break the filter object for multilingual support.

Return values
string

Reimplemented in qbank_deletequestion\hidden_condition, qbank_editquestion\status_condition, qbank_managecategories\category_condition, qbank_tagquestion\tag_condition, qbank_viewcreator\createdby_condition, qbank_viewcreator\modifiedby_condition, qbank_viewcreator\timemodified_condition, qbank_viewquestionname\question_idnumber_condition, qbank_viewquestionname\question_name_condition, qbank_viewquestiontext\questiontext_condition, and qbank_viewquestiontype\type_condition.

◆ get_filter_class()

core_question\local\bank\condition::get_filter_class ( )

Return the Javascript filter class to provide the UI for this condition.

If left as null, this will use the default core/datafilter/filtertype class. Otherwise, override it to return the full path to the Javascript module path for the class.

Return values
?stringfilter class

Reimplemented in qbank_deletequestion\hidden_condition, qbank_editquestion\status_condition, qbank_managecategories\category_condition, qbank_tagquestion\tag_condition, qbank_viewcreator\timemodified_condition, qbank_viewcreator\user_condition, qbank_viewquestionname\question_idnumber_condition, qbank_viewquestionname\question_name_condition, qbank_viewquestiontext\questiontext_condition, and qbank_viewquestiontype\type_condition.

◆ get_filter_from_list()

static core_question\local\bank\condition::get_filter_from_list ( array $filters)
static

Given an array of filters, pick the entry that matches the condition key and return it.

Parameters
array$filtersArray of filters, keyed by condition.
Return values
?arrayThe filter that matches this condition

◆ get_filteroptions()

core_question\local\bank\condition::get_filteroptions ( )

Extra data specific to this condition.

Return values
stdClass

Reimplemented in qbank_managecategories\category_condition.

◆ get_initial_values()

core_question\local\bank\condition::get_initial_values ( )

◆ get_join_list()

core_question\local\bank\condition::get_join_list ( )

◆ get_title()

◆ is_required()

core_question\local\bank\condition::is_required ( )

Whether this filter is required - if so it cannot be removed from the list of filters.

Return values
bool

Reimplemented in qbank_deletequestion\hidden_condition, and qbank_managecategories\category_condition.

◆ params()

core_question\local\bank\condition::params ( )

Return parameters to be bound to the above WHERE clause fragment.

Return values
arrayparameter name => value.

◆ where()

core_question\local\bank\condition::where ( )

Return an SQL fragment to be ANDed into the WHERE clause to filter which questions are shown.

Return values
stringSQL fragment. Must use named parameters.

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