LTI Integration Library 5.2.0
PHP class library for building LTI integrations
 
Loading...
Searching...
No Matches
ceLTIc\LTI\ResourceLink Class Reference

Class to represent a platform resource link. More...

+ Inheritance diagram for ceLTIc\LTI\ResourceLink:

Public Member Functions

 __construct ()
 Class constructor.
 
void initialize ()
 Initialise the resource link.
 
void initialise ()
 Initialise the resource link.
 
bool save ()
 Save the resource link to the database.
 
bool delete ()
 Delete the resource link from the database.
 
Platform getPlatform ()
 Get platform.
 
int null getPlatformId ()
 Get platform ID.
 
void setPlatformId (?int $platformId)
 Set platform ID.
 
Context null getContext ()
 Get context.
 
int null getContextId ()
 Get context record ID.
 
void setContext (Context $context)
 Set context.
 
void setContextId (?int $contextId)
 Set context ID.
 
string getKey ()
 Get consumer key.
 
string null getId ()
 Get resource link ID.
 
int null getRecordId ()
 Get resource link record ID.
 
 setRecordId (int|string $id)
 Set resource link record ID.
 
DataConnector null getDataConnector ()
 Get the data connector.
 
string getSetting (string $name, string $default='')
 Get a setting value.
 
void setSetting (string $name, string|array|null $value=null)
 Set a setting value.
 
array getSettings ()
 Get an array of all setting values.
 
void setSettings (array $settings)
 Set an array of all setting values.
 
bool saveSettings ()
 Save setting values.
 
bool hasOutcomesService ()
 Check if an Outcomes service is available.
 
bool hasMembershipsService ()
 Check if a Memberships service is available.
 
bool hasSettingService ()
 Check if the Setting extension service is available.
 
bool hasLineItemService ()
 Check if the Line-item service is available.
 
bool hasScoreService ()
 Check if the Score service is available.
 
bool hasResultService ()
 Check if the Result service is available.
 
bool hasAssessmentControlService ()
 Check if the Assessment Control service is available.
 
bool doOutcomesService (ServiceAction $action, Outcome $ltiOutcome, UserResult $userResult)
 Perform an Outcomes service request.
 
string bool doSettingService (ServiceAction $action, ?string $value=null)
 Perform a Setting service request.
 
bool hasToolSettingsService ()
 Check if the Tool Settings service is available.
 
array bool getToolSettings (?ToolSettingsMode $mode=null, bool $simple=true)
 Get Tool Settings.
 
bool setToolSettings (array $settings=[])
 Set Tool Settings.
 
array bool getMemberships (bool $withGroups=false)
 Get Memberships.
 
UserResult[] getUserResultSourcedIDs (bool $localOnly=false, ?IdScope $idScope=null)
 Obtain an array of UserResult objects for users with a result sourcedId.
 
ResourceLinkShare[] getShares ()
 Get an array of ResourceLinkShare objects for each resource link which is sharing this context.
 
LineItem[] bool getLineItems (?string $resourceId=null, ?string $tag=null, ?int $limit=null)
 Get line-items.
 
bool createLineItem (LineItem $lineItem)
 Create a new line-item.
 
Outcome[] bool getOutcomes (?int $limit=null)
 Get all outcomes.
 
string bool doAssessmentControlAction (AssessmentControlAction $assessmentControlAction, User $user, int $attemptNumber)
 Perform an Assessment Control action.
 

Static Public Member Functions

static ResourceLink fromPlatform (Platform $platform, string $ltiResourceLinkId, ?string $tempId=null)
 Class constructor from platform.
 
static ResourceLink fromContext (Context $context, string $ltiResourceLinkId, ?string $tempId=null)
 Class constructor from context.
 
static ResourceLink fromRecordId (int $id, DataConnector $dataConnector)
 Load the resource link from the database.
 
- Static Public Member Functions inherited from ceLTIc\LTI\ApiHook\ApiHook
static void registerApiHook (string $hookName, string $familyCode, string $className)
 Register the availability of an API hook.
 

Public Attributes

string $title = null
 Context title.
 
string $ltiResourceLinkId = null
 Resource link ID as supplied in the last connection request.
 
array $groupSets = null
 User group sets (null if the platform does not support the groups enhancement)
 
array $groups = null
 User groups (null if the platform does not support the groups enhancement)
 
HttpMessage $lastServiceRequest = null
 HttpMessage object for last service request.
 
string null $extRequest = null
 Request for last service request.
 
array $extRequestHeaders = null
 Request headers for last service request.
 
string $extResponse = null
 Response from last service request.
 
array $extResponseHeaders = null
 Response header from last service request.
 
int $primaryResourceLinkId = null
 Primary key value for resource link being shared (if any).
 
