ILIAS  release_8 Revision v8.24
ILIAS\LTI\ToolProvider\Context Class Reference

Class to represent a platform context. More...

+ Collaboration diagram for ILIAS\LTI\ToolProvider\Context:

Public Member Functions

 __construct ()
 Class constructor. More...
 
 initialize ()
 Initialise the context. More...
 
 initialise ()
 Initialise the context. More...
 
 save ()
 Save the context to the database. More...
 
 delete ()
 Delete the context from the database. More...
 
 getPlatform ()
 Get platform. More...
 
 setPlatformId (int $platformId)
 Set platform ID. More...
 
 getKey ()
 Get consumer key. More...
 
 getId ()
 Get context ID. More...
 
 getRecordId ()
 Get the context record ID. More...
 
 setRecordId (int $id)
 Sets the context record ID. More...
 
 getDataConnector ()
 Get the data connector. More...
 
 getSetting (string $name, string $default='')
 Get a setting value. More...
 
 setSetting (string $name, string $value=null)
 Set a setting value. More...
 
 getSettings ()
 Get an array of all setting values. More...
 
 setSettings (array $settings)
 Set an array of all setting values. More...
 
 saveSettings ()
 Save setting values. More...
 
 hasToolSettingsService ()
 Check if the Tool Settings service is available. More...
 
 getToolSettings (int $mode=Service\ToolSettings::MODE_CURRENT_LEVEL, bool $simple=true)
 Get Tool Settings. More...
 
 setToolSettings (array $settings=array())
 Set Tool Settings. More...
 
 hasGroupService ()
 Check if a Course Group service is available. More...
 
 getGroups ()
 Get course group sets and groups. More...
 
 hasMembershipService ()
 Check if the Membership service is supported. More...
 
 hasMembershipsService ()
 Check if a Membership service is available. More...
 
 getMembership ()
 Get Membership. More...
 
 getMemberships (bool $withGroups=false)
 Get Memberships. More...
 
 hasLineItemService ()
 Check if the Line Item service is available. More...
 
 hasScoreService ()
 Check if the Score service is available. More...
 
 hasResultService ()
 Check if the Result service is available. More...
 
 getLineItems (string $resourceId=null, string $tag=null, int $limit=null)
 Get line items. More...
 
 createLineItem (LineItem $lineItem)
 Create a new line item. More...
 

Static Public Member Functions

static fromRecordId (int $id, \ILIAS\LTI\ToolProvider\DataConnector\DataConnector $dataConnector)
 Load the context from the database. More...
 
static fromPlatform (Platform $platform, string $ltiContextId)
 Class constructor from platform. More...
 

Data Fields

string $ltiContextId = null
 Context ID as supplied in the last connection request. More...
 
string $title = null
 Context title. More...
 
string $type = null
 Context type. More...
 
array $groupSets = null
 User group sets (null if the platform does not support the groups enhancement) More...
 
array $groups = null
 User groups (null if the platform does not support the groups enhancement) More...
 
HTTPMessage $lastServiceRequest = null
 HttpMessage object for last service request. More...
 
int $created = null
 Timestamp for when the object was created. More...
 
int $updated = null
 Timestamp for when the object was last updated. More...
 

Private Member Functions

 load (int $id=null)
 Load the context from the database. More...
 
 getLineItemService ()
 Get the Line Item service object. More...
 

Private Attributes

Platform $platform = null
 Platform for this context. More...
 
int $platformId = null
 Platform ID for this context. More...
 
int $id = null
 ID for this context. More...
 
array $settings = null
 Setting values (LTI parameters, custom parameters and local parameters). More...
 
bool $settingsChanged = false
 Whether the settings value have changed since last saved. More...
 
ILIAS LTI ToolProvider DataConnector DataConnector $dataConnector = null
 Data connector object or string. More...
 

Detailed Description

Class to represent a platform context.

Author
Stephen P Vickers steph.nosp@m.en@s.nosp@m.pvsof.nosp@m.twar.nosp@m.eprod.nosp@m.ucts.nosp@m..com

Definition at line 33 of file Context.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\LTI\ToolProvider\Context::__construct ( )

Class constructor.

Definition at line 151 of file Context.php.

152 {
153 $this->initialize();
154 }
initialize()
Initialise the context.
Definition: Context.php:159

References ILIAS\LTI\ToolProvider\Context\initialize().

+ Here is the call graph for this function:

Member Function Documentation

◆ createLineItem()

ILIAS\LTI\ToolProvider\Context::createLineItem ( LineItem  $lineItem)

Create a new line item.

Parameters
LineItem$lineItemLine item object
Returns
bool True if successful

Definition at line 647 of file Context.php.

647 : bool
648 {
649 $ok = false;
650 $lineItemService = $this->getLineItemService();
651 if (!empty($lineItemService)) {
652 $ok = $lineItemService->createLineItem($lineItem);
653 }
654
655 return $ok;
656 }
getLineItemService()
Get the Line Item service object.
Definition: Context.php:729

References ILIAS\LTI\ToolProvider\Context\getLineItemService().

+ Here is the call graph for this function:

◆ delete()

ILIAS\LTI\ToolProvider\Context::delete ( )

Delete the context from the database.

Returns
bool True if the context was successfully deleted.

Definition at line 199 of file Context.php.

199 : bool
200 {
201 return $this->getDataConnector()->deleteContext($this);
202 }
getDataConnector()
Get the data connector.
Definition: Context.php:302

References ILIAS\LTI\ToolProvider\Context\getDataConnector().

+ Here is the call graph for this function:

◆ fromPlatform()

static ILIAS\LTI\ToolProvider\Context::fromPlatform ( Platform  $platform,
string  $ltiContextId 
)
static

Class constructor from platform.

Parameters
Platform$platformPlatform instance
string$ltiContextIdLTI Context ID value
Returns
Context

Definition at line 695 of file Context.php.

695 : Context
696 {
697 $context = new Context();
698 $context->platform = $platform;
699 $context->dataConnector = $platform->getDataConnector();
700 $context->ltiContextId = $ltiContextId;
701 if (!empty($ltiContextId)) {
702 $context->load();
703 }
704
705 return $context;
706 }
string $ltiContextId
Context ID as supplied in the last connection request.
Definition: Context.php:42
Platform $platform
Platform for this context.
Definition: Context.php:111
getDataConnector()
Get the data connector.
Definition: Platform.php:328
$context
Definition: webdav.php:29

References $context, ILIAS\LTI\ToolProvider\Context\$ltiContextId, ILIAS\LTI\ToolProvider\Context\$platform, and ILIAS\LTI\ToolProvider\Platform\getDataConnector().

Referenced by ILIAS\LTI\ToolProvider\Tool\authenticate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fromRecordId()

static ILIAS\LTI\ToolProvider\Context::fromRecordId ( int  $id,
\ILIAS\LTI\ToolProvider\DataConnector\DataConnector  $dataConnector 
)
static

Load the context from the database.

Parameters
int$idRecord ID of context
\ILIAS\LTI\ToolProvider\DataConnector\DataConnector$dataConnectorDatabase connection object
Returns
Context Context object

Definition at line 664 of file Context.php.

664 : Context
665 {
666 $context = new Context();
667 $context->dataConnector = $dataConnector;
668 $context->load($id);
669
670 return $context;
671 }
int $id
ID for this context.
Definition: Context.php:125
ILIAS LTI ToolProvider DataConnector DataConnector $dataConnector
Data connector object or string.
Definition: Context.php:146

References $context, ILIAS\LTI\ToolProvider\Context\$dataConnector, and ILIAS\LTI\ToolProvider\Context\$id.

Referenced by ILIAS\LTI\ToolProvider\ResourceLink\getContext().

+ Here is the caller graph for this function:

◆ getDataConnector()

ILIAS\LTI\ToolProvider\Context::getDataConnector ( )

Get the data connector.

Returns
mixed Data connector object or string

Definition at line 302 of file Context.php.

303 {
305 }

References ILIAS\LTI\ToolProvider\Context\$dataConnector.

Referenced by ILIAS\LTI\ToolProvider\Context\delete(), ILIAS\LTI\ToolProvider\ResourceLink\fromContext(), ILIAS\LTI\ToolProvider\Context\getPlatform(), ILIAS\LTI\ToolProvider\Context\load(), and ILIAS\LTI\ToolProvider\Context\save().

+ Here is the caller graph for this function:

◆ getGroups()

ILIAS\LTI\ToolProvider\Context::getGroups ( )

Get course group sets and groups.

Returns
bool True if the request was successful

Definition at line 459 of file Context.php.

