class Context extends Entity

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"

Traits

This is a class holding convienence methods to access settings from core objects.
This is a trait convienence methods to access the session from the launch object
This is a class holding convienence methods to access the json column for the core objects.

Properties

$launch A reference to our containing launch from Entity
$settingsDebugArray from SettingsTrait
protected $TABLE_NAME
protected $PRIMARY_KEY
protected $ENTITY_NAME
$id The integer primary key for this context in the 'lti_context' table.
$title The context title
$key
$secret

Methods

session_get($key, $default = null)

Get a key from the session

session_put($key, $value)

Set a key in the session

session_forget($key)

Forget a key in the session

session_flush()

Flush the session

ltiRawPostArray()

Return the original $_POST array

ltiParameter($varname, $default = false)

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

ltiParameterUpdate($varname, $value)

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

ltiRawParameter($varname, $default = false)

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

ltiCustomGet($varname, $default = false)

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

string
getJson()

Load the json field for this entity

from JsonTrait
getJsonKeyLegacy($key, $default = false)

No description

from JsonTrait
getJsonKey($key, $default = false)

Get a JSON key for this entity

from JsonTrait
setJson($json)

Set the JSON entry for this entity

from JsonTrait
setJsonKey($key, $value)

Set/update a JSON key for this entity

from JsonTrait
setJsonKeys($values)

Set/update an array of JSON keys for this entity

from JsonTrait
settingsGetAll()

Retrieve an array of all of the settings

settingsGet($key, $default = false)

Retrieve a particular key from the settings.

settingsSet($key, $value)

Update a single key in settings

settingsUpdate($keyvals)

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

settingsSetAll($new_settings)

Replace all the settings (Dangerous)

settingsDebug()

Retrieve the debug array for the last operation.

mixed
loadNamesAndRoles($with_sourcedids = false, array $debug_log = false)

Load the roster if we can get it from the LMS

mixed
getLineItemsToken(string $missing, string $lti13_lineitems, array $debug_log = false)

Wrapper to get line items token so we can add caching

mixed
loadLineItems($search = false, $debug_log = false)

Load our lineitems from the LMS

mixed
loadLineItem($id, $debug_log = false)

Load the detiail for a lineitem from the LMS

mixed
createLineItem(object $newitem, $debug_log = false)

Create a lineitem in the LMS

mixed
deleteLineItem($id, $debug_log = false)

Delete a lineitem from the LMS

mixed
updateLineItem($id, object $newitem, $debug_log = false)

Update a lineitem in the LMS

mixed
getGradeToken(string $missing, string $subject, array $debug_log = false)

Wrapper to get grade token

mixed
sendLineItemResult($id, $user_key, $grade, $scoreMaximum, $comment, $debug_log = false, $extra13 = false)

Send a lineitem result to the LMS

mixed
loadResults($id, $debug_log = false)

Load the results for a line item

Details

in SessionTrait at line 17
session_get($key, $default = null)

Get a key from the session

Parameters

$key
$default

in SessionTrait at line 24
session_put($key, $value)

Set a key in the session

Parameters

$key
$value

in SessionTrait at line 31
session_forget($key)

Forget a key in the session

Parameters

$key

in SessionTrait at line 38
session_flush()

Flush the session

in SessionTrait at line 45
ltiRawPostArray()

Return the original $_POST array

in SessionTrait at line 53
ltiParameter($varname, $default = false)

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

Parameters

$varname
$default

in SessionTrait at line 61
ltiParameterUpdate($varname, $value)

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

Parameters

$varname
$value

in SessionTrait at line 70
ltiRawParameter($varname, $default = false)

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

Parameters

$varname
$default

in SessionTrait at line 79
ltiCustomGet($varname, $default = false)

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

Parameters

$varname
$default

in JsonTrait at line 21
string getJson()

Load the json field for this entity

Return Value

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

in JsonTrait at line 43
getJsonKeyLegacy($key, $default = false)

Parameters

$key
$default

in JsonTrait at line 61
getJsonKey($key, $default = false)

Get a JSON key for this entity

Parameters

$key The key to be retrieved from the JSON
$default The default value (optional)

in JsonTrait at line 78
setJson($json)

Set the JSON entry for this entity

Parameters

$json This is a string - no validation is done

in JsonTrait at line 96
setJsonKey($key, $value)

Set/update a JSON key for this entity

Parameters

$key The key to be inserted/updated in the JSON
$value The value to be inserted/updated in the JSON

