See Release Notes
Long Term Support Release
Differences Between: [Versions 401 and 402] [Versions 401 and 403]
(no description)
File Size: | 328 lines (12 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
question_handler:: (17 methods):
create()
reset_caches()
can_configure()
can_edit()
can_view()
can_view_type()
set_parent_context()
get_parent_context()
get_configuration_context()
get_configuration_url()
get_instance_context()
get_field_data()
get_categories_fields_data()
display_custom_field_table()
display_custom_categories_fields()
config_form_definition()
restore_instance_data_from_backup()
Class: question_handler - X-Ref
Question handler for custom fields.create(int $itemid = 0) X-Ref |
Creates the custom field handler and returns a singleton. Itemid is always zero as the custom fields are the same for every question across the system. param: int $itemid Always zero. return: \qbank_customfields\customfield\question_handler |
reset_caches() X-Ref |
Run reset code after unit tests to reset the singleton usage. |
can_configure() X-Ref |
The current user can configure custom fields on this component. return: bool true if the current can configure custom fields, false otherwise |
can_edit(field_controller $field, int $instanceid = 0) X-Ref |
The current user can edit custom fields for the given question. param: field_controller $field param: int $instanceid id of the question to test edit permission return: bool true if the current can edit custom fields, false otherwise |
can_view(field_controller $field, int $instanceid) X-Ref |
The current user can view custom fields for the given question. param: field_controller $field param: int $instanceid id of the question to test edit permission return: bool true if the current can edit custom fields, false otherwise |
can_view_type(field_controller $field, \context $context) X-Ref |
Determine if the current user can view custom field in their given context. This determines if the user can see the field at all not just the field for a particular instance. Used primarily in showing or not the field in the question bank table. param: field_controller $field The field trying to be viewed. param: context $context The context the field is being displayed in. return: bool true if the current can edit custom fields, false otherwise. |
set_parent_context(\context $context) X-Ref |
Sets parent context for the question. This may be needed when question is being created, there is no question context but we need to check capabilities param: \context $context |
get_parent_context() X-Ref |
Returns the parent context for the question. return: \context |
get_configuration_context() X-Ref |
Context that should be used for new categories created by this handler. return: \context the context for configuration |
get_configuration_url() X-Ref |
URL for configuration page for the fields for the question custom fields. return: \moodle_url The URL to configure custom fields for this component |
get_instance_context(int $instanceid = 0) X-Ref |
Returns the context for the data associated with the given instanceid. param: int $instanceid id of the record to get the context for return: \context the context for the given record |
get_field_data(\core_customfield\field_controller $field, int $instanceid) X-Ref |
Given a field and instance id get all the filed data. param: field_controller $field The field to get the data for. param: int $instanceid The instance id to get the data for. return: \core_customfield\data_controller The fetched data. |
get_categories_fields_data(int $instanceid) X-Ref |
For a given instance id (question id) get the categories and the fields with any data. Return an array of categories containing an array of field names and values that is ready to be passed to a renderer. param: int $instanceid The instance id to get the data for. return: array $cfdata The fetched data |
display_custom_field_table(object $fielddata) X-Ref |
Get the custom data for the given field and render HTML ready for display in question table. param: object $fielddata The field data used for display. return: string The HTML to display in the table column. |
display_custom_categories_fields(array $catfielddata) X-Ref |
Render the custom field category and filed data as HTML ready for display. param: array $catfielddata Array of categories and field names and values. return: string The HTML to display. |
config_form_definition(\MoodleQuickForm $mform) X-Ref |
Add custom controls to the field configuration form that will be saved. param: \MoodleQuickForm $mform The form to add the custom fields to. |
restore_instance_data_from_backup(\restore_task $task, array $data) X-Ref |
Creates or updates the question custom field data when restoring from a backup. param: \restore_task $task param: array $data |