459 : bool
460 {
461 $groupsUrl = $this->getSetting('custom_context_groups_url');
462 $groupsetsUrl = $this->getSetting('custom_context_group_sets_url');
463 $service = new Service\Groups($this, $groupsUrl, $groupsetsUrl);
464 $ok = $service->get();
465 if (!empty($service->getHttpMessage())) {
466 $this->lastServiceRequest = $service->getHttpMessage();
467 }
468 if (!$ok && $this->hasConfiguredApiHook(self::$GROUPS_SERVICE_HOOK, $this->getPlatform()->getFamilyCode(), $this)) {
469 $className = $this->getApiHook(self::$GROUPS_SERVICE_HOOK, $this->getPlatform()->getFamilyCode());
470 $hook = new $className($this);
471 $ok = $hook->getGroups();
472 }
473
474 return $ok;
475 }
getSetting(string $name, string $default='')
Get a setting value.
Definition: Context.php:313
getPlatform()
Get platform.
Definition: Context.php:239
$service
Definition: ltiservices.php:43
static string $GROUPS_SERVICE_HOOK
Course Groups service hook name.
Definition: ApiHook.php:43
static getApiHook(string $hookName, string $familyCode)
Get the class name for an API hook.
Definition: ApiHook.php:88
static hasConfiguredApiHook(string $hookName, string $familyCode, $sourceObject)
Check if an API hook is registered and configured.
Definition: ApiHook.php:115

References ILIAS\LTI\ToolProvider\ApiHook\$GROUPS_SERVICE_HOOK, $service, ILIAS\LTI\ToolProvider\ApiHook\getApiHook(), ILIAS\LTI\ToolProvider\Context\getPlatform(), ILIAS\LTI\ToolProvider\Context\getSetting(), and ILIAS\LTI\ToolProvider\ApiHook\hasConfiguredApiHook().

+ Here is the call graph for this function:

◆ getId()

ILIAS\LTI\ToolProvider\Context::getId ( )

Get context ID.

Returns
string ID for this context.

Definition at line 273 of file Context.php.

273 : ?string
274 {
275 return $this->ltiContextId;
276 }

References ILIAS\LTI\ToolProvider\Context\$ltiContextId.

◆ getKey()

ILIAS\LTI\ToolProvider\Context::getKey ( )

Get consumer key.

Returns
string Consumer key value for this context.

Definition at line 263 of file Context.php.

263 : string
264 {
265 return $this->getPlatform()->getKey();
266 }

References ILIAS\LTI\ToolProvider\Context\getPlatform().

+ Here is the call graph for this function:

◆ getLineItems()

ILIAS\LTI\ToolProvider\Context::getLineItems ( string  $resourceId = null,
string  $tag = null,
int  $limit = null 
)

Get line items.

Parameters
string | null$resourceIdTool resource ID
string | null$tagTag
int | null$limitLimit of line items to be returned in each request, null for service default
Returns
LineItem[]|bool Array of LineItem objects or false on error

Definition at line 628 of file Context.php.

629 {
630 $lineItems = false;
631 $this->lastServiceRequest = null;
632 $lineItemService = $this->getLineItemService();
633 if (!empty($lineItemService)) {
634 $lineItems = $lineItemService->getAll(null, $resourceId, $tag);
635 $http = $lineItemService->getHttpMessage();
636 $this->lastServiceRequest = $http;
637 }
638
639 return $lineItems;
640 }
$http
Definition: raiseError.php:7

References $http, and ILIAS\LTI\ToolProvider\Context\getLineItemService().

+ Here is the call graph for this function:

◆ getLineItemService()

ILIAS\LTI\ToolProvider\Context::getLineItemService ( )
private

Get the Line Item service object.

Returns
bool|Service\LineItem Line Item service, or false if not available //UK: removed Service\LineItem

Definition at line 729 of file Context.php.

730 {
731 $url = $this->getSetting('custom_lineitems_url');
732 if (!empty($url)) {
733 $lineItemService = new Service\LineItem($this->getPlatform(), $url);
734 } else {
735 $lineItemService = false;
736 }
737
738 return $lineItemService;
739 }
$url

References $url, ILIAS\LTI\ToolProvider\Context\getPlatform(), and ILIAS\LTI\ToolProvider\Context\getSetting().

Referenced by ILIAS\LTI\ToolProvider\Context\createLineItem(), and ILIAS\LTI\ToolProvider\Context\getLineItems().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMembership()

ILIAS\LTI\ToolProvider\Context::getMembership ( )

Get Membership.

Deprecated:
Use getMemberships() instead
See also
Context::getMemberships()
Returns
mixed The array of UserResult objects if successful, otherwise false

Definition at line 516 of file Context.php.

517 {
519 'Method ceLTIc\LTI\Context::getMembership() has been deprecated; please use ceLTIc\LTI\Context::getMemberships() instead.',
520 true
521 );
522 return $this->getMemberships();
523 }
getMemberships(bool $withGroups=false)
Get Memberships.
Definition: Context.php:530
static logDebug(string $message, bool $showSource=false)
Log a debug message.
Definition: Util.php:363

References ILIAS\LTI\ToolProvider\Context\getMemberships(), and ILIAS\LTI\ToolProvider\Util\logDebug().

+ Here is the call graph for this function:

◆ getMemberships()

ILIAS\LTI\ToolProvider\Context::getMemberships ( bool  $withGroups = false)

Get Memberships.

Parameters
bool$withGroupsTrue is group information is to be requested as well
Returns
mixed The array of UserResult objects if successful, otherwise false

Definition at line 530 of file Context.php.

531 {
532 $ok = false;
533 $userResults = array();
534 $hasMembershipsService = !empty($this->getSetting('custom_context_memberships_url'));
535 $hasNRPService = !empty($this->getSetting('custom_context_memberships_v2_url'));
536 $hasGroupsService = !empty($this->getSetting('custom_context_groups_url')) ||
537 $this->hasConfiguredApiHook(self::$GROUPS_SERVICE_HOOK, $this->getPlatform()->getFamilyCode(), $this);
538 $hasApiHook = $this->hasConfiguredApiHook(self::$MEMBERSHIPS_SERVICE_HOOK, $this->getPlatform()->getFamilyCode(), $this);
539 if (($hasMembershipsService || $hasNRPService) && (!$withGroups || ($hasNRPService && $hasGroupsService) || !$hasApiHook)) {
540 if ($hasNRPService) {
541 $url = $this->getSetting('custom_context_memberships_v2_url');
543 } else {
544 $url = $this->getSetting('custom_context_memberships_url');
546 }
547 $service = new Service\Membership($this, $url, $format);
548 if (!$withGroups || !$hasNRPService) {
549 $userResults = $service->get();
550 } else {
551 $userResults = $service->getWithGroups();
552 }
553 if (!empty($service->getHttpMessage())) {
554 $this->lastServiceRequest = $service->getHttpMessage();
555 }
556 $ok = $userResults !== false;
557 }
558 if (!$ok && $hasApiHook) {
559 $className = $this->getApiHook(self::$MEMBERSHIPS_SERVICE_HOOK, $this->getPlatform()->getFamilyCode());
560 $hook = new $className($this);
561 $userResults = $hook->getMemberships($withGroups);
562 }
563
564 return $userResults;
565 }
const MEDIA_TYPE_MEMBERSHIPS_V1
Media type for version 1 of Memberships service.
Definition: Membership.php:37
const MEDIA_TYPE_MEMBERSHIPS_NRPS
Media type for Names and Role Provisioning service.
Definition: Membership.php:42
$format
Definition: metadata.php:235
static string $MEMBERSHIPS_SERVICE_HOOK
Memberships service hook name.
Definition: ApiHook.php:48

References $format, ILIAS\LTI\ToolProvider\ApiHook\$GROUPS_SERVICE_HOOK, ILIAS\LTI\ToolProvider\ApiHook\$MEMBERSHIPS_SERVICE_HOOK, $service, $url, ILIAS\LTI\ToolProvider\ApiHook\getApiHook(), ILIAS\LTI\ToolProvider\Context\getPlatform(), ILIAS\LTI\ToolProvider\Context\getSetting(), ILIAS\LTI\ToolProvider\ApiHook\hasConfiguredApiHook(), ILIAS\LTI\ToolProvider\Service\Membership\MEDIA_TYPE_MEMBERSHIPS_NRPS, and ILIAS\LTI\ToolProvider\Service\Membership\MEDIA_TYPE_MEMBERSHIPS_V1.

Referenced by ILIAS\LTI\ToolProvider\Context\getMembership().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPlatform()

ILIAS\LTI\ToolProvider\Context::getPlatform ( )

◆ getRecordId()

ILIAS\LTI\ToolProvider\Context::getRecordId ( )

Get the context record ID.

Returns
int|null Context record ID value

Definition at line 283 of file Context.php.

283 : ?int
284 {
285 return $this->id;
286 }

References ILIAS\LTI\ToolProvider\Context\$id.

Referenced by ILIAS\LTI\ToolProvider\ResourceLink\setContext().

+ Here is the caller graph for this function:

◆ getSetting()

ILIAS\LTI\ToolProvider\Context::getSetting ( string  $name,
string  $default = '' 
)

Get a setting value.

Parameters
string$nameName of setting
string$defaultValue to return if the setting does not exist (optional, default is an empty string)
Returns
string Setting value

Definition at line 313 of file Context.php.

313 : string
314 {
315 if (array_key_exists($name, $this->settings)) {
316 $value = $this->settings[$name];
317 } else {
318 $value = $default;
319 }
320
321 return $value;
322 }
if($format !==null) $name
Definition: metadata.php:247

References $name, and ILIAS\Repository\settings().

