LTI Integration Library 5.0.0-rc2
PHP class library for building LTI integrations
 
Loading...
Searching...
No Matches
Context Class Reference

Class to represent a platform context. More...

Inheritance diagram for Context:
ApiHook

Public Member Functions

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

Static Public Member Functions

static Context fromRecordId ($id, $dataConnector)
 Load the context from the database.
 
static Context fromConsumer ($consumer, $ltiContextId)
 Class constructor from consumer.
 
static Context fromPlatform ($platform, $ltiContextId)
 Class constructor from platform.
 
- Static Public Member Functions inherited from ApiHook
static void registerApiHook ($hookName, $familyCode, $className)
 Register the availability of an API hook.
 

Public Attributes

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

Additional Inherited Members

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

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
Licence: http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3

Member Function Documentation

◆ createLineItem()

bool createLineItem (   $lineItem)

Create a new line item.

Parameters
LineItem$lineItemLine item object
Returns
bool True if successful

◆ delete()

bool delete ( )

Delete the context from the database.

Returns
bool True if the context was successfully deleted.

References Context\getDataConnector().

◆ fromConsumer()

static Context fromConsumer (   $consumer,
  $ltiContextId 
)
static

Class constructor from consumer.

Deprecated:
Use fromPlatform() instead
See also
Context::fromPlatform()
Parameters
ToolConsumer$consumerConsumer instance
string$ltiContextIdLTI Context ID value
Returns
Context

◆ fromPlatform()

static Context fromPlatform (   $platform,
  $ltiContextId 
)
static

Class constructor from platform.

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

◆ fromRecordId()

static Context fromRecordId (   $id,
  $dataConnector 
)
static

Load the context from the database.

Parameters
int$idRecord ID of context
DataConnector$dataConnectorDatabase connection object
Returns
Context Context object

◆ getConsumer()

ToolConsumer getConsumer ( )

Get tool consumer.

Deprecated:
Use getPlatform() instead
See also
Context::getPlatform()
Returns
ToolConsumer Tool consumer object for this context.

◆ getDataConnector()

mixed getDataConnector ( )

Get the data connector.

Returns
mixed Data connector object or string

Referenced by Platform\__construct(), Context\delete(), and Tool\initialize().

◆ getGroups()

bool getGroups ( )

Get course group sets and groups.

Returns
bool True if the request was successful

◆ getId()

string getId ( )

Get context ID.

Returns
string ID for this context.

◆ getKey()

string getKey ( )

Get consumer key.

Returns
string Consumer key value for this context.

◆ getLineItems()

LineItem[] bool getLineItems (   $resourceId = null,
  $tag = null,
  $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

◆ getMembership()

mixed getMembership ( )

Get Membership.

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

◆ getMemberships()

mixed getMemberships (   $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

◆ getPlatform()

Platform getPlatform ( )

Get platform.

Returns
Platform Platform object for this context.

Referenced by Context\setConsumerId().

◆ getRecordId()

int null getRecordId ( )

Get the context record ID.

Returns
int|null Context record ID value

Referenced by ResourceLink\getKey().

◆ getSetting()

string 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

Referenced by Context\hasResultService(), and Context\hasScoreService().

◆ getSettings()

array getSettings ( )

Get an array of all setting values.

Returns
array Associative array of setting values

◆ getToolSettings()

mixed getToolSettings (   $mode = Service\ToolSettings::MODE_CURRENT_LEVEL,
  $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

◆ hasGroupService()

bool hasGroupService ( )

Check if a Course Group service is available.

Returns
bool True if this context supports a Course Group service

◆ hasLineItemService()

bool hasLineItemService ( )

Check if the Line Item service is available.

Returns
bool True if this context supports the Line Item service

◆ hasMembershipService()

bool 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

◆ hasMembershipsService()

bool hasMembershipsService ( )

Check if a Membership service is available.

Returns
bool True if this context supports a Memberships service

◆ hasResultService()

bool hasResultService ( )

Check if the Result service is available.

Returns
bool True if this context supports the Result service

References Score\$SCOPE, and Context\getSetting().

◆ hasScoreService()

bool hasScoreService ( )

Check if the Score service is available.

Returns
bool True if this context supports the Score service

References Context\getSetting().

◆ hasToolSettingsService()

bool hasToolSettingsService ( )

Check if the Tool Settings service is available.

Returns
bool True if this context supports the Tool Settings service

References Context\save().

◆ initialise()

initialise ( )

Initialise the context.

Synonym for initialize().

◆ save()

bool save ( )

Save the context to the database.

Returns
bool True if the context was successfully saved.

Referenced by Context\hasToolSettingsService().

◆ saveSettings()

bool saveSettings ( )

Save setting values.

Returns
bool True if the settings were successfully saved

◆ setConsumerId()

setConsumerId (   $consumerId)

Set tool consumer ID.

Deprecated:
Use setPlatformId() instead
See also
Context::setPlatformId()
Parameters
int$consumerIdTool Consumer ID for this context.

References Context\getPlatform(), and Util\logDebug().

◆ setPlatformId()

setPlatformId (   $platformId)

Set platform ID.

Parameters
int$platformIdPlatform ID for this context.

◆ setRecordId()

setRecordId (   $id)

Sets the context record ID.

Parameters
int$idContext record ID value

◆ setSetting()

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)

◆ setSettings()

setSettings (   $settings)

Set an array of all setting values.

Parameters
array$settingsAssociative array of setting values

◆ setToolSettings()

bool setToolSettings (   $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

Member Data Documentation

◆ $created

int null $created = null

Timestamp for when the object was created.

$created

◆ $groups

array null $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.

$groups

◆ $groupSets

array null $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.

$groupSets

◆ $lastServiceRequest

HttpMessage null $lastServiceRequest = null

HttpMessage object for last service request.

$lastServiceRequest

◆ $ltiContextId

string null $ltiContextId = null

Context ID as supplied in the last connection request.

$ltiContextId

◆ $title

string null $title = null

Context title.

$title

◆ $type

string null $type = null

Context type.

$type

◆ $updated

int null $updated = null

Timestamp for when the object was last updated.

$updated


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