Skip to content

Commit

Permalink
Update to LTI Documentation
Browse files Browse the repository at this point in the history
git-svn-id: https://xerteonlinetoolkits.googlecode.com/svn/trunk@441 912cdd6b-5c7d-d5a7-a2ba-d0f0cdb91641
  • Loading branch information
Simon Atack committed Oct 3, 2012
1 parent 6e8bcac commit 6e0a204
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 75 deletions.
8 changes: 8 additions & 0 deletions LTI Documentation.txt
Expand Up @@ -3,6 +3,10 @@ LTI Documentation

Very quick & brief documentation.

adds 4 new tables lti_context, lti_keys, lti_resource & lti_user

The LTI Provider Library is from The University Of Nottingham which extends upon the sample LTI Library from IMS, under an MIT Licence.

Setup
-----

Expand All @@ -15,6 +19,7 @@ replace <XOTurl> with the full url to Xerte Online Toolkit.

You then need to add an LTI key from the management interface from LTI Settings under site menu. The secret and the key is then entered into the LTI Consumer along with the destination URL. Context is currently not handled by this as there doesnt seem any logic for it wit XOT.


On launching a link
-------------------

Expand All @@ -25,7 +30,10 @@ if staff it will show existing projects and let you select one for the link to a
if student then launches to project, if not setup display quick error message.


Using Moodle
------------

The easiest way to use this is to set up an external tool under the site administrator. Give the tool a sensible name eg Xerte Online Toolkits. The base URL should be the url to the toolkits with /LTI/ appended, enter the consumer key & shared key that you will enter into Xerte. Under the custom Parameters box there is a tick box with just a help icon next to it (which when help is clicked it starts "Show tool type when creating tool instances tick this box as the lti extension provides a specific landing page than then redirects to where its been configured.



Expand Down
137 changes: 63 additions & 74 deletions LTI/index.php
Expand Up @@ -128,8 +128,8 @@ function html_headers() {
<div style="width:50%; height:100%; float:right; position:relative; background-image:url(http://www.nottingham.ac.uk/toolkits/website_code/images/UofNLogo.jpg); background-repeat:no-repeat; background-position:right; margin-right:10px; float:right">
<p style="float:right; margin:0px; color:#a01a13;"><a href="javascript:logout()" style="color:#a01a13">
END;
// echo INDEX_LOG_OUT;
print <<<END
// echo INDEX_LOG_OUT;
print <<<END
</a></p>
</div>
<img src="../website_code/images/xerteLogo.jpg" style="margin-left:10px; float:left" />
Expand Down Expand Up @@ -171,8 +171,7 @@ function auth($update = false) {
if ($mysqli->error) {
try {
throw new Exception("0MySQL error $mysqli->error <br> Query:<br> $query", $mysqli->errno);
}
catch (Exception $e) {
} catch (Exception $e) {
echo "Error No: " . $e->getCode() . " - " . $e->getMessage() . "<br />";
echo nl2br($e->getTraceAsString());
}
Expand Down Expand Up @@ -205,62 +204,60 @@ function auth($update = false) {
$returned = $lti->lookup_lti_user();


if ($returned === false) {
if ($returned === false) {
//user hasnt authenticated before need authentication




// post so check login
$returnedproc = login_processing(false);
list($success, $errors) = $returnedproc;
if ($success && empty($errors)) {
auth();
login_processing2();
//sucessfull authentication
} else {
html_headers();
login_prompt($errors, '../');
exit();
}


// post so check login
$returnedproc = login_processing(false);
list($success, $errors) = $returnedproc;
if ($success && empty($errors)) {
auth();
login_processing2();
//sucessfull authentication
} else {
$time1 = strtotime($returned[1]);
$time2 = time();
$timediff = $time2 - $time1;
$needreauth = false;
// reauthenticate after 15 weeks ( 60 seconds * 60 mins = 1 hour * 24 hours = 1 day * 7 days = 1 week * 15 = 15 weeks )
if ($timediff > (60 * 60 * 24 * 7 * 15)) {
//if ($timediff > (60 * 60 * 1)) {
$needreauth = true;
}
html_headers();
login_prompt($errors, '../');
exit();
}

//if needreauth then do authentication again else $returned[0] has the user in it do appropriate things

if ($needreauth) {
auth(true);
}
require_once '../' . $xerte_toolkits_site->php_library_path . '/user_library.php';
$data = get_user_info();
} else {
$time1 = strtotime($returned[1]);
$time2 = time();
$timediff = $time2 - $time1;
$needreauth = false;
// reauthenticate after 15 weeks ( 60 seconds * 60 mins = 1 hour * 24 hours = 1 day * 7 days = 1 week * 15 = 15 weeks )
if ($timediff > (60 * 60 * 24 * 7 * 15)) {
//if ($timediff > (60 * 60 * 1)) {
$needreauth = true;
}

//if needreauth then do authentication again else $returned[0] has the user in it do appropriate things

login_processing2($data[0], $data[1], $data[2]);
update_user_logon_time();
if ($needreauth) {
auth(true);
}
require_once '../' . $xerte_toolkits_site->php_library_path . '/user_library.php';
$data = get_user_info();

login_processing2($data[0], $data[1], $data[2]);
update_user_logon_time();
}

// if xerteID set then store the associated data

if (isset($_REQUEST['xerteID'])) {
$retlookup = $_SESSION['postlookup'][$_REQUEST['xerteID']];
unset($_SESSION['postlookup']);
if ($retlookup > 0) {
//$info = $lti->getResourceKey(1);
$lti->add_lti_resource($retlookup, 'xerte');
}
if (isset($_REQUEST['xerteID'])) {
$retlookup = $_SESSION['postlookup'][$_REQUEST['xerteID']];
unset($_SESSION['postlookup']);
if ($retlookup > 0) {
//$info = $lti->getResourceKey(1);
$lti->add_lti_resource($retlookup, 'xerte');
}
}


$returned = $lti->lookup_lti_resource();
$returned = $lti->lookup_lti_resource();

if (!$lti->isInstructor()) {
//student
Expand All @@ -272,11 +269,11 @@ function auth($update = false) {
}
//display a redirect to appropriate page

$returned=$lti->lookup_lti_resource();
$template_id=$returned[0];
$loc=$xerte_toolkits_site->site_url . url_return("play", $template_id);
$returned = $lti->lookup_lti_resource();
$template_id = $returned[0];
$loc = $xerte_toolkits_site->site_url . url_return("play", $template_id);

header("location: ". $loc);
header("location: " . $loc);
echo "Please click <a href=\"$loc\">here</a> to continue";
exit();

Expand All @@ -285,22 +282,21 @@ function auth($update = false) {
//staff
if ($returned !== false) {

//link exists
//
// do same as student
//link exists
//
// do same as student

//display a redirect to appropriate page
//display a redirect to appropriate page

$returned=$lti->lookup_lti_resource();
$template_id=$returned[0];
$loc=$xerte_toolkits_site->site_url . url_return("play", $template_id);
$returned = $lti->lookup_lti_resource();
$template_id = $returned[0];
$loc = $xerte_toolkits_site->site_url . url_return("play", $template_id);

header("location: ". $loc);
echo "Please click <a href=\"$loc\">here</a> to continue";
exit();
header("location: " . $loc);
echo "Please click <a href=\"$loc\">here</a> to continue";
exit();

}
else {
} else {


// display xerte object so a new one can be selected
Expand Down Expand Up @@ -334,30 +330,23 @@ function auth($update = false) {
END;







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

echo "<form method=\"post\">";

//echo "<div class=\"folder\" id=\"folder_workspace\" ondblclick=\"folder_open_close(this)\" onclick=\"highlight_main_toggle(this)\">";



//echo "</div>\r\n<div id=\"folderchild_workspace\" class=\"workspace\">";
//echo "</div>\r\n<div id=\"folderchild_workspace\" class=\"workspace\">";


$level = 1;
$item=1;
$item = 1;


$item = list_folder_contents_event_free(get_user_root_folder(), '../', $item, 'radio');

$item=list_folder_contents_event_free(get_user_root_folder(),'../',$item,'radio');

print <<<END
print <<<END
</div></div>
</div>
<div class="demoHeader"></div>
Expand Down
2 changes: 1 addition & 1 deletion languages/en-GB/website_code/php/management/site.inc
Expand Up @@ -154,7 +154,7 @@ define("LTI_KEYS_NEW",'New');
define("LTI_KEYS_DELETE",'Delete');
define("LTI_KEYS_ADD",'Add New LTI Key');
define("LTI_KEYS_ADD_SUBMIT",'Add New LTI Key');
define("LTI_KEYS_EDIT_SUBMIT",'Edit LTI Key');
define("LTI_KEYS_EDIT_SUBMIT",'Save LTI Key');
define("LTI_KEYS_DELETE_SUBMIT",'Delete LTI Key');


Expand Down

0 comments on commit 6e0a204

Please sign in to comment.