Moodle APIs
3.8
Moodle 3.8.6 (Build: 20201109)
|
Files | |
file | behat_cohort.php |
Cohorts steps definitions. | |
file | cohort_summary_exporter.php |
Class for exporting a cohort summary from an stdClass. | |
file | cohortidnumber.php |
Contains class core_cohort\output\cohortidnumber. | |
file | cohortname.php |
Contains class core_cohort\output\cohortname. | |
file | edit_form.php |
Cohort related management functions, this file needs to be included manually. | |
file | externallib.php |
External cohort API. | |
file | upload_form.php |
A form for cohort upload. | |
Namespaces | |
core_cohort\external | |
| |
core_cohort\output | |
| |
core_cohort\privacy | |
| |
Classes | |
class | behat_cohort |
class | cohort_candidate_selector |
Cohort assignment candidates. More... | |
class | cohort_edit_form |
class | cohort_existing_selector |
Cohort assignment candidates. More... | |
class | cohort_upload_form |
Cohort upload form class. More... | |
class | core_cohort\external\cohort_summary_exporter |
Class for exporting a cohort summary from an stdClass. More... | |
class | core_cohort\output\cohortidnumber |
Class to prepare a cohort idnumber for display. More... | |
class | core_cohort\output\cohortname |
Class to prepare a cohort name for display. More... | |
class | core_cohort\privacy\provider |
Privacy class for requesting user data. More... | |
class | core_cohort_external |
Functions | |
cohort_add_cohort ($cohort) | |
Add new cohort. More... | |
cohort_add_member ($cohortid, $userid) | |
Add cohort member. More... | |
cohort_can_view_cohort ($cohortorid, $currentcontext) | |
Check if cohort exists and user is allowed to access it from the given context. More... | |
cohort_delete_category ($category) | |
Somehow deal with cohorts when deleting course category, we can not just delete them because they might be used in enrol plugins or referenced in external systems. More... | |
cohort_delete_cohort ($cohort) | |
Delete cohort. More... | |
cohort_edit_controls (context $context, moodle_url $currenturl) | |
Returns navigation controls (tabtree) to be displayed on cohort management pages. More... | |
cohort_get_all_cohorts ($page=0, $perpage=25, $search='') | |
Get all the cohorts defined anywhere in system. More... | |
cohort_get_available_cohorts ($currentcontext, $withmembers=0, $offset=0, $limit=25, $search='') | |
Returns the list of cohorts visible to the current user in the given course. More... | |
cohort_get_cohort ($cohortorid, $currentcontext) | |
Get a cohort by id. More... | |
cohort_get_cohorts ($contextid, $page=0, $perpage=25, $search='') | |
Get all the cohorts defined in given context. More... | |
cohort_get_list_of_themes () | |
Returns a list of valid themes which can be displayed in a selector. More... | |
cohort_get_user_cohort_theme ($userid) | |
Get the user cohort theme. More... | |
cohort_get_user_cohorts ($userid) | |
Get all the cohorts where the given user is member of. More... | |
cohort_is_member ($cohortid, $userid) | |
Is this user a cohort member? More... | |
cohort_remove_member ($cohortid, $userid) | |
Remove cohort member. More... | |
cohort_update_cohort ($cohort) | |
Update existing cohort. More... | |
core_cohort_inplace_editable ($itemtype, $itemid, $newvalue) | |
Implements callback inplace_editable() allowing to edit values in-place. More... | |
cohort_add_cohort | ( | $cohort | ) |
Add new cohort.
stdClass | $cohort |
int | new cohort id |
cohort_add_member | ( | $cohortid, | |
$userid | |||
) |
Add cohort member.
int | $cohortid | |
int | $userid |
void |
cohort_can_view_cohort | ( | $cohortorid, | |
$currentcontext | |||
) |
Check if cohort exists and user is allowed to access it from the given context.
stdClass | int | $cohortorid | cohort object or id |
context | $currentcontext | current context (course) where visibility is checked |
boolean |
cohort_delete_category | ( | $category | ) |
Somehow deal with cohorts when deleting course category, we can not just delete them because they might be used in enrol plugins or referenced in external systems.
stdClass | core_course_category | $category |
void |
cohort_delete_cohort | ( | $cohort | ) |
Delete cohort.
stdClass | $cohort |
void |
cohort_edit_controls | ( | context | $context, |
moodle_url | $currenturl | ||
) |
Returns navigation controls (tabtree) to be displayed on cohort management pages.
context | $context | system or category context where cohorts controls are about to be displayed |
moodle_url | $currenturl |
null|renderable |
cohort_get_all_cohorts | ( | $page = 0 , |
|
$perpage = 25 , |
|||
$search = '' |
|||
) |
Get all the cohorts defined anywhere in system.
The function assumes that user capability to view/manage cohorts on system level has already been verified. This function only checks if such capabilities have been revoked in child (categories) contexts.
int | $page | number of the current page |
int | $perpage | items per page |
string | $search | search string |
array | Array(totalcohorts => int, cohorts => array, allcohorts => int) |
cohort_get_available_cohorts | ( | $currentcontext, | |
$withmembers = 0 , |
|||
$offset = 0 , |
|||
$limit = 25 , |
|||
$search = '' |
|||
) |
Returns the list of cohorts visible to the current user in the given course.
The following fields are returned in each record: id, name, contextid, idnumber, visible Fields memberscnt and enrolledcnt will be also returned if requested
context | $currentcontext | |
int | $withmembers | one of the COHORT_XXX constants that allows to return non empty cohorts only or cohorts with enroled/not enroled users, or just return members count |
int | $offset | |
int | $limit | |
string | $search |
array |
cohort_get_cohort | ( | $cohortorid, | |
$currentcontext | |||
) |
Get a cohort by id.
Also does a visibility check and returns false if the user cannot see this cohort.
stdClass | int | $cohortorid | cohort object or id |
context | $currentcontext | current context (course) where visibility is checked |
stdClass|boolean |
cohort_get_cohorts | ( | $contextid, | |
$page = 0 , |
|||
$perpage = 25 , |
|||
$search = '' |
|||
) |
Get all the cohorts defined in given context.
The function does not check user capability to view/manage cohorts in the given context assuming that it has been already verified.
int | $contextid | |
int | $page | number of the current page |
int | $perpage | items per page |
string | $search | search string |
array | Array(totalcohorts => int, cohorts => array, allcohorts => int) |
cohort_get_list_of_themes | ( | ) |
Returns a list of valid themes which can be displayed in a selector.
array | as (string)themename => (string)get_string_theme |
cohort_get_user_cohort_theme | ( | $userid | ) |
Get the user cohort theme.
If the user is member of one cohort, will return this cohort theme (if defined). If the user is member of 2 or more cohorts, will return the theme if all them have the same theme (null themes are ignored).
int | $userid |
string|null |
cohort_get_user_cohorts | ( | $userid | ) |
Get all the cohorts where the given user is member of.
int | $userid |
array | Array |
cohort_is_member | ( | $cohortid, | |
$userid | |||
) |
Is this user a cohort member?
int | $cohortid | |
int | $userid |
bool |
cohort_remove_member | ( | $cohortid, | |
$userid | |||
) |
Remove cohort member.
int | $cohortid | |
int | $userid |
void |
cohort_update_cohort | ( | $cohort | ) |
Update existing cohort.
stdClass | $cohort |
void |
core_cohort_inplace_editable | ( | $itemtype, | |
$itemid, | |||
$newvalue | |||
) |
Implements callback inplace_editable() allowing to edit values in-place.
string | $itemtype | |
int | $itemid | |
mixed | $newvalue |
core |