LTI Tool Provider Library  3.0.2
PHP class library for building LTI Tool Providers
ResourceLink Class Reference

Class to represent a tool consumer resource link. More...

Public Member Functions

 __construct ()
 Class constructor. More...
 
 initialize ()
 Initialise the resource link. More...
 
 initialise ()
 Initialise the resource link. More...
 
 save ()
 Save the resource link to the database. More...
 
 delete ()
 Delete the resource link from the database. More...
 
 getConsumer ()
 Get tool consumer. More...
 
 setConsumerId ($consumerId)
 Set tool consumer ID. More...
 
 getContext ()
 Get context. More...
 
 getContextId ()
 Get context record ID. More...
 
 setContextId ($contextId)
 Set context ID. More...
 
 getKey ()
 Get tool consumer key. More...
 
 getId ()
 Get resource link ID. More...
 
 getRecordId ()
 Get resource link record ID. More...
 
 setRecordId ($id)
 Set resource link record ID. More...
 
 getDataConnector ()
 Get the data connector. More...
 
 getSetting ($name, $default= '')
 Get a setting value. More...
 
 setSetting ($name, $value=null)
 Set a setting value. More...
 
 getSettings ()
 Get an array of all setting values. More...
 
 setSettings ($settings)
 Set an array of all setting values. More...
 
 saveSettings ()
 Save setting values. More...
 
 hasOutcomesService ()
 Check if the Outcomes service is supported. More...
 
 hasMembershipsService ()
 Check if the Memberships extension service is supported. More...
 
 hasSettingService ()
 Check if the Setting extension service is supported. More...
 
 doOutcomesService ($action, $ltiOutcome, $user)
 Perform an Outcomes service request. More...
 
 doMembershipsService ($withGroups=false)
 Perform a Memberships service request. More...
 
 doSettingService ($action, $value=null)
 Perform a Setting service request. More...
 
 hasToolSettingsService ()
 Check if the Tool Settings service is supported. More...
 
 getToolSettings ($mode=Service\ToolSettings::MODE_CURRENT_LEVEL, $simple=true)
 Get Tool Settings. More...
 
 setToolSettings ($settings=array())
 Perform a Tool Settings service request. More...
 
 hasMembershipService ()
 Check if the Membership service is supported. More...
 
 getMembership ()
 Get Memberships. More...
 
 getUserResultSourcedIDs ($localOnly=false, $idScope=null)
 Obtain an array of User objects for users with a result sourcedId. More...
 
 getShares ()
 Get an array of ResourceLinkShare objects for each resource link which is sharing this context. More...
 

Static Public Member Functions

static fromConsumer ($consumer, $ltiResourceLinkId, $tempId=null)
 Class constructor from consumer. More...
 
static fromContext ($context, $ltiResourceLinkId, $tempId=null)
 Class constructor from context. More...
 
static fromRecordId ($id, $dataConnector)
 Load the resource link from the database. More...
 

Data Fields

const EXT_READ = 1
 Read action. More...
 
const EXT_WRITE = 2
 Write (create/update) action. More...
 
const EXT_DELETE = 3
 Delete action. More...
 
const EXT_CREATE = 4
 Create action. More...
 
const EXT_UPDATE = 5
 Update action. More...
 
const EXT_TYPE_DECIMAL = 'decimal'
 Decimal outcome type. More...
 
const EXT_TYPE_PERCENTAGE = 'percentage'
 Percentage outcome type. More...
 
const EXT_TYPE_RATIO = 'ratio'
 Ratio outcome type. More...
 
const EXT_TYPE_LETTER_AF = 'letteraf'
 Letter (A-F) outcome type. More...
 
const EXT_TYPE_LETTER_AF_PLUS = 'letterafplus'
 Letter (A-F) with optional +/- outcome type. More...
 
const EXT_TYPE_PASS_FAIL = 'passfail'
 Pass/fail outcome type. More...
 
