Class to represent a tool consumer resource link

author Stephen P Vickers
version 2.5.00
license GNU Lesser General Public License, version 3
package LTI

 Methods

Class constructor.

__construct(string $consumer, string $id, string $current_id = NULL

Parameters

$consumer

string

Consumer key value

$id

string

Resource link ID value

$current_id

string

Current ID of resource link (optional, default is NULL)

Delete the resource link from the database.

delete() : boolean

Returns

booleanTrue if the resource link was successfully deleted.

Perform a Memberships service request.

doMembershipsService(boolean $withGroups = FALSE) : mixed
The user table is updated with the new list of user objects.

Parameters

$withGroups

boolean

True is group information is to be requested as well

Returns

mixedArray of LTI_User objects or False if the request was not successful

Perform an Outcomes service request.

doOutcomesService(integer $action, \LTI_Outcome $lti_outcome, \LTI_User $user = NULL) : boolean

Parameters

$action

integer

The action type constant

$lti_outcome

\LTI_Outcome

Outcome object

$user

\LTI_User

User object

Returns

booleanTrue if the request was successfully processed

Perform a Setting service request.

doSettingService(integer $action, string $value = NULL) : mixed

Parameters

$action

integer

The action type constant

$value

string

The setting value (optional, default is null)

Returns

mixedThe setting value for a read action, true if a write or delete action was successful, otherwise false

Get tool consumer.

getConsumer() : object

Returns

objectLTI_Tool_Consumer object for this resource link.

Get resource link ID.

getId(string $previous = FALSE) : string

Parameters

$previous

string

TRUE if previous ID value is to be returned (optional, default is FALSE)

Returns

stringID for this resource link.

Get tool consumer key.

getKey() : string

Returns

stringConsumer key value for this resource link.

Get a setting value.

getSetting(string $name, string $default = '') : string

Parameters

$name

string

Name of setting

$default

string

Value to return if the setting does not exist (optional, default is an empty string)

Returns

stringSetting value

Get an array of all setting values.

getSettings() : array

Returns

arrayAssociative array of setting values

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

getShares() : array

Returns

arrayArray of LTI_Resource_Link_Share objects

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

getUserResultSourcedIDs(boolean $local_only = FALSE, integer $id_scope = NULL) : array
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

$local_only

boolean

True if only users from this resource link are to be returned, not users from shared resource links (optional, default is false)

$id_scope

integer

Scope to use for ID values (optional, default is null for consumer default)

Returns

arrayArray of LTI_User objects

Check if the Memberships service is supported.

hasMembershipsService() : boolean

Returns

booleanTrue if this resource link supports the Memberships service

Check if the Outcomes service is supported.

hasOutcomesService() : boolean

Returns

booleanTrue if this resource link supports the Outcomes service (either the LTI 1.1 or extension service)

Check if the Setting service is supported.

hasSettingService() : boolean

Returns

booleanTrue if this resource link supports the Setting service

Initialise the resource link.

initialise() 

Save the resource link to the database.

save() : boolean

Returns

booleanTrue if the resource link was successfully saved.

Save setting values.

saveSettings() : boolean

Returns

booleanTrue if the settings were successfully saved

Set a setting value.

setSetting(string $name, string $value = NULL

Parameters

$name

string

Name of setting

$value

string

Value to set, use an empty value to delete a setting (optional, default is null)

Convert data type of value to a supported type if possible.

checkValueType(\LTI_Outcome $lti_outcome, array<mixed,string> $supported_types = NULL) : boolean

Parameters

$lti_outcome

\LTI_Outcome

Outcome object

$supported_types

array<mixed,string>

Array of outcome types to be supported (optional, default is null to use supported types reported in the last launch for this resource link)

Returns

booleanTrue if the type/value are valid and supported

Send a service request to the tool consumer.

doLTI11Service(string $type, string $url, string $xml) : boolean

Parameters

$type

string

Message type value

$url

string

URL to send request to

$xml

string

XML of message request

Returns

booleanTrue if the request successfully obtained a response

Send a service request to the tool consumer.

doService(string $type, string $url, array $params) : boolean

Parameters

$type

string

Message type value

$url

string

URL to send request to

$params

array

Associative array of parameter values to be passed

Returns

booleanTrue if the request successfully obtained a response

Convert DOM nodes to array.

domnode_to_array(\DOMElement $node) : array

Parameters

$node

\DOMElement

XML element

Returns

arrayArray of XML document elements

Load the resource link from the database.

load() : boolean

Returns

booleanTrue if resource link was successfully loaded

 Properties

 

Date/time when the object was created.

$created : object

Default

NULL
 

Request for last service request.

$ext_request : string

Default

NULL
 

Request headers for last service request.

$ext_request_headers : array

Default

NULL
 

Response from last service request.

$ext_response : string

Default

NULL
 

Response header from last service request.

$ext_response_headers : array

Default

NULL
 

User group sets (NULL if the consumer does not support the groups enhancement)

$group_sets : array

Default

NULL
 

User groups (NULL if the consumer does not support the groups enhancement)

$groups : array

Default

NULL
 

Context ID as supplied in the last connection request.

$lti_context_id : string

Default

NULL
 

Resource link ID as supplied in the last connection request.

$lti_resource_id : string

Default

NULL
 

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

$primary_consumer_key : string

Default

NULL
   

Setting values (LTI parameters, custom parameters and local parameters).

$settings : array

Default

NULL
 

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

$share_approved : boolean

Default

NULL
 

Context title.

$title : string

Default

NULL
 

Date/time when the object was last updated.

$updated : object

Default

NULL
 

Tool Consumer for this resource link.

$consumer : \LTI_Tool_Consumer

Default

NULL
 

XML document for the last extension service request.

$ext_doc : string

Default

NULL
 

XML node array for the last extension service request.

$ext_nodes : array

Default

NULL
 

ID for this resource link.

$id : string

Default

NULL
 

Previous ID for this resource link.

$previous_id : string

Default

NULL
 

Whether the settings value have changed since last saved.

$settings_changed : boolean

Default

FALSE

 Constants

 

Delete action.

EXT_DELETE = 3 
 

Read action.

EXT_READ = 1 
 

Decimal outcome type.

EXT_TYPE_DECIMAL = 'decimal' 
 

Letter (A-F) outcome type.

EXT_TYPE_LETTER_AF = 'letteraf' 
 

Letter (A-F) with optional +/- outcome type.

EXT_TYPE_LETTER_AF_PLUS = 'letterafplus' 
 

Pass/fail outcome type.

EXT_TYPE_PASS_FAIL = 'passfail' 
 

Percentage outcome type.

EXT_TYPE_PERCENTAGE = 'percentage' 
 

Ratio outcome type.

EXT_TYPE_RATIO = 'ratio' 
 

Free text outcome type.

EXT_TYPE_TEXT = 'freetext' 
 

Write (create/update) action.

EXT_WRITE = 2