Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

(no description)

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

Defines 1 class


Class: manager  - X-Ref

Class manager for database activity

__construct(cm_info $cm, stdClass $instance)   X-Ref
Class constructor.

param: cm_info $cm course module info object
param: stdClass $instance activity instance object.

create_from_instance(stdClass $instance)   X-Ref
Create a manager instance from an instance record.

param: stdClass $instance an activity record
return: manager

create_from_coursemodule($cm)   X-Ref
Create a manager instance from a course_modules record.

param: stdClass|cm_info $cm an activity record
return: manager

create_from_data_record($record)   X-Ref
Create a manager instance from a data_record entry.

param: stdClass $record the data_record record
return: manager

get_context()   X-Ref
Return the current context.

return: context_module

get_instance()   X-Ref
Return the current instance.

return: stdClass the instance record

get_coursemodule()   X-Ref
Return the current cm_info.

return: cm_info the course module

get_renderer(?moodle_page $page = null)   X-Ref
Return the current module renderer.

param: moodle_page|null $page the current page
return: mod_data_renderer the module renderer

set_module_viewed(stdClass $course)   X-Ref
Trigger module viewed event and set the module viewed for completion.

param: stdClass $course course object

set_template_viewed()   X-Ref
Trigger module template viewed event.


has_records()   X-Ref
Return if the database has records.

return: bool true if the database has records

has_fields()   X-Ref
Return if the database has fields.

return: bool true if the database has fields

get_fields()   X-Ref
Return the database fields.

return: data_field_base[] the field instances.

get_field_records()   X-Ref
Return the field records (the current data_fields records).

return: stdClass[] an array of records

get_field(stdClass $fieldrecord)   X-Ref
Return a specific field instance from a field record.

param: stdClass $fieldrecord the fieldrecord to convert
return: data_field_base the data field class instance

get_template(string $templatename, array $options = [])   X-Ref
Return a specific template.

NOTE: this method returns a default template if the module template is empty.
However, it won't update the template database field.

Some possible options:
- search: string with the current searching text.
- page: integer repesenting the current pagination page numbre (if any)
- baseurl: a moodle_url object to the current page.

param: string $templatename
param: array $options extra display options array
return: template the template instance

can_manage_templates(?int $userid = null)   X-Ref
No description

can_export_entries(?int $userid = null)   X-Ref
No description

update_templates(stdClass $newtemplates)   X-Ref
Update the database templates.

param: stdClass $newtemplates an object with all the new templates
return: bool if updated successfully.

reset_all_templates()   X-Ref
Reset all templates.

return: bool if the reset is done or not

reset_template(string $templatename)   X-Ref
Reset all templates related to a specific template.

param: string $templatename the template name
return: bool if the reset is done or not

can_view_preset(preset $preset, ?int $userid = null)   X-Ref
No description

get_available_presets()   X-Ref
Returns an array of all the available presets.

return: array A list with the datapreset plugins and the presets saved by users.

get_available_saved_presets()   X-Ref
Returns an array of all the presets that users have saved to the site.

return: array A list with the preset saved by the users.

get_available_plugin_presets()   X-Ref
Returns an array of all the available plugin presets.

return: array A list with the datapreset plugins.