Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.

Differences Between: [Versions 310 and 403] [Versions 311 and 403] [Versions 39 and 403] [Versions 400 and 403] [Versions 401 and 403] [Versions 402 and 403]

Bulk activity completion manager class

Copyright: 2017 Adrian Greeve
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 630 lines (27 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: manager  - X-Ref

Bulk activity completion manager class

__construct($courseid)   X-Ref
manager constructor.

param: int $courseid the course id.

get_context()   X-Ref
Returns current course context or system level for $SITE courseid.

return: context The course based on current courseid or system context.

get_activities_and_headings()   X-Ref
Gets the data (context) to be used with the bulkactivitycompletion template.

return: stdClass data for use with the bulkactivitycompletion template.

get_activities($cmids, $withcompletiondetails = false)   X-Ref
Gets the data (context) to be used with the activityinstance template

param: array $cmids list of course module ids
param: bool $withcompletiondetails include completion details
return: array

get_completion_detail($mod)   X-Ref
Get completion information on the selected module or module type

param: cm_info|stdClass $mod either instance of cm_info (with 'customcompletionrules' in customdata) or
return: array

get_completion_active_rule_descriptions($moduledata)   X-Ref
Get the descriptions for all active conditional completion rules for the current module.

param: cm_info|stdClass $moduledata either instance of cm_info (with 'customcompletionrules' in customdata) or
return: array $activeruledescriptions an array of strings describing the active completion rules.

get_activities_and_resources(bool $includedefaults = true)   X-Ref
Gets the course modules for the current course.

param: bool $includedefaults Whether the default values should be included or not.
return: stdClass $data containing the modules

can_edit_bulk_completion($courseorid, $cm = null)   X-Ref
Checks if current user can edit activity completion

param: int|stdClass $courseorid
param: \cm_info|null $cm if specified capability for a given coursemodule will be check,

get_available_completion_tabs($courseorid)   X-Ref
Gets the available completion tabs for the current course and user.

param: stdClass|int $courseorid the course object or id.
return: tabobject[]

get_available_completion_options(int $courseid)   X-Ref
Returns an array with the available completion options (url => name) for the current course and user.

param: int $courseid The course id.
return: array

apply_completion($data, $updateinstances)   X-Ref
Applies completion from the bulk edit form to all selected modules

param: stdClass $data data received from the core_completion_bulkedit_form
param: bool $updateinstances if we need to update the instance tables of the module (i.e. 'assign', 'forum', etc.) -

apply_completion_cm(\cm_info $cm, $data, $updateinstance)   X-Ref
Applies new completion rules to one course module

param: \cm_info $cm
param: array $data
param: bool $updateinstance if we need to update the instance table of the module (i.e. 'assign', 'forum', etc.) -
return: bool if module was updated

apply_default_completion($data, $updatecustomrules, string $suffix = '')   X-Ref
Saves default completion from edit form to all selected module types

param: stdClass $data data received from the core_completion_bulkedit_form
param: bool $updatecustomrules if we need to update the custom rules of the module -
param: string $suffix the suffix to add to the name of the completion rules.

get_default_completion($course, $module, $flatten = true, string $suffix = '')   X-Ref
Returns default completion rules for given module type in the given course

param: stdClass $course
param: stdClass $module
param: bool $flatten if true all module custom completion rules become properties of the same object,
param: string $suffix the suffix to add to the name of the completion rules.
return: stdClass