Still needs some help text when an error occurs.
$string['viewsubmissions'] = 'View submissions and grading screen';
//New admin strings
-
$string['show_in_course'] = 'Show tool type when creating tool instances';
$string['delegate'] = 'Delegate to Instructor';
$string['tool_settings'] = 'Tool Settings';
$string['custom_config'] = 'Using custom tool configuration.';
$string['tool_config_not_found'] = 'Tool configuration not found for this URL.';
+$string['return_to_course'] = 'Click <a href="{$a->link}" target="_top">here</a> to return to the course.';
+
//Instance help
$string['external_tool_type_help'] = <<<HTML
//Add outcome service URL
$url = new moodle_url('/mod/lti/service.php');
$requestparams['lis_outcome_service_url'] = $url->out();
+
+ $launchcontainer = lti_get_launch_container($instance, $typeconfig);
+
+ //Add the return URL. We send the launch container along to help us avoid frames-within-frames when the user returns
+ $url = new moodle_url('/mod/lti/return.php', array('course' => $course->id, 'launch_container' => $launchcontainer));
+ $requestparams['launch_presentation_return_url'] = $url->out(false);
// Concatenate the custom parameters from the administrator and the instructor
// Instructor parameters are only taken into consideration if the administrator
global $DB;
return $DB->get_record('lti_types', array('id' => $typeid));
+}
+
+function lti_get_launch_container($lti, $toolconfig){
+ $launchcontainer = $lti->launchcontainer == LTI_LAUNCH_CONTAINER_DEFAULT ?
+ $toolconfig['launchcontainer'] :
+ $lti->launchcontainer;
+
+ $devicetype = get_device_type();
+
+ //Scrolling within the object element doesn't work on iOS or Android
+ //Opening the popup window also had some issues in testing
+ //For mobile devices, always take up the entire screen to ensure the best experience
+ if($devicetype === 'mobile' || $devicetype === 'tablet' ){
+ $launchcontainer = LTI_LAUNCH_CONTAINER_REPLACE_MOODLE_WINDOW;
+ }
+
+ return $launchcontainer;
}
\ No newline at end of file
--- /dev/null
+<?php
+
+//This page is used to handle the return back to Moodle from the tool provider
+
+require_once('../../config.php');
+require_once($CFG->dirroot.'/mod/lti/lib.php');
+
+$courseid = required_param('course', PARAM_INT);
+$errormsg = optional_param('lti_errormsg', '', PARAM_RAW);
+$launchcontainer = optional_param('launch_container', LTI_LAUNCH_CONTAINER_WINDOW, PARAM_INT);
+
+$course = $DB->get_record('course', array('id' => $courseid));
+
+require_login($course);
+
+if(!empty($errormsg)){
+ $url = new moodle_url('/mod/lti/return.php', array('course' => $courseid));
+ $PAGE->set_url($url);
+
+ $pagetitle = strip_tags($course->shortname);
+ $PAGE->set_title($pagetitle);
+ $PAGE->set_heading($course->fullname);
+
+ //Avoid frame-in-frame action
+ if($launchcontainer == LTI_LAUNCH_CONTAINER_EMBED || $launchcontainer == LTI_LAUNCH_CONTAINER_EMBED_NO_BLOCKS) {
+ $PAGE->set_pagelayout('embedded');
+ } else {
+ $PAGE->set_pagelayout('incourse');
+ }
+
+ echo $OUTPUT->header();
+
+ //TODO: Add some help around this error message.
+ echo htmlspecialchars($errormsg);
+
+ echo $OUTPUT->footer();
+} else {
+ $courseurl = new moodle_url('/course/view.php', array('id' => $courseid));
+ $url = $courseurl->out();
+
+ //Avoid frame-in-frame action
+ if($launchcontainer == LTI_LAUNCH_CONTAINER_EMBED || $launchcontainer == LTI_LAUNCH_CONTAINER_EMBED_NO_BLOCKS) {
+ //Output a page containing some script to break out of frames and redirect them
+
+ echo '<html><body>';
+
+ $script = <<<SCRIPT
+ <script type='text/javascript'>
+ //<![CDATA[
+ if(window != top){
+ top.location.href = '{$url}';
+ }
+ //]]
+ </script>
+SCRIPT;
+
+ $clickhere = get_string('return_to_course', 'lti', (object)array('link' => $url));
+
+ $noscript = <<<NOSCRIPT
+ <noscript>
+ {$clickhere}
+ </noscript>
+NOSCRIPT;
+
+ echo $script;
+ echo $noscript;
+
+ echo '</body></html>';
+ } else {
+ //If no error, take them back to the course
+ redirect($url);
+ }
+}
\ No newline at end of file
$url = new moodle_url('/mod/lti/view.php', array('id'=>$cm->id));
$PAGE->set_url($url);
-$launchcontainer = $basiclti->launchcontainer == LTI_LAUNCH_CONTAINER_DEFAULT ?
- $toolconfig['launchcontainer'] :
- $basiclti->launchcontainer;
-
-$devicetype = get_device_type();
-
-//Scrolling within the object element doesn't work on iOS or Android
-//Opening the popup window also had some issues in testing
-//For mobile devices, always take up the entire screen to ensure the best experience
-if($devicetype === 'mobile' || $devicetype === 'tablet' ){
- $launchcontainer = LTI_LAUNCH_CONTAINER_REPLACE_MOODLE_WINDOW;
-}
+$launchcontainer = lti_get_launch_container($basiclti, $toolconfig);
if($launchcontainer == LTI_LAUNCH_CONTAINER_EMBED_NO_BLOCKS){
$PAGE->set_pagelayout('frametop'); //Most frametops don't include footer, and pre-post blocks