const EXT_TYPE_TEXT = 'freetext'
 Free text outcome type. More...
 
 $title = null
 Context title. More...
 
 $ltiResourceLinkId = null
 Resource link ID as supplied in the last connection request. More...
 
 $groupSets = null
 User group sets (null if the consumer does not support the groups enhancement) More...
 
 $groups = null
 User groups (null if the consumer does not support the groups enhancement) More...
 
 $extRequest = null
 Request for last service request. More...
 
 $extRequestHeaders = null
 Request headers for last service request. More...
 
 $extResponse = null
 Response from last service request. More...
 
 $extResponseHeaders = null
 Response header from last service request. More...
 
 $primaryResourceLinkId = null
 Consumer key value for resource link being shared (if any). More...
 
 $shareApproved = null
 Whether the sharing request has been approved by the primary resource link. More...
 
 $created = null
 Date/time when the object was created. More...
 
 $updated = null
 Date/time when the object was last updated. More...
 

Detailed Description

Class to represent a tool consumer resource link.

Author
Stephen P Vickers svick.nosp@m.ers@.nosp@m.imsgl.nosp@m.obal.nosp@m..org
Date
2016
Version
3.0.2
Licence:
http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0

Definition at line 21 of file ResourceLink.php.

Constructor & Destructor Documentation

__construct ( )

Class constructor.

Definition at line 211 of file ResourceLink.php.

References ResourceLink\initialize().

Member Function Documentation

delete ( )

Delete the resource link from the database.

Returns
boolean True if the resource link was successfully deleted.

Definition at line 269 of file ResourceLink.php.

References ResourceLink\getDataConnector().

doMembershipsService (   $withGroups = false)

Perform a Memberships service request.

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

Parameters
boolean$withGroupsTrue is group information is to be requested as well
Returns
mixed Array of User objects or False if the request was not successful

Set the user roles

Definition at line 677 of file ResourceLink.php.

References ResourceLink\$groups, User\fromResourceLink(), ResourceLink\getConsumer(), ResourceLink\getSetting(), ResourceLink\getUserResultSourcedIDs(), ToolProvider\ID_SCOPE_RESOURCE, and ToolProvider\parseRoles().

doOutcomesService (   $action,
  $ltiOutcome,
  $user 
)

Perform an Outcomes service request.

Parameters
int$actionThe action type constant
Outcome$ltiOutcomeOutcome object
User$userUser object
Returns
boolean True if the request was successfully processed

Definition at line 545 of file ResourceLink.php.

doSettingService (   $action,
  $value = null 
)

Perform a Setting service request.

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

Definition at line 791 of file ResourceLink.php.

References ResourceLink\getSetting(), ResourceLink\saveSettings(), and ResourceLink\setSetting().

static fromConsumer (   $consumer,
  $ltiResourceLinkId,
  $tempId = null 
)
static

Class constructor from consumer.

Parameters
ToolConsumer$consumerConsumer object
string$ltiResourceLinkIdResource link ID value
string$tempIdTemporary Resource link ID value (optional, default is null)
Returns
ResourceLink

Definition at line 970 of file ResourceLink.php.

References ResourceLink\$ltiResourceLinkId.

Referenced by ToolProvider\onError().

static fromContext (   $context,
  $ltiResourceLinkId,
  $tempId = null 
)
static

Class constructor from context.

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

Definition at line 998 of file ResourceLink.php.

References ResourceLink\$ltiResourceLinkId.

static fromRecordId (   $id,
  $dataConnector 
)
static

Load the resource link from the database.

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

Definition at line 1027 of file ResourceLink.php.

References OAuthRequest\from_consumer_and_token(), ResourceLink\getConsumer(), ResourceLink\getDataConnector(), ResourceLink\getKey(), ResourceLink\getSetting(), and ResourceLink\initialize().

Referenced by User\getResourceLink().

getConsumer ( )

Get tool consumer.

Returns
ToolConsumer Tool consumer object for this resource link.

Definition at line 281 of file ResourceLink.php.

References ToolConsumer\fromRecordId(), ResourceLink\getContext(), and ResourceLink\getDataConnector().

Referenced by ResourceLink\doMembershipsService(), ResourceLink\fromRecordId(), and ResourceLink\getKey().

getContext ( )

Get context.

Returns
object LTIContext object for this resource link.

Definition at line 314 of file ResourceLink.php.

References Context\fromRecordId(), and ResourceLink\getDataConnector().

Referenced by ResourceLink\getConsumer(), ResourceLink\getMembership(), and ResourceLink\hasMembershipService().

getContextId ( )

Get context record ID.

Returns
int Context record ID for this resource link.

Definition at line 330 of file ResourceLink.php.

getDataConnector ( )
getId ( )

Get resource link ID.

Returns
string ID for this resource link.

Definition at line 367 of file ResourceLink.php.

References ResourceLink\$ltiResourceLinkId.

getKey ( )

Get tool consumer key.

Returns
string Consumer key value for this resource link.

Definition at line 355 of file ResourceLink.php.

References ResourceLink\getConsumer().

Referenced by ResourceLink\fromRecordId().

getMembership ( )

Get Memberships.

Returns
mixed The array of User objects if successful, otherwise false

Definition at line 916 of file ResourceLink.php.

References ResourceLink\getContext().

getRecordId ( )

Get resource link record ID.

Returns
int Record ID for this resource link.

Definition at line 379 of file ResourceLink.php.

getSetting (   $name,
  $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 418 of file ResourceLink.php.

Referenced by ResourceLink\doMembershipsService(), ResourceLink\doSettingService(), ResourceLink\fromRecordId(), ResourceLink\getToolSettings(), ResourceLink\hasMembershipService(), ResourceLink\hasMembershipsService(), ResourceLink\hasOutcomesService(), ResourceLink\hasSettingService(), ResourceLink\hasToolSettingsService(), ResourceLink\setSetting(), and ResourceLink\setToolSettings().

getSettings ( )

Get an array of all setting values.

Returns
array Associative array of setting values

Definition at line 457 of file ResourceLink.php.

getShares ( )

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

Returns
array Array of ResourceLinkShare objects

Definition at line 955 of file ResourceLink.php.

References ResourceLink\getDataConnector().

getToolSettings (   $mode = Service\ToolSettings::MODE_CURRENT_LEVEL,
  $simple = true 
)

Get Tool Settings.

Parameters
int$modeMode for request (optional, default is current level only)
boolean$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 865 of file ResourceLink.php.

References ResourceLink\getSetting().

getUserResultSourcedIDs (   $localOnly = false,
  $idScope = null 
)

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.

Parameters
boolean$localOnlyTrue if only users from this resource link are to be returned, not users from shared resource links (optional, default is false)
int$idScopeScope to use for ID values (optional, default is null for consumer default)
Returns
array Array of User objects

Definition at line 943 of file ResourceLink.php.

References ResourceLink\getDataConnector().

Referenced by ResourceLink\doMembershipsService().

hasMembershipService ( )

Check if the Membership service is supported.

Returns
boolean True if this resource link supports the Membership service

Definition at line 899 of file ResourceLink.php.

References ResourceLink\getContext(), and ResourceLink\getSetting().

hasMembershipsService ( )

Check if the Memberships extension service is supported.

Returns
boolean True if this resource link supports the Memberships extension service

Definition at line 513 of file ResourceLink.php.

References ResourceLink\getSetting().

hasOutcomesService ( )

Check if the Outcomes service is supported.

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

Definition at line 499 of file ResourceLink.php.

References ResourceLink\getSetting().

hasSettingService ( )

Check if the Setting extension service is supported.

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

Definition at line 527 of file ResourceLink.php.

References ResourceLink\getSetting().

hasToolSettingsService ( )

Check if the Tool Settings service is supported.

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

Definition at line 848 of file ResourceLink.php.

References ResourceLink\getSetting().

initialise ( )

Initialise the resource link.

Pseudonym for initialize().

Definition at line 240 of file ResourceLink.php.

References ResourceLink\initialize().

initialize ( )

Initialise the resource link.

Definition at line 221 of file ResourceLink.php.

Referenced by ResourceLink\__construct(), ResourceLink\fromRecordId(), and ResourceLink\initialise().

save ( )

Save the resource link to the database.

Returns
boolean True if the resource link was successfully saved.

Definition at line 252 of file ResourceLink.php.

References ResourceLink\getDataConnector().

Referenced by ResourceLink\saveSettings().

saveSettings ( )

Save setting values.

Returns
boolean True if the settings were successfully saved

Definition at line 481 of file ResourceLink.php.

References ResourceLink\save().

Referenced by ResourceLink\doSettingService().

setConsumerId (   $consumerId)

Set tool consumer ID.

Parameters
int$consumerIdTool Consumer ID for this resource link.

Definition at line 301 of file ResourceLink.php.

setContextId (   $contextId)

Set context ID.

Parameters
int$contextIdContext ID for this resource link.

Definition at line 342 of file ResourceLink.php.

setRecordId (   $id)

Set resource link record ID.

Parameters
int$idRecord ID for this resource link.

Definition at line 391 of file ResourceLink.php.

setSetting (   $name,
  $value = null 
)

Set a setting value.

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

Definition at line 437 of file ResourceLink.php.

References ResourceLink\getSetting().

Referenced by ResourceLink\doSettingService().

setSettings (   $settings)

Set an array of all setting values.

Parameters
array$settingsAssociative array of setting values

Definition at line 469 of file ResourceLink.php.

setToolSettings (   $settings = array())

Perform a Tool Settings service request.

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

Definition at line 883 of file ResourceLink.php.

References ResourceLink\getSetting().

Field Documentation

int $created = null

Date/time when the object was created.

Definition at line 139 of file ResourceLink.php.

string $extRequest = null

Request for last service request.

Definition at line 103 of file ResourceLink.php.

array $extRequestHeaders = null

Request headers for last service request.

Definition at line 109 of file ResourceLink.php.

string $extResponse = null

Response from last service request.

Definition at line 115 of file ResourceLink.php.

array $extResponseHeaders = null

Response header from last service request.

Definition at line 121 of file ResourceLink.php.

array $groups = null

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

Definition at line 97 of file ResourceLink.php.

Referenced by ResourceLink\doMembershipsService().

array $groupSets = null

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

Definition at line 91 of file ResourceLink.php.

string $ltiResourceLinkId = null

Resource link ID as supplied in the last connection request.

Definition at line 85 of file ResourceLink.php.

Referenced by ResourceLink\fromConsumer(), ResourceLink\fromContext(), and ResourceLink\getId().

string $primaryResourceLinkId = null

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

Definition at line 127 of file ResourceLink.php.

boolean $shareApproved = null

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

Definition at line 133 of file ResourceLink.php.

string $title = null

Context title.

Definition at line 79 of file ResourceLink.php.

int $updated = null

Date/time when the object was last updated.

Definition at line 145 of file ResourceLink.php.

const EXT_CREATE = 4

Create action.

Definition at line 39 of file ResourceLink.php.

const EXT_DELETE = 3

Delete action.

Definition at line 35 of file ResourceLink.php.

const EXT_READ = 1

Read action.

Definition at line 27 of file ResourceLink.php.

const EXT_TYPE_DECIMAL = 'decimal'

Decimal outcome type.

Definition at line 48 of file ResourceLink.php.

const EXT_TYPE_LETTER_AF = 'letteraf'

Letter (A-F) outcome type.

Definition at line 60 of file ResourceLink.php.

const EXT_TYPE_LETTER_AF_PLUS = 'letterafplus'

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

Definition at line 64 of file ResourceLink.php.

const EXT_TYPE_PASS_FAIL = 'passfail'

Pass/fail outcome type.

Definition at line 68 of file ResourceLink.php.

const EXT_TYPE_PERCENTAGE = 'percentage'

Percentage outcome type.

Definition at line 52 of file ResourceLink.php.

const EXT_TYPE_RATIO = 'ratio'

Ratio outcome type.

Definition at line 56 of file ResourceLink.php.

const EXT_TYPE_TEXT = 'freetext'

Free text outcome type.

Definition at line 72 of file ResourceLink.php.

const EXT_UPDATE = 5

Update action.

Definition at line 43 of file ResourceLink.php.

const EXT_WRITE = 2

Write (create/update) action.

Definition at line 31 of file ResourceLink.php.


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