bool $shareApproved = null
 Whether the sharing request has been approved by the primary resource link.
 
int $created = null
 Timestamp for when the object was created.
 
int $updated = null
 Timestamp for when the object was last updated.
 

Additional Inherited Members

- Static Public Attributes inherited from ceLTIc\LTI\ApiHook\ApiHook
static string $USER_ID_HOOK = "UserId"
 User Id hook name.
 
static string $CONTEXT_ID_HOOK = "ContextId"
 Context Id hook name.
 
static string $GROUPS_SERVICE_HOOK = "Groups"
 Course Groups service hook name.
 
static string $MEMBERSHIPS_SERVICE_HOOK = "Memberships"
 Memberships service hook name.
 
static string $OUTCOMES_SERVICE_HOOK = "Outcomes"
 Outcomes service hook name.
 
static string $TOOL_SETTINGS_SERVICE_HOOK = "ToolSettings"
 Tool Settings service hook name.
 
static string $ACCESS_TOKEN_SERVICE_HOOK = "AccessToken"
 Access Token service hook name.
 

Detailed Description

Class to represent a platform resource link.

Author
Stephen P Vickers steph.nosp@m.en@s.nosp@m.pvsof.nosp@m.twar.nosp@m.eprod.nosp@m.ucts.nosp@m..com
Licence: http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3

Constructor & Destructor Documentation

◆ __construct()

ceLTIc\LTI\ResourceLink::__construct ( )

Class constructor.

References getDataConnector().

Member Function Documentation

◆ createLineItem()

bool ceLTIc\LTI\ResourceLink::createLineItem ( LineItem $lineItem)

Create a new line-item.

Parameters
LineItem$lineItemLine-item object
Returns
bool True if successful

Referenced by getShares().

◆ delete()

bool ceLTIc\LTI\ResourceLink::delete ( )

Delete the resource link from the database.

Returns
bool True if the resource link was successfully deleted.

◆ doAssessmentControlAction()

string bool ceLTIc\LTI\ResourceLink::doAssessmentControlAction ( AssessmentControlAction $assessmentControlAction,
User $user,
int $attemptNumber )

Perform an Assessment Control action.

Parameters
AssessmentControlAction$assessmentControlActionAssessment control object
User$userUser object
int$attemptNumberNumber of attempt
Returns
string|bool The response status or false if the request was not successfully processed

References $ltiResourceLinkId.

◆ doOutcomesService()

bool ceLTIc\LTI\ResourceLink::doOutcomesService ( ServiceAction $action,
Outcome $ltiOutcome,
UserResult $userResult )

Perform an Outcomes service request.

Parameters
ServiceAction$actionThe action type constant
Outcome$ltiOutcomeOutcome object
UserResult$userResultUserResult object
Returns
bool True if the request was successfully processed

◆ doSettingService()

string bool ceLTIc\LTI\ResourceLink::doSettingService ( ServiceAction $action,
?string $value = null )

Perform a Setting service request.

Parameters
ServiceAction$actionThe action type
string | null$valueThe setting value (optional, default is null)
Returns
string|bool The setting value for a read action, true if a write or delete action was successful, otherwise false

◆ fromContext()

static ResourceLink ceLTIc\LTI\ResourceLink::fromContext ( Context $context,
string $ltiResourceLinkId,
?string $tempId = null )
static

Class constructor from context.

Parameters
Context$contextContext object
string$ltiResourceLinkIdResource link ID value
string | null$tempIdTemporary Resource link ID value (optional, default is null)
Returns
ResourceLink

References getDataConnector(), and initialize().

◆ fromPlatform()

static ResourceLink ceLTIc\LTI\ResourceLink::fromPlatform ( Platform $platform,
string $ltiResourceLinkId,
?string $tempId = null )
static

Class constructor from platform.

Parameters
Platform$platformPlatform object
string$ltiResourceLinkIdResource link ID value
string | null$tempIdTemporary Resource link ID value (optional, default is null)
Returns
ResourceLink

References $ltiResourceLinkId.

◆ fromRecordId()

static ResourceLink ceLTIc\LTI\ResourceLink::fromRecordId ( int $id,
DataConnector $dataConnector )
static

Load the resource link from the database.

Parameters
int$idRecord ID of resource link
DataConnector$dataConnectorDatabase connection object
Returns
ResourceLink ResourceLink object

References getSetting().

Referenced by ceLTIc\LTI\UserResult\initialize().

◆ getContext()

Context null ceLTIc\LTI\ResourceLink::getContext ( )

Get context.

Returns
Context|null LTIContext object for this resource link.

Referenced by initialise().

◆ getContextId()

int null ceLTIc\LTI\ResourceLink::getContextId ( )

Get context record ID.

