Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
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)
 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 ()
 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 ($courseorid)
 Gets the available completion tabs for the current course and user.
 
static get_default_completion ($course, $module, $flatten=true)
 Returns default completion rules for given module type in the given course.
 

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.
 

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 )

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.

◆ 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 ( )

Gets the course modules for the current course.

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 ( $courseorid)
static

Gets the available completion tabs for the current course and user.

Deprecated
since Moodle 4.0
Parameters
stdClass | int$courseoridthe course object or id.
Return values
tabobject[]

◆ 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_default_completion()

static core_completion\manager::get_default_completion ( $course,
$module,
$flatten = true )
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']
Return values
stdClass

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