Moodle APIs 4.3
Moodle 4.3.6 (Build: 20240812)
core_completion

Topics

 completion
 
 
 external
 
 
 test
 
 

Namespaces

namespace  core_completion
  
 
namespace  core_completion\external
  
 
namespace  core_completion\form
  
 
namespace  core_completion\privacy
 Privacy class for requesting user data.
 

Classes

class  behat_core_completion_generator
 Completion test generator for Behat. More...
 
class  core_completion\activity_custom_completion
 Base class for defining an activity module's custom completion rules. More...
 
class  core_completion\api
 Class containing completion API. More...
 
class  core_completion\cm_completion_details
 Class for building the user's activity completion details. More...
 
class  core_completion\external\completion_info_exporter
 Completion info exporter. More...
 
class  core_completion\privacy\provider
 Privacy class for requesting user data. More...
 
class  core_completion\progress
 Class used to return completion progress information. More...
 
class  core_completion_bulkedit_form
 Bulk edit activity completion form. More...
 
class  core_completion_defaultedit_form
 Default activity completion form. More...
 
class  core_completion_edit_base_form
 Base form for changing completion rules. More...
 
class  core_completion_generator
 Completion test generator. More...
 

Functions

 core_completion\form::add_completion_elements (string $modname=null, bool $supportviews=false, bool $supportgrades=false, bool $rating=false, ?int $courseid=null)
 Add completion elements to the form.
 
 core_completion\form::add_completion_rules ()
 Add completion elements to the form and return the list of element ids.
 
 core_completion\form::add_completiongrade_elements (string $modname, bool $rating=false)
 Add completion grade elements to the form.
 
 core_completion\form::add_completiongrade_rules ()
 Add completion grading elements to the form and return the list of element ids.
 
 core_completion\form::completion_rule_enabled ($data)
 Called during validation.
 
 core_completion\form::definition_after_data_completion (?cm_info $cm=null)
 It should be called from the definition_after_data() to setup the completion settings in the form.
 
 core_completion\form::get_form ()
 Get the form associated to this class, where the completion elements will be added.
 
 core_completion\form::get_suffix ()
 Get the suffix to be added to the completion elements when creating them (for example, 'completion_assign').
 
 core_completion\form::set_suffix (string $suffix)
 Set the suffix to be added to the completion elements when creating them (for example, 'completion_assign').
 
 core_completion\form::validate_completion (array $data)
 Perform some extra validation for completion settings.
 

Variables

trait core_completion\form::form_trait
 Completion trait helper, with methods to add completion elements and validate them.
 

Detailed Description

Function Documentation

◆ add_completion_elements()

core_completion\form\add_completion_elements ( string $modname = null,
bool $supportviews = false,
bool $supportgrades = false,
bool $rating = false,
?int $courseid = null )
protected

Add completion elements to the form.

Parameters
string | null$modnameThe module name (for example, 'assign'). If null and form is moodleform_mod, the parameters are overriden with the expected values from the form.
bool$supportviewsTrue if the module supports views and false otherwise.
bool$supportgradesTrue if the module supports grades and false otherwise.
bool$ratingTrue if the rating feature is enabled and false otherwise.
int | null$courseidCourse where to add completion elements.
Exceptions
coding_exceptionIf the form is not moodleform_mod and $modname is null.

◆ add_completion_rules()

core_completion\form\add_completion_rules ( )
abstractprotected

Add completion elements to the form and return the list of element ids.

Return values
arrayArray of string IDs of added items, empty array if none

◆ add_completiongrade_elements()

core_completion\form\add_completiongrade_elements ( string $modname,
bool $rating = false )
protected

Add completion grade elements to the form.

Parameters
string$modnameThe name of the module (for example, 'assign').
bool$ratingTrue if the rating feature is enabled and false otherwise.

◆ add_completiongrade_rules()

core_completion\form\add_completiongrade_rules ( )
abstract

Add completion grading elements to the form and return the list of element ids.

Return values
arrayArray of string IDs of added items, empty array if none

◆ completion_rule_enabled()

core_completion\form\completion_rule_enabled ( $data)
abstractprotected

Called during validation.

Override this method to indicate, based on the data, whether a custom completion rule is selected or not.

Parameters
array$dataInput data (not yet validated)
Return values
boolTrue if one or more rules are enabled; false if none are.

◆ definition_after_data_completion()

core_completion\form\definition_after_data_completion ( ?cm_info $cm = null)
protected

It should be called from the definition_after_data() to setup the completion settings in the form.

Parameters
cm_info | null$cmThe course module associated to this form.

◆ get_form()

core_completion\form\get_form ( )
protected

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 values
MoodleQuickForm
Exceptions
coding_exceptionIf the class does not have a _form property.

◆ get_suffix()

core_completion\form\get_suffix ( )

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

Return values
stringThe suffix

◆ set_suffix()

core_completion\form\set_suffix ( string $suffix)

Set the suffix to be added to the completion elements when creating them (for example, 'completion_assign').

Parameters
string$suffix

◆ validate_completion()

core_completion\form\validate_completion ( array $data)
protected

Perform some extra validation for completion settings.

Parameters
array$dataArray of ["fieldname" => value] of submitted data.
Return values
arrayList of ["element_name" => "error_description"] if there are errors or an empty array if everything is OK.

Variable Documentation

◆ form_trait

trait core_completion::form\form_trait
Initial value:
{
protected string $suffix = ''

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

Since
Moodle 4.3
License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later