Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 310 and 400] [Versions 311 and 400] [Versions 39 and 400]

Class exposing the api for the cohortroles tool.

Copyright: 2015 Damyon Wiese
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 275 lines (12 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: api  - X-Ref

Class for doing things with cohort roles.

create_cohort_role_assignment(stdClass $record)   X-Ref
Create a cohort role assignment from a record containing all the data for the class.

Requires moodle/role:manage capability at the system context.

return: competency
param: stdClass $record Record containing all the data for an instance of the class.

delete_cohort_role_assignment($id)   X-Ref
Delete a cohort role assignment by id.

Requires moodle/role:manage capability at the system context.

return: boolean
param: int $id The record to delete. This will also remove this role from the user for all users in the system.

list_cohort_role_assignments($sort = '', $order = 'ASC', $skip = 0, $limit = 0)   X-Ref
Perform a search based on the provided filters and return a paginated list of records.

Requires moodle/role:manage capability at the system context.

return: array of cohort_role_assignment
param: string $sort The column to sort on
param: string $order ('ASC' or 'DESC')
param: int $skip Number of records to skip (pagination)
param: int $limit Max of records to return (pagination)

count_cohort_role_assignments()   X-Ref
Perform a search based on the provided filters and return a paginated list of records.

Requires moodle/role:manage capability at system context.

return: int

sync_all_cohort_roles()   X-Ref
Sync all roles - adding and deleting role assignments as required.

Slow. Should only be called from a background task.

Requires moodle/role:manage capability at the system context.

return: array('rolesadded' => array of (useridassignedto, useridassignedover, roleid),