Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

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

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.

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