in JsonTrait at line 114
setJsonKeys($values)

Set/update an array of JSON keys for this entity

Parameters

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

in SettingsTrait at line 23
settingsGetAll()

Retrieve an array of all of the settings

If there are no settings, return an empty array.

in SettingsTrait at line 70
settingsGet($key, $default = false)

Retrieve a particular key from the settings.

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

Parameters

$key
  • The key to get from the settings.
$default
  • What to return if the key is not present

in SettingsTrait at line 83
settingsSet($key, $value)

Update a single key in settings

Parameters

$key
$value

in SettingsTrait at line 96
settingsUpdate($keyvals)

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

Parameters

$keyvals

in SettingsTrait at line 119
protected settingsSetAll($new_settings)

Replace all the settings (Dangerous)

Parameters

$new_settings

in SettingsTrait at line 155
settingsDebug()

Retrieve the debug array for the last operation.

at line 100
mixed loadNamesAndRoles($with_sourcedids = false, array $debug_log = false)

Load the roster if we can get it from the LMS

Parameters

$with_sourcedids If true, ask for the sourcedids
array $debug_log If this is an array, debug information is returned as the process progresses.

Return Value

mixed If this works it returns the NRPS object. If it fails, it returns a string.

at line 145
mixed getLineItemsToken(string $missing, string $lti13_lineitems, array $debug_log = false)

Wrapper to get line items token so we can add caching

Parameters

string $missing This is a non-empty string with error detail if there was an error
string $lti13_lineitems The url for the LineItems Service if there was no error
array $debug_log If this is an array, debug information is returned as the process progresses.

Return Value

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)

at line 174
mixed loadLineItems($search = false, $debug_log = false)

Load our lineitems from the LMS

Parameters

$search mixed - search values to apply to the load
$debug_log Returns a log of actions taken

Return Value

mixed If this works it returns the LineItems array. If it fails, it returns a string.

at line 199
mixed loadLineItem($id, $debug_log = false)

Load the detiail for a lineitem from the LMS

Parameters

$id mixed - search values to apply to the load $lineitem_id = $lineitems[0]->id;
$debug_log Returns a log of actions taken

Return Value

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

at line 223
mixed createLineItem(object $newitem, $debug_log = false)

Create a lineitem in the LMS

Parameters

object $newitem The fields to update

$newitem = new \stdClass();
$newitem->scoreMaximum = 100;
$newitem->label = 'Week 3 Feedback';
$newitem->resourceId = '2987487943';
$newitem->tag = 'optional';
$debug_log Returns a log of actions taken

Return Value

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

at line 242
mixed deleteLineItem($id, $debug_log = false)

Delete a lineitem from the LMS

Parameters

$id mixed - search values to apply to the load $lineitem_id = $lineitems[0]->id;
$debug_log Returns a log of actions taken

Return Value

mixed If this works it returns true. If it fails, it returns a string.

at line 268
mixed updateLineItem($id, object $newitem, $debug_log = false)

Update a lineitem in the LMS

Parameters

$id mixed - search values to apply to the load $lineitem_id = $lineitems[0]->id;
object $newitem The fields to update

$newitem = new \stdClass();
$newitem->scoreMaximum = 100;
$newitem->label = 'Week 3 Feedback';
$newitem->resourceId = '2987487943';
$newitem->tag = 'optional';
$debug_log Returns a log of actions taken

Return Value

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

at line 290
mixed getGradeToken(string $missing, string $subject, array $debug_log = false)

Wrapper to get grade token

Parameters

string $missing This is a non-empty string with error detail if there was an error
string $subject The subject if there is no error
array $debug_log If this is an array, debug information is returned as the process progresses.

Return Value

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)

at line 321
mixed sendLineItemResult($id, $user_key, $grade, $scoreMaximum, $comment, $debug_log = false, $extra13 = false)

Send a lineitem result to the LMS

Parameters

$id The REST endpoint (id) for this line item
$user_key The user for this grade
$grade Value to send
$scoreMaximum What the score is relative to
$comment An optional comment
$debug_log Returns a log of actions taken
$extra13 A key/value store of extra LTI1.3 parameters

Return Value

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

at line 341
mixed loadResults($id, $debug_log = false)

Load the results for a line item

Parameters

$id The REST endpoint (id) for this line item
$debug_log Returns a log of actions taken

Return Value

mixed If this works it returns the Results array. If it fails, it returns a string.