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.

Completion trait helper, with methods to add completion elements and validate them.

Copyright: 2023 Sara Arjona (sara@moodle.com)
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 502 lines (23 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

Defines 6 functions

  get_form()

Class: does  - X-Ref

set_suffix(string $suffix)   X-Ref
Set the suffix to be added to the completion elements when creating them (for example, 'completion_assign').

param: string $suffix

get_suffix()   X-Ref
Get the suffix to be added to the completion elements when creating them (for example, 'completion_assign').

return: string The suffix

add_completion_elements(string $modname = null,bool $supportviews = false,bool $supportgrades = false,bool $rating = false,?int $courseid = null)   X-Ref
Add completion elements to the form.

param: string|null $modname The module name (for example, 'assign'). If null and form is moodleform_mod, the parameters are
param: bool $supportviews True if the module supports views and false otherwise.
param: bool $supportgrades True if the module supports grades and false otherwise.
param: bool $rating True if the rating feature is enabled and false otherwise.
param: int|null $courseid Course where to add completion elements.

add_completiongrade_elements(string $modname,bool $rating = false)   X-Ref
Add completion grade elements to the form.

param: string $modname The name of the module (for example, 'assign').
param: bool $rating True if the rating feature is enabled and false otherwise.

validate_completion(array $data)   X-Ref
Perform some extra validation for completion settings.

param: array $data Array of ["fieldname" => value] of submitted data.
return: array List of ["element_name" => "error_description"] if there are errors or an empty array if everything is OK.

definition_after_data_completion(?cm_info $cm = null)   X-Ref
It should be called from the definition_after_data() to setup the completion settings in the form.

param: cm_info|null $cm The course module associated to this form.

Functions that are not part of a class:

get_form()   X-Ref
Get the form associated to this class, where the completion elements will be added.
This method must be overriden by the class using this trait if it doesn't include a _form property.

return: \MoodleQuickForm