Class to represent an LTI Tool. More...
Public Member Functions | |
__construct ($dataConnector=null) | |
Class constructor. | |
initialize () | |
Initialise the tool. | |
save () | |
Save the tool to the database. | |
delete () | |
Delete the tool from the database. | |
getMessageParameters ($strictMode=false, $disableCookieCheck=false, $generateWarnings=false) | |
Get the message parameters. | |
handleRequest ($strictMode=false, $disableCookieCheck=false, $generateWarnings=false) | |
Process an incoming request. | |
setParameterConstraint ($name, $required=true, $maxLength=null, $messageTypes=null) | |
Add a parameter constraint to be checked on launch. | |
getConsumers () | |
Get an array of defined tool consumers. | |
getPlatforms () | |
Get an array of defined platforms. | |
findService ($format, $methods) | |
Find an offered service based on a media type and HTTP action(s) | |
doToolProxyService () | |
Send the tool proxy to the platform. | |
![]() | |
getRecordId () | |
Get the system record ID. | |
setRecordId ($id) | |
Sets the system record ID. | |
getKey () | |
Get the consumer key. | |
setKey ($key) | |
Set the consumer key. | |
getSetting ($name, $default='') | |
Get a setting value. | |
setSetting ($name, $value=null) | |
Set a setting value. | |
getSettings () | |
Get an array of all setting values. | |
setSettings ($settings) | |
Set an array of all setting values. | |
saveSettings () | |
Save setting values. | |
hasJwt () | |
Check whether a JWT exists. | |
getJwt () | |
Get the JWT. | |
getRawParameters () | |
Get the raw POST parameters. | |
getMessageClaims ($fullyQualified=false) | |
Get the message claims. | |
signParameters ($url, $type, $version, $params) | |
Add the signature to an LTI message. | |
signMessage (&$url, $type, $version, $params, $loginHint=null, $ltiMessageHint=null) | |
Add the signature to an LTI message. | |
sendMessage ($url, $type, $messageParams, $target='', $userId=null, $hint=null) | |
Generate a web page containing an auto-submitted form of LTI message parameters. | |
signServiceRequest ($url, $method, $type, $data=null) | |
Generates the headers for an LTI service request. | |
doServiceRequest ($service, $method, $format, $data) | |
Perform a service request. | |
useOAuth1 () | |
Determine whether this consumer is using the OAuth 1 security model. | |
addSignature ($endpoint, $data, $method='POST', $type=null, $nonce='', $hash=null, $timestamp=null) | |
Add the signature to an array of message parameters or to a header string. | |
checkMessage () | |
Verify the required properties of an LTI message. | |
verifySignature () | |
Verify the signature of a message. | |
Static Public Member Functions | |
static | sendForm ($url, $params, $target='') |
Generate a web page containing an auto-submitted form of parameters. | |
static | fromConsumerKey ($key=null, $dataConnector=null, $autoEnable=false) |
Load the tool from the database by its consumer key. | |
static | fromInitiateLoginUrl ($initiateLoginUrl, $dataConnector=null, $autoEnable=false) |
Load the tool from the database by its initiate login URL. | |
static | fromRecordId ($id, $dataConnector) |
Load the tool from the database by its record ID. | |
![]() | |
static | parseRoles ($roles, $ltiVersion=Util::LTI_VERSION1, $addPrincipalRole=false) |
Parse a set of roles to comply with a specified version of LTI. | |
![]() | |
static | registerApiHook ($hookName, $familyCode, $className) |
Register the availability of an API hook. | |
Data Fields | |
const | CONNECTION_ERROR_MESSAGE = 'Sorry, there was an error connecting you to the application.' |
Default connection error message. | |
const | ID_SCOPE_ID_ONLY = 0 |
Use ID value only. | |
const | ID_SCOPE_GLOBAL = 1 |
Prefix an ID with the consumer key. | |
const | ID_SCOPE_CONTEXT = 2 |
Prefix the ID with the consumer key and context ID. | |
const | ID_SCOPE_RESOURCE = 3 |
Prefix the ID with the consumer key and resource ID. | |
const | ID_SCOPE_SEPARATOR = ':' |
Character used to separate each element of an ID. | |
$consumer = null | |
Tool consumer object. | |
$platform = null | |
Platform object. | |
$returnUrl = null | |
Return URL provided by platform. | |
$userResult = null | |
UserResult object. | |
$resourceLink = null | |
Resource link object. | |
$context = null | |
Context object. | |
$defaultEmail = '' | |
Default email domain. | |
$idScope = self::ID_SCOPE_ID_ONLY | |
Scope to use for user IDs. | |
$allowSharing = false | |
Whether shared resource link arrangements are permitted. | |
$message = null | |
Message for last request processed. | |
$baseUrl = null | |
Base URL for tool service. | |
$vendor = null | |
Vendor details. | |
$product = null | |
Product details. | |
$requiredServices = null | |
Services required by Tool. | |
$optionalServices = null | |
Optional services used by Tool. | |
$resourceHandlers = null | |
Resource handlers for Tool. | |
$messageUrl = null | |
Message URL for Tool. | |
$initiateLoginUrl = null | |
Initiate Login request URL for Tool. | |
$redirectionUris = null | |
Redirection URIs for Tool. | |
![]() | |
$ok = true | |
True if the last request was successful. | |
$ltiVersion = null | |
LTI version. | |
$name = null | |
Local name of platform/tool. | |
$secret = null | |
Shared secret. | |
$signatureMethod = 'HMAC-SHA1' | |
Method used for signing messages. | |
$encryptionMethod = '' | |
Algorithm used for encrypting messages. | |
$dataConnector = null | |
Data connector object. | |
$rsaKey = null | |
RSA key in PEM or JSON format. | |
$requiredScopes = array() | |
Scopes to request when obtaining an access token. | |
$kid = null | |
Key ID. | |
$jku = null | |
Endpoint for public key. | |
$reason = null | |
Error message for last request processed. | |
$details = array() | |
Details for error message relating to last request processed. | |
$warnings = array() | |
Warnings relating to last request processed. | |
$debugMode = false | |
Whether debug level messages are to be reported. | |
$enabled = false | |
Whether the system instance is enabled to accept connection requests. | |
$enableFrom = null | |
Timestamp from which the the system instance is enabled to accept connection requests. | |
$enableUntil = null | |
Timestamp until which the system instance is enabled to accept connection requests. | |
$lastAccess = null | |
Timestamp for date of last connection to this system. | |
$created = null | |
Timestamp for when the object was created. | |
$updated = null | |
Timestamp for when the object was last updated. | |
Static Public Attributes | |
static | $MESSAGE_TYPES |
List of supported incoming message types. | |
static | $defaultTool = null |
Default tool for use with service requests. | |
static | $authenticateUsingGet = false |
Use GET method for authentication request messages when true. | |
static | $stateLife = 10 |
Life in seconds for the state value issued during the OIDC login process. | |
static | $postMessageTimeoutDelay = 20 |
Period in milliseconds to wait for a response to a postMessage. | |
![]() | |
static | $USER_ID_HOOK = "UserId" |
User Id hook name. | |
static | $CONTEXT_ID_HOOK = "ContextId" |
Context Id hook name. | |
static | $GROUPS_SERVICE_HOOK = "Groups" |
Course Groups service hook name. | |
static | $MEMBERSHIPS_SERVICE_HOOK = "Memberships" |
Memberships service hook name. | |
static | $OUTCOMES_SERVICE_HOOK = "Outcomes" |
Outcomes service hook name. | |
static | $TOOL_SETTINGS_SERVICE_HOOK = "ToolSettings" |
Tool Settings service hook name. | |
static | $ACCESS_TOKEN_SERVICE_HOOK = "AccessToken" |
Access Token service hook name. | |
Protected Member Functions | |
onLaunch () | |
Process a valid launch request. | |
onConfigure () | |
Process a valid configure request. | |
onDashboard () | |
Process a valid dashboard request. | |
onContentItem () | |
Process a valid content-item request. | |
onContentItemUpdate () | |
Process a valid content-item update request. | |
onSubmissionReview () | |
Process a valid submission review request. | |
onRegister () | |
Process a valid tool proxy registration request. | |
onRegistration () | |
Process a dynamic registration request. | |
onLtiStartProctoring () | |
Process a valid start proctoring request. | |
onLtiEndAssessment () | |
Process a valid end assessment request. | |
onInitiateLogin ($requestParameters, &$authParameters) | |
Process a login initiation request. | |
onAuthenticate ($state, $nonce, $usePlatformStorage) | |
Process response to an authentication request. | |
onResetSessionId () | |
Process a change in the session ID. | |
onError () | |
Process a response to an invalid request. | |
getPlatformConfiguration () | |
Fetch a platform's configuration data. | |
getConfiguration ($platformConfig) | |
Prepare the tool's configuration data. | |
sendRegistration ($platformConfig, $toolConfig) | |
Send the tool registration to the platform. | |
getPlatformToRegister ($platformConfig, $registrationConfig, $doSave=true) | |
Initialise the platform to be registered. | |
getRegistrationResponsePage ($toolConfig) | |
Prepare the page to complete a registration request. | |
Protected Attributes | |
$redirectUrl = null | |
URL to redirect user to on successful completion of the request. | |
$mediaTypes = null | |
Media types accepted by the platform. | |
$contentTypes = null | |
Content item types accepted by the platform. | |
$fileTypes = null | |
File types accepted by the platform. | |
$documentTargets = null | |
Document targets accepted by the platform. | |
$output = null | |
Default HTML to be displayed on a successful completion of the request. | |
$errorOutput = null | |
HTML to be displayed on an unsuccessful completion of the request and no return URL is available. | |
![]() | |
$jwt = null | |
JWT ClientInterface object. | |
$rawParameters = null | |
Raw message parameters. | |
$messageParameters = null | |
LTI message parameters. | |
Class to represent an LTI Tool.
__construct | ( | $dataConnector = null | ) |
Class constructor.
DataConnector | $dataConnector | Object containing a database connection object |
Reimplemented in ToolProvider.
Definition at line 378 of file Tool.php.
References System\$dataConnector, Tool\$platform, Context\getDataConnector(), and Tool\initialize().
delete | ( | ) |
doToolProxyService | ( | ) |
Send the tool proxy to the platform.
Definition at line 610 of file Tool.php.
References System\$ok, System\$secret, Tool\findService(), and Util\getRandomString().
findService | ( | $format, | |
$methods | |||
) |
Find an offered service based on a media type and HTTP action(s)
string | $format | Media type required |
array | $methods | Array of HTTP actions required |
Definition at line 577 of file Tool.php.
Referenced by Tool\doToolProxyService().
|
static |
Load the tool from the database by its consumer key.
string | null | $key | Consumer key |
DataConnector | $dataConnector | A data connector object |
bool | $autoEnable | True if the tool is to be enabled automatically (optional, default is false) |
Definition at line 1187 of file Tool.php.
References System\$dataConnector, and System\$ok.
|
static |
Load the tool from the database by its initiate login URL.
string | $initiateLoginUrl | The initiate login URL |
DataConnector | $dataConnector | A data connector object |
bool | $autoEnable | True if the tool is to be enabled automatically (optional, default is false) |
Definition at line 1210 of file Tool.php.
References System\$dataConnector, and Tool\$initiateLoginUrl.
|
static |
Load the tool from the database by its record ID.
int | $id | The tool record ID |
DataConnector | $dataConnector | A data connector object |
Definition at line 1231 of file Tool.php.
References System\$dataConnector.
|
protected |
Prepare the tool's configuration data.
array | $platformConfig | Platform configuration data |
Definition at line 895 of file Tool.php.
References System\$jku, Tool\$message, System\$name, and Util\MESSAGE_TYPE_MAPPING.
Referenced by Tool\onRegistration().
getConsumers | ( | ) |
Get an array of defined tool consumers.
Definition at line 552 of file Tool.php.
References Tool\getPlatforms(), and Util\logDebug().
getMessageParameters | ( | $strictMode = false , |
|
$disableCookieCheck = false , |
|||
$generateWarnings = false |
|||
) |
Get the message parameters.
bool | $strictMode | True if full compliance with the LTI specification is required (optional, default is false) |
bool | $disableCookieCheck | True if no cookie check should be made (optional, default is false) |
bool | $generateWarnings | True if warning messages should be generated (optional, default is false) |
Definition at line 448 of file Tool.php.
References Util\$logLevel, System\$messageParameters, and Util\LOGLEVEL_DEBUG.
Referenced by Tool\handleRequest().
|
protected |
Fetch a platform's configuration data.
Definition at line 839 of file Tool.php.
References Util\getRequestParameters(), and Util\jsonDecode().
Referenced by Tool\onRegistration().
getPlatforms | ( | ) |
Get an array of defined platforms.
Definition at line 564 of file Tool.php.
Referenced by Tool\getConsumers().
|
protected |
Initialise the platform to be registered.
array | $platformConfig | Platform configuration data |
array | $registrationConfig | Registration data |
bool | $doSave | True if the platform should be saved (optional, default is true) |
Definition at line 1041 of file Tool.php.
References Tool\$platform, and Util\LTI_VERSION1P3.
Referenced by Tool\onRegistration().
|
protected |
Prepare the page to complete a registration request.
array | $toolConfig | Tool configuration data |
Definition at line 1077 of file Tool.php.
References System\$enabled.
Referenced by Tool\onRegistration().
handleRequest | ( | $strictMode = false , |
|
$disableCookieCheck = false , |
|||
$generateWarnings = false |
|||
) |
Process an incoming request.
bool | $strictMode | True if full compliance with the LTI specification is required (optional, default is false) |
bool | $disableCookieCheck | True if no cookie check should be made (optional, default is false) |
bool | $generateWarnings | True if warning messages should be generated (optional, default is false) |
Definition at line 481 of file Tool.php.
References Util\$logLevel, Tool\getMessageParameters(), Util\getRequestParameters(), Util\logError(), Util\LOGLEVEL_DEBUG, Util\logRequest(), and Tool\onRegistration().
initialize | ( | ) |
|
protected |
Process response to an authentication request.
string | $state | State value |
string | $nonce | Nonce value |
bool | $usePlatformStorage | True if platform storage is being used |
Definition at line 778 of file Tool.php.
References Util\sendForm().
|
protected |
Process a valid configure request.
Definition at line 664 of file Tool.php.
References Tool\onError().
|
protected |
Process a valid content-item request.
Definition at line 682 of file Tool.php.
References Tool\onError().
|
protected |
Process a valid content-item update request.
Definition at line 691 of file Tool.php.
References Tool\onError().
|
protected |
Process a valid dashboard request.
Definition at line 673 of file Tool.php.
References Tool\onError().
|
protected |
Process a response to an invalid request.
Definition at line 829 of file Tool.php.
Referenced by Tool\onConfigure(), Tool\onContentItem(), Tool\onContentItemUpdate(), Tool\onDashboard(), Tool\onLaunch(), Tool\onLtiEndAssessment(), Tool\onLtiStartProctoring(), Tool\onRegister(), and Tool\onSubmissionReview().
|
protected |
|
protected |
|
protected |
Process a valid end assessment request.
Definition at line 744 of file Tool.php.
References Tool\onError().
|
protected |
Process a valid start proctoring request.
Definition at line 735 of file Tool.php.
References Tool\onError().
|
protected |
Process a valid tool proxy registration request.
Definition at line 709 of file Tool.php.
References Tool\onError().
|
protected |
Process a dynamic registration request.
Definition at line 718 of file Tool.php.
References Tool\getConfiguration(), Tool\getPlatformConfiguration(), Tool\getPlatformToRegister(), Tool\getRegistrationResponsePage(), and Tool\sendRegistration().
Referenced by Tool\handleRequest().
|
protected |
|
protected |
Process a valid submission review request.
Definition at line 700 of file Tool.php.
References Tool\onError().
save | ( | ) |
|
static |
Generate a web page containing an auto-submitted form of parameters.
string | $url | URL to which the form should be submitted |
array | $params | Array of form parameters |
string | $target | Name of target (optional) |
Definition at line 641 of file Tool.php.
References Util\logDebug(), and Util\sendForm().
|
protected |
Send the tool registration to the platform.
array | $platformConfig | Platform configuration data |
array | $toolConfig | Tool configuration data |
Definition at line 1006 of file Tool.php.
References Util\getRequestParameters(), and Util\jsonDecode().
Referenced by Tool\onRegistration().
setParameterConstraint | ( | $name, | |
$required = true , |
|||
$maxLength = null , |
|||
$messageTypes = null |
|||
) |
Add a parameter constraint to be checked on launch.
string | $name | Name of parameter to be checked |
bool | $required | True if parameter is required (optional, default is true) |
int | null | $maxLength | Maximum permitted length of parameter value (optional, default is null) |
array | null | $messageTypes | Array of message types to which the constraint applies (optional, default is all) |
Definition at line 536 of file Tool.php.
References System\$name.
bool $allowSharing = false |
|
static |
ToolConsumer null $consumer = null |
|
protected |
|
static |
Default tool for use with service requests.
Definition at line 294 of file Tool.php.
Referenced by AccessToken\get(), OAuthDataStore\lookup_consumer(), System\signMessage(), and System\verifySignature().
|
protected |
|
protected |
|
protected |
int $idScope = self::ID_SCOPE_ID_ONLY |
string null $initiateLoginUrl = null |
Initiate Login request URL for Tool.
Definition at line 280 of file Tool.php.
Referenced by Tool\fromInitiateLoginUrl().
|
protected |
string null $message = null |
Message for last request processed.
Definition at line 224 of file Tool.php.
Referenced by Tool\getConfiguration().
|
static |
List of supported incoming message types.
array null $optionalServices = null |
|
protected |
Platform null $platform = null |
Platform object.
Definition at line 168 of file Tool.php.
Referenced by Tool\__construct(), and Tool\getPlatformToRegister().
|
static |
array null $redirectionUris = null |
|
protected |
array null $requiredServices = null |
array null $resourceHandlers = null |
ResourceLink null $resourceLink = null |
string null $returnUrl = null |
|
static |
UserResult null $userResult = null |
const CONNECTION_ERROR_MESSAGE = 'Sorry, there was an error connecting you to the application.' |
const ID_SCOPE_CONTEXT = 2 |
Prefix the ID with the consumer key and context ID.
Definition at line 44 of file Tool.php.
Referenced by UserResult\getId().
const ID_SCOPE_GLOBAL = 1 |
Prefix an ID with the consumer key.
Definition at line 39 of file Tool.php.
Referenced by UserResult\getId().
const ID_SCOPE_ID_ONLY = 0 |
Use ID value only.
Definition at line 34 of file Tool.php.
Referenced by UserResult\getId(), Platform\initialize(), DataConnector_mysql\loadUserResult(), DataConnector_mysqli\loadUserResult(), DataConnector_oci\loadUserResult(), DataConnector_pdo\loadUserResult(), DataConnector_pg\loadUserResult(), DataConnector_sqlsrv\loadUserResult(), DataConnector_mysql\saveUserResult(), DataConnector_mysqli\saveUserResult(), DataConnector_oci\saveUserResult(), DataConnector_pdo\saveUserResult(), DataConnector_pg\saveUserResult(), and DataConnector_sqlsrv\saveUserResult().
const ID_SCOPE_RESOURCE = 3 |
Prefix the ID with the consumer key and resource ID.
Definition at line 49 of file Tool.php.
Referenced by UserResult\getId(), and ResourceLink\getMemberships().
const ID_SCOPE_SEPARATOR = ':' |
Character used to separate each element of an ID.
Definition at line 54 of file Tool.php.
Referenced by UserResult\getId().