Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

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

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: 274 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.

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

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

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

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

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.

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)
return: array of cohort_role_assignment

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),