Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
core_completion\manager Class Reference

Bulk activity completion manager class. More...

Public Member Functions

 __construct ($courseid)
 manager constructor.
 
 apply_completion ($data, $updateinstances)
 Applies completion from the bulk edit form to all selected modules.
 
 apply_default_completion ($data, $updatecustomrules, string $suffix='')
 Saves default completion from edit form to all selected module types.
 
 get_activities ($cmids, $withcompletiondetails=false)
 Gets the data (context) to be used with the activityinstance template.
 
 get_activities_and_headings ()
 Gets the data (context) to be used with the bulkactivitycompletion template.
 
 get_activities_and_resources (bool $includedefaults=true)
 Gets the course modules for the current course.
 

Static Public Member Functions

static can_edit_bulk_completion ($courseorid, $cm=null)
 Checks if current user can edit activity completion.
 
static get_available_completion_options (int $courseid)
 Returns an array with the available completion options (url => name) for the current course and user.
 
static get_available_completion_tabs ()
 
static get_default_completion ($course, $module, $flatten=true, string $suffix='')
 Returns default completion rules for given module type in the given course.
 
static get_module_form (string $modname, stdClass $course, ?cm_info $cm=null, string $suffix='')
 Return a mod_form of the given module.
 

Protected Member Functions

 apply_completion_cm (\cm_info $cm, $data, $updateinstance)
 Applies new completion rules to one course module.
 
 get_completion_active_rule_descriptions ($moduledata)
 Get the descriptions for all active conditional completion rules for the current module.
 
 get_context ()
 Returns current course context or system level for $SITE courseid.
 

Protected Attributes

int $courseid
 $courseid the course id.
 

Detailed Description

Bulk activity completion manager class.

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

Constructor & Destructor Documentation

◆ __construct()

core_completion\manager::__construct ( $courseid)

manager constructor.

Parameters
int$courseidthe course id.

Member Function Documentation

◆ apply_completion()

core_completion\manager::apply_completion ( $data,
$updateinstances )

Applies completion from the bulk edit form to all selected modules.

Parameters
stdClass$datadata received from the core_completion_bulkedit_form
bool$updateinstancesif we need to update the instance tables of the module (i.e. 'assign', 'forum', etc.) - if no module-specific completion rules were added to the form, update of the module table is not needed.

◆ apply_completion_cm()

core_completion\manager::apply_completion_cm ( \cm_info $cm,
$data,
$updateinstance )
protected

Applies new completion rules to one course module.

Parameters
cm_info$cm
array$data
bool$updateinstanceif we need to update the instance table of the module (i.e. 'assign', 'forum', etc.) - if no module-specific completion rules were added to the form, update of the module table is not needed.
Return values
boolif module was updated

◆ apply_default_completion()

core_completion\manager::apply_default_completion ( $data,
$updatecustomrules,
string $suffix = '' )

Saves default completion from edit form to all selected module types.

Parameters
stdClass$datadata received from the core_completion_bulkedit_form
bool$updatecustomrulesif we need to update the custom rules of the module - if no module-specific completion rules were added to the form, update of the module table is not needed.
string$suffixthe suffix to add to the name of the completion rules.

◆ can_edit_bulk_completion()

static core_completion\manager::can_edit_bulk_completion ( $courseorid,
$cm = null )
static

Checks if current user can edit activity completion.

Parameters
int | stdClass$courseorid
cm_info | null$cmif specified capability for a given coursemodule will be check, if not specified capability to edit at least one activity is checked.

◆ get_activities()

core_completion\manager::get_activities ( $cmids,
$withcompletiondetails = false )

Gets the data (context) to be used with the activityinstance template.

Parameters
array$cmidslist of course module ids
bool$withcompletiondetailsinclude completion details
Return values
array

◆ get_activities_and_headings()

core_completion\manager::get_activities_and_headings ( )

Gets the data (context) to be used with the bulkactivitycompletion template.

Return values
stdClassdata for use with the bulkactivitycompletion template.

◆ get_activities_and_resources()

core_completion\manager::get_activities_and_resources ( bool $includedefaults = true)

Gets the course modules for the current course.

Parameters
bool$includedefaultsWhether the default values should be included or not.
Return values
stdClass\$datacontaining the modules

◆ get_available_completion_options()

static core_completion\manager::get_available_completion_options ( int $courseid)
static

Returns an array with the available completion options (url => name) for the current course and user.

Parameters
int$courseidThe course id.
Return values
array

◆ get_available_completion_tabs()

static core_completion\manager::get_available_completion_tabs ( )
static
Deprecated
since Moodle 4.0

◆ get_completion_active_rule_descriptions()

core_completion\manager::get_completion_active_rule_descriptions ( $moduledata)
protected

Get the descriptions for all active conditional completion rules for the current module.

Parameters
cm_info | stdClass$moduledataeither instance of cm_info (with 'customcompletionrules' in customdata) or object with fields ->completion, ->completionview, ->completionexpected, ->completionusegrade and ->customdata['customcompletionrules']
Return values
array\$activeruledescriptionsan array of strings describing the active completion rules.

◆ get_context()

core_completion\manager::get_context ( )
protected

Returns current course context or system level for $SITE courseid.

Return values
contextThe course based on current courseid or system context.

◆ get_default_completion()

static core_completion\manager::get_default_completion ( $course,
$module,
$flatten = true,
string $suffix = '' )
static

Returns default completion rules for given module type in the given course.

Parameters
stdClass$course
stdClass$module
bool$flattenif true all module custom completion rules become properties of the same object, otherwise they can be found as array in ->customdata['customcompletionrules']
string$suffixthe suffix to add to the name of the completion rules.
Return values
stdClass

◆ get_module_form()

static core_completion\manager::get_module_form ( string $modname,
stdClass $course,
?cm_info $cm = null,
string $suffix = '' )
static

Return a mod_form of the given module.

Parameters
string$modnameModule to get the form from.
stdClass$courseCourse object.
?cm_info$cmcm_info object to use.
string$suffixThe suffix to add to the name of the completion rules.
Return values
?\moodleform_modThe moodleform_mod object if everything goes fine. Null otherwise.

The documentation for this class was generated from the following file: