Tsugi

Lti13TestLaunch
in package

A signed LTI 1.3 resource-link test for a tool this course can already see.

The test page starts the tool's login. The tool sends the browser back to the platform authorization URL, and that response is the launch. A privacy launch uses the same login and a smaller token. A deep link opens in a panel and its return is not stored. Course scoped stays in the list.

Table of Contents

Constants

HINT_SECONDS  : mixed = 600

Methods

acceptReturn()  : array{registration_id: int, context_id: int, user_id: int, role: string, deployment_id: string, items: array, json: string}>, msg: string, log: string, errormsg: string, errorlog: string}
Check a deep link return and pull out its items. The return is not stored.
choices()  : array<int, array{type: string, label: string, ready: bool}>
Launches this tool registered, in test-page order.
complete()  : array{redirect_uri: string, id_token: string, state: string}
The tool's authentication request. Returns the form fields for the launch.
courseResourceLink()  : array{endpoint: string, parameters: array, protocol: string}
A lesson launch. The content row is the resource link. The stored URL is the target.
launch()  : array{title: string, endpoint: string, form_endpoint: string, message_type: string, label: string, role: string, ready: bool, new_window: bool, missing_resource_link: bool, content_item_url: bool, parameters: array, jwt_json: string, jwt_signed: string}
Start one test launch, or report that this message type is not sent yet.
launches()  : array<string, array{label: string, ready: bool}>
launchReturned()  : array{title: string, endpoint: string, form_endpoint: string, message_type: string, label: string, role: string, ready: bool, new_window: bool, modal: bool, missing_resource_link: bool, content_item_url: bool, parameters: array, jwt_json: string, jwt_signed: string}
A resource link aimed at a URL a deep link return just verified.
returnUrl()  : string
contentItem()  : array{type: string, title: string, text: string, url: string, custom: array, json: string}
contextRow()  : array{context_id: string, title: string, label: string, key_id: int}
db()  : PDOX
decodeHint()  : array<string, mixed>
deepLinkClaims()  : array<string, mixed>
deepLinkData()  : string
The value echoed in the deep link data claim. It outlives the login hint so a person can spend time choosing.
deployment()  : array{tool_deployment_id: int, deployment_id: string, allowed_claims: array, allowed_scopes: array}
deploymentById()  : array{tool_deployment_id: int, deployment_id: string, allowed_claims: array, allowed_scopes: array}
deploymentMatching()  : array{tool_deployment_id: int, deployment_id: string, allowed_claims: array, allowed_scopes: array}
effectiveTarget()  : string
encodeHint()  : string
gradeServiceClaim()  : array<string, mixed>|null
Scopes the deployment actually allows, plus the line-item URLs.
hasMessageTarget()  : bool
hintCustom()  : array<string, string>
hintSecret()  : string
httpUrl()  : string
includeLineItems()  : bool
A missing flag still includes the URL. The test page sets it false to leave the URL out.
keyRow()  : array{guid: string, name: string}
launchUrlIsContentItem()  : bool
The registration launch URL is also a content-item message target.
messageTarget()  : string
Target of the first message of this type.
placementCustom()  : array<string, string>
Content-item custom parameters for this launch.
prefix()  : string
previewToken()  : array{json: string, signed: string}
privacyClaims()  : array<string, mixed>
A privacy launch is the resource-link token without the resource, the course, and the service claims. for_user names the person whose data the tool is asked to act on. This test acts on the person who launched.
privacyRoleUri()  : string
Privacy launches carry a system role. Context membership roles do not apply.
requestString()  : string
resourceLinkClaims()  : array<string, mixed>
resourceLinkIdentity()  : array{id: string, title: string, description?: string}
The resource link in a lesson is the content row. A test launch uses a stand-in id.
roleUri()  : string
sameMessageType()  : bool
sign()  : string
substituteCustom()  : string
Name and email variables are filled only when this launch releases that claim.
toolTarget()  : string
userRow()  : array{full: string, given: string, family: string, email: string, guid: ?string}
verifyToolKeyset()  : void
withCustomClaim()  : array<string, mixed>
Put custom parameters on the launch.
withPnpClaim()  : array<string, mixed>
Attach the PNP endpoint claim when $CFG->lti_pnp_baseurl is set.

Constants

Methods

acceptReturn()

Check a deep link return and pull out its items. The return is not stored.

public static acceptReturn(string $jwt[, string|null $publicKey = null ]) : array{registration_id: int, context_id: int, user_id: int, role: string, deployment_id: string, items: array, json: string}>, msg: string, log: string, errormsg: string, errorlog: string}
Parameters
$jwt : string
$publicKey : string|null = null

Tool public key. When omitted, the registration key set is read.

