-
Notifications
You must be signed in to change notification settings - Fork 38
Course Groups service
The Course Gropups service allow a tool to obtain group membership information from a platform. This information can be obtained by using the Memberships service, or by using the Course Groups service directly.
The Course Groups service class offers the following methods:
-
get
- gets both group set and group information for a context, and allows the following optional parameters:-
$allowNonSets
- whentrue
groups which do not belong to group sets will be included (default isfalse
) -
$user
- limit the information to those group sets and groups for which the specified user is a member -
$limit
- used to limit the number of group sets or groups are requested to be included in each response
-
-
getGroupSets
- get the grooup sets information for a context, and supports the optionallimit
parameter (see above) -
getGroups
- get the group information for a context, and supports the optional$allowNonSets
,$user
and$limit
parameters (see above)
The above methods will populate the groupSets
property of the context, and the groups
property of the user when passed, otherwise the groups
property of the context. A group set is a collection of groups into which users have been assigned. Usually each user is restricted to being a member of only a single group in the collection, but this is a platform specific issue. For example,
use ceLTIc\LTI\Service;
$groupsUrl = $context->getSetting('custom_context_groups_url');
$groupSetsUrl = $context->getSetting('custom_context_group_sets_url');
$groupsService = new Service\Groups($context, $groupsUrl, $groupSetsUrl);
$groupsService->get();
Obtaining a list of all groups (including those which are not part of a group set) for a specific user can be performed as follows:
// Create the user object, such as:
$user = new ceLTIc\LTI\User();
$user->ltiUserId = $ltiUserId;
$groupsService->getGroups(true, $user);
The default limit for the size of response pages from the platform can be overridden by changing the value of the Service\Groups::$defaultLimit
property.
The $user->groups
array will contain the groups the user is a member of. Note that group information is not persisted by the library.
© 2022 Stephen P Vickers. All Rights Reserved.