Returns
int|null Context record ID for this resource link.

References ceLTIc\LTI\System\getKey(), and getPlatform().

Referenced by setSettings().

◆ getDataConnector()

DataConnector null ceLTIc\LTI\ResourceLink::getDataConnector ( )

Get the data connector.

Returns
DataConnector|null Data connector object or string

References getSetting().

Referenced by __construct(), fromContext(), getPlatform(), and initialize().

◆ getId()

string null ceLTIc\LTI\ResourceLink::getId ( )

Get resource link ID.

Returns
string|null ID for this resource link.

Referenced by ceLTIc\LTI\DataConnector\DataConnector_sql\saveResourceLink().

◆ getKey()

string ceLTIc\LTI\ResourceLink::getKey ( )

Get consumer key.

Returns
string Consumer key value for this resource link.

References getPlatform().

◆ getLineItems()

LineItem[] bool ceLTIc\LTI\ResourceLink::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

◆ getMemberships()

array bool ceLTIc\LTI\ResourceLink::getMemberships ( bool $withGroups = false)

Get Memberships.

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

◆ getOutcomes()

Outcome[] bool ceLTIc\LTI\ResourceLink::getOutcomes ( ?int $limit = null)

Get all outcomes.

Parameters
int | null$limitLimit of outcomes to be returned in each request, null for service default
Returns
Outcome[]|bool Array of Outcome objects or false on error

References getSetting().

◆ getPlatform()

Platform ceLTIc\LTI\ResourceLink::getPlatform ( )

Get platform.

Returns
Platform Platform object for this resource link.

References ceLTIc\LTI\Context\fromRecordId(), and getDataConnector().

Referenced by getContextId(), getKey(), getSettings(), and hasToolSettingsService().

◆ getPlatformId()

int null ceLTIc\LTI\ResourceLink::getPlatformId ( )

Get platform ID.

Returns
int|null Platform ID for this resource link.

◆ getRecordId()

◆ getSetting()

string ceLTIc\LTI\ResourceLink::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

Referenced by fromRecordId(), getDataConnector(), getOutcomes(), getSettings(), hasLineItemService(), hasMembershipsService(), hasOutcomesService(), and hasToolSettingsService().

◆ getSettings()

array ceLTIc\LTI\ResourceLink::getSettings ( )

Get an array of all setting values.

Returns
array Associative array of setting values

References ceLTIc\LTI\Service\Result\$SCOPE, ceLTIc\LTI\Service\Score\$SCOPE, getPlatform(), and getSetting().

Referenced by ceLTIc\LTI\DataConnector\DataConnector_sql\saveResourceLink().

◆ getShares()

ResourceLinkShare[] ceLTIc\LTI\ResourceLink::getShares ( )

Get an array of ResourceLinkShare objects for each resource link which is sharing this context.

Returns
ResourceLinkShare[] Array of ResourceLinkShare objects

References createLineItem().

◆ getToolSettings()

array bool ceLTIc\LTI\ResourceLink::getToolSettings ( ?ToolSettingsMode $mode = null,
bool $simple = true )

Get Tool Settings.

Parameters
ToolSettingsMode | null$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
array|bool The array of settings if successful, otherwise false

◆ getUserResultSourcedIDs()

UserResult[] ceLTIc\LTI\ResourceLink::getUserResultSourcedIDs ( bool $localOnly = false,
?IdScope $idScope = null )

Obtain an array of UserResult objects for users with a result sourcedId.

The array may include users from other resource links which are sharing this resource link. It may also be optionally indexed by the user ID of a specified scope.

Parameters
bool$localOnlyTrue if only users from this resource link are to be returned, not users from shared resource links (optional, default is false)
IdScope | null$idScopeScope to use for ID values (optional, default is null for platform default)
Returns
UserResult[] Array of UserResult objects

◆ hasAssessmentControlService()

bool ceLTIc\LTI\ResourceLink::hasAssessmentControlService ( )

Check if the Assessment Control service is available.

Returns
bool True if this resource link supports the Assessment Control service

◆ hasLineItemService()

bool ceLTIc\LTI\ResourceLink::hasLineItemService ( )

Check if the Line-item service is available.

Returns
bool True if this resource link supports the Line-item service

References ceLTIc\LTI\Service\Result\$SCOPE, and getSetting().

◆ hasMembershipsService()

bool ceLTIc\LTI\ResourceLink::hasMembershipsService ( )

Check if a Memberships service is available.

Returns
bool True if this resource link supports a Memberships service

References getSetting().

◆ hasOutcomesService()

bool ceLTIc\LTI\ResourceLink::hasOutcomesService ( )

Check if an Outcomes service is available.

Returns
bool True if this resource link supports an Outcomes service

References getSetting().

◆ hasResultService()

