Differences Between: [Versions 400 and 401] [Versions 400 and 402] [Versions 400 and 403]
1 <?php 2 3 namespace Packback\Lti1p3; 4 5 class LtiCourseGroupsService extends LtiAbstractService 6 { 7 public const CONTENTTYPE_CONTEXTGROUPCONTAINER = 'application/vnd.ims.lti-gs.v1.contextgroupcontainer+json'; 8 9 public function getScope(): array 10 { 11 return $this->getServiceData()['scope']; 12 } 13 14 public function getGroups(): array 15 { 16 $request = new ServiceRequest( 17 LtiServiceConnector::METHOD_GET, 18 $this->getServiceData()['context_groups_url'] 19 ); 20 $request->setAccept(static::CONTENTTYPE_CONTEXTGROUPCONTAINER); 21 22 return $this->getAll($request, 'groups'); 23 } 24 25 public function getSets(): array 26 { 27 // Sets are optional. 28 if (!isset($this->getServiceData()['context_group_sets_url'])) { 29 return []; 30 } 31 32 $request = new ServiceRequest( 33 LtiServiceConnector::METHOD_GET, 34 $this->getServiceData()['context_group_sets_url'] 35 ); 36 $request->setAccept(static::CONTENTTYPE_CONTEXTGROUPCONTAINER); 37 38 return $this->getAll($request, 'sets'); 39 } 40 41 public function getGroupsBySet() 42 { 43 $groups = $this->getGroups(); 44 $sets = $this->getSets(); 45 46 $groupsBySet = []; 47 $unsetted = []; 48 49 foreach ($sets as $key => $set) { 50 $groupsBySet[$set['id']] = $set; 51 $groupsBySet[$set['id']]['groups'] = []; 52 } 53 54 foreach ($groups as $key => $group) { 55 if (isset($group['set_id']) && isset($groupsBySet[$group['set_id']])) { 56 $groupsBySet[$group['set_id']]['groups'][$group['id']] = $group; 57 } else { 58 $unsetted[$group['id']] = $group; 59 } 60 } 61 62 if (!empty($unsetted)) { 63 $groupsBySet['none'] = [ 64 'name' => 'None', 65 'id' => 'none', 66 'groups' => $unsetted, 67 ]; 68 } 69 70 return $groupsBySet; 71 } 72 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body