Tsugi

LTI
in package

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.

Table of Contents

Methods

addCustom()  : mixed
bodyRequest()  : mixed
compareBaseStrings()  : mixed
get_string()  : mixed
getAuthorizationHeader()  : mixed
getContentTypeHeader()  : mixed
getContextMemberships()  : mixed
getLastOAuthBodyBaseString()  : mixed
getLastOAuthBodyHashInfo()  : mixed
getLtiLinkJSON()  : mixed
getLtiLinkJson - Get a JSON object for an LTI Link Content Item Return
getOAuthKeyFromHeaders()  : mixed
getPOXGrade()  : mixed
Retrieve a grade using the LTI 1.1 protocol (POX)
getPOXGradeRequest()  : mixed
getPOXRequest()  : mixed
getPOXResponse()  : mixed
getResultJSON()  : mixed
Return an array suitable for sending to the LTI 2.x result_url
handleOAuthBodyPOST()  : mixed
isRequest()  : mixed
Determines if this is a valid Basic LTI message
isRequestCheck()  : mixed
Determines if this is a valid Basic LTI message
isValidMessageType()  : mixed
isValidVersion()  : mixed
jsonIndent()  : mixed
ltiLinkUrl()  : string
ltiLinkUrl - Returns true if we can return LTI Links for this launch
mapCustomName()  : mixed
Lower case and turn non letters / numbers into underscores per LTI 1.1
parseContextMembershipsResponse()  : mixed
parseResponse()  : mixed
postLaunchHTML()  : mixed
replaceResultRequest()  : mixed
sendJSONBody()  : mixed
Send a JSON body LTI 2.x Style
sendJSONGrade()  : mixed
Send a grade using the JSON protocol from IMS LTI 2.x
sendJSONSettings()  : mixed
Send setings data using the JSON protocol from IMS LTI 2.x
sendOAuthBody()  : mixed
sendOAuthGET()  : mixed
sendPOXGrade()  : mixed
Send a grade using the LTI 1.1 protocol (POX)
signParameters()  : mixed
verifyKeyAndSecret()  : mixed
Verify the message signature for this request
normalizeOAuthParameterValuesForSigning()  : array<string|int, mixed>
Normalize string values before OAuth signing for HTML form POST launches.

Methods

addCustom()

public static addCustom(mixed &$parms, mixed $custom) : mixed
Parameters
$parms : mixed
$custom : mixed

bodyRequest()

public static bodyRequest(mixed $url, mixed $method, mixed $data[, mixed $optional_headers = null ]) : mixed
Parameters
$url : mixed
$method : mixed
$data : mixed
$optional_headers : mixed = null

compareBaseStrings()

public static compareBaseStrings(mixed $string1, mixed $string2) : mixed
Parameters
$string1 : mixed
$string2 : mixed

get_string()

public static get_string(mixed $key, mixed $bundle) : mixed
Parameters
$key : mixed
$bundle : mixed

getAuthorizationHeader()

public static getAuthorizationHeader() : mixed

getContentTypeHeader()

public static getContentTypeHeader() : mixed

getContextMemberships()

public static getContextMemberships(mixed $membershipsid, mixed $membershipsurl, mixed $key_key, mixed $secret[, mixed $groups = false ][, mixed $signature = false ][, mixed &$debug_log = false ]) : mixed
Parameters
$membershipsid : mixed
$membershipsurl : mixed
$key_key : mixed
$secret : mixed
$groups : mixed = false
$signature : mixed = false
$debug_log : mixed = false

getLastOAuthBodyBaseString()

public static getLastOAuthBodyBaseString() : mixed

getLastOAuthBodyHashInfo()

public static getLastOAuthBodyHashInfo() : mixed

getLtiLinkJSON()

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

public static getLtiLinkJSON(mixed $url[, mixed $title = false ][, mixed $text = false ][, mixed $icon = false ][, mixed $fa_icon = false ][, mixed $custom = false ]) : mixed
Parameters
$url : mixed
$title : mixed = false
$text : mixed = false
$icon : mixed = false
$fa_icon : mixed = false
$custom : mixed = false

