Disable Next Or Previous Button while the item position is First or Last - Refs #11192

pull/2487/head
José Loguercio 9 years ago
parent 0dfdd23a2c
commit 547e8c6c07
  1. 2
      app/Resources/public/css/scorm.css
  2. 10
      main/inc/ajax/lp.ajax.php
  3. 5
      main/newscorm/learnpath.class.php
  4. 28
      main/newscorm/scorm_api.php
  5. 1
      main/template/default/learnpath/view.tpl

@ -445,7 +445,7 @@ See https://support.chamilo.org/issues/6976
.icon-toolbar{
border-radius: 100%;
width: 35px;
display: inline-block !important;
display: inline-block;
margin: 0px 5px 5px 0px;
color: #fff;

@ -280,6 +280,16 @@ switch ($action) {
}
echo json_encode($jsonGamification);
break;
case 'check_item_position':
$lp = isset($_SESSION['oLP']) ? $_SESSION['oLP'] : null;
$lpItemId = isset($_GET['lp_item']) ? intval($_GET['lp_item']) : 0;
if ($lp) {
$position = $_SESSION['oLP']->isFirstOrLastItem($lpItemId);
}
echo json_encode($position);
break;
default:
echo '';

@ -11118,16 +11118,16 @@ EOD;
/**
* Check if the current lp item is first, both, last or none from lp list
*
* @param int $currentItemId
* @return string
*/
public function isFirstOrLastItem()
public function isFirstOrLastItem($currentItemId)
{
if ($this->debug > 0) {
error_log('New LP - In learnpath::isFirstOrLastItem', 0);
}
$lpItemId = [];
$currentItemId = $this->get_current_item_id();
$typeListNotToVerify = self::getChapterTypes();
foreach ($this->items as $item) {
@ -11136,7 +11136,6 @@ EOD;
}
}
$answer = '';
$lastLpItemIndex = count($lpItemId) - 1;
$position = array_search($currentItemId, $lpItemId);

@ -1664,10 +1664,38 @@ function switch_item(current_item, next_item){
olms.switch_finished = 0; //only changed back once LMSInitialize() happens
loadForumThead(olms.lms_lp_id, next_item);
checkCurrentItemPosition(olms.lms_item_id);
return true;
}
/**
* Hide or show the navigation buttons if the current item is the First or Last
*/
var checkCurrentItemPosition = function(lpItemId) {
var currentItem = $.getJSON('<?php echo api_get_path(WEB_AJAX_PATH) ?>lp.ajax.php', {
a: 'check_item_position',
lp_item: lpItemId
}
).done(function(parsedResponse,statusText,jqXhr) {
var position = jqXhr.responseJSON;
if (position == 'first') {
$("#scorm-previous").hide();
$("#scorm-next").show();
} else if (position == 'none') {
$("#scorm-previous").show();
$("#scorm-next").show();
} else if (position == 'last') {
$("#scorm-previous").show();
$("#scorm-next").hide();
} else if (position == 'both') {
$("#scorm-previous").hide();
$("#scorm-next").hide();
}
});
}
/**
* Get a forum info when the learning path item has a associated forum
*/

@ -215,6 +215,7 @@
});
loadForumThead({{ lp_id }}, {{ lp_current_item_id }});
checkCurrentItemPosition({{ lp_current_item_id }});
{% if glossary_extra_tools in glossary_tool_availables %}
// Loads the glossary library.

Loading…
Cancel
Save