Search moodle.org's
Developer Documentation

See Release Notes

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

(no description)

File Size: 222 lines (6 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: condition  - X-Ref

An abstract class for filtering/searching questions.

__construct(view $qbank = null)   X-Ref
Extract the required filter from the provided question bank view.

This will look for the filter matching {@see get_condition_key()}

param: view|null $qbank

allow_custom()   X-Ref
Whether customisation is allowed.

return: bool

allow_multiple()   X-Ref
Whether multiple values are allowed .

return: bool

get_initial_values()   X-Ref
Initial values of the condition

return: array

get_filteroptions()   X-Ref
Extra data specific to this condition.

return: \stdClass

allow_empty()   X-Ref
Whether empty value is allowed

return: bool

is_required()   X-Ref
Whether this filter is required - if so it cannot be removed from the list of filters.

return: bool

get_condition_class()   X-Ref
Return this condition class

return: string

get_condition_key()   X-Ref
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: string

where()   X-Ref
Return an SQL fragment to be ANDed into the WHERE clause to filter which questions are shown.

return: string SQL fragment. Must use named parameters.

params()   X-Ref
Return parameters to be bound to the above WHERE clause fragment.

return: array parameter name => value.

display_options_adv()   X-Ref
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: bool|string HTML form fragment

display_options()   X-Ref
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: bool|string HTML form fragment

get_join_list()   X-Ref
Get the list of available joins for the filter.

return: array

get_filter_from_list(array $filters)   X-Ref
Given an array of filters, pick the entry that matches the condition key and return it.

param: array $filters Array of filters, keyed by condition.
return: ?array The filter that matches this condition

build_query_from_filter(array $filter)   X-Ref
Build query from filter value

param: array $filter filter properties
return: array where sql and params