getOAuthKeyFromHeaders()

public static getOAuthKeyFromHeaders() : mixed

getPOXGrade()

Retrieve a grade using the LTI 1.1 protocol (POX)

public static getPOXGrade(mixed $sourcedid, mixed $service, mixed $key_key, mixed $secret[, mixed &$debug_log = false ][, mixed $signature = false ]) : mixed

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

Parameters
$sourcedid : mixed
$service : mixed
$key_key : mixed
$secret : mixed
$debug_log : mixed = false
$signature : mixed = false
Return values
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.

getPOXGradeRequest()

public static getPOXGradeRequest() : mixed

getPOXRequest()

public static getPOXRequest() : mixed

getPOXResponse()

public static getPOXResponse() : mixed

getResultJSON()

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

public static getResultJSON(mixed $grade, mixed $comment) : mixed
Parameters
$grade : mixed
$comment : mixed

handleOAuthBodyPOST()

public static handleOAuthBodyPOST(mixed $oauth_consumer_key, mixed $oauth_consumer_secret[, mixed $postdata = false ]) : mixed
Parameters
$oauth_consumer_key : mixed
$oauth_consumer_secret : mixed
$postdata : mixed = false

isRequest()

Determines if this is a valid Basic LTI message

public static isRequest([mixed $request_data = false ]) : mixed

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

Parameters
$request_data : mixed = false

isRequestCheck()

Determines if this is a valid Basic LTI message

public static isRequestCheck([mixed $request_data = false ]) : mixed
Parameters
$request_data : mixed = false
Tags
retval

mixed Returns true if this is a Basic LTI message with minimum values to meet the protocol. Returns false if this is not even close to an LTI launch. If this is a broken launch, it returns an error as to why.

isValidMessageType()

public static isValidMessageType(mixed $lti_message_type) : mixed
Parameters
$lti_message_type : mixed

isValidVersion()

public static isValidVersion(mixed $lti_version) : mixed
Parameters
$lti_version : mixed

jsonIndent()

public static jsonIndent(mixed $json) : mixed
Parameters
$json : mixed

ltiLinkUrl()

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

public static ltiLinkUrl([mixed $postdata = false ]) : string

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

Parameters
$postdata : mixed = false
Return values
string —

The content_item_return_url or false

mapCustomName()

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

public static mapCustomName(mixed $name) : mixed

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 : mixed

parseContextMembershipsResponse()

public static parseContextMembershipsResponse(mixed $response) : mixed
Parameters
$response : mixed

parseResponse()

public static parseResponse(mixed $response) : mixed
Parameters
$response : mixed

postLaunchHTML()

public static postLaunchHTML(mixed $newparms, mixed $endpoint[, mixed $debug = false ][, mixed $iframeattr = false ][, mixed $endform = false ][, mixed $iframetitle = null ][, mixed $protocol = '1.1' ][, mixed $jwt = null ]) : mixed
Parameters
$newparms : mixed
$endpoint : mixed
$debug : mixed = false
$iframeattr : mixed = false
$endform : mixed = false
$iframetitle : mixed = null
$protocol : mixed = '1.1'
$jwt : mixed = null

replaceResultRequest()

public static replaceResultRequest(mixed $grade, mixed $sourcedid, mixed $endpoint, mixed $oauth_consumer_key, mixed $oauth_consumer_secret[, mixed $signature = false ]) : mixed
Parameters
$grade : mixed
$sourcedid : mixed
$endpoint : mixed
$oauth_consumer_key : mixed
$oauth_consumer_secret : mixed
$signature : mixed = false

sendJSONBody()

Send a JSON body LTI 2.x Style

