45 public static string $SCOPE =
'https://purl.imsglobal.org/spec/lti-gs/scope/contextgroup.readonly';
99 public function __construct(
Context $context,
string $groupsEndpoint,
string $groupSetsEndpoint = null,
int $limit = null,
bool $pagingMode =
false)
103 $this->scope = self::$SCOPE;
104 $this->mediaType = self::MEDIA_TYPE_COURSE_GROUPS;
123 $ok = $this->
getGroups($allowNonSets, $user, $limit);
126 $this->context->groupSets = null;
127 $this->context->groups = null;
141 $ok = !empty($this->endpoint);
143 $this->mediaType = self::MEDIA_TYPE_COURSE_GROUP_SETS;
144 $parameters = array();
145 if (is_null($limit)) {
148 if (is_null($limit)) {
149 $limit = self::$defaultLimit;
151 if (!empty($limit)) {
152 $parameters[
'limit'] = strval($limit);
154 $this->context->groupSets = array();
155 $groupSets = array();
162 if (isset(
$http->responseJson->sets)) {
163 foreach (
$http->responseJson->sets as $set) {
164 $groupSets[$set->id] = array(
'title' => $set->name,
'groups' => array(),
165 'num_members' => 0,
'num_staff' => 0,
'num_learners' => 0);
168 if (!$this->pagingMode &&
$http->hasRelativeLink(
'next')) {
170 $this->endpoint =
$url;
171 $parameters = array();
177 $this->context->groupSets = $groupSets;
191 public function getGroups(
bool $allowNonSets =
false, \
ILIAS\
LTI\ToolProvider\
User $user = null,
int $limit = null): bool
194 $ok = !empty($this->endpoint);
196 $this->mediaType = self::MEDIA_TYPE_COURSE_GROUPS;
197 $parameters = array();
199 if (!empty($user) && !empty($user->ltiUserId)) {
200 $ltiUserId = $user->ltiUserId;
202 if (!empty($ltiUserId)) {
203 $parameters[
'user_id'] = $ltiUserId;
205 if (is_null($limit)) {
208 if (is_null($limit)) {
209 $limit = self::$defaultLimit;
211 if (!empty($limit)) {
212 $parameters[
'limit'] = strval($limit);
214 if (is_null($this->context->groupSets)) {
215 $groupSets = array();
217 $groupSets = $this->context->groupSets;
226 if (isset(
$http->responseJson->groups)) {
227 foreach (
$http->responseJson->groups as $agroup) {
228 if (!$allowNonSets && empty($agroup->set_id)) {
231 $group = array(
'title' => $agroup->name);
232 if (!empty($agroup->set_id)) {
233 if (!array_key_exists($agroup->set_id, $groupSets)) {
234 $groupSets[$agroup->set_id] = array(
'title' =>
"Set {$agroup->set_id}",
'groups' => array(),
235 'num_members' => 0,
'num_staff' => 0,
'num_learners' => 0);
237 $groupSets[$agroup->set_id][
'groups'][] = $agroup->id;
238 $group[
'set'] = $agroup->set_id;
240 if (!empty($agroup->tag)) {
241 $group[
'tag'] = $agroup->tag;
243 $groups[$agroup->id] = $group;
246 if (!$this->pagingMode &&
$http->hasRelativeLink(
'next')) {
248 $this->endpoint =
$url;
249 $parameters = array();
255 $this->context->groupSets = $groupSets;
256 if (empty($ltiUserId)) {
257 $this->context->groups = $groups;
259 $user->groups = $groups;
Class ChatMainBarProvider .
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
Class to represent a platform context.
getPlatform()
Get tool consumer.