-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlms.php
138 lines (124 loc) · 5.18 KB
/
lms.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<?php
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
ini_set("display_errors", 1);
header('Content-Type: text/html; charset=utf-8');
session_start();
?>
<html>
<head>
<title>IMS Basic Learning Tools Interoperability</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body style="font-family:sans-serif">
<?php
echo("<p><b>IMS LTI 1.1 Consumer Launch</b></p>\n");
echo("<p>This is a very simple reference implementaton of the LMS side (i.e. consumer) for IMS LTI 1.1.</p>\n");
require_once("misc.php");
require_once("ims-blti/blti_util.php");
$lmsdata = array(
"resource_link_id" => "120988f929-274612",
"resource_link_title" => "Weekly Blog",
"resource_link_description" => "A weekly blog.",
"user_id" => "292832126",
"roles" => "Instructor", // or Learner
"lis_person_name_full" => 'Jane Q. Public',
"lis_person_name_family" => 'Public',
"lis_person_name_given" => 'Given',
"lis_person_contact_email_primary" => "[email protected]",
"lis_person_sourcedid" => "school.edu:user",
"context_id" => "456434513",
"context_title" => "Design of Personal Environments",
"context_label" => "SI182",
"tool_consumer_info_product_family_code" => "ims",
"tool_consumer_info_version" => "1.1",
"tool_consumer_instance_guid" => "lmsng.school.edu",
"tool_consumer_instance_description" => "University of School (LMSng)",
);
foreach ($lmsdata as $k => $val ) {
if ( $_POST[$k] && strlen($_POST[$k]) > 0 ) {
$lmsdata[$k] = $_POST[$k];
}
}
$cur_url = curPageURL();
$key = $_REQUEST["key"];
if ( ! $key ) $key = "12345";
$secret = $_REQUEST["secret"];
if ( ! $secret ) $secret = "secret";
$endpoint = $_REQUEST["endpoint"];
$b64 = base64_encode($key.":::".$secret);
if ( ! $endpoint ) $endpoint = str_replace("lms.php","tool.php",$cur_url);
$outcomes = $_REQUEST["outcomes"];
if ( ! $outcomes ) {
$outcomes = str_replace("lms.php","tool_consumer_outcome.php",$cur_url);
$outcomes .= "?b64=" . htmlentities($b64);
}
$tool_consumer_instance_guid = $lmsdata['tool_consumer_instance_guid'];
$tool_consumer_instance_description = $lmsdata['tool_consumer_instance_description'];
$xmldesc = str_replace("\\\"","\"",$_REQUEST["xmldesc"]);
if ( ! $xmldesc ) $xmldesc = $default_desc;
?>
<script language="javascript">
//<![CDATA[
function lmsdataToggle() {
var ele = document.getElementById("lmsDataForm");
if(ele.style.display == "block") {
ele.style.display = "none";
}
else {
ele.style.display = "block";
}
}
//]]>
</script>
<a id="displayText" href="javascript:lmsdataToggle();">Toggle Resource and Launch Data</a>
<?php
echo("<div id=\"lmsDataForm\" style=\"display:block\">\n");
echo("<form method=\"post\">\n");
echo("<input type=\"submit\" value=\"Recompute Launch Data\">\n");
echo("<input type=\"submit\" name=\"reset\" value=\"Reset\">\n");
echo("<fieldset><legend>BasicLTI Resource</legend>\n");
$disabled = '';
echo("Launch URL: <input size=\"60\" type=\"text\" $disabled size=\"60\" name=\"endpoint\" value=\"$endpoint\">\n");
echo("<br/>Key: <input type\"text\" name=\"key\" $disabled size=\"60\" value=\"$key\">\n");
echo("<br/>Secret: <input type\"text\" name=\"secret\" $disabled size=\"60\" value=\"$secret\">\n");
echo("</fieldset><p>");
echo("<fieldset><legend>Launch Data</legend>\n");
foreach ($lmsdata as $k => $val ) {
echo($k.": <input type=\"text\" name=\"".$k."\" value=\"");
echo(htmlspecialchars($val));
echo("\"><br/>\n");
}
echo("</fieldset>\n");
echo("</form>\n");
echo("</div>\n");
echo("<hr>");
$parms = $lmsdata;
// Cleanup parms before we sign
foreach( $parms as $k => $val ) {
if (strlen(trim($parms[$k]) ) < 1 ) {
unset($parms[$k]);
}
}
// Add oauth_callback to be compliant with the 1.0A spec
$parms["oauth_callback"] = "about:blank";
if ( $outcomes ) {
$parms["lis_outcome_service_url"] = $outcomes;
$parms["lis_result_sourcedid"] = "feb-123-456-2929::28883";
}
$parms = signParameters($parms, $endpoint, "POST", $key, $secret, "Press to Launch", $tool_consumer_instance_guid, $tool_consumer_instance_description);
$content = postLaunchHTML($parms, $endpoint, true,
"width=\"100%\" height=\"900\" scrolling=\"auto\" frameborder=\"1\" transparency");
print($content);
?>
<hr>
<p>
Note: Unpublished drafts of IMS Specifications are only available to
IMS members and any software based on an unpublished draft is subject to change.
Sample code is provided to help developers understand the specification more quickly.
Simply interoperating with this sample implementation code does not
allow one to claim compliance with a specification.
<p>
<a href=http://www.imsglobal.org/toolsinteroperability2.cfm>IMS Learning Tools Interoperability Working Group</a> <br/>
<a href="http://www.imsglobal.org/ProductDirectory/directory.cfm">IMS Compliance Detail</a> <br/>
<a href="http://www.imsglobal.org/community/forum/index.cfm?forumid=11">IMS Developer Community</a> <br/>
<a href="http:///www.imsglobal.org/" class="footerlink">© 2009 IMS Global Learning Consortium, Inc.</a> under the Apache 2 License.</p>