public static sendJSONBody(mixed $method, mixed $postBody, mixed $content_type, mixed $rest_url, mixed $key_key, mixed $secret[, mixed &$debug_log = false ][, mixed $signature = false ]) : mixed
Parameters
$method : mixed
$postBody : mixed
$content_type : mixed
$rest_url : mixed
$key_key : mixed
$secret : mixed
$debug_log : mixed = false
$signature : mixed = false
Return values
mixed —

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

sendJSONGrade()

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

public static sendJSONGrade(mixed $grade, mixed $comment, mixed $result_url, mixed $key_key, mixed $secret[, mixed &$debug_log = false ][, mixed $signature = false ]) : mixed
Parameters
$grade : mixed
$comment : mixed
$result_url : mixed
$key_key : mixed
$secret : mixed
$debug_log : mixed = false
$signature : mixed = false
Return values
mixed —

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

sendJSONSettings()

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

public static sendJSONSettings(mixed $settings, mixed $settings_url, mixed $key_key, mixed $secret[, mixed &$debug_log = false ][, mixed $signature = false ]) : mixed
Parameters
$settings : mixed
$settings_url : mixed
$key_key : mixed
$secret : mixed
$debug_log : mixed = false
$signature : mixed = false
Return values
mixed —

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

sendOAuthBody()

public static sendOAuthBody(mixed $method, mixed $endpoint, mixed $oauth_consumer_key, mixed $oauth_consumer_secret, mixed $content_type, mixed $body[, mixed $more_headers = false ][, mixed $signature = false ]) : mixed
Parameters
$method : mixed
$endpoint : mixed
$oauth_consumer_key : mixed
$oauth_consumer_secret : mixed
$content_type : mixed
$body : mixed
$more_headers : mixed = false
$signature : mixed = false

sendOAuthGET()

public static sendOAuthGET(mixed $endpoint, mixed $oauth_consumer_key, mixed $oauth_consumer_secret, mixed $accept_type[, mixed $signature = false ]) : mixed
Parameters
$endpoint : mixed
$oauth_consumer_key : mixed
$oauth_consumer_secret : mixed
$accept_type : mixed
$signature : mixed = false

sendPOXGrade()

Send a grade using the LTI 1.1 protocol (POX)

public static sendPOXGrade(mixed $grade, mixed $sourcedid, mixed $service, mixed $key_key, mixed $secret[, mixed &$debug_log = false ][, mixed $signature = false ]) : mixed

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

Parameters
$grade : mixed
$sourcedid : mixed
$service : mixed
$key_key : mixed
$secret : mixed
$debug_log : mixed = false
$signature : mixed = false
Return values
mixed —

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

signParameters()

public static signParameters(mixed $oldparms, mixed $endpoint, mixed $method, mixed $oauth_consumer_key, mixed $oauth_consumer_secret[, mixed $submit_text = false ][, mixed $org_id = false ][, mixed $org_desc = false ]) : mixed
Parameters
$oldparms : mixed
$endpoint : mixed
$method : mixed
$oauth_consumer_key : mixed
$oauth_consumer_secret : mixed
$submit_text : mixed = false
$org_id : mixed = false
$org_desc : mixed = false

verifyKeyAndSecret()

Verify the message signature for this request

public static verifyKeyAndSecret(mixed $key, mixed $secret[, mixed $http_url = null ][, mixed $parameters = null ][, mixed $http_method = null ]) : mixed
Parameters
$key : mixed
$secret : mixed
$http_url : mixed = null
$parameters : mixed = null
$http_method : mixed = null
Return values
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.

normalizeOAuthParameterValuesForSigning()

Normalize string values before OAuth signing for HTML form POST launches.

private static normalizeOAuthParameterValuesForSigning(array<string|int, mixed> $parms) : array<string|int, mixed>

Newlines and mixed line endings (CR/LF/CRLF) in parameter values often do not survive HTML hidden-field encoding and browser application/x-www-form-urlencoded submission the same way PHP represented them when signing, which breaks signature verification. Collapse whitespace so the signed string matches what POST delivers.

Parameters
$parms : array<string|int, mixed>
Return values
array<string|int, mixed>

        
On this page

Search results