| Moodle APIs 4.3
    Moodle 4.3.6 (Build: 20240812) | 
| Topics | |
| external | |
| group | |
| privacy | |
| test | |
| Directories | |
| directory | reportbuilder | 
|  | |
| Namespaces | |
| namespace | core\event | 
|  | |
| namespace | core_group | 
| Group visibility methods. | |
| namespace | core_group\customfield | 
|  | |
| namespace | core_group\output | 
| Group details page. | |
| namespace | core_group\reportbuilder\datasource | 
|  | |
| namespace | core_group\reportbuilder\local\entities | 
|  | |
| Functions | |
| core_group_inplace_editable ($itemtype, $itemid, $newvalue) | |
| Callback for inplace editable API. | |
| get_group_custom_fields_data (array $groupids) | |
| Returns custom fields data for provided groups. | |
| get_grouping_custom_fields_data (array $groupingids) | |
| Returns custom fields data for provided groupings. | |
| groups_add_member ($grouporid, $userorid, $component=null, $itemid=0) | |
| Extra library for groups and groupings. | |
| groups_assign_grouping ($groupingid, $groupid, $timeadded=null, $invalidatecache=true) | |
| Assigns group into grouping. | |
| groups_calculate_role_people ($rs, $context) | |
| Internal function used by groups_get_members_by_role to handle the results of a database query that includes a list of users and possible roles on a course. | |
| groups_create_group ($data, $editform=false, $editoroptions=false) | |
| Add a new group. | |
| groups_create_grouping ($data, $editoroptions=null) | |
| Add a new grouping. | |
| groups_delete_group ($grouporid) | |
| Delete a group best effort, first removing members and links with courses and groupings. | |
| groups_delete_group_members ($courseid, $userid=0, $unused=false) | |
| Remove all users (or one user) from all groups in course. | |
| groups_delete_grouping ($groupingorid) | |
| Delete grouping. | |
| groups_delete_groupings ($courseid, $showfeedback=false) | |
| Delete all groupings from course. | |
| groups_delete_groupings_groups ($courseid, $showfeedback=false) | |
| Remove all groups from all groupings in course. | |
| groups_delete_groups ($courseid, $showfeedback=false) | |
| Delete all groups from course. | |
| groups_get_members_by_role (int $groupid, int $courseid, string $fields='u.*', ?string $sort=null, string $extrawheretest='', array $whereorsortparams=[], string $joins='') | |
| Lists users in a group based on their role on the course. | |
| groups_get_possible_roles ($context) | |
| Obtains a list of the possible roles that group members might come from, on a course. | |
| groups_get_potential_members ($courseid, $roleid=null, $source=null, $orderby='lastname ASC, firstname ASC', $notingroup=null, $onlyactiveenrolments=false, $extrafields=[]) | |
| Gets potential group members for grouping. | |
| groups_parse_name ($format, $groupnumber) | |
| Parse a group name for characters to replace. | |
| groups_remove_member ($grouporid, $userorid) | |
| Deletes the link between the specified user and group. | |
| groups_remove_member_allowed ($grouporid, $userorid) | |
| Checks whether the current user is permitted (using the normal UI) to remove a specific group member, assuming that they have access to remove group members in general. | |
| groups_sync_with_enrolment ($enrolname, $courseid=0, $gidfield='customint2') | |
| Synchronises enrolments with the group membership. | |
| groups_unassign_grouping ($groupingid, $groupid, $invalidatecache=true) | |
| Unassigns group from grouping. | |
| groups_update_group ($data, $editform=false, $editoroptions=false) | |
| Update group. | |
| groups_update_group_icon ($group, $data, $editform) | |
| Update the group icon from form data. | |
| groups_update_grouping ($data, $editoroptions=null) | |
| Update grouping. | |
| set_groups_messaging (array $groupids, bool $enabled) | |
| Updates group messaging to enable/disable in bulk. | |
| Variables | |
| global | core_group\reportbuilder\local\entities::$CFG | 
| $row = array() | |
| Prints navigation tabs. | |
| $row [] | |
| if (!defined( 'MOODLE_INTERNAL')) | |
| Auto group form. | |
| if (!defined( 'MOODLE_INTERNAL')) | |
| A form for creating and editing groupings. | |
| if (!defined( 'MOODLE_INTERNAL')) | |
| A form for group import. | |
| core_group_inplace_editable | ( | $itemtype, | |
| $itemid, | |||
| $newvalue ) | 
Callback for inplace editable API.
| string | $itemtype | - Only user_groups is supported. | 
| string | $itemid | - Userid and groupid separated by a : | 
| string | $newvalue | - json encoded list of groupids. | 
| core\output\inplace_editable | 
| get_group_custom_fields_data | ( | array | $groupids | ) | 
Returns custom fields data for provided groups.
| array | $groupids | a list of group IDs to provide data for. | 
| core_customfield\data_controller[] | 
| get_grouping_custom_fields_data | ( | array | $groupingids | ) | 
Returns custom fields data for provided groupings.
| array | $groupingids | a list of group IDs to provide data for. | 
| core_customfield\data_controller[] | 
| groups_add_member | ( | $grouporid, | |
| $userorid, | |||
| $component = null, | |||
| $itemid = 0 ) | 
Extra library for groups and groupings.
| mixed | $grouporid | The group id or group object | 
| mixed | $userorid | The user id or user object | 
| string | $component | Optional component name e.g. 'enrol_imsenterprise' | 
| int | $itemid | Optional itemid associated with component | 
| bool | True if user added successfully or the user is already a member of the group, false otherwise. | 
| groups_assign_grouping | ( | $groupingid, | |
| $groupid, | |||
| $timeadded = null, | |||
| $invalidatecache = true ) | 
Assigns group into grouping.
| int | groupingid | |
| int | groupid | |
| int | $timeadded | The time the group was added to the grouping. | 
| bool | $invalidatecache | If set to true the course group cache and the user group cache will be invalidated as well. | 
| bool | true or exception | 
| groups_calculate_role_people | ( | $rs, | |
| $context ) | 
Internal function used by groups_get_members_by_role to handle the results of a database query that includes a list of users and possible roles on a course.
| moodle_recordset | $rs | The record set (may be false) | 
| int | $context | ID of course context | 
| array | As described in groups_get_members_by_role | 
| groups_create_group | ( | $data, | |
| $editform = false, | |||
| $editoroptions = false ) | 
Add a new group.
| stdClass | $data | group properties | 
| stdClass | $editform | |
| array | $editoroptions | 
| int | id of group or throws an exception on error | 
| moodle_exception | 
| groups_create_grouping | ( | $data, | |
| $editoroptions = null ) | 
Add a new grouping.
| stdClass | $data | grouping properties | 
| array | $editoroptions | 
| int | id of grouping or throws an exception on error | 
| moodle_exception | 
| groups_delete_group | ( | $grouporid | ) | 
Delete a group best effort, first removing members and links with courses and groupings.
Removes group avatar too.
| mixed | $grouporid | The id of group to delete or full group object | 
| bool | True if deletion was successful, false otherwise | 
| groups_delete_group_members | ( | $courseid, | |
| $userid = 0, | |||
| $unused = false ) | 
Remove all users (or one user) from all groups in course.
| int | $courseid | |
| int | $userid | 0 means all users | 
| bool | $unused | - formerly $showfeedback, is no longer used. | 
| bool | success | 
| groups_delete_grouping | ( | $groupingorid | ) | 
Delete grouping.
| int | $groupingorid | 
| bool | success | 
| groups_delete_groupings | ( | $courseid, | |
| $showfeedback = false ) | 
Delete all groupings from course.
| int | $courseid | |
| bool | $showfeedback | 
| bool | success | 
| groups_delete_groupings_groups | ( | $courseid, | |
| $showfeedback = false ) | 
Remove all groups from all groupings in course.
| int | $courseid | |
| bool | $showfeedback | 
| bool | success | 
| groups_delete_groups | ( | $courseid, | |
| $showfeedback = false ) | 
Delete all groups from course.
| int | $courseid | |
| bool | $showfeedback | 
| bool | success | 
| groups_get_members_by_role | ( | int | $groupid, | 
| int | $courseid, | ||
| string | $fields = 'u.*', | ||
| ?string | $sort = null, | ||
| string | $extrawheretest = '', | ||
| array | $whereorsortparams = [], | ||
| string | $joins = '' ) | 
Lists users in a group based on their role on the course.
Returns false if there's an error or there are no users in the group. Otherwise returns an array of role ID => role data, where role data includes: (role) $id, $shortname, $name $users: array of objects for each user which include the specified fields Users who do not have a role are stored in the returned array with key '-' and pseudo-role details (including a name, 'No role'). Users with multiple roles, same deal with key '*' and name 'Multiple roles'. You can find out which roles each has by looking in the $roles array of the user object.
| int | $groupid | |
| int | $courseid | Course ID (should match the group's course) | 
| string | $fields | List of fields from user table (prefixed with u) and joined tables, default 'u.*' | 
| string | null | $sort | SQL ORDER BY clause, default (when null passed) is what comes from users_order_by_sql. | 
| string | $extrawheretest | extra SQL conditions ANDed with the existing where clause. | 
| array | $whereorsortparams | any parameters required by $extrawheretest or $joins (named parameters). | 
| string | $joins | any joins required to get the specified fields. | 
| array | Complex array as described above | 
| groups_get_possible_roles | ( | $context | ) | 
Obtains a list of the possible roles that group members might come from, on a course.
Generally this includes only profile roles.
| context | $context | Context of course | 
| Array | of role ID integers, or false if error/none. | 
| groups_get_potential_members | ( | $courseid, | |
| $roleid = null, | |||
| $source = null, | |||
| $orderby = 'lastname ASC, | |||
| firstname ASC' | , | ||
| $notingroup = null, | |||
| $onlyactiveenrolments = false, | |||
| $extrafields = [] ) | 
Gets potential group members for grouping.
| int | $courseid | The id of the course | 
| int | $roleid | The role to select users from | 
| mixed | $source | restrict to cohort, grouping or group id | 
| string | $orderby | The column to sort users by | 
| int | $notingroup | restrict to users not in existing groups | 
| bool | $onlyactiveenrolments | restrict to users who have an active enrolment in the course | 
| array | $extrafields | Extra user fields to return | 
| array | An array of the users | 
| groups_parse_name | ( | $format, | |
| $groupnumber ) | 
Parse a group name for characters to replace.
| string | $format | The format a group name will follow | 
| int | $groupnumber | The number of the group to be used in the parsed format string | 
| string | the parsed format string | 
| groups_remove_member | ( | $grouporid, | |
| $userorid ) | 
Deletes the link between the specified user and group.
| mixed | $grouporid | The group id or group object | 
| mixed | $userorid | The user id or user object | 
| bool | True if deletion was successful, false otherwise | 
| groups_remove_member_allowed | ( | $grouporid, | |
| $userorid ) | 
Checks whether the current user is permitted (using the normal UI) to remove a specific group member, assuming that they have access to remove group members in general.
For automatically-created group member entries, this checks with the relevant plugin to see whether it is permitted. The default, if the plugin doesn't provide a function, is true.
For other entries (and any which have already been deleted/don't exist) it just returns true.
| mixed | $grouporid | The group id or group object | 
| mixed | $userorid | The user id or user object | 
| bool | True if permitted, false otherwise | 
| groups_sync_with_enrolment | ( | $enrolname, | |
| $courseid = 0, | |||
| $gidfield = 'customint2' ) | 
Synchronises enrolments with the group membership.
Designed for enrolment methods provide automatic synchronisation between enrolled users and group membership, such as enrol_cohort and enrol_meta .
| string | $enrolname | name of enrolment method without prefix | 
| int | $courseid | course id where sync needs to be performed (0 for all courses) | 
| string | $gidfield | name of the field in 'enrol' table that stores group id | 
| array | Returns the list of removed and added users. Each record contains fields: userid, enrolid, courseid, groupid, groupname | 
| groups_unassign_grouping | ( | $groupingid, | |
| $groupid, | |||
| $invalidatecache = true ) | 
Unassigns group from grouping.
| int | groupingid | |
| int | groupid | |
| bool | $invalidatecache | If set to true the course group cache and the user group cache will be invalidated as well. | 
| bool | success | 
| groups_update_group | ( | $data, | |
| $editform = false, | |||
| $editoroptions = false ) | 
Update group.
| stdClass | $data | group properties (with magic quotes) | 
| stdClass | $editform | |
| array | $editoroptions | 
| bool | true or exception | 
| groups_update_group_icon | ( | $group, | |
| $data, | |||
| $editform ) | 
Update the group icon from form data.
| stdClass | $group | group information | 
| stdClass | $data | |
| stdClass | $editform | 
| groups_update_grouping | ( | $data, | |
| $editoroptions = null ) | 
Update grouping.
| stdClass | $data | grouping properties (with magic quotes) | 
| array | $editoroptions | 
| bool | true or exception | 
| set_groups_messaging | ( | array | $groupids, | 
| bool | $enabled ) | 
Updates group messaging to enable/disable in bulk.
| array | $groupids | array of group id numbers. | 
| bool | $enabled | if true, enables messaging else disables messaging | 
| $row = array() | 
Prints navigation tabs.
| $row[] | 
| if(!defined('MOODLE_INTERNAL')) | ( | ! | defined 'MOODLE_INTERNAL' | ) | 
Auto group form.
| if(!defined('MOODLE_INTERNAL')) | ( | ! | defined 'MOODLE_INTERNAL' | ) | 
A form for creating and editing groupings.
| if(!defined('MOODLE_INTERNAL')) | ( | ! | defined 'MOODLE_INTERNAL' | ) | 
A form for group import.