Moodle APIs 4.3
Moodle 4.3.6 (Build: 20240812)
core_group

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
  
 

Classes

class  autogroup_form
 Auto group form class. More...
 
class  core\event\group_updated
 Group updated event class. More...
 
class  core\event\grouping_created
 Grouping created event class. More...
 
class  core_group\customfield\group_handler
 Group handler for custom fields. More...
 
class  core_group\customfield\grouping_handler
 Grouping handler for custom fields. More...
 
class  core_group\output\group_details
 Group details page class. More...
 
class  core_group\output\index_page
 Group index page class. More...
 
class  core_group\output\renderer
 Renderer class. More...
 
class  core_group\output\user_groups_editable
 Class to display list of user groups. More...
 
class  core_group\reportbuilder\datasource\groups
 Groups datasource. More...
 
class  core_group\reportbuilder\local\entities\group
 Group entity. More...
 
class  core_group\reportbuilder\local\entities\group_member
 Group member entity. More...
 
class  core_group\reportbuilder\local\entities\grouping
 Grouping entity. More...
 
class  core_group\visibility
 Group visibility methods. More...
 
class  group_form
 Group form class. More...
 
class  grouping_form
 Grouping form class. More...
 
class  groups_import_form
 Groups import form class. More...
 

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.
 

Detailed Description

Function Documentation

◆ core_group_inplace_editable()

core_group_inplace_editable ( $itemtype,
$itemid,
$newvalue )

Callback for inplace editable API.

Parameters
string$itemtype- Only user_groups is supported.
string$itemid- Userid and groupid separated by a :
string$newvalue- json encoded list of groupids.
Return values
core\output\inplace_editable

◆ get_group_custom_fields_data()

get_group_custom_fields_data ( array $groupids)

Returns custom fields data for provided groups.

Parameters
array$groupidsa list of group IDs to provide data for.
Return values
core_customfield\data_controller[]

◆ get_grouping_custom_fields_data()

get_grouping_custom_fields_data ( array $groupingids)

Returns custom fields data for provided groupings.

Parameters
array$groupingidsa list of group IDs to provide data for.
Return values
core_customfield\data_controller[]

◆ groups_add_member()

groups_add_member ( $grouporid,
$userorid,
$component = null,
$itemid = 0 )

Extra library for groups and groupings.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later Adds a specified user to a group
Parameters
mixed$grouporidThe group id or group object
mixed$useroridThe user id or user object
string$componentOptional component name e.g. 'enrol_imsenterprise'
int$itemidOptional itemid associated with component
Return values
boolTrue if user added successfully or the user is already a member of the group, false otherwise.

◆ groups_assign_grouping()

groups_assign_grouping ( $groupingid,
$groupid,
$timeadded = null,
$invalidatecache = true )

Assigns group into grouping.

Parameters
intgroupingid
intgroupid
int$timeaddedThe time the group was added to the grouping.
bool$invalidatecacheIf set to true the course group cache and the user group cache will be invalidated as well.
Return values
booltrue or exception

◆ groups_calculate_role_people()

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.

Parameters
moodle_recordset$rsThe record set (may be false)
int$contextID of course context
Return values
arrayAs described in groups_get_members_by_role

◆ groups_create_group()

groups_create_group ( $data,
$editform = false,
$editoroptions = false )

Add a new group.

Parameters
stdClass$datagroup properties
stdClass$editform
array$editoroptions
Return values
intid of group or throws an exception on error
Exceptions
moodle_exception

◆ groups_create_grouping()

groups_create_grouping ( $data,
$editoroptions = null )

Add a new grouping.

Parameters
stdClass$datagrouping properties
array$editoroptions
Return values
intid of grouping or throws an exception on error
Exceptions
moodle_exception

◆ groups_delete_group()

groups_delete_group ( $grouporid)

Delete a group best effort, first removing members and links with courses and groupings.

Removes group avatar too.

Parameters
mixed$grouporidThe id of group to delete or full group object
Return values
boolTrue if deletion was successful, false otherwise

◆ groups_delete_group_members()

groups_delete_group_members ( $courseid,
$userid = 0,
$unused = false )

Remove all users (or one user) from all groups in course.

Parameters
int$courseid
int$userid0 means all users
bool$unused- formerly $showfeedback, is no longer used.
Return values
boolsuccess

◆ groups_delete_grouping()

groups_delete_grouping ( $groupingorid)

Delete grouping.

Parameters
int$groupingorid
Return values
boolsuccess

◆ groups_delete_groupings()

groups_delete_groupings ( $courseid,
$showfeedback = false )

Delete all groupings from course.

Parameters
int$courseid
bool$showfeedback
Return values
boolsuccess

◆ groups_delete_groupings_groups()

