From 750a498a4dc3800889b5d861c870a67b2cf96bb9 Mon Sep 17 00:00:00 2001 From: Christian Beeznest Date: Tue, 10 Feb 2026 23:15:59 -0500 Subject: [PATCH] Learnpath: Improve top navigation layout when toggling TOC - refs #7469 --- public/main/lp/learnpath.class.php | 2 +- public/main/lp/scorm_api.php | 34 ++- .../views/LearnPath/menubar.html.twig | 6 +- .../Resources/views/LearnPath/view.html.twig | 231 +++++++++++++----- 4 files changed, 190 insertions(+), 83 deletions(-) diff --git a/public/main/lp/learnpath.class.php b/public/main/lp/learnpath.class.php index c741fa50303..93eafcfb122 100644 --- a/public/main/lp/learnpath.class.php +++ b/public/main/lp/learnpath.class.php @@ -1358,7 +1358,7 @@ public function get_navigation_bar($barId = '') $reportingIcon = ' '.$icon.''.$reportingText.' diff --git a/public/main/lp/scorm_api.php b/public/main/lp/scorm_api.php index 600a0a18f01..464028b5240 100644 --- a/public/main/lp/scorm_api.php +++ b/public/main/lp/scorm_api.php @@ -217,7 +217,7 @@ function APIobject() { olms.lms_auto_forward_video = auto_forward_video; ?>; var courseUrl = '?cid='+olms.lms_course_id+'&sid='+olms.lms_session_id+'&lp_id='+olms.lms_lp_id; -var statsUrl = 'lp_controller.php' + courseUrl + '&action=stats'; +var statsUrl = 'lp_controller.php' + courseUrl + '&action=stats&origin=learnpath'; /** * Add the "addListeners" function to the "onload" event of the window and @@ -249,6 +249,16 @@ function getContentFrame() { return $f; } + function setContentFrameSrc(src) { + var $frame = getContentFrame(); + if (!$frame.length) { + logit_lms("[LP] Content iframe not found (#content_id / #content_id_blank).", 0); + return false; + } + $frame.attr("src", src); + return true; + } + $(function() { var $frame = getContentFrame(); @@ -1723,18 +1733,18 @@ function switch_item(current_item, next_item) { var mysrc = buildLpContentSrc(targetItemId); mode) { ?> - var w = window.open("" + mysrc, "content_id", "toolbar=0,location=0,status=0,scrollbars=1,resizable=1"); - if (w) { - w.onload = function () { - olms.info_lms_item[0] = currentItemId; - }; - w.onunload = function () { - olms.info_lms_item[0] = currentItemId; - }; - } + var w = window.open("" + mysrc, "content_id", "toolbar=0,location=0,status=0,scrollbars=1,resizable=1"); + if (w) { + w.onload = function () { + olms.info_lms_item[0] = currentItemId; + }; + w.onunload = function () { + olms.info_lms_item[0] = currentItemId; + }; + } - log_in_log("Loading " + mysrc + " in iframe", 2); - $("#content_id").attr("src", mysrc); + log_in_log("Loading " + mysrc + " in iframe", 2); + setContentFrameSrc(mysrc); // (6) Update nav buttons visibility diff --git a/src/CoreBundle/Resources/views/LearnPath/menubar.html.twig b/src/CoreBundle/Resources/views/LearnPath/menubar.html.twig index cd04b554a99..93843597596 100644 --- a/src/CoreBundle/Resources/views/LearnPath/menubar.html.twig +++ b/src/CoreBundle/Resources/views/LearnPath/menubar.html.twig @@ -2,8 +2,8 @@ {% set toc_hidden = (toc_hidden|default(0) + 0) %} {% set show_left_column = (show_left_column|default(1) + 0) %} {% set show_toolbar_by_default = (show_toolbar_by_default|default(0) + 0) %} - {# Force the toolbar open when TOC is hidden so navigation is always visible #} - {% set force_open = (show_toolbar_by_default == 1) or (toc_hidden == 1 and menu_location != 'top') %} + {# Do not force-open the toolbar; user controls it via hamburger #} + {% set force_open = (show_toolbar_by_default == 1) %} {% if navigation_in_the_middle %}