Updating launch container for mobile devices
authorChris Scribner <scriby@gmail.com>
Mon, 3 Oct 2011 18:47:37 +0000 (14:47 -0400)
committerChris Scribner <scriby@gmail.com>
Mon, 7 Nov 2011 01:41:54 +0000 (20:41 -0500)
mod/lti/locallib.php
mod/lti/view.php

index bfb55bc..2a7fd85 100644 (file)
@@ -57,6 +57,7 @@ define('LTI_LAUNCH_CONTAINER_DEFAULT', 1);
 define('LTI_LAUNCH_CONTAINER_EMBED', 2);
 define('LTI_LAUNCH_CONTAINER_EMBED_NO_BLOCKS', 3);
 define('LTI_LAUNCH_CONTAINER_WINDOW', 4);
+define('LTI_LAUNCH_CONTAINER_REPLACE_MOODLE_WINDOW', 5);
 
 define('LTI_TOOL_STATE_ANY', 0);
 define('LTI_TOOL_STATE_CONFIGURED', 1);
index ea28f4e..fb1759f 100644 (file)
@@ -95,9 +95,20 @@ $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;
+}
+
 if($launchcontainer == LTI_LAUNCH_CONTAINER_EMBED_NO_BLOCKS){
     $PAGE->set_pagelayout('frametop'); //Most frametops don't include footer, and pre-post blocks
     $PAGE->blocks->show_only_fake_blocks(); //Disable blocks for layouts which do include pre-post blocks
+} else if($launchcontainer == LTI_LAUNCH_CONTAINER_REPLACE_MOODLE_WINDOW) {
+    redirect('launch.php?id=' . $cm->id);
 } else {
     $PAGE->set_pagelayout('incourse');
 }
@@ -130,7 +141,7 @@ if ( $launchcontainer == LTI_LAUNCH_CONTAINER_WINDOW ) {
     echo "<p>".get_string("basiclti_in_new_window", "lti")."</p>\n";
 } else {
     // Request the launch content with an object tag
-    echo '<object id="contentframe" height="600px" width="100%" type="text/html" data="launch.php?id='.$cm->id.'&amp;withobject=true"></object>';
+    echo '<object id="contentframe" height="600px" width="100%" type="text/html" data="launch.php?id='.$cm->id.'"></object>';
     
     //Output script to make the object tag be as large as possible
     $resize = <<<'SCRIPT'