Return values
array{registration_id: int, context_id: int, user_id: int, role: string, deployment_id: string, items: array, json: string}>, msg: string, log: string, errormsg: string, errorlog: string}

choices()

Launches this tool registered, in test-page order.

public static choices(int $contextId, int $registrationId) : array<int, array{type: string, label: string, ready: bool}>

Resource link is listed even when the registration did not declare one.

Parameters
$contextId : int
$registrationId : int
Return values
array<int, array{type: string, label: string, ready: bool}>

complete()

The tool's authentication request. Returns the form fields for the launch.

public static complete(array<string, mixed> $request) : array{redirect_uri: string, id_token: string, state: string}
Parameters
$request : array<string, mixed>
Return values
array{redirect_uri: string, id_token: string, state: string}

A lesson launch. The content row is the resource link. The stored URL is the target.

public static courseResourceLink(int $contextId, int $toolDeploymentId, int $userId, string $resourceLinkId, string $resourceLinkTitle, string $returnUrl[, string $role = 'Learner' ][, string $userKey = '' ][, bool|null $sendName = null ][, bool|null $sendEmail = null ][, string $launchUrl = '' ][, string $documentTarget = '' ][, string $elementId = '' ][, bool|null $sendGrade = null ][, bool $gradeColumnMissing = false ]) : array{endpoint: string, parameters: array, protocol: string}

A privacy placement and a content-item placement launch this same way. The message that supplied the URL is not launched again. Custom parameters stored on the content row go on this launch.

Parameters
$contextId : int
$toolDeploymentId : int
$userId : int
$resourceLinkId : string
$resourceLinkTitle : string
$returnUrl : string
$role : string = 'Learner'
$userKey : string = ''

Unused. The token subject is the user id.

$sendName : bool|null = null

Null follows the deployment grant. False omits the name.

$sendEmail : bool|null = null

Null follows the deployment grant. False omits the email.

$launchUrl : string = ''
$documentTarget : string = ''
$elementId : string = ''

Unused.

$sendGrade : bool|null = null

Null follows the score scope. False omits the grade service.

$gradeColumnMissing : bool = false
Return values
array{endpoint: string, parameters: array, protocol: string}

launch()

Start one test launch, or report that this message type is not sent yet.

public static launch(int $contextId, int $registrationId, int $userId, string $messageType, string $returnUrl[, string $role = 'Instructor' ][, bool $lineItems = true ][, string|null $targetLinkUri = null ][, int $toolDeploymentId = 0 ]) : array{title: string, endpoint: string, form_endpoint: string, message_type: string, label: string, role: string, ready: bool, new_window: bool, missing_resource_link: bool, content_item_url: bool, parameters: array, jwt_json: string, jwt_signed: string}

Ready launches post the login request to the tool. The signed token is produced when the tool calls the authorization URL.

Parameters
$contextId : int
$registrationId : int
$userId : int
$messageType : string
$returnUrl : string
$role : string = 'Instructor'

Instructor or Learner

$lineItems : bool = true

Include the line items URL. A tool that creates columns keeps them in the course.

$targetLinkUri : string|null = null

A message target. Empty uses the first message of this type.

$toolDeploymentId : int = 0

Deployment to launch. Zero uses the first deployment on the tool.

Return values
array{title: string, endpoint: string, form_endpoint: string, message_type: string, label: string, role: string, ready: bool, new_window: bool, missing_resource_link: bool, content_item_url: bool, parameters: array, jwt_json: string, jwt_signed: string}

launches()

public static launches() : array<string, array{label: string, ready: bool}>
Return values
array<string, array{label: string, ready: bool}>

launchReturned()

A resource link aimed at a URL a deep link return just verified.

public static launchReturned(int $contextId, int $registrationId, int $userId, string $target, string $returnUrl[, string $role = 'Instructor' ][, string $title = '' ][, bool $lineItems = true ][, array<string, string> $custom = array() ]) : array{title: string, endpoint: string, form_endpoint: string, message_type: string, label: string, role: string, ready: bool, new_window: bool, modal: bool, missing_resource_link: bool, content_item_url: bool, parameters: array, jwt_json: string, jwt_signed: string}

The content item custom rides on the signed hint. This return is not a content row.

Parameters
$contextId : int
$registrationId : int
$userId : int
$target : string
$returnUrl : string
$role : string = 'Instructor'
$title : string = ''
$lineItems : bool = true

Include the line items URL. A tool that creates columns keeps them in the course.

$custom : array<string, string> = array()

Content item custom parameters. They replace a registration parameter with the same name.

Return values
array{title: string, endpoint: string, form_endpoint: string, message_type: string, label: string, role: string, ready: bool, new_window: bool, modal: bool, missing_resource_link: bool, content_item_url: bool, parameters: array, jwt_json: string, jwt_signed: string}

returnUrl()

public static returnUrl() : string
Return values
string

contentItem()

private static contentItem(mixed $item) : array{type: string, title: string, text: string, url: string, custom: array, json: string}
Parameters
$item : mixed
Return values
array{type: string, title: string, text: string, url: string, custom: array, json: string}

contextRow()

private static contextRow(int $contextId) : array{context_id: string, title: string, label: string, key_id: int}
Parameters
$contextId : int
Return values
array{context_id: string, title: string, label: string, key_id: int}

decodeHint()

private static decodeHint(string $hint) : array<string, mixed>
Parameters
$hint : string
Return values
array<string, mixed>

deepLinkClaims()

private static deepLinkClaims(array<string, mixed> $tool, array{tool_deployment_id: int, deployment_id: string, allowed_claims: array, allowed_scopes: array} $deployment, array<string, mixed> $hint, string $nonce) : array<string, mixed>
Parameters
$tool : array<string, mixed>
$deployment : array{tool_deployment_id: int, deployment_id: string, allowed_claims: array, allowed_scopes: array}
$hint : array<string, mixed>
$nonce : string
Return values
array<string, mixed>

deepLinkData()

The value echoed in the deep link data claim. It outlives the login hint so a person can spend time choosing.

private static deepLinkData(array<string, mixed> $hint) : string
Parameters
$hint : array<string, mixed>
Return values
string

deployment()

private static deployment(array<string, mixed> $tool) : array{tool_deployment_id: int, deployment_id: string, allowed_claims: array, allowed_scopes: array}
Parameters
$tool : array<string, mixed>
Return values
array{tool_deployment_id: int, deployment_id: string, allowed_claims: array, allowed_scopes: array}

deploymentById()

private static deploymentById(array<string, mixed> $tool, int $toolDeploymentId) : array{tool_deployment_id: int, deployment_id: string, allowed_claims: array, allowed_scopes: array}
Parameters
$tool : array<string, mixed>
$toolDeploymentId : int
Return values
array{tool_deployment_id: int, deployment_id: string, allowed_claims: array, allowed_scopes: array}

deploymentMatching()

private static deploymentMatching(array<string, mixed> $tool, string $deploymentId) : array{tool_deployment_id: int, deployment_id: string, allowed_claims: array, allowed_scopes: array}
Parameters
$tool : array<string, mixed>
$deploymentId : string
Return values
array{tool_deployment_id: int, deployment_id: string, allowed_claims: array, allowed_scopes: array}

effectiveTarget()

private static effectiveTarget(mixed $stored, string $fallback) : string
Parameters
$stored : mixed
$fallback : string
Return values
string

encodeHint()

private static encodeHint(array<string, mixed> $payload) : string
Parameters
$payload : array<string, mixed>
Return values
string

gradeServiceClaim()

Scopes the deployment actually allows, plus the line-item URLs.

private static gradeServiceClaim(int $contextId, array<int, string> $scopes, string|null $resourceLinkId) : array<string, mixed>|null

lineitem is the column coupled to this resource link, when one exists.

Parameters
$contextId : int
$scopes : array<int, string>
$resourceLinkId : string|null
Return values
array<string, mixed>|null

hasMessageTarget()

private static hasMessageTarget(array<string, mixed> $tool, string $messageType, string $target) : bool
Parameters
$tool : array<string, mixed>
$messageType : string
$target : string
Return values
bool

hintCustom()

private static hintCustom(mixed $value) : array<string, string>
Parameters
$value : mixed
Return values
array<string, string>

hintSecret()

private static hintSecret() : string
Return values
string

httpUrl()

private static httpUrl(string $url) : string
Parameters
$url : string
Return values
string

includeLineItems()

A missing flag still includes the URL. The test page sets it false to leave the URL out.

private static includeLineItems(array<string, mixed> $hint) : bool
Parameters
$hint : array<string, mixed>
Return values
bool

keyRow()

private static keyRow(int $keyId) : array{guid: string, name: string}
Parameters
$keyId : int
Return values
array{guid: string, name: string}

launchUrlIsContentItem()

The registration launch URL is also a content-item message target.

private static launchUrlIsContentItem(array<string, mixed> $tool) : bool
Parameters
$tool : array<string, mixed>
Return values
bool

messageTarget()

Target of the first message of this type.

private static messageTarget(array<string, mixed> $tool, string $messageType) : string

A message with no target link uses the registration target link. A resource link is implicit when the registration has a target link and that address is not a content-item message's own target.

Parameters
$tool : array<string, mixed>
$messageType : string
Return values
string

placementCustom()

Content-item custom parameters for this launch.

private static placementCustom(array<string, mixed> $hint) : array<string, string>

A returned launch carries them on the hint. A lesson launch reads the content row. The row replaces a hint parameter with the same name.

