From d97d72aab9fa86456b02ddad6e6caab01ab747b8 Mon Sep 17 00:00:00 2001 From: Chris Scribner Date: Tue, 30 Aug 2011 16:35:50 -0400 Subject: [PATCH] Implemented launch options & fixed issues with frame sizing --- mod/blti/basiclti.js | 4 +- mod/blti/edit_form.php | 30 +++++--------- mod/blti/lang/en/blti.php | 7 ++-- mod/blti/lib.php | 8 ++++ mod/blti/locallib.php | 39 +++++++------------ mod/blti/mod_form.php | 29 +++++--------- mod/blti/view.php | 82 +++++++++++++++++++++++++++++---------- 7 files changed, 110 insertions(+), 89 deletions(-) diff --git a/mod/blti/basiclti.js b/mod/blti/basiclti.js index 2d9dfe340a3..5b0673cc7c3 100644 --- a/mod/blti/basiclti.js +++ b/mod/blti/basiclti.js @@ -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'); \ No newline at end of file diff --git a/mod/blti/edit_form.php b/mod/blti/edit_form.php index 55e07873612..995824d2b89 100644 --- a/mod/blti/edit_form.php +++ b/mod/blti/edit_form.php @@ -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 diff --git a/mod/blti/lang/en/blti.php b/mod/blti/lang/en/blti.php index b13eeb7c591..afc41ef394d 100644 --- a/mod/blti/lang/en/blti.php +++ b/mod/blti/lang/en/blti.php @@ -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'; \ No newline at end of file +$string['automatic'] = 'Automatic, based on Launch URL'; +$string['default'] = 'Default'; diff --git a/mod/blti/lib.php b/mod/blti/lib.php index 2c13f93a652..214de3cab06 100644 --- a/mod/blti/lib.php +++ b/mod/blti/lib.php @@ -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; diff --git a/mod/blti/locallib.php b/mod/blti/locallib.php index 8e616f1469a..6d32d437e88 100644 --- a/mod/blti/locallib.php +++ b/mod/blti/locallib.php @@ -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 = "
\n"; - } else { - $r = "\n"; - } + + $r = "\n"; + $submittext = $newparms['ext_submit']; // Contruct html for the launch parameters diff --git a/mod/blti/mod_form.php b/mod/blti/mod_form.php index 670f4216424..7ec6413f718 100644 --- a/mod/blti/mod_form.php +++ b/mod/blti/mod_form.php @@ -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'); diff --git a/mod/blti/view.php b/mod/blti/view.php index 47364bf3f64..3624e681548 100644 --- a/mod/blti/view.php +++ b/mod/blti/view.php @@ -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 ''; } -echo $OUTPUT->box_start('generalbox activity'); - - -if ( false /*$basiclti->launchinpopup > 0*/ ) { - print "\n"; - print "

".get_string("basiclti_in_new_window", "blti")."

\n"; +if ( $launchcontainer == BLTI_LAUNCH_CONTAINER_WINDOW ) { + echo "\n"; + echo "

".get_string("basiclti_in_new_window", "blti")."

\n"; } else { // Request the launch content with an object tag - /*$height = $basiclti->preferheight; - if ((!$height) || ($height == 0)) { - $height = 400; - }*/ - $height=600; - print ''; + echo ''; + + //Output script to make the object tag be as large as possible + $resize = <<<'SCRIPT' + +SCRIPT; + + echo $resize; } -echo $OUTPUT->box_end(); /// Finish the page echo $OUTPUT->footer();