class LTI

This is a general purpose LTI class with no Tsugi-specific dependencies.

This class handles the protocol and OAuth validation and does not deal with how to use LTI data during the runtime of the tool.

Methods

static 
isRequestCheck($request_data = false)

Determines if this is a valid Basic LTI message

static 
isRequest($request_data = false)

Determines if this is a valid Basic LTI message

static 
isValidMessageType($lti_message_type)

No description

static 
isValidVersion($lti_version)

No description

static mixed
verifyKeyAndSecret($key, $secret, $http_url = NULL, $parameters = null, $http_method = NULL)

Verify the message signature for this request

static 
signParameters($oldparms, $endpoint, $method, $oauth_consumer_key, $oauth_consumer_secret, $submit_text = false, $org_id = false, $org_desc = false)

No description

static 
postLaunchHTML($newparms, $endpoint, $debug = false, $iframeattr = false, $endform = false)

No description

static 
get_string($key, $bundle)

No description

static 
bodyRequest($url, $method, $data, $optional_headers = null)

No description

static 
mapCustomName($name)

Lower case and turn non letters / numbers into underscores per LTI 1.1

static 
addCustom($parms, $custom)

No description

static 
getLastOAuthBodyBaseString()

No description

static 
getLastOAuthBodyHashInfo()

No description

static 
getAuthorizationHeader()

No description

static 
getContentTypeHeader()

No description

static 
getOAuthKeyFromHeaders()

No description

static 
handleOAuthBodyPOST($oauth_consumer_key, $oauth_consumer_secret, $postdata = false)

No description

static 
sendOAuthGET($endpoint, $oauth_consumer_key, $oauth_consumer_secret, $accept_type, $signature = false)

No description

static 
sendOAuthBody($method, $endpoint, $oauth_consumer_key, $oauth_consumer_secret, $content_type, $body, $more_headers = false, $signature = false)

No description

static mixed
getPOXGrade($sourcedid, $service, $key_key, $secret, $debug_log = false, $signature = false)

Retrieve a grade using the LTI 1.1 protocol (POX)

static mixed
sendPOXGrade($grade, $sourcedid, $service, $key_key, $secret, $debug_log = false, $signature = false)

Send a grade using the LTI 1.1 protocol (POX)

static 
getPOXGradeRequest()

No description

static 
getPOXRequest()

No description

static 
getPOXResponse()

No description

static 
getContextMemberships($membershipsid, $membershipsurl, $key_key, $secret, $groups = false, $signature = false, $debug_log = false)

No description

static 
parseContextMembershipsResponse($response)

No description

static 
replaceResultRequest($grade, $sourcedid, $endpoint, $oauth_consumer_key, $oauth_consumer_secret, $signature = false)

No description

static 
parseResponse($response)

No description

static mixed
sendJSONGrade($grade, $comment, $result_url, $key_key, $secret, $debug_log = false, $signature = false)

Send a grade using the JSON protocol from IMS LTI 2.x

static 
getResultJSON($grade, $comment)

Return an array suitable for sending to the LTI 2.x result_url

static mixed
sendJSONSettings($settings, $settings_url, $key_key, $secret, $debug_log = false, $signature = false)

Send setings data using the JSON protocol from IMS LTI 2.x

static mixed
sendJSONBody($method, $postBody, $content_type, $rest_url, $key_key, $secret, $debug_log = false, $signature = false)

Send a JSON body LTI 2.x Style

static string
ltiLinkUrl($postdata = false)

ltiLinkUrl - Returns true if we can return LTI Links for this launch

static 
getLtiLinkJSON($url, $title = false, $text = false, $icon = false, $fa_icon = false, $custom = false)

getLtiLinkJson - Get a JSON object for an LTI Link Content Item Return

static 
compareBaseStrings($string1, $string2)

No description

static 
jsonIndent($json)

No description

Details

at line 33
static isRequestCheck($request_data = false)

Determines if this is a valid Basic LTI message

Parameters

$request_data

at line 50
static isRequest($request_data = false)

Determines if this is a valid Basic LTI message

Returns true if this is a Basic LTI message with minimum values to meet the protocol

Parameters

$request_data

at line 61
static isValidMessageType($lti_message_type)

Parameters

$lti_message_type

at line 68
static isValidVersion($lti_version)

Parameters

$lti_version

at line 79
static mixed verifyKeyAndSecret($key, $secret, $http_url = NULL, $parameters = null, $http_method = NULL)

Verify the message signature for this request

Parameters

$key
$secret
$http_url
$parameters
$http_method

Return Value

mixed This returns true if the request verified. If the request did not verify, this returns an array with the first element as an error string, and the second element as the base string of the request.

at line 104
static signParameters($oldparms, $endpoint, $method, $oauth_consumer_key, $oauth_consumer_secret, $submit_text = false, $org_id = false, $org_desc = false)

Parameters

$oldparms
$endpoint
$method
$oauth_consumer_key
$oauth_consumer_secret
$submit_text
$org_id
$org_desc

at line 148
static postLaunchHTML($newparms, $endpoint, $debug = false, $iframeattr = false, $endform = false)

Parameters

$newparms
$endpoint
$debug
$iframeattr
$endform

at line 256
static get_string($key, $bundle)

Parameters

$key
$bundle

at line 260
static bodyRequest($url, $method, $data, $optional_headers = null)

Parameters

$url
$method
$data
$optional_headers

at line 286
static mapCustomName($name)

Lower case and turn non letters / numbers into underscores per LTI 1.1

http://www.imsglobal.org/specs/ltiv1p1p1/implementation-guide

When there are custom name / value parameters in the launch, a POST parameter is included for each custom parameter. The parameter names are mapped to lower case and any character that is neither a number nor letter in a parameter name is replaced with an "underscore". So if a custom entry was as follows:

Review:Chapter=1.2.56

would be mapped to:

custom_review_chapter=1.2.56

Parameters

$name

at line 298
static addCustom($parms, $custom)

Parameters

$parms
$custom

at line 317
static getLastOAuthBodyBaseString()

at line 322
static getLastOAuthBodyHashInfo()

at line 327
static getAuthorizationHeader()

at line 335
static getContentTypeHeader()

at line 344
static getOAuthKeyFromHeaders()

at line 358
static handleOAuthBodyPOST($oauth_consumer_key, $oauth_consumer_secret, $postdata = false)

Parameters

$oauth_consumer_key
$oauth_consumer_secret
$postdata

at line 407
static sendOAuthGET($endpoint, $oauth_consumer_key, $oauth_consumer_secret, $accept_type, $signature = false)

Parameters

$endpoint
$oauth_consumer_key
$oauth_consumer_secret
$accept_type
$signature

at line 433
static sendOAuthBody($method, $endpoint, $oauth_consumer_key, $oauth_consumer_secret, $content_type, $body, $more_headers = false, $signature = false)

Parameters

$method
$endpoint
$oauth_consumer_key
$oauth_consumer_secret
$content_type
$body
$more_headers
$signature

at line 485
static mixed getPOXGrade($sourcedid, $service, $key_key, $secret, $debug_log = false, $signature = false)

Retrieve a grade using the LTI 1.1 protocol (POX)

This retrieves a grade using the Plain-Old-XML protocol from IMS LTI 1.1

Parameters

$sourcedid
$service
$key_key
$secret
$debug_log
$signature

Return Value

mixed If things go well this returns a float of the existing grade. If this goes badly, this returns a string with an error message.

at line 572
static mixed sendPOXGrade($grade, $sourcedid, $service, $key_key, $secret, $debug_log = false, $signature = false)

Send a grade using the LTI 1.1 protocol (POX)

This sends a grade using the Plain-Old-XML protocol from IMS LTI 1.1

Parameters

$grade
$sourcedid
$service
$key_key
$secret
$debug_log
$signature

Return Value

mixed If things go well this returns true. If this goes badly, this returns a string with an error message.

at line 629
static getPOXGradeRequest()

at line 661
static getPOXRequest()

at line 685
static getPOXResponse()

at line 706
static getContextMemberships($membershipsid, $membershipsurl, $key_key, $secret, $groups = false, $signature = false, $debug_log = false)

Parameters

$membershipsid
$membershipsurl
$key_key
$secret
$groups
$signature
$debug_log

at line 744
static parseContextMembershipsResponse($response)

Parameters

$response

at line 787
static replaceResultRequest($grade, $sourcedid, $endpoint, $oauth_consumer_key, $oauth_consumer_secret, $signature = false)

Parameters

$grade
$sourcedid
$endpoint
$oauth_consumer_key
$oauth_consumer_secret
$signature

at line 803
static parseResponse($response)

Parameters

$response

at line 845
static mixed sendJSONGrade($grade, $comment, $result_url, $key_key, $secret, $debug_log = false, $signature = false)

Send a grade using the JSON protocol from IMS LTI 2.x

Parameters

$grade
$comment
$result_url
$key_key
$secret
$debug_log
$signature

Return Value

mixed If things go well this returns true. If this goes badly, this returns a string with an error message.

at line 875
static getResultJSON($grade, $comment)

Return an array suitable for sending to the LTI 2.x result_url

Parameters

$grade
$comment

at line 900
static mixed sendJSONSettings($settings, $settings_url, $key_key, $secret, $debug_log = false, $signature = false)

Send setings data using the JSON protocol from IMS LTI 2.x

Parameters

$settings
$settings_url
$key_key
$secret
$debug_log
$signature

Return Value

mixed If things go well this returns true. If this goes badly, this returns a string with an error message.

at line 939
static mixed sendJSONBody($method, $postBody, $content_type, $rest_url, $key_key, $secret, $debug_log = false, $signature = false)

Send a JSON body LTI 2.x Style

Parameters

$method
$postBody
$content_type
$rest_url
$key_key
$secret
$debug_log
$signature

Return Value

mixed If things go well this returns true. If this goes badly, this returns a string with an error message.

at line 964
static string ltiLinkUrl($postdata = false)

ltiLinkUrl - Returns true if we can return LTI Links for this launch

IMS Public Draft: http://www.imsglobal.org/specs/lticiv1p0

Parameters

$postdata

Return Value

string The content_item_return_url or false

at line 987
static getLtiLinkJSON($url, $title = false, $text = false, $icon = false, $fa_icon = false, $custom = false)

getLtiLinkJson - Get a JSON object for an LTI Link Content Item Return

Parameters

$url
$title
$text
$icon
$fa_icon
$custom

at line 1027
static compareBaseStrings($string1, $string2)

Parameters

$string1
$string2

at line 1077
static jsonIndent($json)

Parameters

$json