Parameters
$hint : array<string, mixed>
Return values
array<string, string>

previewToken()

private static previewToken(array<string, mixed> $claims) : array{json: string, signed: string}
Parameters
$claims : array<string, mixed>
Return values
array{json: string, signed: string}

privacyClaims()

A privacy launch is the resource-link token without the resource, the course, and the service claims. for_user names the person whose data the tool is asked to act on. This test acts on the person who launched.

private static privacyClaims(array<string, mixed> $tool, array{tool_deployment_id: int, deployment_id: string, allowed_claims: array, allowed_scopes: array} $deployment, array<string, mixed> $hint, string $nonce) : array<string, mixed>
Parameters
$tool : array<string, mixed>
$deployment : array{tool_deployment_id: int, deployment_id: string, allowed_claims: array, allowed_scopes: array}
$hint : array<string, mixed>
$nonce : string
Return values
array<string, mixed>

privacyRoleUri()

Privacy launches carry a system role. Context membership roles do not apply.

private static privacyRoleUri(string $role) : string
Parameters
$role : string
Return values
string

requestString()

private static requestString(array<string, mixed> $request, string $name, int $limit) : string
Parameters
$request : array<string, mixed>
$name : string
$limit : int
Return values
string

resourceLinkClaims()

private static resourceLinkClaims(array<string, mixed> $tool, array{tool_deployment_id: int, deployment_id: string, allowed_claims: array, allowed_scopes: array} $deployment, array<string, mixed> $hint, string $nonce) : array<string, mixed>
Parameters
$tool : array<string, mixed>
$deployment : array{tool_deployment_id: int, deployment_id: string, allowed_claims: array, allowed_scopes: array}
$hint : array<string, mixed>
$nonce : string
Return values
array<string, mixed>

resourceLinkIdentity()

The resource link in a lesson is the content row. A test launch uses a stand-in id.

private static resourceLinkIdentity(array<string, mixed> $tool, array<string, mixed> $hint) : array{id: string, title: string, description?: string}
Parameters
$tool : array<string, mixed>
$hint : array<string, mixed>
Return values
array{id: string, title: string, description?: string}

roleUri()

private static roleUri(string $role) : string
Parameters
$role : string
Return values
string

sameMessageType()

private static sameMessageType(mixed $left, string $right) : bool
Parameters
$left : mixed
$right : string
Return values
bool

sign()

private static sign(array<string, mixed> $claims) : string
Parameters
$claims : array<string, mixed>
Return values
string

substituteCustom()

Name and email variables are filled only when this launch releases that claim.

private static substituteCustom(string $value, array<string, mixed> $claims, array{context_id: string, title: string, label: string, key_id: int} $context, array{id: string, title: string, description?: string}|null $resourceLink) : string
Parameters
$value : string
$claims : array<string, mixed>
$context : array{context_id: string, title: string, label: string, key_id: int}
$resourceLink : array{id: string, title: string, description?: string}|null
Return values
string

toolTarget()

private static toolTarget(array<string, mixed> $tool) : string
Parameters
$tool : array<string, mixed>
Return values
string

userRow()

private static userRow(int $userId, int $keyId) : array{full: string, given: string, family: string, email: string, guid: ?string}
Parameters
$userId : int
$keyId : int
Return values
array{full: string, given: string, family: string, email: string, guid: ?string}

verifyToolKeyset()

private static verifyToolKeyset(string $jwt, string $jwksUrl) : void
Parameters
$jwt : string
$jwksUrl : string

withCustomClaim()

Put custom parameters on the launch.

private static withCustomClaim(array<string, mixed> $claims, array<string, mixed> $tool, array<string, mixed> $hint, string $messageType, array{context_id: string, title: string, label: string, key_id: int} $context, array{id: string, title: string, description?: string}|null $resourceLink) : array<string, mixed>

Registration parameters come first. A content item parameter replaces one with the same claim name. A substitution this platform can fill is replaced. $Context.id.history and other values this platform does not fill stay as written.

Parameters
$claims : array<string, mixed>
$tool : array<string, mixed>
$hint : array<string, mixed>
$messageType : string
$context : array{context_id: string, title: string, label: string, key_id: int}
$resourceLink : array{id: string, title: string, description?: string}|null
Return values
array<string, mixed>

withPnpClaim()

Attach the PNP endpoint claim when $CFG->lti_pnp_baseurl is set.

private static withPnpClaim(array<string, mixed> $claims, string|null $userGuid) : array<string, mixed>

@ in that URL is this user's guid. The email is the one this launch actually releases, and it replaces the guid when lti_pnp_use_email is on.

Parameters
$claims : array<string, mixed>
$userGuid : string|null
Return values
array<string, mixed>

        
On this page

Search results