Referenced by ILIAS\LTI\ToolProvider\Context\getGroups(), ILIAS\LTI\ToolProvider\Context\getLineItemService(), ILIAS\LTI\ToolProvider\Context\getMemberships(), ILIAS\LTI\ToolProvider\Context\getToolSettings(), ILIAS\LTI\ToolProvider\Context\hasGroupService(), ILIAS\LTI\ToolProvider\Context\hasLineItemService(), ILIAS\LTI\ToolProvider\Context\hasMembershipsService(), ILIAS\LTI\ToolProvider\Context\hasResultService(), ILIAS\LTI\ToolProvider\Context\hasScoreService(), ILIAS\LTI\ToolProvider\Context\hasToolSettingsService(), ILIAS\LTI\ToolProvider\Context\setSetting(), and ILIAS\LTI\ToolProvider\Context\setToolSettings().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSettings()

ILIAS\LTI\ToolProvider\Context::getSettings ( )

Get an array of all setting values.

Returns
array Associative array of setting values

Definition at line 347 of file Context.php.

347 : ?array
348 {
349 return $this->settings;
350 }
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: Context.php:132

References ILIAS\LTI\ToolProvider\Context\$settings.

◆ getToolSettings()

ILIAS\LTI\ToolProvider\Context::getToolSettings ( int  $mode = Service\ToolSettings::MODE_CURRENT_LEVEL,
bool  $simple = true 
)

Get Tool Settings.

Parameters
int$modeMode for request (optional, default is current level only)
bool$simpleTrue if all the simple media type is to be used (optional, default is true)
Returns
mixed The array of settings if successful, otherwise false

Definition at line 397 of file Context.php.

398 {
399 $ok = false;
400 $settings = array();
401 if (!empty($this->getSetting('custom_context_setting_url'))) {
402 $url = $this->getSetting('custom_context_setting_url');
403 $service = new Service\ToolSettings($this, $url, $simple);
404 $settings = $service->get($mode);
405 $this->lastServiceRequest = $service->getHttpMessage();
406 $ok = $settings !== false;
407 }
408 if (!$ok && $this->hasConfiguredApiHook(self::$TOOL_SETTINGS_SERVICE_HOOK, $this->getPlatform()->getFamilyCode(), $this)) {
409 $className = $this->getApiHook(self::$TOOL_SETTINGS_SERVICE_HOOK, $this->getPlatform()->getFamilyCode());
410 $hook = new $className($this);
411 $settings = $hook->getToolSettings($mode, $simple);
412 }
413
414 return $settings;
415 }
static string $TOOL_SETTINGS_SERVICE_HOOK
Tool Settings service hook name.
Definition: ApiHook.php:58

References $service, ILIAS\LTI\ToolProvider\Context\$settings, ILIAS\LTI\ToolProvider\ApiHook\$TOOL_SETTINGS_SERVICE_HOOK, $url, ILIAS\LTI\ToolProvider\ApiHook\getApiHook(), ILIAS\LTI\ToolProvider\Context\getPlatform(), ILIAS\LTI\ToolProvider\Context\getSetting(), and ILIAS\LTI\ToolProvider\ApiHook\hasConfiguredApiHook().

+ Here is the call graph for this function:

◆ hasGroupService()

ILIAS\LTI\ToolProvider\Context::hasGroupService ( )

Check if a Course Group service is available.

Returns
bool True if this context supports a Course Group service

Definition at line 445 of file Context.php.

445 : bool
446 {
447 $has = !empty($this->getSetting('custom_context_groups_url'));
448 if (!$has) {
449 $has = self::hasConfiguredApiHook(self::$MEMBERSHIPS_SERVICE_HOOK, $this->getPlatform()->getFamilyCode(), $this);
450 }
451 return $has;
452 }

References ILIAS\LTI\ToolProvider\ApiHook\$MEMBERSHIPS_SERVICE_HOOK, ILIAS\LTI\ToolProvider\Context\getPlatform(), ILIAS\LTI\ToolProvider\Context\getSetting(), and ILIAS\LTI\ToolProvider\ApiHook\hasConfiguredApiHook().

+ Here is the call graph for this function:

◆ hasLineItemService()

ILIAS\LTI\ToolProvider\Context::hasLineItemService ( )

Check if the Line Item service is available.

Returns
bool True if this context supports the Line Item service

Definition at line 572 of file Context.php.

572 : bool
573 {
574 $has = false;
575 if (!empty($this->getSetting('custom_ags_scopes'))) {
576 $scopes = explode(',', $this->getSetting('custom_ags_scopes'));
577 if (in_array(Service\LineItem::$SCOPE, $scopes) || in_array(Service\LineItem::$SCOPE_READONLY, $scopes)) {
578 $has = !empty($this->getSetting('custom_lineitems_url'));
579 }
580 }
581
582 return $has;
583 }
$scopes
Definition: ltitoken.php:99

