cohort_support
class cohort_support
| internal |
Utility functions for Moodle cohorts.
Methods
Retrieves cohorts for a given context with pagination and optional search.
Retrieves cohorts with normalization and total count.
Retrieves all visible cohorts as an options list [id => name].
Creates a new cohort if a cohort with the given idnumber does not exist.
Details
at line 48
static array
get_cohorts(int $contextid, int $page = 0, int $perpage = 25, string $search = '')
Retrieves cohorts for a given context with pagination and optional search.
at line 66
static array
get_cohorts_with_total(int $contextid, int $page = 0, int $perpage = 25, string $search = '')
Retrieves cohorts with normalization and total count.
Some Moodle versions return an associative array with keys like 'cohorts' and 'totalcohorts'. This method abstracts that variation and always returns a normalized structure.
at line 103
static array
get_all()
Retrieves all visible cohorts as an options list [id => name].
at line 127
static void
create_cohort(string $name, string $idnumber)
Creates a new cohort if a cohort with the given idnumber does not exist.