$tabs[3] = array('alternative_content', 'alternatives.inc.php', 'l');
//Harris: Extended test functionality into content export
$tabs[4] = array('tests', 'tests.inc.php', 't');
- $tabs[5] = array('tools', 'tools.inc.php', 'o');
return $tabs;
}
* @param: $content
* @return: none
*/
-function populate_a4a($cid, $content){
- include_once(AT_INCLUDE_PATH.'../mods/_core/imsafa/html/resources_parser.inc.php');
- include_once(AT_INCLUDE_PATH.'../mods/_core/imsafa/classes/A4a.class.php');
+function populate_a4a($cid, $content, $formatting){
+ global $db, $my_files, $content_base_href, $contentManager;
- $resources = get_primary_resources($content);
-
- if (count($resources) == 0) return;
+ // Defining alternatives is only available for content type "html".
+ // But don't clean up the a4a tables at other content types in case the user needs them back at html.
+ if ($formatting <> 1) return;
+ include_once(AT_INCLUDE_PATH.'../mods/_core/imsafa/classes/A4a.class.php');
+ include_once(AT_INCLUDE_PATH.'classes/XML/XML_HTMLSax/XML_HTMLSax.php'); /* for XML_HTMLSax */
+ include_once(AT_INCLUDE_PATH.'classes/ContentOutputParser.class.php'); /* for parser */
+
+ // initialize content_base_href; used in format_content
+ if (!isset($content_base_href)) {
+ $result = $contentManager->getContentPage($cid);
+ // return if the cid is not found
+ if (!($content_row = @mysql_fetch_assoc($result))) return;
+ $content_base_href = $content_row["content_path"].'/';
+ }
+
+ $body = format_content($content, $formatting,array());
+
+ $handler = new ContentOutputParser();
+ $parser = new XML_HTMLSax();
+ $parser->set_object($handler);
+ $parser->set_element_handler('openHandler','closeHandler');
+
+ $my_files = array();
+ $parser->parse($body);
+ $my_files = array_unique($my_files);
+
+ foreach ($my_files as $file) {
+ /* filter out full urls */
+ $url_parts = @parse_url($file);
+
+ // file should be relative to content
+ if ((substr($file, 0, 1) == '/')) {
+ continue;
+ }
+
+ // The URL of the movie from youtube.com has been converted above in embed_media().
+ // For example: http://www.youtube.com/watch?v=a0ryB0m0MiM is converted to
+ // http://www.youtube.com/v/a0ryB0m0MiM to make it playable. This creates the problem
+ // that the parsed-out url (http://www.youtube.com/v/a0ryB0m0MiM) does not match with
+ // the URL saved in content table (http://www.youtube.com/watch?v=a0ryB0m0MiM).
+ // The code below is to convert the URL back to original.
+ $file = convert_youtube_playURL_to_watchURL($file);
+
+ $resources[] = convert_amp($file); // converts & to &
+ }
+
$a4a = new A4a($cid);
$db_primary_resources = $a4a->getPrimaryResources();
// clean up the removed resources
foreach ($db_primary_resources as $primary_rid=>$db_resource){
//if this file from our table is not found in the $resource, then it's not used.
- if(in_array($db_resource['resource'], $resources)===false){
- $a4a->deletePrimaryResource($primary_rid);
+ if(count($resources) == 0 || !in_array($db_resource['resource'], $resources)){
+ $a4a->deletePrimaryResource($primary_rid);
}
}
+
+ if (count($resources) == 0) return;
// insert the new resources
foreach($resources as $primary_resource)
$_REQUEST['cid'] = $cid;
}
// re-populate a4a tables based on the new content
- populate_a4a($cid, $orig_body_text);
+ populate_a4a($cid, $orig_body_text, $_POST['formatting']);
}
else return;
}
}
- // Add/Update The Tool
- if ( isset($_POST['toolid']) ) {
- $toolid = $_POST['toolid'];
- $sql = "SELECT * FROM ".TABLE_PREFIX."basiclti_content
- WHERE content_id=".$_POST[cid];
- $result = mysql_query($sql, $db);
- if ( $toolid == '--none--' ) {
- $sql = "DELETE FROM ". TABLE_PREFIX . "basiclti_content
- WHERE content_id=".$_POST[cid];
- $result = mysql_query($sql, $db);
- } else if ( mysql_num_rows($result) == 0 ) {
- $sql = "INSERT INTO ". TABLE_PREFIX . "basiclti_content
- SET toolid='".$toolid."', content_id=".$_POST[cid];
- $result = mysql_query($sql, $db);
- if ($result===false) $msg->addError('MYSQL_FAILED');
- } else {
- $sql = "UPDATE ". TABLE_PREFIX . "basiclti_content
- SET toolid='".$toolid."' WHERE content_id=".$_POST[cid];
- $result = mysql_query($sql, $db);
- if ($result===false) $msg->addError('MYSQL_FAILED');
- }
- }
-
//TODO*******************BOLOGNA****************REMOVE ME**************/
if(isset($_SESSION['associated_forum']) && !$msg->containsErrors()){
if($_SESSION['associated_forum']=='none'){
+++ /dev/null
-<?php
-/****************************************************************/
-/* ATutor */
-/****************************************************************/
-/* Copyright (c) 2002-2010 */
-/* Inclusive Design Institute */
-/* http://atutor.ca */
-/* */
-/* This program is free software. You can redistribute it and/or*/
-/* modify it under the terms of the GNU General Public License */
-/* as published by the Free Software Foundation. */
-/****************************************************************/
-// $Id: tests.inc.php 10197 2010-09-16 16:18:25Z greg $
-if (!defined('AT_INCLUDE_PATH')) { exit; }
-
-$cid = intval($_REQUEST['cid']);
-
-/* get a list of all the tools, we have */
-$sql = "SELECT * FROM ".TABLE_PREFIX."basiclti_tools ORDER BY title;";
-$toolresult = mysql_query($sql, $db);
-$num_tools = mysql_num_rows($toolresult);
-
-//If there are no Tools, don't display anything except a message
-if ($num_tools == 0){
- $msg->addInfo('NO_PROXY_TOOLS');
- $msg->printInfos();
- return;
-}
-
-// Get the current content item
-$sql = "SELECT * FROM ".TABLE_PREFIX."basiclti_content
- WHERE content_id=$cid";
-$contentresult = mysql_query($sql, $db);
-$row = mysql_fetch_assoc($contentresult);
-// if ( $row ) echo("FOUND"); else echo("NOT");
-?>
-<div class="row">
- <span style="font-weight:bold"><?php echo _AT('about_content_tools'); ?></span>
-</div>
-
-<div class="row">
- <?php echo _AT('bl_choose_tool'); ?><br/>
- <select id="toolid" name="toolid">
- <option value="--none--"> </option><?php
- while ( $tool = mysql_fetch_assoc($toolresult) ) {
- $selected = "";
- if ( $tool['toolid'] == $row['toolid'] ) {
- $selected = ' selected="yes"';
- }
- echo '<option value="'.$tool['toolid'].'"'.$selected.'>'.$tool['title']."</option>\n";
- } ?>
- </select>
-</div>
exit;\r
}\r
\r
-$_pages['mods/_standard/blogs/post.php']['title'] = AT_PRINT($post_row['title'], 'blog_posts.title') . ($post_row['private'] ? ' - '._AT('private') : '');\r
+$_pages['mods/_standard/blogs/post.php']['title'] = AT_print($post_row['title'], 'blog_posts.title') . ($post_row['private'] ? ' - '._AT('private') : '');\r
$_pages['mods/_standard/blogs/post.php']['parent'] = 'mods/_standard/blogs/view.php?ot='.BLOGS_GROUP.SEP.'oid='.$owner_id;\r
if (query_bit($owner_status, BLOGS_AUTH_WRITE)) {\r
$_pages['mods/_standard/blogs/post.php']['children'] = array('mods/_standard/blogs/edit_post.php?ot='.BLOGS_GROUP.SEP.'oid='.$owner_id.SEP.'id='.$id, 'mods/_standard/blogs/delete_post.php?ot='.BLOGS_GROUP.SEP.'oid='.$owner_id.SEP.'id='.$id);\r
<div class="entry">\r
<h3 class="date"><?php echo get_display_name($post_row['member_id']); ?> - <?php echo AT_date(_AT('forum_date_format'), $post_row['date'], AT_DATE_MYSQL_DATETIME); ?></h3>\r
\r
- <p><?php echo AT_PRINT($post_row['body'], 'blog_posts.body'); ?></p>\r
+ <p><?php echo AT_print($post_row['body'], 'blog_posts.body'); ?></p>\r
</div>\r
\r
<a name="comments"></a><h2><?php echo _AT('comments'); ?></h2>\r
<?php if (mysql_num_rows($result)): ?>\r
<?php while (($row = mysql_fetch_assoc($result)) && ($count < $num_posts_per_page)): $count++; ?>\r
<div class="entry">\r
- <h2><a href="<?php echo url_rewrite('mods/_standard/blogs/post.php?ot='.BLOGS_GROUP.SEP.'oid='.$_REQUEST['oid'].SEP.'id='.$row['post_id']); ?>"><?php echo AT_PRINT($row['title'], 'blog_posts.title'); ?></a>\r
+ <h2><a href="<?php echo url_rewrite('mods/_standard/blogs/post.php?ot='.BLOGS_GROUP.SEP.'oid='.$_REQUEST['oid'].SEP.'id='.$row['post_id']); ?>"><?php echo AT_print($row['title'], 'blog_posts.title'); ?></a>\r
<?php if ($row['private']): ?>\r
- <?php echo _AT('private'); ?>\r
<?php endif; ?></h2>\r
<h3 class="date"><?php echo get_display_name($row['member_id']); ?> - <?php echo AT_date(_AT('forum_date_format'), $row['date'], AT_DATE_MYSQL_DATETIME); ?></h3>\r
\r
- <p><?php echo AT_PRINT($row['body'], 'blog_posts.body'); ?></p>\r
+ <p><?php echo AT_print($row['body'], 'blog_posts.body'); ?></p>\r
\r
<p><a href="<?php echo url_rewrite('mods/_standard/blogs/post.php?ot='.BLOGS_GROUP.SEP.'oid='.$_REQUEST['oid'].SEP.'id='.$row['post_id']); ?>#comments"><?php echo _AT('comments_num', $row['num_comments']); ?></a></p>\r
<hr />\r
echo '<input type="checkbox" value="'.$row['question_id'].'|'.$row['type'].'" name="questions['.$cat['category_id'].'][]" id="q'.$row['question_id'].'" onmouseup="this.checked=!this.checked" /></td>';\r
echo '<td>';\r
echo '<a title="'.htmlentities($row[question], ENT_QUOTES, 'UTF-8').'">';\r
- echo AT_PRINT(htmlentities(validate_length($row['question'], 100, VALIDATE_LENGTH_FOR_DISPLAY), ENT_QUOTES, 'UTF-8'), 'tests_questions.question');\r
+ echo AT_print(htmlentities(validate_length($row['question'], 100, VALIDATE_LENGTH_FOR_DISPLAY), ENT_QUOTES, 'UTF-8'), 'tests_questions.question');\r
echo '</a>';\r
echo '</td>';\r
echo '<td>';\r
+++ /dev/null
-Mon Oct 25 21:40:17 EDT 2010
-
-Hi this is a prototype of an ATutor Basic LTI Integration.
-
-First check this out from
-
-https://source.sakaiproject.org/contrib//csev/trunk/atutor/basiclti/
-
-And place this into:
-
-/atutor/docs/mods/basiclti
-
-In your ATutor distribution.
-
-There is also a patch file to apply to the rest of the ATutor distro.
-
--rw-r--r-- 1 root admin 4799 Oct 25 21:39 atutor-patches-01.txt
-
-This is mostly hacking Basic LTI into the content system. This was
-not particularly elegant, I might add - I welcome a cleaner approach.
-
-Here is a video of it all working:
-
-http://www.vimeo.com/16193060
-
-Here are the steps in ATutor after the software
-(1) Install the Module from the Admin Modules Tab and Enable it
-(2) Under the Proxy Tools tab creat a new tool with the standard stuff
- http://www.imsglobal.org/developers/BLTI/tool.php
- lmsng.school.edu
- secet
-(3) Make a course. Go into content and add a new content item. Give it a title
-and then select the "Tools" tab after "Surveys and Tests" - you should be able to
-pick the prxy tool you just built. Press Save and Close and it should launch.
-
-Lots of features are not working yet, privacy, popup, height, etc. I
-needed to knock this out to start a conversation with the ATutor team.
-They will quickly come up with the right/elegant way to do this.
-
-I wanted to put it in content so it looks as much as possible like what
-I expect IMS Common Cartridge 1.1 will look like since AT already has a
-nice imscc 1.0 import.
-
-/Chuck
-
+++ /dev/null
-<?php
-$form_create_blti = array(
- 'title:text:required=true:size=25',
- 'toolid:text:required=true:size=16',
- 'description:textarea:required=true:rows=2:cols=25',
- 'toolurl:text:label=bl_toolurl:required=true:size=80',
- 'resourcekey:text:label=bl_resourcekey:required=true:size=80',
- 'password:text:required=true:label=bl_password:size=80',
- 'preferheight:integer:size=80',
- 'launchinpopup:radio:label=bl_launchinpopup:choices=off,on,instructor',
- 'debuglaunch:radio:label=bl_debuglaunch:choices=off,on,instructor',
- 'sendname:radio:label=bl_sendname:choices=off,on,instructor',
- 'sendemailaddr:radio:label=bl_sendemailaddr:choices=off,on,instructor',
- 'acceptgrades:radio:label=bl_acceptgrades:choices=off,on',
- 'customparameters:textarea:label=bl_customparameters:rows=5:cols=25',
- 'organizationid:text:label=bl_organizationid:size=80',
- 'organizationurl:text:label=bl_organizationurl:size=80',
- 'organizationdescr:text:label=bl_organizationdescr:size=80',
- );
-?>
+++ /dev/null
-<?php
-define('AT_INCLUDE_PATH', '../../../include/');
-require(AT_INCLUDE_PATH.'vitals.inc.php');
-admin_authenticate(AT_ADMIN_PRIV_BASICLTI);
-
-require('../lib/at_form_util.php');
-require('basic_lti_form.php');
-
-if (isset($_POST['cancel'])) {
- $msg->addFeedback('CANCELLED');
- header('Location: '.AT_BASE_HREF.'mods/basiclti/index_admin.php');
- exit;
-} else if (isset($_POST['form_basiclti'])) {
-
- if ( at_form_validate($form_create_blti, $msg) ) {
- $sql = "SELECT count(*) cnt FROM ".TABLE_PREFIX."basiclti_tools WHERE toolid = '".
- mysql_real_escape_string($_POST['toolid'])."';";
- $result = mysql_query($sql, $db) or die(mysql_error());
- $row = mysql_fetch_assoc($result);
-
- if ($row["cnt"] != 0) {
- $msg->addFeedback('NEED_UNIQUE_TOOLID');
- } else {
- $sql = at_form_insert($_POST, $form_create_blti);
- $sql = 'INSERT INTO '.TABLE_PREFIX."basiclti_tools ".$sql.";";
- $result = mysql_query($sql, $db) or die(mysql_error());
- write_to_log(AT_ADMIN_LOG_INSERT, 'basiclti_create', mysql_affected_rows($db), $sql);
- $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
- header('Location: '.AT_BASE_HREF.'mods/basiclti/index_admin.php');
- exit;
- }
- }
-}
-
-include(AT_INCLUDE_PATH.'header.inc.php');
-
-$msg->printAll();
-
-?>
-<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" name="basiclti_form" enctype="multipart/form-data">
- <input type="hidden" name="form_basiclti" value="true" />
- <div class="input-form">
- <fieldset class="group_form"><legend class="group_form"><?php echo _AT('properties'); ?></legend>
-<?php at_form_generate($_POST, $form_create_blti); ?>
- <div class="buttons">
- <input type="submit" name="submit" value="<?php echo _AT('save'); ?>" accesskey="s" />
- <input type="submit" name="cancel" value="<?php echo _AT('cancel');?>" />
- </div>
- </fieldset>
- </div>
-</form>
-
-<?php
-require(AT_INCLUDE_PATH.'footer.inc.php');
+++ /dev/null
-<?php
-error_reporting(E_ALL & ~E_NOTICE);
-ini_set("display_errors", 1);
-
-define('AT_INCLUDE_PATH', '../../../include/');
-require(AT_INCLUDE_PATH.'vitals.inc.php');
-admin_authenticate(AT_ADMIN_BASICLTI);
-
-$tool = intval($_REQUEST['id']);
-
-$sql = "SELECT title FROM ".TABLE_PREFIX."basiclti_tools WHERE id = ".$tool.";";
-$result = mysql_query($sql, $db) or die(mysql_error());
-$row = mysql_fetch_assoc($result);
-
-if ( strlen($row["title"]) < 1) {
- $msg->addFeedback('UNABLE_TO_FIND_TOOL');
- header('Location: ../index_admin.php');
- exit;
-}
-
-if (isset($_POST['submit_no'])) {
- $msg->addFeedback('CANCELLED');
- header('Location: ../index_admin.php');
- exit;
-} else if (isset($_POST['step']) && ($_POST['step'] == 2) && isset($_POST['submit_yes'])) {
- $sql = "DELETE FROM ".TABLE_PREFIX."basiclti_tools WHERE id = ".$tool.";";
- $result = mysql_query($sql, $db) or die(mysql_error());
- write_to_log(AT_ADMIN_LOG_DELETE, 'basiclti_delete', mysql_affected_rows($db), $sql);
- $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
- header('Location: ../index_admin.php');
- exit;
-}
-
-require(AT_INCLUDE_PATH.'header.inc.php');
-
-if (!isset($_POST['step'])) {
- $hidden_vars['step'] = 1;
- $hidden_vars['id'] = $tool;
- $msg->addConfirm(array('DELETE_TOOL_1', $row['title']), $hidden_vars);
- $msg->printConfirm();
-} else if ($_POST['step'] == 1) {
- $hidden_vars['step'] = 2;
- $hidden_vars['id'] = $tool;
- $msg->addConfirm(array('DELETE_TOOL_2', $row['title']), $hidden_vars);
- $msg->printConfirm();
-}
-
-require(AT_INCLUDE_PATH.'footer.inc.php');
+++ /dev/null
-<?php
-define('AT_INCLUDE_PATH', '../../../include/');
-require(AT_INCLUDE_PATH.'vitals.inc.php');
-admin_authenticate(AT_ADMIN_PRIV_BASICLTI);
-
-require('../lib/at_form_util.php');
-require('basic_lti_form.php');
-
-$tool = intval($_REQUEST['id']);
-
-if (isset($_POST['cancel'])) {
- $msg->addFeedback('CANCELLED');
- header('Location: '.AT_BASE_HREF.'mods/basiclti/index_admin.php');
- exit;
-} else if (isset($_POST['form_basiclti'], $tool)) {
-
- if ( at_form_validate($form_create_blti, $msg) ) {
- $sql = "SELECT count(*) cnt FROM ".TABLE_PREFIX."basiclti_tools WHERE toolid = '".
- mysql_real_escape_string($_POST['toolid'])." AND id = $tool';";
- $result = mysql_query($sql, $db) or die(mysql_error());
- $row = mysql_fetch_assoc($result);
-
- if ($row["cnt"] != 0) {
- $msg->addFeedback('NEED_UNIQUE_TOOLID');
- } else {
- $sql = at_form_update($_POST, $form_create_blti);
- $sql = 'UPDATE '.TABLE_PREFIX."basiclti_tools SET ".$sql." WHERE id = $tool;";
- $result = mysql_query($sql, $db) or die(mysql_error());
- write_to_log(AT_ADMIN_LOG_INSERT, 'basiclti_create', mysql_affected_rows($db), $sql);
- $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
- header('Location: '.AT_BASE_HREF.'mods/basiclti/index_admin.php');
- exit;
- }
- }
-}
-
-$sql = "SELECT * FROM ".TABLE_PREFIX."basiclti_tools WHERE id = ".$tool.";";
-$result = mysql_query($sql, $db) or die(mysql_error());
-$row = mysql_fetch_assoc($result);
-if ( $row['id'] != $tool ) {
- $msg->addFeedback('COULD_NOT_LOAD_TOOL');
- header('Location: '.AT_BASE_HREF.'mods/basiclti/index_admin.php');
- exit;
-}
-
-include(AT_INCLUDE_PATH.'header.inc.php');
-
-$msg->printAll();
-
-?>
-<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" name="basiclti_form" enctype="multipart/form-data">
- <input type="hidden" name="form_basiclti" value="true" />
- <input type="hidden" name="id" value="<?php echo $tool; ?>" />
- <div class="input-form">
- <fieldset class="group_form"><legend class="group_form"><?php echo _AT('properties'); ?></legend>
-<?php at_form_generate($row, $form_create_blti); ?>
- <div class="buttons">
- <input type="submit" name="submit" value="<?php echo _AT('save'); ?>" accesskey="s" />
- <input type="submit" name="cancel" value="<?php echo _AT('cancel');?>" />
- </div>
- </fieldset>
- </div>
-</form>
-
-<?php
-require(AT_INCLUDE_PATH.'footer.inc.php');
+++ /dev/null
-<?php
-define('AT_INCLUDE_PATH', '../../../include/');
-require(AT_INCLUDE_PATH.'vitals.inc.php');
-admin_authenticate(AT_ADMIN_PRIV_BASICLTI);
-
-require('../lib/at_form_util.php');
-require('basic_lti_form.php');
-
-$tool = intval($_REQUEST['id']);
-
-if (isset($_POST['done'])) {
- header('Location: '.AT_BASE_HREF.'mods/basiclti/index_admin.php');
- exit;
-} else if (isset($_POST['form_basiclti'], $tool)) {
-
- if ( at_form_validate($form_create_blti, $msg) ) {
- $sql = "SELECT count(*) cnt FROM ".TABLE_PREFIX."basiclti_tools WHERE toolid = '".
- mysql_real_escape_string($_POST['toolid'])." AND id = $tool';";
- $result = mysql_query($sql, $db) or die(mysql_error());
- $row = mysql_fetch_assoc($result);
-
- if ($row["cnt"] != 0) {
- $msg->addFeedback('NEED_UNIQUE_TOOLID');
- } else {
- $sql = at_form_update($_POST, $form_create_blti);
- $sql = 'UPDATE '.TABLE_PREFIX."basiclti_tools SET ".$sql." WHERE id = $tool;";
- $result = mysql_query($sql, $db) or die(mysql_error());
- write_to_log(AT_ADMIN_LOG_INSERT, 'basiclti_create', mysql_affected_rows($db), $sql);
- $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
- header('Location: '.AT_BASE_HREF.'mods/basiclti/index_admin.php');
- exit;
- }
- }
-}
-
-$sql = "SELECT * FROM ".TABLE_PREFIX."basiclti_tools WHERE id = ".$tool.";";
-$result = mysql_query($sql, $db) or die(mysql_error());
-$row = mysql_fetch_assoc($result);
-if ( $row['id'] != $tool ) {
- $msg->addFeedback('COULD_NOT_LOAD_TOOL');
- header('Location: '.AT_BASE_HREF.'mods/basiclti/index_admin.php');
- exit;
-}
-
-include(AT_INCLUDE_PATH.'header.inc.php');
-
-$msg->printAll();
-
-?>
-<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" name="basiclti_form" enctype="multipart/form-data">
- <input type="hidden" name="form_basiclti" value="true" />
- <input type="hidden" name="id" value="<?php echo $tool; ?>" />
- <div class="input-form">
- <fieldset class="group_form"><legend class="group_form"><?php echo _AT('properties'); ?></legend>
-<?php at_form_view($row, $form_create_blti); ?>
- <div class="buttons">
- <input type="submit" name="done" value="<?php echo _AT('done');?>" />
- </div>
- </fieldset>
- </div>
-</form>
-
-<?php
-require(AT_INCLUDE_PATH.'footer.inc.php');
+++ /dev/null
-Index: docs/themes/default/content.tmpl.php
-===================================================================
---- docs/themes/default/content.tmpl.php (revision 10276)
-+++ docs/themes/default/content.tmpl.php (working copy)
-@@ -95,8 +95,20 @@
- </div>\r
- <?php endif; ?>\r
- \r
-+<?php\r
-+if (!empty($this->proxy_ids)): ?>\r
-+<div id="content-proxy" class="input-form">\r
-+ <strong><?php echo _AT('proxy') . ':' ; ?></strong>\r
-+ <?php\r
-+ foreach ($this->proxy_ids as $id ) {\r
-+ echo '<iframe src="'.AT_BASE_HREF.'mods/basiclti/launch/launch.php?cid='.$id.'" height="1200" width="100%"></iframe>';\r
-+ }\r
-+ ?>\r
-+</div>\r
-+<?php endif; ?>\r
- \r
-+\r
- <div id="content-info">\r
- <?php echo $this->content_info; ?>\r
- \r
--</div>
-\ No newline at end of file
-+</div>\r
-Index: docs/content.php
-===================================================================
---- docs/content.php (revision 10276)
-+++ docs/content.php (working copy)
-@@ -135,6 +135,16 @@
- $content_forum_ids[] = $content_forum_row;
- }
-
-+// For Proxy Tools
-+$content_proxy_ids = array();
-+$sql = "SELECT * FROM ".TABLE_PREFIX."basiclti_content
-+ WHERE content_id=".$cid;
-+$contentresult = mysql_query($sql, $db);
-+$row = mysql_fetch_assoc($contentresult);
-+if ( $row ) {
-+ $content_proxy_ids[] = $cid;
-+}
-+
- // use any styles that were part of the imported document
- // $_custom_css = $_base_href.'headstuff.php?cid='.$cid.SEP.'path='.urlEncode($_base_href.$course_base_href.$content_base_href);
-
-@@ -167,7 +177,7 @@
-
- if ($released_status === TRUE || authenticate(AT_PRIV_CONTENT, AT_PRIV_RETURN)) {
- //if it has test and forum associated with it, still display it even if the content is empty
-- if ($content_row['text'] == '' && (empty($content_test_ids) && empty($content_forum_ids))){
-+ if ($content_row['text'] == '' && (empty($content_proxy_ids) && empty($content_test_ids) && empty($content_forum_ids))){
- $msg->addInfo('NO_PAGE_CONTENT');
- $savant->assign('body', '');
- } else {
-@@ -225,6 +235,8 @@
- $savant->assign('test_message', '');
- $savant->assign('test_ids', array());
- }
-+
-+ $savant->assign('proxy_ids', $content_proxy_ids);
-
- /*TODO***************BOLOGNA***************REMOVE ME**********/
- //assign forum pages if there are forums associated with this content page
-@@ -253,4 +265,4 @@
- $_SESSION['last_visited_page'] = $server_protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
-
- require (AT_INCLUDE_PATH.'footer.inc.php');
--?>
-\ No newline at end of file
-+?>
-Index: docs/mods/_core/editor/editor_tab_functions.inc.php
-===================================================================
---- docs/mods/_core/editor/editor_tab_functions.inc.php (revision 10276)
-+++ docs/mods/_core/editor/editor_tab_functions.inc.php (working copy)
-@@ -35,6 +35,7 @@
- $tabs[3] = array('alternative_content', 'alternatives.inc.php', 'l');
- //Harris: Extended test functionality into content export
- $tabs[4] = array('tests', 'tests.inc.php', 't');
-+ $tabs[5] = array('tools', 'tools.inc.php', 'o');
-
- return $tabs;
- }
-@@ -320,6 +321,29 @@
- }
- }
-
-+ // Add/Update The Tool
-+ if ( isset($_POST['toolid']) ) {
-+ $toolid = $_POST['toolid'];
-+ $sql = "SELECT * FROM ".TABLE_PREFIX."basiclti_content
-+ WHERE content_id=".$_POST[cid];
-+ $result = mysql_query($sql, $db);
-+ if ( $toolid == '--none--' ) {
-+ $sql = "DELETE FROM ". TABLE_PREFIX . "basiclti_content
-+ WHERE content_id=".$_POST[cid];
-+ $result = mysql_query($sql, $db);
-+ } else if ( mysql_num_rows($result) == 0 ) {
-+ $sql = "INSERT INTO ". TABLE_PREFIX . "basiclti_content
-+ SET toolid='".$toolid."', content_id=".$_POST[cid];
-+ $result = mysql_query($sql, $db);
-+ if ($result===false) $msg->addError('MYSQL_FAILED');
-+ } else {
-+ $sql = "UPDATE ". TABLE_PREFIX . "basiclti_content
-+ SET toolid='".$toolid."' WHERE content_id=".$_POST[cid];
-+ $result = mysql_query($sql, $db);
-+ if ($result===false) $msg->addError('MYSQL_FAILED');
-+ }
-+ }
-+
- //TODO*******************BOLOGNA****************REMOVE ME**************/
- if(isset($_SESSION['associated_forum']) && !$msg->containsErrors()){
- if($_SESSION['associated_forum']=='none'){
-Index: docs/include/header.inc.php
-===================================================================
---- docs/include/header.inc.php (revision 10276)
-+++ docs/include/header.inc.php (working copy)
-@@ -100,7 +100,11 @@
- $savant->assign('user_name', _AT('guest'));
- }
-
-+
- if (!isset($_pages[$current_page])) {
-+print_r($_pages);
-+echo($current_page);
-+exit();
- global $msg;
- $msg->addError('PAGE_NOT_FOUND'); // probably the wrong error
- header('location: '.AT_BASE_HREF.'index.php');
+++ /dev/null
-<?php
-
-define('AT_BL_BASENAME', 'mods/basiclti/');
-define('AT_BL_BASE', AT_INCLUDE_PATH.'../mods/basiclti/');
-define('AT_BL_INCLUDE', AT_BL_BASE.'include/');
-define('AT_BL_CONTENT_DIR', AT_CONTENT_DIR.'basiclti/');
-?>
+++ /dev/null
-<?php
-define('AT_INCLUDE_PATH', '../../include/');
-require (AT_INCLUDE_PATH.'vitals.inc.php');
-$_custom_css = $_base_path . 'mods/basiclti/module.css'; // use a custom stylesheet
-require (AT_INCLUDE_PATH.'header.inc.php');
-?>
-
-<div id="helloworld">
- Hello Student!! :)
-</div>
-
-<?php require (AT_INCLUDE_PATH.'footer.inc.php'); ?>
+++ /dev/null
-<?php
-define('AT_INCLUDE_PATH', '../../include/');
-require (AT_INCLUDE_PATH.'vitals.inc.php');
-admin_authenticate(AT_ADMIN_PRIV_BASICLTI);
-
-if (isset($_GET['view'], $_GET['id'])) {
- header('Location: admin/view_tool.php?id='.$_GET['id']);
- exit;
-} else if (isset($_GET['edit'], $_GET['id'])) {
- header('Location: admin/edit_tool.php?id='.$_GET['id']);
- exit;
-} else if (isset($_GET['delete'], $_GET['id'])) {
- header('Location: admin/delete_tool.php?id='.$_GET['id']);
- exit;
-}
-
-require (AT_INCLUDE_PATH.'header.inc.php');
-
-$sql = "SELECT id,title,toolid,course_id,description FROM ".TABLE_PREFIX."basiclti_tools WHERE course_id = 0 ORDER BY TITLE";
-$result = mysql_query($sql, $db) or die(mysql_error());
-?>
-<form name="form" method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
-<table class="data static" summary="" rules="all">
- <thead>
- <th> </th>
- <th><?php echo _AT('bl_title'); ?></th>
- <th><?php echo _AT('bl_toolid'); ?></th>
- <th><?php echo _AT('bl_description'); ?></th>
- </thead>
- <tfoot>
- <tr>
- <td colspan="4"><input type="submit" name="view" value="<?php echo _AT('view'); ?>" />
- <input type="submit" name="edit" value="<?php echo _AT('edit'); ?>" />
- <input type="submit" name="delete" value="<?php echo _AT('delete'); ?>" /></td>
- </tr>
- </tfoot>
- <tbody>
- <?php while($row = mysql_fetch_array($result)) { ?><tr>
- <td><input type="radio" name="id" value="<?php echo $row['id']; ?>" id="m<?php echo $row['id']; ?>" /></td>
- <td><?php echo $row['title']; ?></td>
- <td><?php echo $row['toolid']; ?></td>
- <td><?php echo $row['description']; ?></td>
- </tr> <?php } ?>
- </tbody>
-</table>
-</form>
-<?php
-include(AT_INCLUDE_PATH.'footer.inc.php');
-?>
+++ /dev/null
-<?php
-define('AT_INCLUDE_PATH', '../../include/');
-require (AT_INCLUDE_PATH.'vitals.inc.php');
-authenticate(AT_PRIV_BASICLTI);
-require (AT_INCLUDE_PATH.'header.inc.php');
-?>
-
-Hello Instructor!! :)
-
-<?php require (AT_INCLUDE_PATH.'footer.inc.php'); ?>
+++ /dev/null
-<?php
-$_user_location = 'users';
-define('AT_INCLUDE_PATH', '../../include/');
-require (AT_INCLUDE_PATH.'vitals.inc.php');
-$_custom_css = $_base_path . 'mods/basiclti/module.css'; // use a custom stylesheet
-require (AT_INCLUDE_PATH.'header.inc.php');
-?>
-
-<div id="helloworld">
- This is a page of the Hello World module that requires a login session, but might contain a tool that is not a course tool :)
-</div>
-
-<?php require (AT_INCLUDE_PATH.'footer.inc.php'); ?>
+++ /dev/null
-<?php
-
-$_user_location = 'public';
-
-define('AT_INCLUDE_PATH', '../../include/');
-require (AT_INCLUDE_PATH.'vitals.inc.php');
-$_custom_css = $_base_path . 'mods/basiclti/module.css'; // use a custom stylesheet
-require (AT_INCLUDE_PATH.'header.inc.php');
-?>
-
-<div id="helloworld">
- This is a public page from the Hello World module, that does not require a login session to view. :)
-</div>
-
-<?php require (AT_INCLUDE_PATH.'footer.inc.php'); ?>
+++ /dev/null
-The MIT License
-
-Copyright (c) 2007 Andy Smith
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-
+++ /dev/null
-<?php
-// vim: foldmethod=marker
-
-$OAuth_last_computed_siguature = false;
-
-/* Generic exception class
- */
-class OAuthException extends Exception {
- // pass
-}
-
-class OAuthConsumer {
- public $key;
- public $secret;
-
- function __construct($key, $secret, $callback_url=NULL) {
- $this->key = $key;
- $this->secret = $secret;
- $this->callback_url = $callback_url;
- }
-
- function __toString() {
- return "OAuthConsumer[key=$this->key,secret=$this->secret]";
- }
-}
-
-class OAuthToken {
- // access tokens and request tokens
- public $key;
- public $secret;
-
- /**
- * key = the token
- * secret = the token secret
- */
- function __construct($key, $secret) {
- $this->key = $key;
- $this->secret = $secret;
- }
-
- /**
- * generates the basic string serialization of a token that a server
- * would respond to request_token and access_token calls with
- */
- function to_string() {
- return "oauth_token=" .
- OAuthUtil::urlencode_rfc3986($this->key) .
- "&oauth_token_secret=" .
- OAuthUtil::urlencode_rfc3986($this->secret);
- }
-
- function __toString() {
- return $this->to_string();
- }
-}
-
-class OAuthSignatureMethod {
- public function check_signature(&$request, $consumer, $token, $signature) {
- $built = $this->build_signature($request, $consumer, $token);
- return $built == $signature;
- }
-}
-
-class OAuthSignatureMethod_HMAC_SHA1 extends OAuthSignatureMethod {
- function get_name() {
- return "HMAC-SHA1";
- }
-
- public function build_signature($request, $consumer, $token) {
- global $OAuth_last_computed_signature;
- $OAuth_last_computed_signature = false;
-
- $base_string = $request->get_signature_base_string();
- $request->base_string = $base_string;
-
- $key_parts = array(
- $consumer->secret,
- ($token) ? $token->secret : ""
- );
-
- $key_parts = OAuthUtil::urlencode_rfc3986($key_parts);
- $key = implode('&', $key_parts);
-
- $computed_signature = base64_encode(hash_hmac('sha1', $base_string, $key, true));
- $OAuth_last_computed_signature = $computed_signature;
- return $computed_signature;
- }
-
-}
-
-class OAuthSignatureMethod_PLAINTEXT extends OAuthSignatureMethod {
- public function get_name() {
- return "PLAINTEXT";
- }
-
- public function build_signature($request, $consumer, $token) {
- $sig = array(
- OAuthUtil::urlencode_rfc3986($consumer->secret)
- );
-
- if ($token) {
- array_push($sig, OAuthUtil::urlencode_rfc3986($token->secret));
- } else {
- array_push($sig, '');
- }
-
- $raw = implode("&", $sig);
- // for debug purposes
- $request->base_string = $raw;
-
- return OAuthUtil::urlencode_rfc3986($raw);
- }
-}
-
-class OAuthSignatureMethod_RSA_SHA1 extends OAuthSignatureMethod {
- public function get_name() {
- return "RSA-SHA1";
- }
-
- protected function fetch_public_cert(&$request) {
- // not implemented yet, ideas are:
- // (1) do a lookup in a table of trusted certs keyed off of consumer
- // (2) fetch via http using a url provided by the requester
- // (3) some sort of specific discovery code based on request
- //
- // either way should return a string representation of the certificate
- throw Exception("fetch_public_cert not implemented");
- }
-
- protected function fetch_private_cert(&$request) {
- // not implemented yet, ideas are:
- // (1) do a lookup in a table of trusted certs keyed off of consumer
- //
- // either way should return a string representation of the certificate
- throw Exception("fetch_private_cert not implemented");
- }
-
- public function build_signature(&$request, $consumer, $token) {
- $base_string = $request->get_signature_base_string();
- $request->base_string = $base_string;
-
- // Fetch the private key cert based on the request
- $cert = $this->fetch_private_cert($request);
-
- // Pull the private key ID from the certificate
- $privatekeyid = openssl_get_privatekey($cert);
-
- // Sign using the key
- $ok = openssl_sign($base_string, $signature, $privatekeyid);
-
- // Release the key resource
- openssl_free_key($privatekeyid);
-
- return base64_encode($signature);
- }
-
- public function check_signature(&$request, $consumer, $token, $signature) {
- $decoded_sig = base64_decode($signature);
-
- $base_string = $request->get_signature_base_string();
-
- // Fetch the public key cert based on the request
- $cert = $this->fetch_public_cert($request);
-
- // Pull the public key ID from the certificate
- $publickeyid = openssl_get_publickey($cert);
-
- // Check the computed signature against the one passed in the query
- $ok = openssl_verify($base_string, $decoded_sig, $publickeyid);
-
- // Release the key resource
- openssl_free_key($publickeyid);
-
- return $ok == 1;
- }
-}
-
-class OAuthRequest {
- private $parameters;
- private $http_method;
- private $http_url;
- // for debug purposes
- public $base_string;
- public static $version = '1.0';
- public static $POST_INPUT = 'php://input';
-
- function __construct($http_method, $http_url, $parameters=NULL) {
- @$parameters or $parameters = array();
- $this->parameters = $parameters;
- $this->http_method = $http_method;
- $this->http_url = $http_url;
- }
-
-
- /**
- * attempt to build up a request from what was passed to the server
- */
- public static function from_request($http_method=NULL, $http_url=NULL, $parameters=NULL) {
- $scheme = (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != "on")
- ? 'http'
- : 'https';
- $port = "";
- if ( $_SERVER['SERVER_PORT'] != "80" && $_SERVER['SERVER_PORT'] != "443" &&
- strpos(':', $_SERVER['HTTP_HOST']) < 0 ) {
- $port = ':' . $_SERVER['SERVER_PORT'] ;
- }
- @$http_url or $http_url = $scheme .
- '://' . $_SERVER['HTTP_HOST'] .
- $port .
- $_SERVER['REQUEST_URI'];
- @$http_method or $http_method = $_SERVER['REQUEST_METHOD'];
-
- // We weren't handed any parameters, so let's find the ones relevant to
- // this request.
- // If you run XML-RPC or similar you should use this to provide your own
- // parsed parameter-list
- if (!$parameters) {
- // Find request headers
- $request_headers = OAuthUtil::get_headers();
-
- // Parse the query-string to find GET parameters
- $parameters = OAuthUtil::parse_parameters($_SERVER['QUERY_STRING']);
-
- $ourpost = $_POST;
- // Deal with magic_quotes
- // http://www.php.net/manual/en/security.magicquotes.disabling.php
- if ( get_magic_quotes_gpc() ) {
- $outpost = array();
- foreach ($_POST as $k => $v) {
- $v = stripslashes($v);
- $ourpost[$k] = $v;
- }
- }
- // Add POST Parameters if they exist
- $parameters = array_merge($parameters, $ourpost);
-
- // We have a Authorization-header with OAuth data. Parse the header
- // and add those overriding any duplicates from GET or POST
- if (@substr($request_headers['Authorization'], 0, 6) == "OAuth ") {
- $header_parameters = OAuthUtil::split_header(
- $request_headers['Authorization']
- );
- $parameters = array_merge($parameters, $header_parameters);
- }
-
- }
-
- return new OAuthRequest($http_method, $http_url, $parameters);
- }
-
- /**
- * pretty much a helper function to set up the request
- */
- public static function from_consumer_and_token($consumer, $token, $http_method, $http_url, $parameters=NULL) {
- @$parameters or $parameters = array();
- $defaults = array("oauth_version" => OAuthRequest::$version,
- "oauth_nonce" => OAuthRequest::generate_nonce(),
- "oauth_timestamp" => OAuthRequest::generate_timestamp(),
- "oauth_consumer_key" => $consumer->key);
- if ($token)
- $defaults['oauth_token'] = $token->key;
-
- $parameters = array_merge($defaults, $parameters);
-
- // Parse the query-string to find and add GET parameters
- $parts = parse_url($http_url);
- if ( $parts['query'] ) {
- $qparms = OAuthUtil::parse_parameters($parts['query']);
- $parameters = array_merge($qparms, $parameters);
- }
-
-
- return new OAuthRequest($http_method, $http_url, $parameters);
- }
-
- public function set_parameter($name, $value, $allow_duplicates = true) {
- if ($allow_duplicates && isset($this->parameters[$name])) {
- // We have already added parameter(s) with this name, so add to the list
- if (is_scalar($this->parameters[$name])) {
- // This is the first duplicate, so transform scalar (string)
- // into an array so we can add the duplicates
- $this->parameters[$name] = array($this->parameters[$name]);
- }
-
- $this->parameters[$name][] = $value;
- } else {
- $this->parameters[$name] = $value;
- }
- }
-
- public function get_parameter($name) {
- return isset($this->parameters[$name]) ? $this->parameters[$name] : null;
- }
-
- public function get_parameters() {
- return $this->parameters;
- }
-
- public function unset_parameter($name) {
- unset($this->parameters[$name]);
- }
-
- /**
- * The request parameters, sorted and concatenated into a normalized string.
- * @return string
- */
- public function get_signable_parameters() {
- // Grab all parameters
- $params = $this->parameters;
-
- // Remove oauth_signature if present
- // Ref: Spec: 9.1.1 ("The oauth_signature parameter MUST be excluded.")
- if (isset($params['oauth_signature'])) {
- unset($params['oauth_signature']);
- }
-
- return OAuthUtil::build_http_query($params);
- }
-
- /**
- * Returns the base string of this request
- *
- * The base string defined as the method, the url
- * and the parameters (normalized), each urlencoded
- * and the concated with &.
- */
- public function get_signature_base_string() {
- $parts = array(
- $this->get_normalized_http_method(),
- $this->get_normalized_http_url(),
- $this->get_signable_parameters()
- );
-
- $parts = OAuthUtil::urlencode_rfc3986($parts);
-
- return implode('&', $parts);
- }
-
- /**
- * just uppercases the http method
- */
- public function get_normalized_http_method() {
- return strtoupper($this->http_method);
- }
-
- /**
- * parses the url and rebuilds it to be
- * scheme://host/path
- */
- public function get_normalized_http_url() {
- $parts = parse_url($this->http_url);
-
- $port = @$parts['port'];
- $scheme = $parts['scheme'];
- $host = $parts['host'];
- $path = @$parts['path'];
-
- $port or $port = ($scheme == 'https') ? '443' : '80';
-
- if (($scheme == 'https' && $port != '443')
- || ($scheme == 'http' && $port != '80')) {
- $host = "$host:$port";
- }
- return "$scheme://$host$path";
- }
-
- /**
- * builds a url usable for a GET request
- */
- public function to_url() {
- $post_data = $this->to_postdata();
- $out = $this->get_normalized_http_url();
- if ($post_data) {
- $out .= '?'.$post_data;
- }
- return $out;
- }
-
- /**
- * builds the data one would send in a POST request
- */
- public function to_postdata() {
- return OAuthUtil::build_http_query($this->parameters);
- }
-
- /**
- * builds the Authorization: header
- */
- public function to_header() {
- $out ='Authorization: OAuth realm=""';
- $total = array();
- foreach ($this->parameters as $k => $v) {
- if (substr($k, 0, 5) != "oauth") continue;
- if (is_array($v)) {
- throw new OAuthException('Arrays not supported in headers');
- }
- $out .= ',' .
- OAuthUtil::urlencode_rfc3986($k) .
- '="' .
- OAuthUtil::urlencode_rfc3986($v) .
- '"';
- }
- return $out;
- }
-
- public function __toString() {
- return $this->to_url();
- }
-
-
- public function sign_request($signature_method, $consumer, $token) {
- $this->set_parameter(
- "oauth_signature_method",
- $signature_method->get_name(),
- false
- );
- $signature = $this->build_signature($signature_method, $consumer, $token);
- $this->set_parameter("oauth_signature", $signature, false);
- }
-
- public function build_signature($signature_method, $consumer, $token) {
- $signature = $signature_method->build_signature($this, $consumer, $token);
- return $signature;
- }
-
- /**
- * util function: current timestamp
- */
- private static function generate_timestamp() {
- return time();
- }
-
- /**
- * util function: current nonce
- */
- private static function generate_nonce() {
- $mt = microtime();
- $rand = mt_rand();
-
- return md5($mt . $rand); // md5s look nicer than numbers
- }
-}
-
-class OAuthServer {
- protected $timestamp_threshold = 300; // in seconds, five minutes
- protected $version = 1.0; // hi blaine
- protected $signature_methods = array();
-
- protected $data_store;
-
- function __construct($data_store) {
- $this->data_store = $data_store;
- }
-
- public function add_signature_method($signature_method) {
- $this->signature_methods[$signature_method->get_name()] =
- $signature_method;
- }
-
- // high level functions
-
- /**
- * process a request_token request
- * returns the request token on success
- */
- public function fetch_request_token(&$request) {
- $this->get_version($request);
-
- $consumer = $this->get_consumer($request);
-
- // no token required for the initial token request
- $token = NULL;
-
- $this->check_signature($request, $consumer, $token);
-
- $new_token = $this->data_store->new_request_token($consumer);
-
- return $new_token;
- }
-
- /**
- * process an access_token request
- * returns the access token on success
- */
- public function fetch_access_token(&$request) {
- $this->get_version($request);
-
- $consumer = $this->get_consumer($request);
-
- // requires authorized request token
- $token = $this->get_token($request, $consumer, "request");
-
-
- $this->check_signature($request, $consumer, $token);
-
- $new_token = $this->data_store->new_access_token($token, $consumer);
-
- return $new_token;
- }
-
- /**
- * verify an api call, checks all the parameters
- */
- public function verify_request(&$request) {
- global $OAuth_last_computed_signature;
- $OAuth_last_computed_signature = false;
- $this->get_version($request);
- $consumer = $this->get_consumer($request);
- $token = $this->get_token($request, $consumer, "access");
- $this->check_signature($request, $consumer, $token);
- return array($consumer, $token);
- }
-
- // Internals from here
- /**
- * version 1
- */
- private function get_version(&$request) {
- $version = $request->get_parameter("oauth_version");
- if (!$version) {
- $version = 1.0;
- }
- if ($version && $version != $this->version) {
- throw new OAuthException("OAuth version '$version' not supported");
- }
- return $version;
- }
-
- /**
- * figure out the signature with some defaults
- */
- private function get_signature_method(&$request) {
- $signature_method =
- @$request->get_parameter("oauth_signature_method");
- if (!$signature_method) {
- $signature_method = "PLAINTEXT";
- }
- if (!in_array($signature_method,
- array_keys($this->signature_methods))) {
- throw new OAuthException(
- "Signature method '$signature_method' not supported " .
- "try one of the following: " .
- implode(", ", array_keys($this->signature_methods))
- );
- }
- return $this->signature_methods[$signature_method];
- }
-
- /**
- * try to find the consumer for the provided request's consumer key
- */
- private function get_consumer(&$request) {
- $consumer_key = @$request->get_parameter("oauth_consumer_key");
- if (!$consumer_key) {
- throw new OAuthException("Invalid consumer key");
- }
-
- $consumer = $this->data_store->lookup_consumer($consumer_key);
- if (!$consumer) {
- throw new OAuthException("Invalid consumer");
- }
-
- return $consumer;
- }
-
- /**
- * try to find the token for the provided request's token key
- */
- private function get_token(&$request, $consumer, $token_type="access") {
- $token_field = @$request->get_parameter('oauth_token');
- if ( !$token_field) return false;
- $token = $this->data_store->lookup_token(
- $consumer, $token_type, $token_field
- );
- if (!$token) {
- throw new OAuthException("Invalid $token_type token: $token_field");
- }
- return $token;
- }
-
- /**
- * all-in-one function to check the signature on a request
- * should guess the signature method appropriately
- */
- private function check_signature(&$request, $consumer, $token) {
- // this should probably be in a different method
- global $OAuth_last_computed_signature;
- $OAuth_last_computed_signature = false;
-
- $timestamp = @$request->get_parameter('oauth_timestamp');
- $nonce = @$request->get_parameter('oauth_nonce');
-
- $this->check_timestamp($timestamp);
- $this->check_nonce($consumer, $token, $nonce, $timestamp);
-
- $signature_method = $this->get_signature_method($request);
-
- $signature = $request->get_parameter('oauth_signature');
- $valid_sig = $signature_method->check_signature(
- $request,
- $consumer,
- $token,
- $signature
- );
-
- if (!$valid_sig) {
- $ex_text = "Invalid signature";
- if ( $OAuth_last_computed_signature ) {
- $ex_text = $ex_text . " ours= $OAuth_last_computed_signature yours=$signature";
- }
- throw new OAuthException($ex_text);
- }
- }
-
- /**
- * check that the timestamp is new enough
- */
- private function check_timestamp($timestamp) {
- // verify that timestamp is recentish
- $now = time();
- if ($now - $timestamp > $this->timestamp_threshold) {
- throw new OAuthException(
- "Expired timestamp, yours $timestamp, ours $now"
- );
- }
- }
-
- /**
- * check that the nonce is not repeated
- */
- private function check_nonce($consumer, $token, $nonce, $timestamp) {
- // verify that the nonce is uniqueish
- $found = $this->data_store->lookup_nonce(
- $consumer,
- $token,
- $nonce,
- $timestamp
- );
- if ($found) {
- throw new OAuthException("Nonce already used: $nonce");
- }
- }
-
-}
-
-class OAuthDataStore {
- function lookup_consumer($consumer_key) {
- // implement me
- }
-
- function lookup_token($consumer, $token_type, $token) {
- // implement me
- }
-
- function lookup_nonce($consumer, $token, $nonce, $timestamp) {
- // implement me
- }
-
- function new_request_token($consumer) {
- // return a new token attached to this consumer
- }
-
- function new_access_token($token, $consumer) {
- // return a new access token attached to this consumer
- // for the user associated with this token if the request token
- // is authorized
- // should also invalidate the request token
- }
-
-}
-
-class OAuthUtil {
- public static function urlencode_rfc3986($input) {
- if (is_array($input)) {
- return array_map(array('OAuthUtil', 'urlencode_rfc3986'), $input);
- } else if (is_scalar($input)) {
- return str_replace(
- '+',
- ' ',
- str_replace('%7E', '~', rawurlencode($input))
- );
- } else {
- return '';
- }
-}
-
-
- // This decode function isn't taking into consideration the above
- // modifications to the encoding process. However, this method doesn't
- // seem to be used anywhere so leaving it as is.
- public static function urldecode_rfc3986($string) {
- return urldecode($string);
- }
-
- // Utility function for turning the Authorization: header into
- // parameters, has to do some unescaping
- // Can filter out any non-oauth parameters if needed (default behaviour)
- public static function split_header($header, $only_allow_oauth_parameters = true) {
- $pattern = '/(([-_a-z]*)=("([^"]*)"|([^,]*)),?)/';
- $offset = 0;
- $params = array();
- while (preg_match($pattern, $header, $matches, PREG_OFFSET_CAPTURE, $offset) > 0) {
- $match = $matches[0];
- $header_name = $matches[2][0];
- $header_content = (isset($matches[5])) ? $matches[5][0] : $matches[4][0];
- if (preg_match('/^oauth_/', $header_name) || !$only_allow_oauth_parameters) {
- $params[$header_name] = OAuthUtil::urldecode_rfc3986($header_content);
- }
- $offset = $match[1] + strlen($match[0]);
- }
-
- if (isset($params['realm'])) {
- unset($params['realm']);
- }
-
- return $params;
- }
-
- // helper to try to sort out headers for people who aren't running apache
- public static function get_headers() {
- if (function_exists('apache_request_headers')) {
- // we need this to get the actual Authorization: header
- // because apache tends to tell us it doesn't exist
- return apache_request_headers();
- }
- // otherwise we don't have apache and are just going to have to hope
- // that $_SERVER actually contains what we need
- $out = array();
- foreach ($_SERVER as $key => $value) {
- if (substr($key, 0, 5) == "HTTP_") {
- // this is chaos, basically it is just there to capitalize the first
- // letter of every word that is not an initial HTTP and strip HTTP
- // code from przemek
- $key = str_replace(
- " ",
- "-",
- ucwords(strtolower(str_replace("_", " ", substr($key, 5))))
- );
- $out[$key] = $value;
- }
- }
- return $out;
- }
-
- // This function takes a input like a=b&a=c&d=e and returns the parsed
- // parameters like this
- // array('a' => array('b','c'), 'd' => 'e')
- public static function parse_parameters( $input ) {
- if (!isset($input) || !$input) return array();
-
- $pairs = split('&', $input);
-
- $parsed_parameters = array();
- foreach ($pairs as $pair) {
- $split = split('=', $pair, 2);
- $parameter = OAuthUtil::urldecode_rfc3986($split[0]);
- $value = isset($split[1]) ? OAuthUtil::urldecode_rfc3986($split[1]) : '';
-
- if (isset($parsed_parameters[$parameter])) {
- // We have already recieved parameter(s) with this name, so add to the list
- // of parameters with this name
-
- if (is_scalar($parsed_parameters[$parameter])) {
- // This is the first duplicate, so transform scalar (string) into an array
- // so we can add the duplicates
- $parsed_parameters[$parameter] = array($parsed_parameters[$parameter]);
- }
-
- $parsed_parameters[$parameter][] = $value;
- } else {
- $parsed_parameters[$parameter] = $value;
- }
- }
- return $parsed_parameters;
- }
-
- public static function build_http_query($params) {
- if (!$params) return '';
-
- // Urlencode both keys and values
- $keys = OAuthUtil::urlencode_rfc3986(array_keys($params));
- $values = OAuthUtil::urlencode_rfc3986(array_values($params));
- $params = array_combine($keys, $values);
-
- // Parameters are sorted by name, using lexicographical byte value ordering.
- // Ref: Spec: 9.1.1 (1)
- uksort($params, 'strcmp');
-
- $pairs = array();
- foreach ($params as $parameter => $value) {
- if (is_array($value)) {
- // If two or more parameters share the same name, they are sorted by their value
- // Ref: Spec: 9.1.1 (1)
- natsort($value);
- foreach ($value as $duplicate_value) {
- $pairs[] = $parameter . '=' . $duplicate_value;
- }
- } else {
- $pairs[] = $parameter . '=' . $value;
- }
- }
- // For each parameter, the name is separated from the corresponding value by an '=' character (ASCII code 61)
- // Each name-value pair is separated by an '&' character (ASCII code 38)
- return implode('&', $pairs);
- }
-}
-
-?>
+++ /dev/null
-<?php
-
-require_once 'OAuth.php';
-
-// Returns true if this is a Basic LTI message
-// with minimum values to meet the protocol
-function is_basic_lti_request() {
- $good_message_type = $_REQUEST["lti_message_type"] == "basic-lti-launch-request";
- $good_lti_version = $_REQUEST["lti_version"] == "LTI-1p0";
- $resource_link_id = $_REQUEST["resource_link_id"];
- if ($good_message_type and $good_lti_version and isset($resource_link_id) ) return(true);
- return false;
-}
-
-/**
- * A Trivial memory-based store - no support for tokens
- */
-class TrivialOAuthDataStore extends OAuthDataStore {
- private $consumers = array();
-
- function add_consumer($consumer_key, $consumer_secret) {
- $this->consumers[$consumer_key] = $consumer_secret;
- }
-
- function lookup_consumer($consumer_key) {
- if ( strpos($consumer_key, "http://" ) === 0 ) {
- $consumer = new OAuthConsumer($consumer_key,"secret", NULL);
- return $consumer;
- }
- if ( $this->consumers[$consumer_key] ) {
- $consumer = new OAuthConsumer($consumer_key,$this->consumers[$consumer_key], NULL);
- return $consumer;
- }
- return NULL;
- }
-
- function lookup_token($consumer, $token_type, $token) {
- return new OAuthToken($consumer, "");
- }
-
- // Return NULL if the nonce has not been used
- // Return $nonce if the nonce was previously used
- function lookup_nonce($consumer, $token, $nonce, $timestamp) {
- // Should add some clever logic to keep nonces from
- // being reused - for no we are really trusting
- // that the timestamp will save us
- return NULL;
- }
-
- function new_request_token($consumer) {
- return NULL;
- }
-
- function new_access_token($token, $consumer) {
- return NULL;
- }
-}
-
-
-// Basic LTI Class that does the setup and provides utility
-// functions
-class BLTI {
-
- public $valid = false;
- public $complete = false;
- public $message = false;
- public $basestring = false;
- public $info = false;
- public $row = false;
- public $context_id = false; // Override context_id
-
- function __construct($parm=false, $usesession=true, $doredirect=true) {
-
- // If this request is not an LTI Launch, either
- // give up or try to retrieve the context from session
- if ( ! is_basic_lti_request() ) {
- if ( $usesession === false ) return;
- if ( strlen(session_id()) > 0 ) {
- $row = $_SESSION['_basiclti_lti_row'];
- if ( isset($row) ) $this->row = $row;
- $context_id = $_SESSION['_basiclti_lti_context_id'];
- if ( isset($context_id) ) $this->context_id = $context_id;
- $info = $_SESSION['_basic_lti_context'];
- if ( isset($info) ) {
- $this->info = $info;
- $this->valid = true;
- return;
- }
- $this->message = "Could not find context in session";
- return;
- }
- $this->message = "Session not available";
- return;
- }
-
- // Insure we have a valid launch
- if ( empty($_REQUEST["oauth_consumer_key"]) ) {
- $this->message = "Missing oauth_consumer_key in request";
- return;
- }
- $oauth_consumer_key = $_REQUEST["oauth_consumer_key"];
-
- // Find the secret - either form the parameter as a string or
- // look it up in a database from parameters we are given
- $secret = false;
- $row = false;
- if ( is_string($parm) ) {
- $secret = $parm;
- } else if ( ! is_array($parm) ) {
- $this->message = "Constructor requires a secret or database information.";
- return;
- } else {
- $sql = 'SELECT * FROM '.$parm['table'].' WHERE '.
- ($parm['key_column'] ? $parm['key_column'] : 'oauth_consumer_key').
- '='.
- "'".mysql_real_escape_string($oauth_consumer_key)."'";
- $result = mysql_query($sql);
- $num_rows = mysql_num_rows($result);
- if ( $num_rows != 1 ) {
- $this->message = "Your consumer is not authorized oauth_consumer_key=".$oauth_consumer_key;
- return;
- } else {
- while ($row = mysql_fetch_assoc($result)) {
- $secret = $row[$parms['secret_column']?$parms['secret_column']:'secret'];
- $context_id = $row[$parms['context_column']?$parms['context_column']:'context_id'];
- if ( $context_id ) $this->context_id = $context_id;
- $this->row = $row;
- break;
- }
- if ( ! is_string($secret) ) {
- $this->message = "Could not retrieve secret oauth_consumer_key=".$oauth_consumer_key;
- return;
- }
- }
- }
-
- // Verify the message signature
- $store = new TrivialOAuthDataStore();
- $store->add_consumer($oauth_consumer_key, $secret);
-
- $server = new OAuthServer($store);
-
- $method = new OAuthSignatureMethod_HMAC_SHA1();
- $server->add_signature_method($method);
- $request = OAuthRequest::from_request();
-
- $this->basestring = $request->get_signature_base_string();
-
- try {
- $server->verify_request($request);
- $this->valid = true;
- } catch (Exception $e) {
- $this->message = $e->getMessage();
- return;
- }
-
- // Store the launch information in the session for later
- $newinfo = array();
- foreach($_POST as $key => $value ) {
- if ( $key == "basiclti_submit" ) continue;
- if ( strpos($key, "oauth_") === false ) {
- $newinfo[$key] = $value;
- continue;
- }
- if ( $key == "oauth_consumer_key" ) {
- $newinfo[$key] = $value;
- continue;
- }
- }
-
- $this->info = $newinfo;
- if ( $usesession == true and strlen(session_id()) > 0 ) {
- $_SESSION['_basic_lti_context'] = $this->info;
- unset($_SESSION['_basiclti_lti_row']);
- unset($_SESSION['_basiclti_lti_context_id']);
- if ( $this->row ) $_SESSION['_basiclti_lti_row'] = $this->row;
- if ( $this->context_id ) $_SESSION['_basiclti_lti_context_id'] = $this->context_id;
- }
-
- if ( $this->valid && $doredirect ) {
- $this->redirect();
- $this->complete = true;
- }
- }
-
- function addSession($location) {
- if ( ini_get('session.use_cookies') == 0 ) {
- if ( strpos($location,'?') > 0 ) {
- $location = $location . '&';
- } else {
- $location = $location . '?';
- }
- $location = $location . session_name() . '=' . session_id();
- }
- return $location;
- }
-
- function isInstructor() {
- $roles = $this->info['roles'];
- $roles = strtolower($roles);
- if ( ! ( strpos($roles,"instructor") === false ) ) return true;
- if ( ! ( strpos($roles,"administrator") === false ) ) return true;
- return false;
- }
-
- function getUserEmail() {
- $email = $this->info['lis_person_contact_email_primary'];
- if ( strlen($email) > 0 ) return $email;
- # Sakai Hack
- $email = $this->info['lis_person_contact_emailprimary'];
- if ( strlen($email) > 0 ) return $email;
- return false;
- }
-
- function getUserShortName() {
- $email = $this->getUserEmail();
- $givenname = $this->info['lis_person_name_given'];
- $familyname = $this->info['lis_person_name_family'];
- $fullname = $this->info['lis_person_name_full'];
- if ( strlen($email) > 0 ) return $email;
- if ( strlen($givenname) > 0 ) return $givenname;
- if ( strlen($familyname) > 0 ) return $familyname;
- return $this->getUserName();
- }
-
- function getUserName() {
- $givenname = $this->info['lis_person_name_given'];
- $familyname = $this->info['lis_person_name_family'];
- $fullname = $this->info['lis_person_name_full'];
- if ( strlen($fullname) > 0 ) return $fullname;
- if ( strlen($familyname) > 0 and strlen($givenname) > 0 ) return $givenname + $familyname;
- if ( strlen($givenname) > 0 ) return $givenname;
- if ( strlen($familyname) > 0 ) return $familyname;
- return $this->getUserEmail();
- }
-
- function getUserKey() {
- $oauth = $this->info['oauth_consumer_key'];
- $id = $this->info['user_id'];
- if ( strlen($id) > 0 and strlen($oauth) > 0 ) return $oauth . ':' . $id;
- return false;
- }
-
- function getUserImage() {
- $image = $this->info['user_image'];
- if ( strlen($image) > 0 ) return $image;
- $email = $this->getUserEmail();
- if ( $email === false ) return false;
- $size = 40;
- $grav_url = $_SERVER['HTTPS'] ? 'https://' : 'http://';
- $grav_url = $grav_url . "www.gravatar.com/avatar.php?gravatar_id=".md5( strtolower($email) )."&size=".$size;
- return $grav_url;
- }
-
- function getResourceKey() {
- $oauth = $this->info['oauth_consumer_key'];
- $id = $this->info['resource_link_id'];
- if ( strlen($id) > 0 and strlen($oauth) > 0 ) return $oauth . ':' . $id;
- return false;
- }
-
- function getResourceTitle() {
- $title = $this->info['resource_link_title'];
- if ( strlen($title) > 0 ) return $title;
- return false;
- }
-
- function getConsumerKey() {
- $oauth = $this->info['oauth_consumer_key'];
- return $oauth;
- }
-
- function getCourseKey() {
- if ( $this->context_id ) return $this->context_id;
- $oauth = $this->info['oauth_consumer_key'];
- $id = $this->info['context_id'];
- if ( strlen($id) > 0 and strlen($oauth) > 0 ) return $oauth . ':' . $id;
- return false;
- }
-
- function getCourseName() {
- $label = $this->info['context_label'];
- $title = $this->info['context_title'];
- $id = $this->info['context_id'];
- if ( strlen($label) > 0 ) return $label;
- if ( strlen($title) > 0 ) return $title;
- if ( strlen($id) > 0 ) return $id;
- return false;
- }
-
- // TODO: Add javasript version if headers are already sent
- function redirect() {
- $host = $_SERVER['HTTP_HOST'];
- $uri = $_SERVER['PHP_SELF'];
- $location = $_SERVER['HTTPS'] ? 'https://' : 'http://';
- $location = $location . $host . $uri;
- $location = $this->addSession($location);
- header("Location: $location");
- }
-
- function dump() {
- if ( ! $this->valid or $this->info == false ) return "Context not valid\n";
- $ret = "";
- if ( $this->isInstructor() ) {
- $ret .= "isInstructor() = true\n";
- } else {
- $ret .= "isInstructor() = false\n";
- }
- $ret .= "getUserKey() = ".$this->getUserKey()."\n";
- $ret .= "getUserEmail() = ".$this->getUserEmail()."\n";
- $ret .= "getUserShortName() = ".$this->getUserShortName()."\n";
- $ret .= "getUserName() = ".$this->getUserName()."\n";
- $ret .= "getUserImage() = ".$this->getUserImage()."\n";
- $ret .= "getResourceKey() = ".$this->getResourceKey()."\n";
- $ret .= "getResourceTitle() = ".$this->getResourceTitle()."\n";
- $ret .= "getCourseName() = ".$this->getCourseName()."\n";
- $ret .= "getCourseKey() = ".$this->getCourseKey()."\n";
- $ret .= "getConsumerKey() = ".$this->getConsumerKey()."\n";
- return $ret;
- }
-
-}
-
-?>
+++ /dev/null
-<?php
-
-require_once 'OAuth.php';
-
- // Replace this with some real function that pulls from the LMS.
- function getLMSDummyData() {
- $parms = array(
- "resource_link_id" => "120988f929-274612",
- "resource_link_title" => "Weekly Blog",
- "resource_link_description" => "Each student needs to reflect on the weekly reading. These should be one paragraph long.",
- "user_id" => "292832126",
- "roles" => "Instructor", // or Learner
- "lis_person_name_full" => 'Jane Q. Public',
- "lis_person_contact_email_primary" => "user@school.edu",
- "lis_person_sourcedid" => "school.edu:user",
- "context_id" => "456434513",
- "context_title" => "Design of Personal Environments",
- "context_label" => "SI182",
- );
-
- return $parms;
- }
-
- function validateDescriptor($descriptor)
- {
- $xml = new SimpleXMLElement($xmldata);
- if ( ! $xml ) {
- echo("Error parsing Descriptor XML\n");
- return;
- }
- $launch_url = $xml->secure_launch_url[0];
- if ( ! $launch_url ) $launch_url = $xml->launch_url[0];
- if ( $launch_url ) $launch_url = (string) $launch_url;
- return $launch_url;
- }
-
- // Parse a descriptor
- function launchInfo($xmldata) {
- $xml = new SimpleXMLElement($xmldata);
- if ( ! $xml ) {
- echo("Error parsing Descriptor XML\n");
- return;
- }
- $launch_url = $xml->secure_launch_url[0];
- if ( ! $launch_url ) $launch_url = $xml->launch_url[0];
- if ( $launch_url ) $launch_url = (string) $launch_url;
- $custom = array();
- if ( $xml->custom[0]->parameter )
- foreach ( $xml->custom[0]->parameter as $resource) {
- $key = (string) $resource['key'];
- $key = strtolower($key);
- $nk = "";
- for($i=0; $i < strlen($key); $i++) {
- $ch = substr($key,$i,1);
- if ( $ch >= "a" && $ch <= "z" ) $nk .= $ch;
- else if ( $ch >= "0" && $ch <= "9" ) $nk .= $ch;
- else $nk .= "_";
- }
- $value = (string) $resource;
- $custom["custom_".$nk] = $value;
- }
- return array("launch_url" => $launch_url, "custom" => $custom ) ;
- }
-
-function split_custom_parameters($customstr) {
- $lines = preg_split("/[\n;]/",$customstr);
- $retval = array();
- foreach ($lines as $line){
- $pos = strpos($line,"=");
- if ( $pos === false || $pos < 1 ) continue;
- $key = trim(substr($line, 0, $pos));
- $val = trim(substr($line, $pos+1));
- $key = map_keyname($key);
- $retval['custom_'.$key] = $val;
- }
- return $retval;
-}
-
-function map_keyname($key) {
- $newkey = "";
- $key = strtolower(trim($key));
- foreach (str_split($key) as $ch) {
- if ( ($ch >= 'a' && $ch <= 'z') || ($ch >= '0' && $ch <= '9') ) {
- $newkey .= $ch;
- } else {
- $newkey .= '_';
- }
- }
- return $newkey;
-}
-
-function signParameters($oldparms, $endpoint, $method, $oauth_consumer_key, $oauth_consumer_secret,
- $submit_text = false, $org_id = false, $org_desc = false)
-{
- global $last_base_string;
- $parms = $oldparms;
- if ( ! isset($parms["lti_version"]) ) $parms["lti_version"] = "LTI-1p0";
- if ( ! isset($parms["lti_message_type"]) ) $parms["lti_message_type"] = "basic-lti-launch-request";
- if ( $org_id ) $parms["tool_consumer_instance_guid"] = $org_id;
- if ( $org_desc ) $parms["tool_consumer_instance_description"] = $org_desc;
- if ( $submit_text ) $parms["ext_submit"] = $submit_text;
-
- $test_token = '';
-
- $hmac_method = new OAuthSignatureMethod_HMAC_SHA1();
- $test_consumer = new OAuthConsumer($oauth_consumer_key, $oauth_consumer_secret, NULL);
-
- $acc_req = OAuthRequest::from_consumer_and_token($test_consumer, $test_token, $method, $endpoint, $parms);
- $acc_req->sign_request($hmac_method, $test_consumer, $test_token);
-
- // Pass this back up "out of band" for debugging
- $last_base_string = $acc_req->get_signature_base_string();
-
- $newparms = $acc_req->get_parameters();
-
- return $newparms;
-}
-
-function postLaunchHTML($newparms, $endpoint, $debug=false, $iframeattr=false) {
- global $last_base_string;
- $r = "<div id=\"ltiLaunchFormSubmitArea\">\n";
- if ( $iframeattr ) {
- $r = "<form action=\"".$endpoint."\" name=\"ltiLaunchForm\" id=\"ltiLaunchForm\" method=\"post\" target=\"basicltiLaunchFrame\" encType=\"application/x-www-form-urlencoded\">\n" ;
- } else {
- $r = "<form action=\"".$endpoint."\" name=\"ltiLaunchForm\" id=\"ltiLaunchForm\" method=\"post\" encType=\"application/x-www-form-urlencoded\">\n" ;
- }
- $submit_text = $newparms['ext_submit'];
- foreach($newparms as $key => $value ) {
- $key = htmlspecialchars($key);
- $value = htmlspecialchars($value);
- if ( $key == "ext_submit" ) {
- $r .= "<input type=\"submit\" name=\"";
- } else {
- $r .= "<input type=\"hidden\" name=\"";
- }
- $r .= $key;
- $r .= "\" value=\"";
- $r .= $value;
- $r .= "\"/>\n";
- }
- if ( $debug ) {
- $r .= "<script language=\"javascript\"> \n";
- $r .= " //<![CDATA[ \n" ;
- $r .= "function basicltiDebugToggle() {\n";
- $r .= " var ele = document.getElementById(\"basicltiDebug\");\n";
- $r .= " if(ele.style.display == \"block\") {\n";
- $r .= " ele.style.display = \"none\";\n";
- $r .= " }\n";
- $r .= " else {\n";
- $r .= " ele.style.display = \"block\";\n";
- $r .= " }\n";
- $r .= "} \n";
- $r .= " //]]> \n" ;
- $r .= "</script>\n";
- $r .= "<a id=\"displayText\" href=\"javascript:basicltiDebugToggle();\">";
- $r .= get_string("toggle_debug_data","basiclti")."</a>\n";
- $r .= "<div id=\"basicltiDebug\" style=\"display:none\">\n";
- $r .= "<b>".get_string("basiclti_endpoint","basiclti")."</b><br/>\n";
- $r .= $endpoint . "<br/>\n <br/>\n";
- $r .= "<b>".get_string("basiclti_parameters","basiclti")."</b><br/>\n";
- foreach($newparms as $key => $value ) {
- $key = htmlspecialchars($key);
- $value = htmlspecialchars($value);
- $r .= "$key = $value<br/>\n";
- }
- $r .= " <br/>\n";
- $r .= "<p><b>".get_string("basiclti_base_string","basiclti")."</b><br/>\n".$last_base_string."</p>\n";
- $r .= "</div>\n";
- }
- $r .= "</form>\n";
- if ( $iframeattr ) {
- $r .= "<iframe name=\"basicltiLaunchFrame\" id=\"basicltiLaunchFrame\" src=\"\"\n";
- $r .= $iframeattr . ">\n<p>".get_string("frames_required","basiclti")."</p>\n</iframe>\n";
- }
- if ( ! $debug ) {
- $ext_submit = "ext_submit";
- $ext_submit_text = $submit_text;
- $r .= " <script type=\"text/javascript\"> \n" .
- " //<![CDATA[ \n" .
- " document.getElementById(\"ltiLaunchForm\").style.display = \"none\";\n" .
- " nei = document.createElement('input');\n" .
- " nei.setAttribute('type', 'hidden');\n" .
- " nei.setAttribute('name', '".$ext_submit."');\n" .
- " nei.setAttribute('value', '".$ext_submit_text."');\n" .
- " document.getElementById(\"ltiLaunchForm\").appendChild(nei);\n" .
- " document.ltiLaunchForm.submit(); \n" .
- " //]]> \n" .
- " </script> \n";
- }
- $r .= "</div>\n";
- return $r;
-}
-
-/* This is a bit of homage to Moodle's pattern of internationalisation */
-function get_string($key,$bundle) {
- return $key;
-}
-
-function do_post_request($url, $data, $optional_headers = null)
-{
- $params = array('http' => array(
- 'method' => 'POST',
- 'content' => $data
- ));
- if ($optional_headers !== null) {
- $params['http']['header'] = $optional_headers;
- }
- $ctx = stream_context_create($params);
- $fp = @fopen($url, 'rb', false, $ctx);
- if (!$fp) {
- throw new Exception("Problem with $url, $php_errormsg");
- }
- $response = @stream_get_contents($fp);
- if ($response === false) {
- throw new Exception("Problem reading data from $url, $php_errormsg");
- }
- return $response;
-}
-
+++ /dev/null
-<?php
-define('AT_INCLUDE_PATH', '../../../include/');
-require(AT_INCLUDE_PATH.'vitals.inc.php');
-// admin_authenticate(AT_ADMIN_PRIV_BASICLTI);
-
-$cid = intval($_GET['cid']);
-
-$sql = "SELECT * FROM ".TABLE_PREFIX."basiclti_content
- WHERE content_id=".$cid;
-$contentresult = mysql_query($sql, $db);
-$row = mysql_fetch_assoc($contentresult);
-if ( ! $row ) {
- echo("Not Configured\n");
- exit;
-}
-
-$toolid = $row['toolid'];
-$sql = "SELECT * FROM ".TABLE_PREFIX."basiclti_tools
- WHERE toolid='".$toolid."'";
-$contentresult = mysql_query($sql, $db);
-$toolrow = mysql_fetch_assoc($contentresult);
-if ( ! $toolrow ) {
- echo("Tool definition missing\n");
- exit;
-}
-// print_r($toolrow); echo("<hr>\n");
-
-$sql = "SELECT * FROM ".TABLE_PREFIX."content
- WHERE content_id=".$cid;
-$contentresult = mysql_query($sql, $db);
-$contentrow = mysql_fetch_assoc($contentresult);
-if ( ! $contentrow ) {
- echo("Not Configured\n");
- exit;
-}
-// print_r($contentrow); echo("<hr>\n");
-
-$sql = "SELECT * FROM ".TABLE_PREFIX."courses
- WHERE course_id='".$_SESSION['course_id']."'";
-$courseresult = mysql_query($sql, $db);
-$courserow = mysql_fetch_assoc($courseresult);
-if ( ! $courserow ) {
- echo("Course definition missing\n");
- exit;
-}
-// print_r($courserow); echo("<hr>\n");
-
-$sql = "SELECT * FROM ".TABLE_PREFIX."members
- WHERE member_id='".$_SESSION['member_id']."'";
-$memberresult = mysql_query($sql, $db);
-$memberrow = mysql_fetch_assoc($memberresult);
-if ( ! $memberrow ) {
- echo("Course definition missing\n");
- exit;
-}
-// print_r($memberrow); echo("<hr>\n");
-
- $lmsdata = array(
- "resource_link_id" => $cid,
- "resource_link_title" => $contentrow['title'],
- "resource_link_description" => $contentrow['text'],
- "user_id" => $memberrow['member_id'],
- "roles" => "Instructor", // or Learner
- "lis_person_name_family" => $memberrow['last_name'],
- "lis_person_name_given" => $memberrow['first_name'],
- "lis_person_contact_email_primary" => $memberrow['email'],
- "context_id" => $courserow['course_id'],
- "context_title" => $courserow['title'],
- "context_label" => $courserow['title'],
- );
-
-// print_r($lmsdata);echo("<hr>\n");
-
-$parms = $lmsdata;
-
-$endpoint = $toolrow['toolurl'];
-$key = $toolrow['resourcekey'];
-$secret = $toolrow['password'];
-
-require_once("ims-blti/blti_util.php");
-
- $parms = signParameters($parms, $endpoint, "POST", $key, $secret, "Press to Launch", $tool_consumer_instance_guid, $tool_consumer_instance_description);
-
- $content = postLaunchHTML($parms, $endpoint, false);
-
- print($content);
-
-
-?>
+++ /dev/null
-<?php
-
-// Parse a form field description
-// field:type:key=value:key2=value2
-function parseFormString($str) {
- $op = array();
- $pairs = explode(":", $str);
- foreach ($pairs as $pair) {
- $kv = explode("=", $pair);
- if ( sizeof($kv) == 1 ) {
- $op[] = $pair;
- } else {
- $op[$kv[0]] = $kv[1];
- }
- }
- return $op;
-}
-
-function at_form_input($row,$fieldinfo)
-{
- $info = parseFormString($fieldinfo);
- if ( isset($info[0]) ) $field = $info[0]; else return;
- if ( isset($info[1]) ) $type = $info[1]; else return;
- $label = $field;
- if ( isset($info['label']) ) $label = $info['label'];
- $required = isset($info['required']);
-
- if ( $type == 'text' || $type == 'integer' ) {
- $size = isset($info['size']) ? $info['size'] : 40; ?>
- <div class="row">
- <?php if ($required) { ?><span class="required" title="<?php echo _AT('required_field'); ?>">*</span><?php } ?><label for="<?php echo $field;?>"><?php echo _AT($label); ?></label><br />
- <input type="text" id="<?php echo $field;?>" name="<?php echo $field;?>" size="<?php echo $size;?>" value="<?php echo htmlspecialchars($row[$field]); ?>" />
- </div>
- <?php }
- else if ( $type == 'textarea' ) {
- $cols = isset($info['cols']) ? $info['cols'] : 25;
- $rows = isset($info['rows']) ? $info['rows'] : 2; ?>
- <div class="row">
- <?php if ($required) { ?><span class="required" title="<?php echo _AT('required_field'); ?>">*</span><?php } ?><label for="<?php echo $field;?>"><?php echo _AT($label); ?></label><br />
- <textarea id="<?php echo $field;?>" name="<?php echo $field;?>" cols="<?php echo $cols;?>" rows="<?php echo $rows;?>"><?php echo htmlspecialchars($row[$field]); ?></textarea>
- </div>
- <?php }
- else if ( $type == 'radio' ) {
- if ( isset($info['choices']) ) {
- $choices = explode(',', $info['choices']);
- } else {
- echo('<!-- at_form_radio requires choices=on,off,part -->');
- return;
- }
- $current = isset($row[$field]) ? $row[$field] : -1;
- ?>
- <div class="row">
- <?php if ($required) { ?><span class="required" title="<?php echo _AT('required_field'); ?>">*</span><?php } ?><label for="<?php echo $field;?>"><?php echo _AT($label); ?></label><br />
-<?php
-foreach($choices as $key => $value ) {
-$checked = '';
-if ( $key == $current ) $checked = ' checked="checked"';
-?>
- <label><input type="radio" name="<?php echo $field; ?>" value="<?php echo $key?>" id="<?php echo $field.'_'.$value;?>"<?php echo $checked; ?>/><?php echo _AT($label.'_'.$value); ?></label><br />
-<?php } ?>
- </div>
-<?php
- }
-}
-
-function at_form_generate($row, $form_definition) {
- foreach ( $form_definition as $forminput ) {
- at_form_input($row,$forminput);
- }
-}
-
-
-function at_form_output($row,$fieldinfo)
-{
- $info = parseFormString($fieldinfo);
- if ( isset($info[0]) ) $field = $info[0]; else return;
- if ( isset($info[1]) ) $type = $info[1]; else return;
- $label = $field;
- if ( isset($info['label']) ) $label = $info['label'];
-
- if ( $type == 'text' || $type == 'integer' || $type == 'textarea') {
- if ( strlen($row[$field]) < 1 ) return; ?>
- <div class="row">
- <?php echo _AT($label); ?><br/>
- <?php echo htmlspecialchars($row[$field]); ?>
- </div>
- <?php }
- else if ( $type == 'radio' ) {
- if ( isset($info['choices']) ) {
- $choices = explode(',', $info['choices']);
- } else {
- echo('<!-- at_form_radio requires choices=on,off,part -->');
- return;
- }
- $current = isset($row[$field]) ? $row[$field] : 0;
- if ( $current < 0 || $current >= sizeof($choices) ) $current = 0;
- ?>
- <div class="row"> <?php
- $value = $choices[$current];
- echo _AT($label)."<br/>\n";
- echo _AT($label.'_'.$value); ?>
- </div>
-<?php
- }
-}
-
-function at_form_view($row, $form_definition) {
- foreach ( $form_definition as $forminput ) {
- at_form_output($row,$forminput);
- }
-}
-
-function at_form_validate($form_definition, $msg ) {
- $retval = true;
- $missing_fields = array();
- $numeric_fields = array();
-
- foreach ( $form_definition as $forminput ) {
- $info = parseFormString($forminput);
- $label = isset($info['label']) ? $info['label'] : $info[0];
- $datafield = $_POST[$info[0]];
- $datafield = trim($datafield);
- // echo($info[0] . '=' . $datafield. "<br/>\n");
- if ( isset($info['required']) && strlen($datafield) < 1 ) {
- $missing_fields[] = _AT($label);
- }
- if ( $info[1] == 'integer' || $info[1] == 'radio') {
- if ( preg_match("/[0-9]+/", $datafield) == 1 || strlen($datafield) == 0 ) {
- // OK
- } else {
- $numeric_fields[] = _AT($label);
- }
- }
- }
- if (sizeof($missing_fields) > 0) {
- $missing_fields = implode(', ', $missing_fields);
- $msg->addError(array('EMPTY_FIELDS', $missing_fields));
- $retval = false;
- }
- if (sizeof($numeric_fields) > 0) {
- $numeric_fields = implode(', ', $numeric_fields);
- // TODO: Make sure this prints out the list of fields
- $msg->addError(array('NUMERIC_FIELDS', $numeric_fields));
- $msg->addError($numeric_fields);
- $retval = false;
- }
- return $retval;
-}
-
-function at_get_field_value($fieldvalue, $type) {
- if ( $type == 'radio' || $type == 'integer') {
- if ( strlen($fieldvalue) < 1 ) $fieldvalue = '0';
- } else {
- $fieldvalue = "'".mysql_real_escape_string($fieldvalue)."'";
- }
- return $fieldvalue;
-}
-
-function at_form_insert($row, $form_definition) {
- $fieldlist = "";
- $valuelist = "";
- foreach ( $form_definition as $forminput ) {
- $info = parseFormString($forminput);
- $fieldname = $info[0];
- $type = $info[1];
- $fieldvalue = $row[$fieldname];
- if ( ! isset($fieldvalue) ) continue;
- $fieldvalue = trim($fieldvalue);
- if ( strlen($fieldvalue) < 1 ) continue;
- $fieldvalue = at_get_field_value($fieldvalue, $type);
- if ( $fieldlist != "" ) $fieldlist = $fieldlist.", ";
- if ( $valuelist != "" ) $valuelist = $valuelist.", ";
- $fieldlist = $fieldlist.$fieldname;
- $valuelist = $valuelist.$fieldvalue;
- }
- $sql = "( $fieldlist ) VALUES ( $valuelist )";
- return $sql;
-}
-
-function at_form_update($row, $form_definition) {
- $setlist = "";
- foreach ( $form_definition as $forminput ) {
- $info = parseFormString($forminput);
- $fieldname = $info[0];
- $type = $info[1];
- $fieldvalue = $row[$info[0]];
- if ( ! isset($fieldvalue) ) $fieldvalue = '';
- $fieldvalue = trim($fieldvalue);
- $fieldvalue = at_get_field_value($fieldvalue, $type);
- if ( $setlist != "" ) $setlist = $setlist.", ";
- $setlist = $setlist.$fieldname." = ".$fieldvalue;
- }
- return $setlist;
-}
-
-if ( ! function_exists('isCli') ) {
- function isCli() {
- $sapi_type = php_sapi_name();
- if (substr($sapi_type, 0, 3) == 'cli' && empty($_SERVER['REMOTE_ADDR'])) {
- return true;
- } else {
- return false;
- }
- }
-}
-
-// If we are running from the command line - do a unit test
-if ( isCli() ) {
- print_r(parseFormString('title:text:required=true:size=25'));
- print_r(parseFormString('description:textarea:required=true:rows=2:cols=25'));
- print_r(parseFormString('sendemail:radio:requred=true:label=bl_sendemail:choices=on,off,part'));
-
- $row = array();
- $row['title'] = 'Fred';
- $row['description'] = 'Desc';
- $row['sendemail'] = 1;
- function _AT($str) { return $str; }
-
- at_form_input($row,'title:text:required=true:size=25');
- at_form_input($row,'description:textarea:required=true:rows=2:cols=25');
- at_form_input($row,'sendemail:radio:requred=true:label=bl_sendemail:choices=on,off,part');
-}
+++ /dev/null
-div#helloworld {
- border: 1px solid #ccc;
- padding: 10px;
- width: 50%;
- margin-right: auto;
- margin-left: auto;
- background-color: #efefef;
- color: #444;
- margin-top: 30px;
- margin-bottom: 30px;
-}
\ No newline at end of file
+++ /dev/null
-<?php
-/*******
- * doesn't allow this file to be loaded with a browser.
- */
-if (!defined('AT_INCLUDE_PATH')) { exit; }
-
-error_reporting(E_ALL & ~E_NOTICE);
-ini_set("display_errors", 1);
-
-/******
- * this file must only be included within a Module obj
- */
-if (!isset($this) || (isset($this) && (strtolower(get_class($this)) != 'module'))) { exit(__FILE__ . ' is not a Module'); }
-
-/*******
- * assign the instructor and admin privileges to the constants.
- */
-define('AT_PRIV_BASICLTI', $this->getPrivilege());
-define('AT_ADMIN_PRIV_BASICLTI', $this->getAdminPrivilege());
-
-/*******
- * set savant variable and constants
- */
-global $savant;
-require(AT_INCLUDE_PATH.'../mods/basiclti/include/constants.inc.php');
-$savant->addPath('template', AT_BL_INCLUDE.'html/');
-
-/*******
- * create a side menu box/stack.
- */
-$this->_stacks['basiclti'] = array('title_var'=>'basiclti', 'file'=>'mods/basiclti/side_menu.inc.php');
-// ** possible alternative: **
-// $this->addStack('basiclti', array('title_var' => 'basiclti', 'file' => './side_menu.inc.php');
-
-/*******
- * create optional sublinks for module "detail view" on course home page
- * when this line is uncommented, "mods/basiclti/sublinks.php" need to be created to return an array of content to be displayed
- */
-//$this->_list['basiclti'] = array('title_var'=>'basiclti','file'=>'mods/basiclti/sublinks.php');
-
-// Uncomment for tiny list bullet icon for module sublinks "icon view" on course home page
-//$this->_pages['mods/basiclti/index.php']['icon'] = 'mods/basiclti/basiclti_sm.jpg';
-
-// Uncomment for big icon for module sublinks "detail view" on course home page
-//$this->_pages['mods/basiclti/index.php']['img'] = 'mods/basiclti/basiclti.jpg';
-
-// ** possible alternative: **
-// the text to display on module "detail view" when sublinks are not available
-$this->_pages['mods/basiclti/index.php']['text'] = _AT('basiclti_text');
-
-/*******
- * if this module is to be made available to students on the Home or Main Navigation.
- */
-$_group_tool = $_student_tool = 'mods/basiclti/index.php';
-
-/*******
- * add the admin pages when needed.
- */
-if (admin_authenticate(AT_ADMIN_PRIV_BASICLTI, TRUE) || admin_authenticate(AT_ADMIN_PRIV_ADMIN, TRUE)) {
- $this->_pages[AT_NAV_ADMIN] = array('mods/basiclti/index_admin.php');
- $this->_pages['mods/basiclti/index_admin.php']['title_var'] = 'basiclti';
- $this->_pages['mods/basiclti/index_admin.php']['parent'] = AT_NAV_ADMIN;
- $this->_pages['mods/basiclti/index_admin.php']['children'] = array('mods/basiclti/admin/create.php');
- $this->_pages['mods/basiclti/admin/create.php']['title_var'] = 'bl_create';
- $this->_pages['mods/basiclti/admin/create.php']['parent'] = 'mods/basiclti/index_admin.php';
- $this->_pages['mods/basiclti/admin/view_tool.php']['title_var'] = 'bl_view';
- $this->_pages['mods/basiclti/admin/view_tool.php']['parent'] = 'mods/basiclti/index_admin.php';
- $this->_pages['mods/basiclti/admin/edit_tool.php']['title_var'] = 'bl_edit';
- $this->_pages['mods/basiclti/admin/edit_tool.php']['parent'] = 'mods/basiclti/index_admin.php';
- $this->_pages['mods/basiclti/admin/delete_tool.php']['title_var'] = 'bl_delete';
- $this->_pages['mods/basiclti/admin/delete_tool.php']['parent'] = 'mods/basiclti/index_admin.php';
-}
-
-/*******
- * instructor Manage section:
- */
-$this->_pages['mods/basiclti/index_instructor.php']['title_var'] = 'basiclti';
-$this->_pages['mods/basiclti/index_instructor.php']['parent'] = 'tools/index.php';
-$this->_pages['mods/basiclti/index_instructor.php']['children'] = array('mods/basiclti/index_instructor.php');
-// ** possible alternative: **
-// $this->pages['./index_instructor.php']['title_var'] = 'basiclti';
-// $this->pages['./index_instructor.php']['parent'] = 'tools/index.php';
-
-/*******
- * student page.
- */
-$this->_pages['mods/basiclti/index.php']['title_var'] = 'basiclti';
-$this->_pages['mods/basiclti/index.php']['img'] = 'mods/basiclti/basiclti.jpg';
-
-/* public pages */
-$this->_pages[AT_NAV_PUBLIC] = array('mods/basiclti/index_public.php');
-$this->_pages['mods/basiclti/index_public.php']['title_var'] = 'basiclti';
-$this->_pages['mods/basiclti/index_public.php']['parent'] = AT_NAV_PUBLIC;
-
-/* my start page pages */
-$this->_pages[AT_NAV_START] = array('mods/basiclti/index_mystart.php');
-$this->_pages['mods/basiclti/index_mystart.php']['title_var'] = 'basiclti';
-$this->_pages['mods/basiclti/index_mystart.php']['parent'] = AT_NAV_START;
-
-function basiclti_get_group_url($group_id) {
- return 'mods/basiclti/index.php';
-}
-?>
+++ /dev/null
-# sql file for basiclti module
-
-INSERT INTO `language_text` VALUES ('en', '_module','basiclti','IMS Basic LTI',NOW(),'');
-INSERT INTO `language_text` VALUES ('en', '_module','basiclti_text','A tool to support IMS Basic Learning Tools Interoperability.',NOW(),'');
-
-CREATE TABLE `basiclti_tools` (
- `id` mediumint(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
- `toolid` varchar(32) NOT NULL,
- `course_id` mediumint(10) NOT NULL DEFAULT '0',
- `title` varchar(255) NOT NULL,
- `description` varchar(1024),
- `timecreated` TIMESTAMP,
- `timemodified` TIMESTAMP,
- `toolurl` varchar(1023) NOT NULL,
- `resourcekey` varchar(1023) NOT NULL,
- `password` varchar(1023) NOT NULL,
- `preferheight` mediumint(4) NOT NULL DEFAULT '0',
- `sendname` mediumint(1) NOT NULL DEFAULT '0',
- `sendemailaddr` mediumint(1) NOT NULL DEFAULT '0',
- `acceptgrades` mediumint(1) NOT NULL DEFAULT '0',
- `customparameters` varchar(255) NOT NULL,
- `organizationid` varchar(64) NOT NULL,
- `organizationurl` varchar(255) NOT NULL,
- `organizationdescr` varchar(255) NOT NULL,
- `launchinpopup` mediumint(1) NOT NULL DEFAULT '0',
- `debuglaunch` mediumint(1) NOT NULL DEFAULT '0',
- UNIQUE KEY (id)
-);
-
-CREATE TABLE `basiclti` (
- `id` mediumint(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
- `course_id` mediumint(10) NOT NULL DEFAULT '0',
- `toolid` varchar(32) NOT NULL,
- `name` varchar(255) NOT NULL,
- `intro` varchar(1024),
- `timecreated` TIMESTAMP,
- `timemodified` TIMESTAMP,
- `sendname` mediumint(1) NOT NULL DEFAULT '0',
- `sendemailaddr` mediumint(1) NOT NULL DEFAULT '0',
- `acceptgrades` mediumint(1) NOT NULL DEFAULT '0',
- `customparameters` varchar(255) NOT NULL,
- `launchinpopup` mediumint(1) NOT NULL DEFAULT '0',
- `debuglaunch` mediumint(1) NOT NULL DEFAULT '0',
- `gradesecret` varchar(1023) NOT NULL,
- `timegradesecret` mediumint(10) NOT NULL DEFAULT '0',
- `oldgradesecret` varchar(1023) NOT NULL,
- UNIQUE KEY (id, course_id)
-);
-
-CREATE TABLE `basiclti_content` (
- `id` mediumint(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
- `content_id` mediumint(10) NOT NULL DEFAULT '0',
- `course_id` mediumint(10) NOT NULL DEFAULT '0',
- `toolid` varchar(32) NOT NULL,
- `sendname` mediumint(1) NOT NULL DEFAULT '0',
- `sendemailaddr` mediumint(1) NOT NULL DEFAULT '0',
- `acceptgrades` mediumint(1) NOT NULL DEFAULT '0',
- `customparameters` varchar(255) NOT NULL,
- `launchinpopup` mediumint(1) NOT NULL DEFAULT '0',
- `debuglaunch` mediumint(1) NOT NULL DEFAULT '0',
- `gradesecret` varchar(1023) NOT NULL,
- `timegradesecret` mediumint(10) NOT NULL DEFAULT '0',
- `oldgradesecret` varchar(1023) NOT NULL,
- UNIQUE KEY (id, course_id, content_id)
-);
-
+++ /dev/null
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<module version="0.1">
- <name lang="en">Proxy Tools</name>
- <description lang="en">This is a module to support the externally hosted tools using the IMS Basic LTI specification to launch those tools.</description>
- <maintainers>
- <maintainer>
- <name>Charles Severance</name>
- <email>csev@umich.edu</email>
- </maintainer>
- </maintainers>
- <url>http://atutor.ca</url>
- <license>BSD</license>
- <release>
- <version>0.3</version>
- <date>2009-07-02</date>
- <state>stable</state>
- <notes></notes>
- </release>
-</module>
+++ /dev/null
-<?php
-/* each table to be backed up. includes the sql entry and fields */
-
-$dirs = array();
-$dirs['basiclti/'] = AT_CONTENT_DIR . 'basiclti' . DIRECTORY_SEPARATOR;
-
-$sql = array();
-$sql['basiclti'] = 'SELECT value FROM '.TABLE_PREFIX.'basiclti WHERE course_id=?';
-
-function basiclti_convert($row, $course_id, $table_id_map, $version) {
- $new_row = array();
- $new_row[0] = $course_id;
- $new_row[1] = $row[0];
-
- return $new_row;
-}
-
-?>
+++ /dev/null
-<?php
-/*******
- * this function named [module_name]_cron is run by the global cron script at the module's specified
- * interval.
- */
-
-function basiclti_cron() {
- global $db;
-
- debug('yay i am running!');
-}
-
-?>
+++ /dev/null
-<?php
-/*******
- * this function named [module_name]_delete is called whenever a course content is deleted
- * which includes when restoring a backup with override set, or when deleting an entire course.
- * the function must delete all module-specific material associated with this course.
- * $course is the ID of the course to delete.
- */
-
-function basiclti_delete($course) {
- global $db;
-
- // delete basiclti course table entries
- $sql = "DELETE FROM ".TABLE_PREFIX."basiclti WHERE course_id=$course";
- mysql_query($sql, $db);
-
- // delete basiclti course files
- $path = AT_CONTENT_DIR .'basiclti/' . $course .'/';
- clr_dir($path);
-}
-
-?>
+++ /dev/null
-<?php
-/*******
- * This file extends the content string manipulation.
- * It affects the output of course content and news content at course home page.
- * Input parameter: global variable $_input. This variable contains the input
- * content/news string.
- * Output: $_input. Please make sure to assign the manipulated string back to $_input.
- */
-
-/*******
- * Global input string. DO NOT CHANGE.
- */
-global $_input;
-
-/*******
- * Example, replace special tag "[black][/black]" with html
- */
-$_input = str_replace('[black]','<span style="color: black;">',$_input);
-$_input = str_replace('[/black]','</span>',$_input);
-
-?>
\ No newline at end of file
+++ /dev/null
-<?php
-/*******
- * the line below safe-guards this file from being accessed directly from
- * a web browser. It will only execute if required from within an ATutor script,
- * in our case the Module::install() method.
- */
-if (!defined('AT_INCLUDE_PATH')) { exit; }
-
-/*******
- * Note: the many options for these variables are used to decrease confusion.
- * TRUE | FALSE | 1 will be the convention.
- *
- * $_course_privilege
- * specifies the type of instructor privilege this module uses.
- * set to empty | FALSE | 0 to disable any privileges.
- * set to 1 | AT_PRIV_ADMIN to use the instructor only privilege.
- * set to TRUE | 'new' to create a privilege specifically for this module:
- * will make this module available as a student privilege.
- *
- * $_admin_privilege
- * specifies the type of ATutor administrator privilege this module uses.
- * set to FALSE | AT_ADMIN_PRIV_ADMIN to use the super administrator only privilege.
- * set to TRUE | 'new' to create a privilege specifically for this module:
- * will make this module available as an administrator privilege.
- *
- *
- * $_cron_interval
- * if non-zero specifies in minutes how often the module's cron job should be run.
- * set to 0 or not set to disable.
- */
-$_course_privilege = TRUE; // possible values: FALSE | AT_PRIV_ADMIN | TRUE
-$_admin_privilege = TRUE; // possible values: FALSE | TRUE
-$_cron_interval = 35; // run every 30 minutes
-
-/********
- * the following code is used for creating a module-specific directory.
- * it generates appropriate error messages to aid in its creation.
- */
-$directory = AT_CONTENT_DIR .'basiclti';
-
-// check if the directory is writeable
-if (!is_dir($directory) && !@mkdir($directory)) {
- $msg->addError(array('MODULE_INSTALL', '<li>'.$directory.' does not exist. Please create it.</li>'));
-} else if (!is_writable($directory) && @chmod($directory, 0666)) {
- $msg->addError(array('MODULE_INSTALL', '<li>'.$directory.' is not writeable. On Unix issue the command <kbd>chmod a+rw</kbd>.</li>'));
-}
-
-/******
- * the following code checks if there are any errors (generated previously)
- * then uses the SqlUtility to run any database queries it needs, ie. to create
- * its own tables.
- */
-if (file_exists(dirname(__FILE__) . '/module.sql')) {
- // deal with the SQL file:
- require(AT_INCLUDE_PATH . 'classes/sqlutility.class.php');
- $sqlUtility =& new SqlUtility();
-
- /*
- * the SQL file could be stored anywhere, and named anything, "module.sql" is simply
- * a convention we're using.
- */
- $sqlUtility->queryFromFile(dirname(__FILE__) . '/module.sql', TABLE_PREFIX);
-}
-
-?>
+++ /dev/null
-<?php
-/*******
- * module_uninstall.php performs reversion of module_install.php
- */
-
-/*******
- * the line below safe-guards this file from being accessed directly from
- * a web browser. It will only execute if required from within an ATutor script,
- * in our case the Module::uninstall() method.
- */
-if (!defined('AT_INCLUDE_PATH')) { exit; }
-
-/********
- * the following code is used for removing a module-specific directory created in module_install.php.
- * it generates appropriate error messages to aid in its creation.
- */
-$directory = AT_CONTENT_DIR .'basiclti';
-
-// check if the directory exists
-if (is_dir($directory)) {
- require(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
-
- if (!clr_dir($directory))
- $msg->addError(array('MODULE_UNINSTALL', '<li>'.$directory.' can not be removed. Please manually remove it.</li>'));
-}
-
-/******
- * the following code checks if there are any errors (generated previously)
- * then uses the SqlUtility to run reverted database queries of module.sql,
- * ie. "create table" statement in module.sql is run as drop according table.
- */
-if (!$msg->containsErrors() && file_exists(dirname(__FILE__) . '/module.sql')) {
- // deal with the SQL file:
- require(AT_INCLUDE_PATH . 'classes/sqlutility.class.php');
- $sqlUtility = new SqlUtility();
-
- /*
- * the SQL file could be stored anywhere, and named anything, "module.sql" is simply
- * a convention we're using.
- */
- $sqlUtility->revertQueryFromFile(dirname(__FILE__) . '/module.sql', TABLE_PREFIX);
-}
-
-?>
-
+++ /dev/null
-<?php
-/* start output buffering: */
-ob_start(); ?>
-
-hello world
-
-<?php
-$savant->assign('dropdown_contents', ob_get_contents());
-ob_end_clean();
-
-$savant->assign('title', _AT('basiclti')); // the box title
-$savant->display('include/box.tmpl.php');
-?>
+++ /dev/null
-<?php
-
-if (!defined('AT_INCLUDE_PATH')) { exit; }
-
-/*****
-* Free form PHP can appear here to retreive current information
-* from the module, or a text description of the module where there is
-* not current information
-*****/
-
-global $db;
-
-$link_limit = 3; // Number of links to be displayed on "detail view" box
-
-$sql = "SELECT basiclti_id, value FROM ".TABLE_PREFIX."basiclti WHERE course_id=".$_SESSION[course_id].
- " ORDER BY value LIMIT $link_limit";
-$result = mysql_query($sql, $db);
-
-if (mysql_num_rows($result) > 0) {
- while ($row = mysql_fetch_assoc($result)) {
- /****
- * SUBLINK_TEXT_LEN, VALIDATE_LENGTH_FOR_DISPLAY are defined in include/lib/constance.lib.inc
- * SUBLINK_TEXT_LEN determins the maxium length of the string to be displayed on "detail view" box.
- *****/
- $list[] = '<a href="'.AT_BASE_HREF.url_rewrite('mods/basiclti/index.php?id='. $row['basiclti_id']).'"'.
- (strlen($row['value']) > SUBLINK_TEXT_LEN ? ' title="'.$row['value'].'"' : '') .'>'.
- validate_length($row['value'], SUBLINK_TEXT_LEN, VALIDATE_LENGTH_FOR_DISPLAY) .'</a>';
- }
- return $list;
-} else {
- return 0;
-}
-
-?>