References $scopes, and ILIAS\LTI\ToolProvider\Context\getSetting().

+ Here is the call graph for this function:

◆ hasMembershipService()

ILIAS\LTI\ToolProvider\Context::hasMembershipService ( )

Check if the Membership service is supported.

Deprecated:
Use hasMembershipsService() instead
See also
Context::hasMembershipsService()
Returns
bool True if this context supports the Membership service

Definition at line 485 of file Context.php.

485 : bool
486 {
488 'Method ceLTIc\LTI\Context::hasMembershipService() has been deprecated; please use ceLTIc\LTI\Context::hasMembershipsService() instead.',
489 true
490 );
491 return $this->hasMembershipsService();
492 }
hasMembershipsService()
Check if a Membership service is available.
Definition: Context.php:499

References ILIAS\LTI\ToolProvider\Context\hasMembershipsService(), and ILIAS\LTI\ToolProvider\Util\logDebug().

+ Here is the call graph for this function:

◆ hasMembershipsService()

ILIAS\LTI\ToolProvider\Context::hasMembershipsService ( )

Check if a Membership service is available.

Returns
bool True if this context supports a Memberships service

Definition at line 499 of file Context.php.

499 : bool
500 {
501 $has = !empty($this->getSetting('custom_context_memberships_url')) || !empty($this->getSetting('custom_context_memberships_v2_url'));
502 if (!$has) {
503 $has = self::hasConfiguredApiHook(self::$MEMBERSHIPS_SERVICE_HOOK, $this->getPlatform()->getFamilyCode(), $this);
504 }
505 return $has;
506 }

References ILIAS\LTI\ToolProvider\ApiHook\$MEMBERSHIPS_SERVICE_HOOK, ILIAS\LTI\ToolProvider\Context\getPlatform(), ILIAS\LTI\ToolProvider\Context\getSetting(), and ILIAS\LTI\ToolProvider\ApiHook\hasConfiguredApiHook().

Referenced by ILIAS\LTI\ToolProvider\Context\hasMembershipService().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasResultService()

ILIAS\LTI\ToolProvider\Context::hasResultService ( )

Check if the Result service is available.

Returns
bool True if this context supports the Result service

Definition at line 608 of file Context.php.

608 : bool
609 {
610 $has = false;
611 if (!empty($this->getSetting('custom_ags_scopes'))) {
612 $scopes = explode(',', $this->getSetting('custom_ags_scopes'));
613 if (in_array(Service\Result::$SCOPE, $scopes)) {
614 $has = !empty($this->getSetting('custom_lineitems_url'));
615 }
616 }
617
618 return $has;
619 }
static string $SCOPE
Access scope.
Definition: Result.php:36

References ILIAS\LTI\ToolProvider\Service\Result\$SCOPE, $scopes, and ILIAS\LTI\ToolProvider\Context\getSetting().

+ Here is the call graph for this function:

◆ hasScoreService()

ILIAS\LTI\ToolProvider\Context::hasScoreService ( )

Check if the Score service is available.

Returns
bool True if this context supports the Score service

Definition at line 590 of file Context.php.

590 : bool
591 {
592 $has = false;
593 if (!empty($this->getSetting('custom_ags_scopes'))) {
594 $scopes = explode(',', $this->getSetting('custom_ags_scopes'));
595 if (in_array(Service\Score::$SCOPE, $scopes)) {
596 $has = !empty($this->getSetting('custom_lineitems_url'));
597 }
598 }
599
600 return $has;
601 }
static string $SCOPE
Access scope.
Definition: Score.php:35

References ILIAS\LTI\ToolProvider\Service\Score\$SCOPE, $scopes, and ILIAS\LTI\ToolProvider\Context\getSetting().

+ Here is the call graph for this function:

◆ hasToolSettingsService()

ILIAS\LTI\ToolProvider\Context::hasToolSettingsService ( )

Check if the Tool Settings service is available.

Returns
bool True if this context supports the Tool Settings service

Definition at line 382 of file Context.php.

382 : bool
383 {
384 $has = !empty($this->getSetting('custom_context_setting_url'));
385 if (!$has) {
386 $has = self::hasConfiguredApiHook(self::$TOOL_SETTINGS_SERVICE_HOOK, $this->getPlatform()->getFamilyCode(), $this);
387 }
388 return $has;
389 }

References ILIAS\LTI\ToolProvider\ApiHook\$TOOL_SETTINGS_SERVICE_HOOK, ILIAS\LTI\ToolProvider\Context\getPlatform(), ILIAS\LTI\ToolProvider\Context\getSetting(), and ILIAS\LTI\ToolProvider\ApiHook\hasConfiguredApiHook().