bool ceLTIc\LTI\ResourceLink::hasResultService ( )

Check if the Result service is available.

Returns
bool True if this resource link supports the Result service

References ceLTIc\LTI\Outcome\setValue().

◆ hasScoreService()

bool ceLTIc\LTI\ResourceLink::hasScoreService ( )

Check if the Score service is available.

Returns
bool True if this resource link supports the Score service

◆ hasSettingService()

bool ceLTIc\LTI\ResourceLink::hasSettingService ( )

Check if the Setting extension service is available.

Returns
bool True if this resource link supports the Setting extension service

◆ hasToolSettingsService()

bool ceLTIc\LTI\ResourceLink::hasToolSettingsService ( )

Check if the Tool Settings service is available.

Returns
bool True if this resource link supports the Tool Settings service

References getPlatform(), getSetting(), and setToolSettings().

◆ initialise()

void ceLTIc\LTI\ResourceLink::initialise ( )

Initialise the resource link.

Synonym for initialize().

References getContext(), and ceLTIc\LTI\Context\getPlatform().

◆ initialize()

void ceLTIc\LTI\ResourceLink::initialize ( )

Initialise the resource link.

References getDataConnector().

Referenced by ceLTIc\LTI\DataConnector\DataConnector\deleteContext(), and fromContext().

◆ save()

bool ceLTIc\LTI\ResourceLink::save ( )

Save the resource link to the database.

Returns
bool True if the resource link was successfully saved.

Referenced by setSetting().

◆ saveSettings()

bool ceLTIc\LTI\ResourceLink::saveSettings ( )

Save setting values.

Returns
bool True if the settings were successfully saved

◆ setContext()

void ceLTIc\LTI\ResourceLink::setContext ( Context $context)

Set context.

Parameters
Context$contextContext for this resource link.

◆ setContextId()

void ceLTIc\LTI\ResourceLink::setContextId ( ?int $contextId)

Set context ID.

Parameters
int | null$contextIdContext ID for this resource link.

◆ setPlatformId()

void ceLTIc\LTI\ResourceLink::setPlatformId ( ?int $platformId)

Set platform ID.

Parameters
int | null$platformIdPlatform ID for this resource link.

◆ setRecordId()

ceLTIc\LTI\ResourceLink::setRecordId ( int|string $id)

Set resource link record ID.

Parameters
int | string$idRecord ID for this resource link.

◆ setSetting()

void ceLTIc\LTI\ResourceLink::setSetting ( string $name,
string|array|null $value = null )

Set a setting value.

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

References save().

◆ setSettings()

void ceLTIc\LTI\ResourceLink::setSettings ( array $settings)

Set an array of all setting values.

Parameters
array$settingsAssociative array of setting values

References getContextId().

◆ setToolSettings()

bool ceLTIc\LTI\ResourceLink::setToolSettings ( array $settings = [])

Set Tool Settings.

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

References ceLTIc\LTI\Service\Membership\MEDIA_TYPE_MEMBERSHIPS_NRPS.

Referenced by hasToolSettingsService().

Member Data Documentation

◆ $created

int ceLTIc\LTI\ResourceLink::$created = null

Timestamp for when the object was created.

◆ $extRequest

string null ceLTIc\LTI\ResourceLink::$extRequest = null

Request for last service request.

$extRequest

◆ $extRequestHeaders

array ceLTIc\LTI\ResourceLink::$extRequestHeaders = null

Request headers for last service request.

◆ $extResponse

string ceLTIc\LTI\ResourceLink::$extResponse = null

Response from last service request.

◆ $extResponseHeaders

array ceLTIc\LTI\ResourceLink::$extResponseHeaders = null

Response header from last service request.

◆ $groups

array ceLTIc\LTI\ResourceLink::$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.

◆ $groupSets

array ceLTIc\LTI\ResourceLink::$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.

◆ $lastServiceRequest

HttpMessage ceLTIc\LTI\ResourceLink::$lastServiceRequest = null

HttpMessage object for last service request.

◆ $ltiResourceLinkId

string ceLTIc\LTI\ResourceLink::$ltiResourceLinkId = null

Resource link ID as supplied in the last connection request.

Referenced by doAssessmentControlAction(), and fromPlatform().

◆ $primaryResourceLinkId

int ceLTIc\LTI\ResourceLink::$primaryResourceLinkId = null

Primary key value for resource link being shared (if any).

◆ $shareApproved

bool ceLTIc\LTI\ResourceLink::$shareApproved = null

Whether the sharing request has been approved by the primary resource link.

◆ $title

string ceLTIc\LTI\ResourceLink::$title = null

Context title.

◆ $updated

int ceLTIc\LTI\ResourceLink::$updated = null

Timestamp for when the object was last updated.