Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 310 and 311] [Versions 39 and 311]

Course handler for custom fields

Copyright: 2018 David Matamoros <davidmc@moodle.com>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 241 lines (9 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: course_handler  - X-Ref

Course handler for custom fields

create(int $itemid = 0)   X-Ref
Returns a singleton

param: int $itemid
return: \core_course\customfield\course_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 on the given course.

param: field_controller $field
param: int $instanceid id of the course 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 on the given course.

param: field_controller $field
param: int $instanceid id of the course to test edit permission
return: bool true if the current can edit custom fields, false otherwise

set_parent_context(\context $context)   X-Ref
Sets parent context for the course

This may be needed when course is being created, there is no course context but we need to check capabilities

param: \context $context

get_parent_context()   X-Ref
Returns the parent context for the course

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 of the fields on this handler.

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

config_form_definition(\MoodleQuickForm $mform)   X-Ref
Allows to add custom controls to the field configuration form that will be saved in configdata

param: \MoodleQuickForm $mform

restore_instance_data_from_backup(\restore_task $task, array $data)   X-Ref
Creates or updates custom field data.

param: \restore_task $task
param: array $data