+ Here is the call graph for this function:

◆ initialise()

ILIAS\LTI\ToolProvider\Context::initialise ( )

Initialise the context.

Synonym for initialize().

Definition at line 174 of file Context.php.

175 {
176 $this->initialize();
177 }

References ILIAS\LTI\ToolProvider\Context\initialize().

+ Here is the call graph for this function:

◆ initialize()

ILIAS\LTI\ToolProvider\Context::initialize ( )

Initialise the context.

Definition at line 159 of file Context.php.

160 {
161 $this->title = '';
162 $this->settings = array();
163 $this->groupSets = null;
164 $this->groups = null;
165 $this->created = null;
166 $this->updated = null;
167 }

References ILIAS\Repository\settings().

Referenced by ILIAS\LTI\ToolProvider\Context\__construct(), ILIAS\LTI\ToolProvider\Context\initialise(), and ILIAS\LTI\ToolProvider\Context\load().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ load()

ILIAS\LTI\ToolProvider\Context::load ( int  $id = null)
private

Load the context from the database.

Parameters
int | null$idRecord ID of context (optional, default is null)
Returns
bool True if context was successfully loaded

Definition at line 717 of file Context.php.

717 : bool
718 {
719 $this->initialize();
720 $this->id = $id;
721 return $this->getDataConnector()->loadContext($this);
722 }

References ILIAS\LTI\ToolProvider\Context\$id, ILIAS\LTI\ToolProvider\Context\getDataConnector(), and ILIAS\LTI\ToolProvider\Context\initialize().

+ Here is the call graph for this function:

◆ save()

ILIAS\LTI\ToolProvider\Context::save ( )

Save the context to the database.

Returns
bool True if the context was successfully saved.

Definition at line 184 of file Context.php.

184 : bool
185 {
186 $ok = $this->getDataConnector()->saveContext($this);
187 if ($ok) {
188 $this->settingsChanged = false;
189 }
190
191 return $ok;
192 }

References ILIAS\LTI\ToolProvider\Context\getDataConnector().

Referenced by ILIAS\LTI\ToolProvider\Context\saveSettings().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveSettings()

ILIAS\LTI\ToolProvider\Context::saveSettings ( )

Save setting values.

Returns
bool True if the settings were successfully saved

Definition at line 366 of file Context.php.

366 : bool
367 {
368 if ($this->settingsChanged) {
369 $ok = $this->save();
370 } else {
371 $ok = true;
372 }
373
374 return $ok;
375 }
save()
Save the context to the database.
Definition: Context.php:184

References ILIAS\LTI\ToolProvider\Context\save().

+ Here is the call graph for this function:

◆ setPlatformId()

ILIAS\LTI\ToolProvider\Context::setPlatformId ( int  $platformId)

Set platform ID.

Parameters
int$platformIdPlatform ID for this context.

Definition at line 252 of file Context.php.

253 {
254 $this->platform = null;
255 $this->platformId = $platformId;
256 }
int $platformId
Platform ID for this context.
Definition: Context.php:118

References ILIAS\LTI\ToolProvider\Context\$platformId.

◆ setRecordId()

ILIAS\LTI\ToolProvider\Context::setRecordId ( int  $id)

Sets the context record ID.

Parameters
int$idContext record ID value

Definition at line 292 of file Context.php.

293 {
294 $this->id = $id;
295 }

References ILIAS\LTI\ToolProvider\Context\$id.

◆ setSetting()

ILIAS\LTI\ToolProvider\Context::setSetting ( string  $name,
string  $value = null 
)

Set a setting value.

Parameters
string$nameName of setting
string | null$valueValue to set, use an empty value to delete a setting (optional, default is null)

Definition at line 329 of file Context.php.

330 {
331 $old_value = $this->getSetting($name);
332 if ($value !== $old_value) {
333 if (!empty($value)) {
334 $this->settings[$name] = $value;
335 } else {
336 unset($this->settings[$name]);
337 }
338 $this->settingsChanged = true;
339 }
340 }

References $name, ILIAS\LTI\ToolProvider\Context\getSetting(), and ILIAS\Repository\settings().

+ Here is the call graph for this function:

◆ setSettings()

ILIAS\LTI\ToolProvider\Context::setSettings ( array  $settings)

Set an array of all setting values.

Parameters
array$settingsAssociative array of setting values

Definition at line 356 of file Context.php.

357 {
358 $this->settings = $settings;
359 }

References ILIAS\LTI\ToolProvider\Context\$settings, and ILIAS\Repository\settings().

+ Here is the call graph for this function:

