Tsugi

Context extends Entity
in package
uses SettingsTrait

This is a class to provide access to the resource context level data.

This data comes from the LTI launch from the LMS. A context is the equivalent of a "class" or course. A context has a roster of users and each user has a role within the context. A launch may or may not contain a context. If there is a link without a context, it is a "system-wide" link like "view profile" or "show all courses"

Table of Contents

Properties

$context_id  : mixed
$guid  : mixed
Stable guid for this context, as 32 lowercase hex characters.
$id  : mixed
The integer primary key for this context in the 'lti_context' table.
$key  : mixed
$launch  : mixed
A reference to our containing launch
$secret  : mixed
$settingsDebugArray  : mixed
$title  : mixed
The context title
$ENTITY_NAME  : mixed
$PRIMARY_KEY  : mixed
$TABLE_NAME  : mixed

Methods

__construct()  : mixed
A guid already on the row is kept with no query. A null guid becomes the value read back after the conditional update, not the candidate that this request generated.
createLineItem()  : object|string
Create a lineitem in the LMS
deleteLineItem()  : bool|string
Delete a lineitem from the LMS
getGradeToken()  : mixed
Wrapper to get grade token
getJson()  : string
Load the json field for this entity
getJsonKey()  : mixed
Get a JSON key for this entity
getJsonKeyLegacy()  : mixed
Get a JSON key for this entity (legacy array style)
getLineItemsToken()  : mixed
Wrapper to get line items token so we can add caching
loadAllGroups()  : object|string|false
Load all the groups if we can get them from the LMS
loadGroups()  : object|string|false
Load the groups from the LMS
loadLineItem()  : object|string
Load the detail for a lineitem from the LMS
loadLineItems()  : array<string|int, mixed>|string
Load our lineitems from the LMS
loadNamesAndRoles()  : object|string|false
Load the roster if we can get it from the LMS
loadResults()  : array<string|int, mixed>|string
Load the results for a line item
ltiCustomGet()  : mixed
Pull out a custom variable from the LTIX session. Do not include the "custom_" prefix - this is automatic.
ltiParameter()  : mixed
Pull a keyed variable from the original LTI post data in the current session with default
ltiParameterUpdate()  : mixed
Update a keyed variable from the original LTI post data in the current session with default
ltiRawParameter()  : mixed
Pull a keyed variable from the original LTI post data in the current session with default
ltiRawPostArray()  : mixed
Return the original $_POST array
sendLineItemResult()  : bool|string
Send a lineitem result to the LMS
setJson()  : mixed
Set the JSON entry for this entity
setJsonKey()  : mixed
Set/update a JSON key for this entity
setJsonKeys()  : mixed
Set/update an array of JSON keys for this entity
settingsDebug()  : mixed
Retrieve the debug array for the last operation.
settingsGet()  : mixed
Retrieve a particular key from the settings.
settingsGetAll()  : mixed
Retrieve an array of all of the settings
settingsSet()  : mixed
Update a single key in settings
settingsUpdate()  : mixed
Set or update a number of keys to new values in link settings.
updateLineItem()  : object|string
Update a lineitem in the LMS
settingsSetAll()  : mixed
Replace all the settings (Dangerous)
loadLTI13Data()  : string
Load the LTI 1.3 data from the session, checking for sanity

Properties

$context_id

public mixed $context_id

$guid

Stable guid for this context, as 32 lowercase hex characters.

public mixed $guid = null

$id

The integer primary key for this context in the 'lti_context' table.

public mixed $id

$launch

A reference to our containing launch

public mixed $launch

$title

The context title

public mixed $title

$ENTITY_NAME

protected mixed $ENTITY_NAME = "context"

$PRIMARY_KEY

protected mixed $PRIMARY_KEY = "context_id"

$TABLE_NAME

protected mixed $TABLE_NAME = "lti_context"

Methods

__construct()

A guid already on the row is kept with no query. A null guid becomes the value read back after the conditional update, not the candidate that this request generated.

public __construct([array<string, mixed>|null $row = null ]) : mixed
Parameters
$row : array<string, mixed>|null = null

Launch or lti_context row. Null leaves guid unset.

createLineItem()

Create a lineitem in the LMS

public createLineItem(object $newitem[, array<string|int, mixed>|false &$debug_log = false ]) : object|string
Parameters
$newitem : object

The fields for the new line item Example: $newitem = new \stdClass(); $newitem->scoreMaximum = 100; $newitem->label = 'Week 3 Feedback'; $newitem->resourceId = '2987487943'; $newitem->tag = 'optional';

$debug_log : array<string|int, mixed>|false = false

Returns a log of actions taken

Return values
object|string —

If this works it returns the LineItem. If it fails, it returns a string.

deleteLineItem()

Delete a lineitem from the LMS

public deleteLineItem(string $id[, array<string|int, mixed>|false &$debug_log = false ]) : bool|string
Parameters
$id : string

The line item ID (REST endpoint URL)

$debug_log : array<string|int, mixed>|false = false

Returns a log of actions taken

Return values
bool|string —

If this works it returns true. If it fails, it returns a string with error details.

getGradeToken()

Wrapper to get grade token

public getGradeToken(string &$missing, string &$subject[, array<string|int, mixed> &$debug_log = false ]) : mixed
Parameters
$missing : string

This is a non-empty string with error detail if there was an error

$subject : string

The subject if there is no error

$debug_log : array<string|int, mixed> = false

If this is an array, debug information is returned as the process progresses.

Return values
mixed —

If there is an error, this returns false and $missing has the detail if this is a success, the token is returned (a string)

getJson()

Load the json field for this entity

public getJson() : string
Return values
string —

This returns the json string - it is not parsed - if there is nothing to return - this returns "false"

getJsonKey()

Get a JSON key for this entity

public getJsonKey(mixed $key[, mixed $default = false ]) : mixed
Parameters
$key : mixed

The key to be retrieved from the JSON

$default : mixed = false

The default value (optional)

getJsonKeyLegacy()

Get a JSON key for this entity (legacy array style)

public getJsonKeyLegacy(mixed $key[, mixed $default = false ]) : mixed
Parameters
$key : mixed

The key to be retrieved from the JSON

$default : mixed = false

The default value (optional)

getLineItemsToken()

Wrapper to get line items token so we can add caching

public getLineItemsToken(string &$missing, string &$lti13_lineitems[, array<string|int, mixed> &$debug_log = false ]) : mixed
Parameters
$missing : string

This is a non-empty string with error detail if there was an error

$lti13_lineitems : string

The url for the LineItems Service if there was no error

$debug_log : array<string|int, mixed> = false

If this is an array, debug information is returned as the process progresses.

Return values
mixed —

If there is an error, this returns false and $missing has the detail if this is a success, the token is returned (a string)

loadAllGroups()

Load all the groups if we can get them from the LMS

public loadAllGroups([array<string|int, mixed>|false &$debug_log = false ]) : object|string|false
Parameters
$debug_log : array<string|int, mixed>|false = false

If this is an array, debug information is returned as the process progresses.

Return values
object|string|false —

If this works it returns the Groups object. If it fails, it returns a string with error details or false.

loadGroups()

Load the groups from the LMS

public loadGroups(string|null $user_id[, array<string|int, mixed>|false &$debug_log = false ]) : object|string|false
Parameters
$user_id : string|null

If this is a string, then only the groups for the user_id are retrieved

$debug_log : array<string|int, mixed>|false = false

If this is an array, debug information is returned as the process progresses.

Return values
object|string|false —

If this works it returns the Groups object. If it fails, it returns a string with error details or false.

loadLineItem()

Load the detail for a lineitem from the LMS

public loadLineItem(string $id[, array<string|int, mixed>|false &$debug_log = false ]) : object|string
Parameters
$id : string

The line item ID (REST endpoint URL)

$debug_log : array<string|int, mixed>|false = false

Returns a log of actions taken

Return values
object|string —

If this works it returns the LineItem. If it fails, it returns a string.

loadLineItems()

Load our lineitems from the LMS

public loadLineItems([array<string|int, mixed>|false $search = false ][, array<string|int, mixed>|false &$debug_log = false ]) : array<string|int, mixed>|string
Parameters
$search : array<string|int, mixed>|false = false

Search values to apply to the load (tag, lti_link_id, resource_id)

$debug_log : array<string|int, mixed>|false = false

Returns a log of actions taken

Return values
array<string|int, mixed>|string —

If this works it returns the LineItems array. If it fails, it returns a string with error details.

loadNamesAndRoles()

Load the roster if we can get it from the LMS

public loadNamesAndRoles([bool $with_sourcedids = false ][, array<string|int, mixed>|false &$debug_log = false ]) : object|string|false
Parameters
$with_sourcedids : bool = false

If true, ask for the sourcedids

$debug_log : array<string|int, mixed>|false = false

If this is an array, debug information is returned as the process progresses.

Return values
object|string|false —

If this works it returns the NRPS object. If it fails, it returns a string with error details or false.

loadResults()

Load the results for a line item

public loadResults(string $id[, array<string|int, mixed>|false &$debug_log = false ]) : array<string|int, mixed>|string
Parameters
$id : string

The REST endpoint (id) for this line item

$debug_log : array<string|int, mixed>|false = false

Returns a log of actions taken

Return values
array<string|int, mixed>|string —

If this works it returns the Results array. If it fails, it returns a string with error details.

ltiCustomGet()

