Skip to content

Commit

Permalink
Update to fix LTI provider as session not existing under some circums…
Browse files Browse the repository at this point in the history
…tances

git-svn-id: https://xerteonlinetoolkits.googlecode.com/svn/trunk@446 912cdd6b-5c7d-d5a7-a2ba-d0f0cdb91641
  • Loading branch information
Simon Atack committed Oct 9, 2012
1 parent e79cbb8 commit a981ea3
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
29 changes: 26 additions & 3 deletions LTI/ims-lti/UoN_LTI.php
Expand Up @@ -4,9 +4,8 @@
* User: cczsa1
* Date: 25/07/12
* Time: 09:59
* Version 1.1 (2012-09-28)
* * Version 1.2 (2012-10-04)
* To change this template use File | Settings | File Templates.
* Copyright The University Of Nottingham
*/

require_once 'lti_util.php';
Expand Down Expand Up @@ -51,6 +50,11 @@ public function init_lti($usesession = true, $doredirect = false) {
// give up or try to retrieve the context from session
if (!is_lti_request()) {
if ($usesession === false) return;

if(session_status()==PHP_SESSION_NONE) {
session_start();
}

if (strlen(session_id()) > 0) {
if (isset($_SESSION['_lti_row'])) $row = $_SESSION['_lti_row'];
if (isset($row)) $this->row = $row;
Expand Down Expand Up @@ -186,6 +190,7 @@ public function init_lti($usesession = true, $doredirect = false) {
continue;
}
}
$newinfo['oauth_consumer_secret']=$secret;

$this->info = $newinfo;
if ($usesession == true and strlen(session_id()) > 0) {
Expand Down Expand Up @@ -239,13 +244,14 @@ function get_lti_keys($deleted=false) {
$dataret[$lti_keys_id]=array('lti_keys_id'=>$lti_keys_id, 'lti_keys_key'=>$lti_keys_key, 'lti_keys_secret'=>$lti_keys_secret, 'lti_keys_name'=>$lti_keys_name, 'lti_keys_context_id'=>$lti_keys_context_id, 'lti_keys_deleted'=>$lti_keys_deleted, 'lti_keys_updated_on'=>$lti_keys_updated_on);
}

return $dataret;
return $dataret;
}


}



/**
* Function to update lti key
* @param int $ltiid unique id of lti key
Expand Down Expand Up @@ -541,4 +547,21 @@ function lookup_lti_context($lti_context_key = false) {
}


function get_consumer_secret() {
if (isset($this->info['oauth_consumer_secret'])) {
return $this->info['oauth_consumer_secret'];
}
return false;
}

function send_grade($grade) {

$oauth_consumer_key = $this->getConsumerKey();
$oauth_consumer_secret = $this->get_consumer_secret();
$endpoint = $this->getOutcomeService();
$sourcedid = $this->getOutcomeSourceDID();

$response = replaceResultRequest($grade, $sourcedid, $endpoint, $oauth_consumer_key, $oauth_consumer_secret);
return $response;
}
}
5 changes: 5 additions & 0 deletions LTI/index.php
Expand Up @@ -58,6 +58,9 @@ function auth($update = false) {

require_once '../' . $xerte_toolkits_site->php_library_path . "login_library.php";

if(session_id()=='') {
session_start();
}
$lti->init_lti();

$errors = array();
Expand Down Expand Up @@ -130,6 +133,8 @@ function auth($update = false) {
}


// check resource status

$returned = $lti->lookup_lti_resource();

if (!$lti->isInstructor()) {
Expand Down

0 comments on commit a981ea3

Please sign in to comment.