class Result extends Entity

This is a class to provide access to the user's result data.

This data comes from the LTI launch from the LMS.

Traits

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
protected $TABLE_NAME
protected $PRIMARY_KEY
$id The integer primary key for this link in the 'lti_result' table.
$grade The current grade for the user
$lastSendTransport The transport used to send the most recent grade.

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
static 
lookupResultBypass($user_id)

No description

static mixed
gradeGet($row = false, $debug_log = false)

Load the grade for a particular row and update our local copy

static mixed
gradeSendStatic($grade, $row = false, $debug_log = false, $extra = false)

Send a grade and update our local copy

mixed
gradeSend($grade, $row = false, $debug_log = false, $extra = false)

Send a grade and update our local copy

gradeSendDueDate($gradetosend, $oldgrade = false, $dueDate = false)

Send a grade applying the due date logic and only increasing grades

The
getJsonForUser($user_id)

Get a JSON for a different user

The
getJsonKeyForUser($key, $default = false, $user_id = false)

Get a JSON key for a result for a different user

The
setJsonForUser($json_str, $user_id = false)

Set JSON for a different user

The
setJsonKeyForUser($key, $value, $user_id = false)

Set a JSON key for a result for a different user

The
getNote($user_id = false)

Get a Note

The
setNote($note_str, $user_id = false)

Set the Note for this result

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

at line 47
static lookupResultBypass($user_id)

Parameters

$user_id

at line 90
static mixed gradeGet($row = false, $debug_log = false)

Load the grade for a particular row and update our local copy

Call the right LTI service to retrieve the server's grade and update our local cached copy of the server_grade and the date retrieved. This routine pulls the key and secret from the LTIX session to avoid crossing cross tenant boundaries.

TODO: Add LTI 2.x support for the JSON style services to this

Parameters

$row An optional array with the data that has the result_id, sourcedid, and service (url) if this is not present, the data is pulled from the LTI session for the current user/link combination.
$debug_log An (optional) array (by reference) that returns the steps that were taken. Each entry is an array with the [0] element a message and an optional [1] element as some detail (i.e. like a POST body)

Return Value

mixed If this work this returns a float. If not you get a string with an error.

at line 153
static mixed gradeSendStatic($grade, $row = false, $debug_log = false, $extra = false)

Send a grade and update our local copy

Call the right LTI service to send a new grade up to the server. update our local cached copy of the server_grade and the date retrieved. This routine pulls the key and secret from the LTIX session to avoid crossing cross tenant boundaries.

Parameters

$grade A new grade - floating point number between 0.0 and 1.0
$row An optional array with the data that has the result_id, sourcedid, service (url), key_key, and secret. If these are not present, the data is pulled from the LTI session for the current user/link combination.
$debug_log An (optional) array (by reference) that returns the steps that were taken. Each entry is an array with the [0] element a message and an optional [1] element as some detail (i.e. like a POST body)
$extra A key/value store of extra parameters

Return Value

mixed If this works it returns true. If not, you get a string with an error.

at line 373
mixed gradeSend($grade, $row = false, $debug_log = false, $extra = false)

Send a grade and update our local copy

Call the right LTI service to send a new grade up to the server. update our local cached copy of the server_grade and the date retrieved. This routine pulls the key and secret from the LTIX session to avoid crossing cross tenant boundaries.

Parameters

$grade A new grade - floating point number between 0.0 and 1.0
$row An optional array with the data that has the result_id, sourcedid, service (url), key_key, and secret. If these are not present, the data is pulled from the LTI session for the current user/link combination.
$debug_log An (optional) array (by reference) that returns the steps that were taken. Each entry is an array with the [0] element a message and an optional [1] element as some detail (i.e. like a POST body)
$extra A key/value store of extra parameters

Return Value

mixed If this works it returns true. If not, you get a string with an error.

at line 413
gradeSendDueDate($gradetosend, $oldgrade = false, $dueDate = false)

Send a grade applying the due date logic and only increasing grades

Puts messages in the session for a redirect.

Parameters

$gradetosend
  • The grade in the range 0.0 .. 1.0
$oldgrade
  • The previous grade in the range 0.0 .. 1.0 (optional)
$dueDate
  • The due date for this assignment

at line 453
The getJsonForUser($user_id)

Get a JSON for a different user

Parameters

$user_id The primary key of the user (instructor only)

Return Value

The JSON string (unparsed)

at line 488
The getJsonKeyForUser($key, $default = false, $user_id = false)

Get a JSON key for a result for a different user

Parameters

$key The key to be retrieved from the JSON
$default The default value (optional)
$user_id The primary key of the user (instructor only)

Return Value

The value of the JSON key (parsed)

at line 514
The setJsonForUser($json_str, $user_id = false)

Set JSON for a different user

Parameters

$json_str The JSON String
$user_id The primary key of the user (instructor only)

Return Value

The annotation array

at line 544
The setJsonKeyForUser($key, $value, $user_id = false)

Set a JSON key for a result for a different user

Parameters

$key The key to be set in the JSON
$value The value to store in the JSON
$user_id The primary key of the user (instructor only)

Return Value

The annotation array

at line 562
The getNote($user_id = false)

Get a Note

Parameters

$user_id The primary key of the user (instructor only)

Return Value

The annotation array

at line 603
The setNote($note_str, $user_id = false)

Set the Note for this result

Parameters

$note_str The Note String
$user_id The primary key of the user (instructor only)

Return Value

The annotation array