Pull out a custom variable from the LTIX session. Do not include the "custom_" prefix - this is automatic.

public ltiCustomGet(mixed $varname[, mixed $default = false ]) : mixed
Parameters
$varname : mixed
$default : mixed = false

ltiParameter()

Pull a keyed variable from the original LTI post data in the current session with default

public ltiParameter(mixed $varname[, mixed $default = false ]) : mixed
Parameters
$varname : mixed
$default : mixed = false

ltiParameterUpdate()

Update a keyed variable from the original LTI post data in the current session with default

public ltiParameterUpdate(mixed $varname, mixed $value) : mixed
Parameters
$varname : mixed
$value : mixed

ltiRawParameter()

Pull a keyed variable from the original LTI post data in the current session with default

public ltiRawParameter(mixed $varname[, mixed $default = false ]) : mixed
Parameters
$varname : mixed
$default : mixed = false

ltiRawPostArray()

Return the original $_POST array

public ltiRawPostArray() : mixed

sendLineItemResult()

Send a lineitem result to the LMS

public sendLineItemResult(string $id, string $user_key, float $grade, float $scoreMaximum, string|null $comment[, array<string|int, mixed>|false &$debug_log = false ][, array<string|int, mixed>|false $extra13 = false ]) : bool|string
Parameters
$id : string

The REST endpoint (id) for this line item

$user_key : string

The user for this grade

$grade : float

Value to send

$scoreMaximum : float

What the score is relative to

$comment : string|null

An optional comment

$debug_log : array<string|int, mixed>|false = false

Returns a log of actions taken

$extra13 : array<string|int, mixed>|false = false

A key/value store of extra LTI1.3 parameters

Return values
bool|string —

If this is a success a true is returned, if not a string with an error is returned.

setJson()

Set the JSON entry for this entity

public setJson(mixed $json) : mixed
Parameters
$json : mixed

This is a string - no validation is done

setJsonKey()

Set/update a JSON key for this entity

public setJsonKey(mixed $key, mixed $value) : mixed
Parameters
$key : mixed

The key to be inserted/updated in the JSON

$value : mixed

The value to be inserted/updated in the JSON

setJsonKeys()

Set/update an array of JSON keys for this entity

public setJsonKeys(mixed $values) : mixed
Parameters
$values : mixed

An array of key/value pairs to be inserted/updated in the JSON

settingsDebug()

Retrieve the debug array for the last operation.

public settingsDebug() : mixed

settingsGet()

Retrieve a particular key from the settings.

public settingsGet(mixed $key[, mixed $default = false ]) : mixed

Returns the value found in settings or false if the key was not found.

If the value is encrypted, it is decrypted using the LTIX::decrypt_secret method.

Parameters
$key : mixed
  • The key to get from the settings.
$default : mixed = false
  • What to return if the key is not present

settingsGetAll()

Retrieve an array of all of the settings

public settingsGetAll() : mixed

If there are no settings, return an empty array.

settingsSet()

Update a single key in settings

public settingsSet(mixed $key, mixed $value) : mixed
Parameters
$key : mixed
$value : mixed

settingsUpdate()

Set or update a number of keys to new values in link settings.

public settingsUpdate(mixed $keyvals) : mixed
Parameters
$keyvals : mixed
Tags
params

$keyvals An array of key value pairs that are to be placed in the settings.

updateLineItem()

Update a lineitem in the LMS

public updateLineItem(string $id, object $newitem[, array<string|int, mixed>|false &$debug_log = false ]) : object|string
Parameters
$id : string

The line item ID (REST endpoint URL)

$newitem : object

The fields to update Example: $newitem = new \stdClass(); $newitem->scoreMaximum = 100; $newitem->label = 'Week 3 Feedback'; $newitem->resourceId = '2987487943'; $newitem->tag = 'optional';

$debug_log : array<string|int, mixed>|false = false

Returns a log of actions taken

Return values
object|string —

If this works it returns the LineItem. If it fails, it returns a string.

settingsSetAll()

Replace all the settings (Dangerous)

protected settingsSetAll(mixed $new_settings) : mixed
Parameters
$new_settings : mixed

loadLTI13Data()

Load the LTI 1.3 data from the session, checking for sanity

private loadLTI13Data(string &$lti13_token_url, string &$privkey, string &$kid, string &$lti13_token_audience, string &$issuer_client, string &$deployment_id) : string
Parameters
$lti13_token_url : string

The token URL (output parameter)

$privkey : string

The current private key (output parameter)

$kid : string

The current kid for the public key (output parameter)

$lti13_token_audience : string

The current optional token audience (output parameter)

$issuer_client : string

The current client_id (output parameter)

$deployment_id : string

The current deployment_id (output parameter)

Return values
string —

Empty string if successful, otherwise contains error details


        
On this page

Search results