Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.

Differences Between: [Versions 310 and 403] [Versions 311 and 403] [Versions 39 and 403] [Versions 400 and 403] [Versions 401 and 403]

(no description)

File Size: 1307 lines (38 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: ResourceLink  - X-Ref

Class to represent a tool consumer resource link

__construct()   X-Ref
Class constructor.


initialize()   X-Ref
Initialise the resource link.


initialise()   X-Ref
Initialise the resource link.

Pseudonym for initialize().

save()   X-Ref
Save the resource link to the database.

return: boolean True if the resource link was successfully saved.

delete()   X-Ref
Delete the resource link from the database.

return: boolean True if the resource link was successfully deleted.

getConsumer()   X-Ref
Get tool consumer.

return: ToolConsumer Tool consumer object for this resource link.

setConsumerId($consumerId)   X-Ref
Set tool consumer ID.

param: int $consumerId   Tool Consumer ID for this resource link.

getContext()   X-Ref
Get context.

return: object LTIContext object for this resource link.

getContextId()   X-Ref
Get context record ID.

return: int Context record ID for this resource link.

setContextId($contextId)   X-Ref
Set context ID.

param: int $contextId   Context ID for this resource link.

getKey()   X-Ref
Get tool consumer key.

return: string Consumer key value for this resource link.

getId()   X-Ref
Get resource link ID.

return: string ID for this resource link.

getRecordId()   X-Ref
Get resource link record ID.

return: int Record ID for this resource link.

setRecordId($id)   X-Ref
Set resource link record ID.

param: int $id  Record ID for this resource link.

getDataConnector()   X-Ref
Get the data connector.

return: mixed Data connector object or string

getSetting($name, $default = '')   X-Ref
Get a setting value.

param: string $name    Name of setting
param: string $default Value to return if the setting does not exist (optional, default is an empty string)
return: string Setting value

setSetting($name, $value = null)   X-Ref
Set a setting value.

param: string $name  Name of setting
param: string $value Value to set, use an empty value to delete a setting (optional, default is null)

getSettings()   X-Ref
Get an array of all setting values.

return: array Associative array of setting values

setSettings($settings)   X-Ref
Set an array of all setting values.

param: array $settings  Associative array of setting values

saveSettings()   X-Ref
Save setting values.

return: boolean True if the settings were successfully saved

hasOutcomesService()   X-Ref
Check if the Outcomes service is supported.

return: boolean True if this resource link supports the Outcomes service (either the LTI 1.1 or extension service)

hasMembershipsService()   X-Ref
Check if the Memberships extension service is supported.

return: boolean True if this resource link supports the Memberships extension service

hasSettingService()   X-Ref
Check if the Setting extension service is supported.

return: boolean True if this resource link supports the Setting extension service

doOutcomesService($action, $ltiOutcome, $user)   X-Ref
Perform an Outcomes service request.

param: int $action The action type constant
param: Outcome $ltiOutcome Outcome object
param: User $user User object
return: boolean True if the request was successfully processed

doMembershipsService($withGroups = false)   X-Ref
Perform a Memberships service request.

The user table is updated with the new list of user objects.

param: boolean $withGroups True is group information is to be requested as well
return: mixed Array of User objects or False if the request was not successful

doSettingService($action, $value = null)   X-Ref
Perform a Setting service request.

param: int    $action The action type constant
param: string $value  The setting value (optional, default is null)
return: mixed The setting value for a read action, true if a write or delete action was successful, otherwise false

hasToolSettingsService()   X-Ref
Check if the Tool Settings service is supported.

return: boolean True if this resource link supports the Tool Settings service

getToolSettings($mode = Service\ToolSettings::MODE_CURRENT_LEVEL, $simple = true)   X-Ref
Get Tool Settings.

param: int      $mode       Mode for request (optional, default is current level only)
param: boolean  $simple     True if all the simple media type is to be used (optional, default is true)
return: mixed The array of settings if successful, otherwise false

setToolSettings($settings = array()   X-Ref
Perform a Tool Settings service request.

param: array    $settings   An associative array of settings (optional, default is none)
return: boolean True if action was successful, otherwise false

hasMembershipService()   X-Ref
Check if the Membership service is supported.

return: boolean True if this resource link supports the Membership service

getMembership()   X-Ref
Get Memberships.

return: mixed The array of User objects if successful, otherwise false

getUserResultSourcedIDs($localOnly = false, $idScope = null)   X-Ref
Obtain an array of User 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.

param: boolean $localOnly True if only users from this resource link are to be returned, not users from shared resource links (optional, default is false)
param: int     $idScope     Scope to use for ID values (optional, default is null for consumer default)
return: array Array of User objects

getShares()   X-Ref
Get an array of ResourceLinkShare objects for each resource link which is sharing this context.

return: array Array of ResourceLinkShare objects

fromConsumer($consumer, $ltiResourceLinkId, $tempId = null)   X-Ref
Class constructor from consumer.

param: ToolConsumer $consumer Consumer object
param: string $ltiResourceLinkId Resource link ID value
param: string $tempId Temporary Resource link ID value (optional, default is null)
return: ResourceLink

fromContext($context, $ltiResourceLinkId, $tempId = null)   X-Ref
Class constructor from context.

param: Context $context Context object
param: string $ltiResourceLinkId Resource link ID value
param: string $tempId Temporary Resource link ID value (optional, default is null)
return: ResourceLink

fromRecordId($id, $dataConnector)   X-Ref
Load the resource link from the database.

param: int $id     Record ID of resource link
param: DataConnector   $dataConnector    Database connection object
return: ResourceLink  ResourceLink object

load($id = null)   X-Ref
Load the resource link from the database.

param: int $id     Record ID of resource link (optional, default is null)
return: boolean True if resource link was successfully loaded

checkValueType($ltiOutcome, $supportedTypes = null)   X-Ref
Convert data type of value to a supported type if possible.

param: Outcome     $ltiOutcome     Outcome object
param: string[]    $supportedTypes Array of outcome types to be supported (optional, default is null to use supported types reported in the last launch for this resource link)
return: boolean True if the type/value are valid and supported

doService($type, $url, $params)   X-Ref
Send a service request to the tool consumer.

param: string $type   Message type value
param: string $url    URL to send request to
param: array  $params Associative array of parameter values to be passed
return: boolean True if the request successfully obtained a response

doLTI11Service($type, $url, $xml)   X-Ref
Send a service request to the tool consumer.

param: string $type Message type value
param: string $url  URL to send request to
param: string $xml  XML of message request
return: boolean True if the request successfully obtained a response

domnodeToArray($node)   X-Ref
Convert DOM nodes to array.

param: DOMElement $node XML element
return: array Array of XML document elements