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 |
does:: (6 methods):
set_suffix()
get_suffix()
add_completion_elements()
add_completiongrade_elements()
validate_completion()
definition_after_data_completion()
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. |