Implemented launch options & fixed issues with frame sizing
This commit is contained in:
@@ -47,10 +47,12 @@
|
||||
|
||||
function basicltiDebugToggle() {
|
||||
var ele = document.getElementById('basicltiDebug');
|
||||
if(ele.style.display == ''block') {
|
||||
if(ele.style.display == 'block') {
|
||||
ele.style.display = 'none';
|
||||
}
|
||||
else {
|
||||
ele.style.display = 'block';
|
||||
}
|
||||
}
|
||||
|
||||
alert('a');
|
||||
+9
-21
@@ -83,6 +83,15 @@ class mod_blti_edit_types_form extends moodleform{
|
||||
|
||||
$mform->addElement('checkbox', 'lti_coursevisible', ' ', ' ' . get_string('show_in_course', 'blti'));
|
||||
|
||||
$launchoptions=array();
|
||||
$launchoptions[BLTI_LAUNCH_CONTAINER_EMBED] = get_string('embed', 'blti');
|
||||
$launchoptions[BLTI_LAUNCH_CONTAINER_EMBED_NO_BLOCKS] = get_string('embed_no_blocks', 'blti');
|
||||
$launchoptions[BLTI_LAUNCH_CONTAINER_WINDOW] = get_string('new_window', 'blti');
|
||||
|
||||
$mform->addElement('select', 'lti_launchcontainer', get_string('default_launch_container', 'blti'), $launchoptions);
|
||||
$mform->setDefault('lti_launchcontainer', BLTI_LAUNCH_CONTAINER_EMBED_NO_BLOCKS);
|
||||
// $mform->addHelpButton('lti_launchinpopup', 'launchinpopup', 'blti');
|
||||
|
||||
// Add privacy preferences fieldset where users choose whether to send their data
|
||||
$mform->addElement('header', 'privacy', get_string('privacy', 'blti'));
|
||||
|
||||
@@ -113,27 +122,6 @@ class mod_blti_edit_types_form extends moodleform{
|
||||
$mform->setDefault('lti_allowroster', '2');
|
||||
// $mform->addHelpButton('lti_allowroster', 'allowroster', 'blti');
|
||||
|
||||
/*
|
||||
// Add grading preferences fieldset where the tool is allowed to update settings
|
||||
$mform->addElement('select', 'lti_allowsetting', get_string('allowsetting', 'blti'), $options);
|
||||
$mform->setDefault('lti_allowsetting', '0');
|
||||
// $mform->addHelpButton('lti_allowsetting', 'allowsetting', 'blti');
|
||||
*/
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
// Add launch parameters fieldset
|
||||
$mform->addElement('header', 'launchoptions', get_string('launchoptions', 'blti'));
|
||||
|
||||
$launchoptions=array();
|
||||
$launchoptions[0] = get_string('embed', 'blti');
|
||||
$launchoptions[1] = get_string('embed_no_blocks', 'blti');
|
||||
$launchoptions[2] = get_string('popup_window', 'blti');
|
||||
$launchoptions[3] = get_string('new_window', 'blti');
|
||||
|
||||
$mform->addElement('select', 'lti_launchinpopup', get_string('launchinpopup', 'blti'), $launchoptions);
|
||||
$mform->setDefault('lti_launchinpopup', '0');
|
||||
// $mform->addHelpButton('lti_launchinpopup', 'launchinpopup', 'blti');
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
// Add setup parameters fieldset
|
||||
|
||||
@@ -170,8 +170,8 @@ $string['tool_settings'] = 'Tool Settings';
|
||||
$string['miscellaneous'] = 'Miscellaneous';
|
||||
$string['embed'] = 'Embed';
|
||||
$string['embed_no_blocks'] = 'Embed, without blocks';
|
||||
$string['popup_window'] = 'Popup window';
|
||||
$string['new_window'] = 'New browser window / tab';
|
||||
$string['new_window'] = 'New window';
|
||||
$string['default_launch_container'] = 'Default Launch Container';
|
||||
|
||||
//New instructor strings
|
||||
$string['display_name'] = 'Display activity name when launched';
|
||||
@@ -182,4 +182,5 @@ $string['share_name'] = 'Share launcher\'s name with the tool';
|
||||
$string['share_email'] = 'Share launcher\'s email with the tool';
|
||||
$string['accept_grades'] = 'Accept grades from the tool';
|
||||
$string['share_roster'] = 'Allow the tool to access this course\'s roster';
|
||||
$string['automatic'] = 'Automatic, based on Launch URL';
|
||||
$string['automatic'] = 'Automatic, based on Launch URL';
|
||||
$string['default'] = 'Default';
|
||||
|
||||
@@ -112,6 +112,14 @@ function blti_update_instance($formdata) {
|
||||
$formdata->timemodified = time();
|
||||
$formdata->id = $formdata->instance;
|
||||
|
||||
if(!isset($formdata->showtitle)){
|
||||
$formdata->showtitle = 0;
|
||||
}
|
||||
|
||||
if(!isset($formdata->showdescription)){
|
||||
$formdata->showdescription = 0;
|
||||
}
|
||||
|
||||
if ($formdata->instructorchoiceacceptgrades == 1) {
|
||||
$basicltirec = $DB->get_record("blti", array("id" => $formdata->id));
|
||||
$basicltirec->cmidnumber = $formdata->cmidnumber;
|
||||
|
||||
+14
-25
@@ -51,6 +51,11 @@ require_once($CFG->dirroot.'/mod/blti/OAuth.php');
|
||||
|
||||
define('BLTI_URL_DOMAIN_REGEX', '/(?:https?:\/\/)?(?:www\.)?([^\/]+)(?:\/|$)/i');
|
||||
|
||||
define('BLTI_LAUNCH_CONTAINER_DEFAULT', 1);
|
||||
define('BLTI_LAUNCH_CONTAINER_EMBED', 2);
|
||||
define('BLTI_LAUNCH_CONTAINER_EMBED_NO_BLOCKS', 3);
|
||||
define('BLTI_LAUNCH_CONTAINER_WINDOW', 4);
|
||||
|
||||
/**
|
||||
* Prints a Basic LTI activity
|
||||
*
|
||||
@@ -459,9 +464,6 @@ function blti_get_type_config_from_instance($id) {
|
||||
if (isset($config['toolurl'])) {
|
||||
$type->lti_toolurl = $config['toolurl'];
|
||||
}
|
||||
if (isset($config['preferheight'])) {
|
||||
$type->lti_preferheight = $config['preferheight'];
|
||||
}
|
||||
if (isset($config['instructorchoicesendname'])) {
|
||||
$type->lti_sendname = $config['instructorchoicesendname'];
|
||||
}
|
||||
@@ -474,9 +476,7 @@ function blti_get_type_config_from_instance($id) {
|
||||
if (isset($config['instructorchoiceallowroster'])) {
|
||||
$type->lti_allowroster = $config['instructorchoiceallowroster'];
|
||||
}
|
||||
if (isset($config['instructorchoiceallowsetting'])) {
|
||||
$type->lti_allowsetting = $config['instructorchoiceallowsetting'];
|
||||
}
|
||||
|
||||
if (isset($config['instructorcustomparameters'])) {
|
||||
$type->lti_allowsetting = $config['instructorcustomparameters'];
|
||||
}
|
||||
@@ -506,9 +506,7 @@ function blti_get_type_type_config($id) {
|
||||
if (isset($config['password'])) {
|
||||
$type->lti_password = $config['password'];
|
||||
}
|
||||
if (isset($config['preferheight'])) {
|
||||
$type->lti_preferheight = $config['preferheight'];
|
||||
}
|
||||
|
||||
if (isset($config['sendname'])) {
|
||||
$type->lti_sendname = $config['sendname'];
|
||||
}
|
||||
@@ -533,18 +531,11 @@ function blti_get_type_type_config($id) {
|
||||
if (isset($config['instructorchoiceallowroster'])){
|
||||
$type->lti_instructorchoiceallowroster = $config['instructorchoiceallowroster'];
|
||||
}
|
||||
if (isset($config['allowsetting'])){
|
||||
$type->lti_allowsetting = $config['allowsetting'];
|
||||
}
|
||||
if (isset($config['instructorchoiceallowsetting'])){
|
||||
$type->lti_instructorchoiceallowsetting = $config['instructorchoiceallowsetting'];
|
||||
}
|
||||
|
||||
if (isset($config['customparameters'])) {
|
||||
$type->lti_customparameters = $config['customparameters'];
|
||||
}
|
||||
if (isset($config['allowinstructorcustom'])) {
|
||||
$type->lti_allowinstructorcustom = $config['allowinstructorcustom'];
|
||||
}
|
||||
|
||||
if (isset($config['organizationid'])) {
|
||||
$type->lti_organizationid = $config['organizationid'];
|
||||
}
|
||||
@@ -554,8 +545,8 @@ function blti_get_type_type_config($id) {
|
||||
if (isset($config['organizationdescr'])) {
|
||||
$type->lti_organizationdescr = $config['organizationdescr'];
|
||||
}
|
||||
if (isset($config['launchinpopup'])) {
|
||||
$type->lti_launchinpopup = $config['launchinpopup'];
|
||||
if (isset($config['launchcontainer'])) {
|
||||
$type->lti_launchcontainer = $config['launchcontainer'];
|
||||
}
|
||||
if (isset($config['debuglaunch'])) {
|
||||
$type->lti_debuglaunch = $config['debuglaunch'];
|
||||
@@ -655,11 +646,9 @@ function sign_parameters($oldparms, $endpoint, $method, $oauthconsumerkey, $oaut
|
||||
*/
|
||||
function post_launch_html($newparms, $endpoint, $debug=false, $height=false) {
|
||||
global $lastbasestring;
|
||||
if ($height) {
|
||||
$r = "<form action=\"".$endpoint."\" name=\"ltiLaunchForm\" id=\"ltiLaunchForm\" method=\"post\" encType=\"application/x-www-form-urlencoded\">\n";
|
||||
} else {
|
||||
$r = "<form action=\"".$endpoint."\" name=\"ltiLaunchForm\" id=\"ltiLaunchForm\" method=\"post\" encType=\"application/x-www-form-urlencoded\">\n";
|
||||
}
|
||||
|
||||
$r = "<form action=\"".$endpoint."\" name=\"ltiLaunchForm\" id=\"ltiLaunchForm\" method=\"post\" encType=\"application/x-www-form-urlencoded\">\n";
|
||||
|
||||
$submittext = $newparms['ext_submit'];
|
||||
|
||||
// Contruct html for the launch parameters
|
||||
|
||||
+10
-19
@@ -115,6 +115,16 @@ class mod_blti_mod_form extends moodleform_mod {
|
||||
$mform->setType('instructorcustomparameters', PARAM_TEXT);
|
||||
$mform->setAdvanced('instructorcustomparameters');
|
||||
|
||||
$launchoptions=array();
|
||||
$launchoptions[BLTI_LAUNCH_CONTAINER_DEFAULT] = get_string('default', 'blti');
|
||||
$launchoptions[BLTI_LAUNCH_CONTAINER_EMBED] = get_string('embed', 'blti');
|
||||
$launchoptions[BLTI_LAUNCH_CONTAINER_EMBED_NO_BLOCKS] = get_string('embed_no_blocks', 'blti');
|
||||
$launchoptions[BLTI_LAUNCH_CONTAINER_WINDOW] = get_string('new_window', 'blti');
|
||||
|
||||
$mform->addElement('select', 'launchcontainer', get_string('launchinpopup', 'blti'), $launchoptions);
|
||||
|
||||
$mform->setDefault('launchcontainer', BLTI_LAUNCH_CONTAINER_DEFAULT);
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
//$mform->addElement('hidden', 'typeid', $this->typeid);
|
||||
//$mform->addElement('hidden', 'toolurl', $this->typeconfig['toolurl']);
|
||||
@@ -138,25 +148,6 @@ class mod_blti_mod_form extends moodleform_mod {
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
|
||||
// Add launch parameters fieldset
|
||||
$mform->addElement('header', 'launchoptions', get_string('launchoptions', 'blti'));
|
||||
|
||||
$launchoptions=array();
|
||||
$launchoptions[0] = get_string('embed', 'blti');
|
||||
$launchoptions[1] = get_string('embed_no_blocks', 'blti');
|
||||
$launchoptions[2] = get_string('popup_window', 'blti');
|
||||
$launchoptions[3] = get_string('new_window', 'blti');
|
||||
|
||||
$mform->addElement('select', 'launchinpopup', get_string('launchinpopup', 'blti'), $launchoptions);
|
||||
|
||||
if (isset($this->typeconfig['launchinpopup'])) {
|
||||
if ($this->typeconfig['launchinpopup'] == 0) {
|
||||
$mform->setDefault('launchinpopup', '0');
|
||||
} else if ($this->typeconfig['launchinpopup'] == 1) {
|
||||
$mform->setDefault('launchinpopup', '1');
|
||||
}
|
||||
}
|
||||
|
||||
/* $debugoptions=array();
|
||||
$debugoptions[0] = get_string('debuglaunchoff', 'blti');
|
||||
$debugoptions[1] = get_string('debuglaunchon', 'blti');
|
||||
|
||||
+62
-20
@@ -77,13 +77,27 @@ if ($id) {
|
||||
}
|
||||
}
|
||||
|
||||
$tool = blti_get_tool_by_url_match($basiclti->toolurl);
|
||||
$toolconfig = blti_get_type_config($tool->id);
|
||||
|
||||
$PAGE->set_cm($cm, $course); // set's up global $COURSE
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
$PAGE->set_context($context);
|
||||
|
||||
$url = new moodle_url('/mod/blti/view.php', array('id'=>$cm->id));
|
||||
$PAGE->set_url($url);
|
||||
$PAGE->set_pagelayout('incourse');
|
||||
|
||||
$launchcontainer = $basiclti->launchcontainer == BLTI_LAUNCH_CONTAINER_DEFAULT ?
|
||||
$toolconfig['launchcontainer'] :
|
||||
$basiclti->launchcontainer;
|
||||
|
||||
if($launchcontainer == BLTI_LAUNCH_CONTAINER_EMBED_NO_BLOCKS){
|
||||
$PAGE->set_pagelayout('frametop'); //Use the frametop layout to get the navbar, but no footer
|
||||
$PAGE->blocks->show_only_fake_blocks(); //Disable blocks
|
||||
} else {
|
||||
$PAGE->set_pagelayout('incourse');
|
||||
}
|
||||
|
||||
require_login($course);
|
||||
|
||||
add_to_log($course->id, "blti", "view", "view.php?id=$cm->id", "$basiclti->id");
|
||||
@@ -95,35 +109,63 @@ $PAGE->set_heading($course->fullname);
|
||||
/// Print the page header
|
||||
echo $OUTPUT->header();
|
||||
|
||||
/// Print the main part of the page
|
||||
echo $OUTPUT->heading(format_string($basiclti->name));
|
||||
echo $OUTPUT->box($basiclti->intro, 'generalbox description', 'intro');
|
||||
if($basiclti->showtitle) {
|
||||
/// Print the main part of the page
|
||||
echo $OUTPUT->heading(format_string($basiclti->name));
|
||||
}
|
||||
|
||||
if($basiclti->showdescription && $basiclti->intro){
|
||||
echo $OUTPUT->box($basiclti->intro, 'generalbox description', 'intro');
|
||||
}
|
||||
|
||||
if ($basiclti->instructorchoiceacceptgrades == 1) {
|
||||
echo '<div class="reportlink">'.submittedlink($cm).'</div>';
|
||||
}
|
||||
|
||||
echo $OUTPUT->box_start('generalbox activity');
|
||||
|
||||
|
||||
if ( false /*$basiclti->launchinpopup > 0*/ ) {
|
||||
print "<script language=\"javascript\">//<![CDATA[\n";
|
||||
print "window.open('launch.php?id=".$cm->id."','window name');";
|
||||
print "//]]\n";
|
||||
print "</script>\n";
|
||||
print "<p>".get_string("basiclti_in_new_window", "blti")."</p>\n";
|
||||
if ( $launchcontainer == BLTI_LAUNCH_CONTAINER_WINDOW ) {
|
||||
echo "<script language=\"javascript\">//<![CDATA[\n";
|
||||
echo "window.open('launch.php?id=".$cm->id."','blti');";
|
||||
echo "//]]\n";
|
||||
echo "</script>\n";
|
||||
echo "<p>".get_string("basiclti_in_new_window", "blti")."</p>\n";
|
||||
} else {
|
||||
// Request the launch content with an object tag
|
||||
/*$height = $basiclti->preferheight;
|
||||
if ((!$height) || ($height == 0)) {
|
||||
$height = 400;
|
||||
}*/
|
||||
$height=600;
|
||||
print '<object height="'.$height.'" width="100%" data="launch.php?id='.$cm->id.'&withobject=true"></object>';
|
||||
echo '<object id="contentframe" height="600px" width="100%" type="text/html" data="launch.php?id='.$cm->id.'&withobject=true"></object>';
|
||||
|
||||
//Output script to make the object tag be as large as possible
|
||||
$resize = <<<'SCRIPT'
|
||||
<script type='text/javascript'>
|
||||
//<![CDATA[
|
||||
(function(){
|
||||
//Take scrollbars off the outer document to prevent double scroll bar effect
|
||||
document.body.style.overflow = 'hidden';
|
||||
|
||||
var dom = YAHOO.util.Dom;
|
||||
var frame = document.getElementById('contentframe');
|
||||
|
||||
var lastHeight;
|
||||
|
||||
var resize = function(){
|
||||
var viewportHeight = dom.getViewportHeight();
|
||||
|
||||
if(lastHeight !== Math.min(dom.getDocumentHeight(), viewportHeight)){
|
||||
frame.style.height = viewportHeight - dom.getY(frame) + 'px';
|
||||
|
||||
lastHeight = Math.min(dom.getDocumentHeight(), dom.getViewportHeight());
|
||||
}
|
||||
};
|
||||
|
||||
resize();
|
||||
|
||||
setInterval(resize, 250);
|
||||
})();
|
||||
//]]
|
||||
</script>
|
||||
SCRIPT;
|
||||
|
||||
echo $resize;
|
||||
}
|
||||
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
/// Finish the page
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
Reference in New Issue
Block a user