Skip to content

Commit

Permalink
Add nav case for Moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
csev committed Aug 10, 2017
1 parent 3e24fd1 commit b796b07
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
18 changes: 18 additions & 0 deletions src/Core/Launch.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,24 @@ public function isCanvas() {
return $product == 'canvas';
}

/**
* Indicate if this launch came from Moodle
*/
public function isMoodle() {
$ext_lms = $this->ltiRawParameter('ext_lms', false);
$ext_lms = strtolower($ext_lms);
return strpos($ext_lms, 'moodle') === 0 ;
}

/**
* Indicate if this launch came from Coursera
*/
public function isCoursera() {
$product = $this->ltiRawParameter('tool_consumer_info_product_family_code', false);
$tci_description = $this->ltiRawParameter('tool_consumer_instance_description', false);
return ( $product == 'ims' && $tci_description == 'Coursera');
}

/**
* set up parameters for an outbound launch from this launch
*/
Expand Down
17 changes: 7 additions & 10 deletions src/UI/Output.php
Original file line number Diff line number Diff line change
Expand Up @@ -598,13 +598,9 @@ function topNavSession($menuset) {
* (2) If we are launched via LTI w/o a session
*/
function topNav($menu_set=false) {
global $CFG;
global $CFG, $LAUNCH;
$sess_key = 'tsugi_top_nav_'.$CFG->wwwroot;
$launch_return_url = LTIX::ltiRawParameter('launch_presentation_return_url', false);
// Canvas test
$product = LTIX::ltiRawParameter('tool_consumer_info_product_family_code', false);
$tci_description = LTIX::ltiRawParameter('tool_consumer_instance_description', false);
if ( $product == 'ims' && $tci_description == 'Coursera') $product = 'coursera';
$launch_return_url = $LAUNCH->ltiRawParameter('launch_presentation_return_url', false);

$same_host = false;
if ( $CFG->apphome && startsWith($launch_return_url, $CFG->apphome) ) $same_host = true;
Expand All @@ -622,10 +618,10 @@ function topNav($menu_set=false) {
} else if ( $launch_target !== false && strtolower($launch_target) == 'window' ) {
$menu_set = self::closeMenuSet();
// Since Coursers sets precious little
} else if ( $product == 'coursera' ) {
} else if ( $LAUNCH->isCoursera() ) {
$menu_set = self::closeMenuSet();
// Since canvas does not set launch_target properly
} else if ( $launch_target !== false && ($product == 'canvas' || $product == 'coursera')) {
} else if ( $launch_target !== false && ( $LAUNCH->isCanvas() || $LAUNCH->isCoursera() ) ) {
$menu_set = self::closeMenuSet();
} else if ( $launch_return_url !== false ) {
$menu_set = self::returnMenuSet($launch_return_url);
Expand Down Expand Up @@ -677,7 +673,7 @@ private function recurseNav($entry, $depth) {
}

function menuNav($set) {
global $CFG;
global $CFG, $LAUNCH;

$retval = <<< EOF
<nav class="navbar navbar-default navbar-fixed-top" role="navigation" id="tsugi_main_nav_bar" style="display:none">
Expand Down Expand Up @@ -717,8 +713,9 @@ function menuNav($set) {
$retval .= " </div> <!--/.nav-collapse -->\n";
$retval .= " </div> <!--container-fluid -->\n";
$retval .= "</nav>\n";
$inmoodle = $LAUNCH->isMoodle() ? "true" : "false";
$retval .= "<script>\n";
$retval .= "if ( ! inIframe() ) {\n";
$retval .= "if ( ".$inmoodle." || ! inIframe() ) {\n";
$retval .= " document.getElementById('tsugi_main_nav_bar').style.display = 'block';\n";
$retval .= " document.getElementsByTagName('body')[0].style.paddingTop = '70px';\n";
$retval .= "}\n";
Expand Down

0 comments on commit b796b07

Please sign in to comment.