Moodle PHP Documentation 4.3
Moodle 4.3.5 (Build: 20240610) (7dcfaa79f78)
tool_cohortroles\api Class Reference

Class for doing things with cohort roles. More...

Static Public Member Functions

static count_cohort_role_assignments ()
 Perform a search based on the provided filters and return a paginated list of records.
 
static create_cohort_role_assignment (stdClass $record)
 Create a cohort role assignment from a record containing all the data for the class.
 
static delete_cohort_role_assignment ($id)
 Delete a cohort role assignment by id.
 
static list_cohort_role_assignments ($sort='', $order='ASC', $skip=0, $limit=0)
 Perform a search based on the provided filters and return a paginated list of records.
 
static sync_all_cohort_roles ()
 Sync all roles - adding and deleting role assignments as required.
 

Detailed Description

Class for doing things with cohort roles.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Member Function Documentation

◆ count_cohort_role_assignments()

static tool_cohortroles\api::count_cohort_role_assignments ( )
static

Perform a search based on the provided filters and return a paginated list of records.

Requires moodle/role:manage capability at system context.

Return values
int

◆ create_cohort_role_assignment()

static tool_cohortroles\api::create_cohort_role_assignment ( stdClass $record)
static

Create a cohort role assignment from a record containing all the data for the class.

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

Parameters
stdClass$recordRecord containing all the data for an instance of the class.
Return values
competency

◆ delete_cohort_role_assignment()

static tool_cohortroles\api::delete_cohort_role_assignment ( $id)
static

Delete a cohort role assignment by id.

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

Parameters
int$idThe record to delete. This will also remove this role from the user for all users in the system.
Return values
boolean

◆ list_cohort_role_assignments()

static tool_cohortroles\api::list_cohort_role_assignments ( $sort = '',
$order = 'ASC',
$skip = 0,
$limit = 0 )
static

Perform a search based on the provided filters and return a paginated list of records.

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

Parameters
string$sortThe column to sort on
string$order('ASC' or 'DESC')
int$skipNumber of records to skip (pagination)
int$limitMax of records to return (pagination)
Return values
arrayof cohort_role_assignment

◆ sync_all_cohort_roles()

static tool_cohortroles\api::sync_all_cohort_roles ( )
static

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 values
array('rolesadded'=> array of (useridassignedto, useridassignedover, roleid), 'rolesremoved' => array of (useridassignedto, useridassignedover, roleid))

The documentation for this class was generated from the following file: