Created
January 30, 2017 14:41
-
-
Save anonymous/bccbfc82caca18cf7896338475bbaf21 to your computer and use it in GitHub Desktop.
LTI Consumer test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use IMSGlobal\LTI\ToolProvider; | |
require_once('vendor/autoload.php'); | |
date_default_timezone_set('UTC'); | |
$launch_url = "http://127.0.0.1:8090/enrol/lti/tool.php?id=1"; | |
$key = "blinc"; | |
$secret = "8qBqXEo5U04oSUqfulPUkBKSYG3CFoSe"; | |
$arguments = array( | |
"user_id" => "3", | |
"ext_user_username" => "micha", | |
"roles" => "Instructor,urn:lti:sysrole:ims/lis/Administrator,urn:lti:instrole:ims/lis/Administrator", | |
"ext_lms" => "moodle-2", | |
"resource_link_id" => "2", // should be unique | |
"resource_link_title" => "LTI Consumer", | |
"resource_link_description" => "", | |
"lis_person_name_full" => "Michael Berhorst", | |
"lis_person_name_family" => "Berhorst", | |
"lis_person_name_given" => "Michael", | |
"lis_person_contact_email_primary" => "mb@sandstorm.de", | |
"lis_person_sourcedid" => "", | |
"lis_course_section_sourcedid" => "", | |
"context_id" => "2", // should be unique, identifies the context that contains the link | |
"context_title" => "LTI Consumer", | |
"context_label" => "LTI Consumer", | |
"context_type" => "CourseSection", | |
"tool_consumer_instance_guid" => "lti-consumer.local", | |
"tool_consumer_info_version" => "1.1", | |
"tool_consumer_instance_name" => "Moodle Consumer", | |
"tool_consumer_instance_description" => "Moodle Consumer", | |
"tool_consumer_info_product_family_code" => "moodle", | |
"launch_presentation_document_target" => "iframe", | |
"launch_presentation_locale" => "en", | |
// "launch_presentation_return_url" => "http://lti-consumer.local/sample-app/src/test.php", | |
"lis_outcome_service_url" => "http://127.0.0.1:8080/mod/lti/service.php", | |
"lis_result_sourcedid" => "eba99f886a944318b11234787c1bd636" // This field is unique for every combination of context_id / resource_link_id / user_id | |
); | |
$consumer = new ToolProvider\ToolConsumer($key, null); | |
$singedParameters = $consumer->signParameters($launch_url, 'basic-lti-launch-request', 'LTI-1p0', $arguments); | |
var_dump($singedParameters); | |
?> | |
<html> | |
<head> | |
<style> | |
body { | |
height: 100%; | |
width: 100%; | |
margin: 0; | |
} | |
iframe { | |
height: 90%; | |
width: 100%; | |
border: none; | |
} | |
</style> | |
</head> | |
<body> | |
<form id="ltiLaunchForm" name="ltiLaunchForm" method="POST" target="my_frame" action="<?php printf($launch_url); ?>"> | |
<?php foreach ($singedParameters as $k => $v ) { ?> | |
<input type="hidden" name="<?php echo $k ?>" value="<?php echo $v ?>"> | |
<?php } ?> | |
<button type="submit">Launch</button> | |
</form> | |
<iframe name="my_frame"></iframe> | |
</body> | |
</html> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment