Skip to content

Commit

Permalink
Add context_id to the Context object
Browse files Browse the repository at this point in the history
  • Loading branch information
csev committed Dec 23, 2023
1 parent 69c5164 commit 93eb263
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/Core/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ class Context extends Entity {
*/
public $secret;

/*
* The context_id from the server
*/
public $context_id;

/**
* Load the LTI 1.3 data from the session, checking for sanity
*
Expand Down
6 changes: 4 additions & 2 deletions src/Core/LTIX.php
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,6 @@ public static function setupSession($needed=self::ALL, $session_object=null, $re
$row['deployment_id'] = $post['deployment_id'];
}


if ( ! $row || ! U::get($row, 'key_id') ) {
if ( U::get($post,'key') ) { // LTI 1.1
self::abort_with_error_log('Launch could not find key: '.htmlentities(U::get($post,'key')));
Expand Down Expand Up @@ -1318,7 +1317,8 @@ public static function loadAllData($p, $profile_table, $post) {
k.lms_issuer, k.lms_client, k.lms_oidc_auth, k.lms_keyset_url,
k.lms_token_url, k.lms_token_audience, k.lms_cache_keyset, k.lms_cache_pubkey, k.lms_cache_kid,
n.nonce,
c.context_id, c.title AS context_title, context_sha256, c.settings_url AS context_settings_url,
c.context_id, c.title AS context_title, context_sha256, C.context_key as context_key,
c.settings_url AS context_settings_url,
c.ext_memberships_id AS ext_memberships_id, c.ext_memberships_url AS ext_memberships_url,
c.lineitems_url AS lineitems_url, c.memberships_url AS memberships_url,
c.lti13_lineitems AS lti13_lineitems, c.lti13_membership_url AS lti13_membership_url,
Expand Down Expand Up @@ -1542,6 +1542,7 @@ public static function adjustData($p, &$row, $post, $needed) {
':title' => $post['context_title'],
':key_id' => $row['key_id']));
$row['context_id'] = $PDOX->lastInsertId();
$row['context_key'] = $post['context_id']; // We rename this for all internal structures...
$row['context_title'] = $post['context_title'];
$row['context_settings_url'] = $context_settings_url;
$actions[] = "=== Inserted context id=".$row['context_id']." ".$row['context_title'];
Expand Down Expand Up @@ -2290,6 +2291,7 @@ public static function buildLaunch($LTI, $session_object=null) {
if (isset($LTI['context_title']) ) $CONTEXT->title = $LTI['context_title'];
if (isset($LTI['key_key']) ) $CONTEXT->key = $LTI['key_key'];
if (isset($LTI['secret']) ) $CONTEXT->secret = $LTI['secret'];
if (isset($LTI['context_key']) ) $CONTEXT->context_id = $LTI['context_key'];
$TSUGI_LAUNCH->context = $CONTEXT;
}

Expand Down

0 comments on commit 93eb263

Please sign in to comment.