Learnpath: Fix lesson title block update issue - BT#21691

pull/5514/head
christianbeeznst 6 months ago
parent 671ce58e3a
commit 0db9727137
  1. 1
      assets/css/scorm.scss
  2. 11
      public/main/lp/ScormApi.php
  3. 19
      public/main/lp/scorm_api.php

@ -398,6 +398,7 @@ body {
#learning_path_right_zone .tab-pane {
height: 100%;
position: relative;
margin-top: 30px;
}
#learning_path_right_zone .tab-pane iframe {

@ -818,6 +818,17 @@ class ScormApi
$updateMinTime"
;
$lpItemParents = $mylp->getCurrentItemParentNames($mylp->get_current_item_id());
$titleItemParents = '';
if (!empty($lpItemParents)) {
$escapedParents = array_map(function($parentTitle) {
return htmlspecialchars($parentTitle, ENT_QUOTES, 'UTF-8');
}, $lpItemParents);
$titleItemParents = json_encode($escapedParents);
}
$return .= "olms.lms_lp_item_parents={$titleItemParents};";
//$return .= 'updateGamificationValues(); ';
$mylp->set_error_msg('');
$mylp->prerequisites_match(); // Check the prerequisites are all complete.

@ -203,6 +203,7 @@ olms.asset_timer = 0;
olms.userfname = '<?php echo addslashes(trim($user['firstname'])); ?>';
olms.userlname = '<?php echo addslashes(trim($user['lastname'])); ?>';
olms.execute_stats = false;
olms.lms_lp_item_parents = '';
var courseUrl = '?cid='+olms.lms_course_id+'&sid='+olms.lms_session_id;
var statsUrl = 'lp_controller.php' + courseUrl + '&action=stats';
@ -1661,6 +1662,8 @@ function switch_item(current_item, next_item)
});
}
}
updateItemParentNames();
var mysrc = '<?php echo api_get_path(WEB_CODE_PATH); ?>lp/lp_controller.php?action=content&lp_id=' + olms.lms_lp_id +
'&item_id=' + next_item + '&cid=' + olms.lms_course_id + '&sid=' + olms.lms_session_id;
var cont_f = $("#content_id");
@ -1718,6 +1721,22 @@ function switch_item(current_item, next_item)
return true;
}
/**
* Updates the 'item-parent-names' div with the titles of the current item's parents.
*/
function updateItemParentNames() {
var parentNamesContainer = document.getElementById('item-parent-names');
if (parentNamesContainer) {
parentNamesContainer.innerHTML = '';
olms.lms_lp_item_parents.forEach(function(parentTitle) {
var h3 = document.createElement('h3');
h3.className = 'text-h5';
h3.textContent = parentTitle;
parentNamesContainer.appendChild(h3);
});
}
}
/**
* Hide or show the navigation buttons if the current item is the First or Last
*/

Loading…
Cancel
Save