◆ setToolSettings()

ILIAS\LTI\ToolProvider\Context::setToolSettings ( array  $settings = array())

Set Tool Settings.

Parameters
array$settingsAn associative array of settings (optional, default is none)
Returns
bool True if action was successful, otherwise false

Definition at line 422 of file Context.php.

422 : bool
423 {
424 $ok = false;
425 if (!empty($this->getSetting('custom_context_setting_url'))) {
426 $url = $this->getSetting('custom_context_setting_url');
427 $service = new Service\ToolSettings($this, $url);
428 $ok = $service->set($settings);
429 $this->lastServiceRequest = $service->getHttpMessage();
430 }
431 if (!$ok && $this->hasConfiguredApiHook(self::$TOOL_SETTINGS_SERVICE_HOOK, $this->getPlatform()->getFamilyCode(), $this)) {
432 $className = $this->getApiHook(self::$TOOL_SETTINGS_SERVICE_HOOK, $this->getPlatform()->getFamilyCode());
433 $hook = new $className($this);
434 $ok = $hook->setToolSettings($settings);
435 }
436
437 return $ok;
438 }

References $service, ILIAS\LTI\ToolProvider\Context\$settings, ILIAS\LTI\ToolProvider\ApiHook\$TOOL_SETTINGS_SERVICE_HOOK, $url, ILIAS\LTI\ToolProvider\ApiHook\getApiHook(), ILIAS\LTI\ToolProvider\Context\getPlatform(), ILIAS\LTI\ToolProvider\Context\getSetting(), and ILIAS\LTI\ToolProvider\ApiHook\hasConfiguredApiHook().

+ Here is the call graph for this function:

Field Documentation

◆ $created

int null ILIAS\LTI\ToolProvider\Context::$created = null

Timestamp for when the object was created.

Definition at line 97 of file Context.php.

◆ $dataConnector

ILIAS LTI ToolProvider DataConnector DataConnector null ILIAS\LTI\ToolProvider\Context::$dataConnector = null
private

Data connector object or string.

Definition at line 146 of file Context.php.

Referenced by ILIAS\LTI\ToolProvider\Context\fromRecordId(), and ILIAS\LTI\ToolProvider\Context\getDataConnector().

◆ $groups

array null ILIAS\LTI\ToolProvider\Context::$groups = null

User groups (null if the platform does not support the groups enhancement)

A group is represented by an associative array with the following elements:

  • title
  • set (ID of group set, array of IDs if the group belongs to more than one set, omitted if the group is not part of a set) The array key value is the group ID.

Definition at line 83 of file Context.php.

◆ $groupSets

array null ILIAS\LTI\ToolProvider\Context::$groupSets = null

User group sets (null if the platform does not support the groups enhancement)

A group set is represented by an associative array with the following elements:

  • title
  • groups (array of group IDs)
  • num_members
  • num_staff
  • num_learners The array key value is the group set ID.

Definition at line 71 of file Context.php.

◆ $id

int null ILIAS\LTI\ToolProvider\Context::$id = null
private

◆ $lastServiceRequest

HttpMessage null ILIAS\LTI\ToolProvider\Context::$lastServiceRequest = null

HttpMessage object for last service request.

Definition at line 90 of file Context.php.

◆ $ltiContextId

string null ILIAS\LTI\ToolProvider\Context::$ltiContextId = null

Context ID as supplied in the last connection request.

Definition at line 42 of file Context.php.

Referenced by ILIAS\LTI\ToolProvider\Context\fromPlatform(), and ILIAS\LTI\ToolProvider\Context\getId().

◆ $platform

Platform null ILIAS\LTI\ToolProvider\Context::$platform = null
private

◆ $platformId

int null ILIAS\LTI\ToolProvider\Context::$platformId = null
private

Platform ID for this context.

Definition at line 118 of file Context.php.

Referenced by ILIAS\LTI\ToolProvider\Context\setPlatformId().

◆ $settings

array null ILIAS\LTI\ToolProvider\Context::$settings = null
private

◆ $settingsChanged

bool ILIAS\LTI\ToolProvider\Context::$settingsChanged = false
private

Whether the settings value have changed since last saved.

Definition at line 139 of file Context.php.

◆ $title

string null ILIAS\LTI\ToolProvider\Context::$title = null

Context title.

Definition at line 49 of file Context.php.

◆ $type

string null ILIAS\LTI\ToolProvider\Context::$type = null

Context type.

Definition at line 56 of file Context.php.

◆ $updated

int null ILIAS\LTI\ToolProvider\Context::$updated = null

Timestamp for when the object was last updated.

Definition at line 104 of file Context.php.


The documentation for this class was generated from the following file: