Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/mod/lti/view.php
Go to the documentation of this file.
00001 <?php
00002 // This file is part of Moodle - http://moodle.org/
00003 //
00004 // Moodle is free software: you can redistribute it and/or modify
00005 // it under the terms of the GNU General Public License as published by
00006 // the Free Software Foundation, either version 3 of the License, or
00007 // (at your option) any later version.
00008 //
00009 // Moodle is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00016 //
00017 // This file is part of BasicLTI4Moodle
00018 //
00019 // BasicLTI4Moodle is an IMS BasicLTI (Basic Learning Tools for Interoperability)
00020 // consumer for Moodle 1.9 and Moodle 2.0. BasicLTI is a IMS Standard that allows web
00021 // based learning tools to be easily integrated in LMS as native ones. The IMS BasicLTI
00022 // specification is part of the IMS standard Common Cartridge 1.1 Sakai and other main LMS
00023 // are already supporting or going to support BasicLTI. This project Implements the consumer
00024 // for Moodle. Moodle is a Free Open source Learning Management System by Martin Dougiamas.
00025 // BasicLTI4Moodle is a project iniciated and leaded by Ludo(Marc Alier) and Jordi Piguillem
00026 // at the GESSI research group at UPC.
00027 // SimpleLTI consumer for Moodle is an implementation of the early specification of LTI
00028 // by Charles Severance (Dr Chuck) htp://dr-chuck.com , developed by Jordi Piguillem in a
00029 // Google Summer of Code 2008 project co-mentored by Charles Severance and Marc Alier.
00030 //
00031 // BasicLTI4Moodle is copyright 2009 by Marc Alier Forment, Jordi Piguillem and Nikolas Galanis
00032 // of the Universitat Politecnica de Catalunya http://www.upc.edu
00033 // Contact info: Marc Alier Forment granludo @ gmail.com or marc.alier @ upc.edu
00034 
00050 require_once('../../config.php');
00051 require_once($CFG->dirroot.'/mod/lti/lib.php');
00052 require_once($CFG->dirroot.'/mod/lti/locallib.php');
00053 
00054 $id = optional_param('id', 0, PARAM_INT); // Course Module ID, or
00055 $l  = optional_param('l', 0, PARAM_INT);  // lti ID
00056 
00057 if ($l) {  // Two ways to specify the module
00058     $lti = $DB->get_record('lti', array('id' => $l), '*', MUST_EXIST);
00059     $cm = get_coursemodule_from_instance('lti', $lti->id, $lti->course, false, MUST_EXIST);
00060 
00061 } else {
00062     $cm = get_coursemodule_from_id('lti', $id, 0, false, MUST_EXIST);
00063     $lti = $DB->get_record('lti', array('id' => $cm->instance), '*', MUST_EXIST);
00064 }
00065 
00066 $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
00067 
00068 $tool = lti_get_tool_by_url_match($lti->toolurl);
00069 if ($tool) {
00070     $toolconfig = lti_get_type_config($tool->id);
00071 } else {
00072     $toolconfig = array();
00073 }
00074 
00075 $PAGE->set_cm($cm, $course); // set's up global $COURSE
00076 $context = get_context_instance(CONTEXT_MODULE, $cm->id);
00077 $PAGE->set_context($context);
00078 
00079 $url = new moodle_url('/mod/lti/view.php', array('id'=>$cm->id));
00080 $PAGE->set_url($url);
00081 
00082 $launchcontainer = lti_get_launch_container($lti, $toolconfig);
00083 
00084 if ($launchcontainer == LTI_LAUNCH_CONTAINER_EMBED_NO_BLOCKS) {
00085     $PAGE->set_pagelayout('frametop'); //Most frametops don't include footer, and pre-post blocks
00086     $PAGE->blocks->show_only_fake_blocks(); //Disable blocks for layouts which do include pre-post blocks
00087 } else if ($launchcontainer == LTI_LAUNCH_CONTAINER_REPLACE_MOODLE_WINDOW) {
00088     redirect('launch.php?id=' . $cm->id);
00089 } else {
00090     $PAGE->set_pagelayout('incourse');
00091 }
00092 
00093 require_login($course);
00094 
00095 add_to_log($course->id, "lti", "view", "view.php?id=$cm->id", "$lti->id");
00096 
00097 $pagetitle = strip_tags($course->shortname.': '.format_string($lti->name));
00098 $PAGE->set_title($pagetitle);
00099 $PAGE->set_heading($course->fullname);
00100 
00101 // Print the page header
00102 echo $OUTPUT->header();
00103 
00104 if ($lti->showtitlelaunch) {
00105     // Print the main part of the page
00106     echo $OUTPUT->heading(format_string($lti->name));
00107 }
00108 
00109 if ($lti->showdescriptionlaunch && $lti->intro) {
00110     echo $OUTPUT->box($lti->intro, 'generalbox description', 'intro');
00111 }
00112 
00113 if ( $launchcontainer == LTI_LAUNCH_CONTAINER_WINDOW ) {
00114     echo "<script language=\"javascript\">//<![CDATA[\n";
00115     echo "window.open('launch.php?id=".$cm->id."','lti');";
00116     echo "//]]\n";
00117     echo "</script>\n";
00118     echo "<p>".get_string("basiclti_in_new_window", "lti")."</p>\n";
00119 } else {
00120     // Request the launch content with an object tag
00121     echo '<object id="contentframe" height="600px" width="100%" type="text/html" data="launch.php?id='.$cm->id.'"></object>';
00122 
00123     //Output script to make the object tag be as large as possible
00124     $resize = '
00125         <script type="text/javascript">
00126         //<![CDATA[
00127             (function(){
00128                 //Take scrollbars off the outer document to prevent double scroll bar effect
00129                 document.body.style.overflow = "hidden";
00130 
00131                 var dom = YAHOO.util.Dom;
00132                 var frame = document.getElementById("contentframe");
00133 
00134                 var padding = 15; //The bottom of the iframe wasn\'t visible on some themes. Probably because of border widths, etc.
00135 
00136                 var lastHeight;
00137 
00138                 var resize = function(){
00139                     var viewportHeight = dom.getViewportHeight();
00140 
00141                     if(lastHeight !== Math.min(dom.getDocumentHeight(), viewportHeight)){
00142 
00143                         frame.style.height = viewportHeight - dom.getY(frame) - padding + "px";
00144 
00145                         lastHeight = Math.min(dom.getDocumentHeight(), dom.getViewportHeight());
00146                     }
00147                 };
00148 
00149                 resize();
00150 
00151                 setInterval(resize, 250);
00152             })();
00153         //]]
00154         </script>
00155 ';
00156 
00157     echo $resize;
00158 }
00159 
00160 // Finish the page
00161 echo $OUTPUT->footer();
 All Data Structures Namespaces Files Functions Variables Enumerations