groups_delete_groupings_groups ( $courseid,
$showfeedback = false )

Remove all groups from all groupings in course.

Parameters
int$courseid
bool$showfeedback
Return values
boolsuccess

◆ groups_delete_groups()

groups_delete_groups ( $courseid,
$showfeedback = false )

Delete all groups from course.

Parameters
int$courseid
bool$showfeedback
Return values
boolsuccess

◆ groups_get_members_by_role()

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.

Parameters
int$groupid
int$courseidCourse ID (should match the group's course)
string$fieldsList of fields from user table (prefixed with u) and joined tables, default 'u.*'
string | null$sortSQL ORDER BY clause, default (when null passed) is what comes from users_order_by_sql.
string$extrawheretestextra SQL conditions ANDed with the existing where clause.
array$whereorsortparamsany parameters required by $extrawheretest or $joins (named parameters).
string$joinsany joins required to get the specified fields.
Return values
arrayComplex array as described above

◆ groups_get_possible_roles()

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.

Parameters
context$contextContext of course
Return values
Arrayof role ID integers, or false if error/none.

◆ groups_get_potential_members()

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.

Parameters
int$courseidThe id of the course
int$roleidThe role to select users from
mixed$sourcerestrict to cohort, grouping or group id
string$orderbyThe column to sort users by
int$notingrouprestrict to users not in existing groups
bool$onlyactiveenrolmentsrestrict to users who have an active enrolment in the course
array$extrafieldsExtra user fields to return
Return values
arrayAn array of the users

◆ groups_parse_name()

groups_parse_name ( $format,
$groupnumber )

Parse a group name for characters to replace.

Parameters
string$formatThe format a group name will follow
int$groupnumberThe number of the group to be used in the parsed format string
Return values
stringthe parsed format string

◆ groups_remove_member()

groups_remove_member ( $grouporid,
$userorid )

Deletes the link between the specified user and group.

Parameters
mixed$grouporidThe group id or group object
mixed$useroridThe user id or user object
Return values
boolTrue if deletion was successful, false otherwise

◆ groups_remove_member_allowed()

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.

Parameters
mixed$grouporidThe group id or group object
mixed$useroridThe user id or user object
Return values
boolTrue if permitted, false otherwise

◆ groups_sync_with_enrolment()

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 .

Parameters
string$enrolnamename of enrolment method without prefix
int$courseidcourse id where sync needs to be performed (0 for all courses)
string$gidfieldname of the field in 'enrol' table that stores group id
Return values
arrayReturns the list of removed and added users. Each record contains fields: userid, enrolid, courseid, groupid, groupname

◆ groups_unassign_grouping()

groups_unassign_grouping ( $groupingid,
$groupid,
$invalidatecache = true )

Unassigns group from grouping.

Parameters
intgroupingid
intgroupid
bool$invalidatecacheIf set to true the course group cache and the user group cache will be invalidated as well.
Return values
boolsuccess

◆ groups_update_group()

groups_update_group ( $data,
$editform = false,
$editoroptions = false )

Update group.

Parameters
stdClass$datagroup properties (with magic quotes)
stdClass$editform
array$editoroptions
Return values
booltrue or exception

◆ groups_update_group_icon()

groups_update_group_icon ( $group,
$data,
$editform )

Update the group icon from form data.

Parameters
stdClass$groupgroup information
stdClass$data
stdClass$editform

◆ groups_update_grouping()

groups_update_grouping ( $data,
$editoroptions = null )

Update grouping.

Parameters
stdClass$datagrouping properties (with magic quotes)
array$editoroptions
Return values
booltrue or exception

◆ set_groups_messaging()

set_groups_messaging ( array $groupids,
bool $enabled )

Updates group messaging to enable/disable in bulk.

Parameters
array$groupidsarray of group id numbers.
bool$enabledif true, enables messaging else disables messaging

Variable Documentation

◆ $row [1/2]

$row = array()

Prints navigation tabs.

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

◆ $row [2/2]

$row[]
Initial value:
= new tabobject('groups',
new moodle_url('/group/index.php', array('id' => $courseid)),
get_string('groups'))
Class for creating and manipulating urls.
Definition weblib.php:261
Stores one tab.
Definition outputcomponents.php:3984
$courseid
The gradebook outcomes report.
Definition index.php:29

◆ if [1/3]

if(!defined('MOODLE_INTERNAL')) ( ! defined 'MOODLE_INTERNAL')

Auto group form.

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

◆ if [2/3]

if(!defined('MOODLE_INTERNAL')) ( ! defined 'MOODLE_INTERNAL')

A form for creating and editing groupings.

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

◆ if [3/3]

if(!defined('MOODLE_INTERNAL')) ( ! defined 'MOODLE_INTERNAL')

A form for group import.

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