Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
core_completion\manager Class Reference

Public Member Functions

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

Static Public Member Functions

static can_edit_bulk_completion ($courseorid, $cm=null)
 Checks if current user can edit activity completion. More...
 
static get_available_completion_tabs ($courseorid)
 Gets the available completion tabs for the current course and user. More...
 
static get_default_completion ($course, $module, $flatten=true)
 Returns default completion rules for given module type in the given course. More...
 

Protected Member Functions

 apply_completion_cm (\cm_info $cm, $data, $updateinstance)
 Applies new completion rules to one course module. More...
 
 get_completion_active_rule_descriptions ($moduledata)
 Get the descriptions for all active conditional completion rules for the current module. More...
 

Protected Attributes

int $courseid
 $courseid the course id.
 

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

static core_completion\manager::get_available_completion_tabs (   $courseorid)
static

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

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: