Fix hide left column in LP see #2261

pull/2487/head
jmontoyaa 8 years ago
parent 30aaa56320
commit 6555d8f1f2
  1. 15
      main/lp/learnpath.class.php
  2. 9
      main/lp/lp_edit.php
  3. 141
      main/lp/lp_view.php
  4. 26
      main/template/default/learnpath/view.tpl

@ -2712,19 +2712,12 @@ class learnpath
}
/**
* Gets the learnpath author
* @return string LP's author
* Gets hide table of contents
* @return int
*/
public function get_hide_toc_frame()
public function getHideTableOfContents()
{
if ($this->debug > 0) {
error_log('New LP - In learnpath::get_author()', 0);
}
if (!empty ($this->hide_toc_frame)) {
return $this->hide_toc_frame;
} else {
return '';
}
return (int) $this->hide_toc_frame;
}
/**

@ -133,7 +133,7 @@ if (api_get_setting('search_enabled') === 'true') {
$defaults['lp_encoding'] = Security::remove_XSS($_SESSION['oLP']->encoding);
$defaults['lp_name'] = Security::remove_XSS($_SESSION['oLP']->get_name());
$defaults['lp_author'] = Security::remove_XSS($_SESSION['oLP']->get_author());
$defaults['hide_toc_frame'] = Security::remove_XSS($_SESSION['oLP']->get_hide_toc_frame());
$defaults['hide_toc_frame'] = $_SESSION['oLP']->getHideTableOfContents();
$defaults['category_id'] = intval($_SESSION['oLP']->getCategoryId());
$defaults['accumulate_scorm_time'] = $_SESSION['oLP']->getAccumulateScormTime();
@ -231,7 +231,6 @@ if ($enableLpExtraFields) {
</script>';
}
$defaults['publicated_on'] = !empty($publicated_on) && $publicated_on !== '0000-00-00 00:00:00' ? api_get_local_time($publicated_on) : null;
$defaults['expired_on'] = (!empty($expired_on)) ? api_get_local_time($expired_on) : date('Y-m-d 12:00:00', time() + 84600);
$defaults['subscribe_users'] = $_SESSION['oLP']->getSubscribeUsers();
@ -241,13 +240,13 @@ Display::display_header(get_lang('CourseSettings'), 'Path');
echo $_SESSION['oLP']->build_action_menu(false, false, true, false);
echo '<div class="row">';
if ($_SESSION['oLP']->get_hide_toc_frame() == 1) {
if ($_SESSION['oLP']->getHideTableOfContents() == 1) {
echo '<div class="col-md-12">';
$form -> display();
$form->display();
echo '</div>';
} else {
echo '<div class="col-md-8">';
$form -> display();
$form->display();
echo '</div>';
echo '<div class="col-md-4" align="center">';
echo Display::return_icon('course_setting_layout.png');

@ -20,7 +20,7 @@ $use_anonymous = true;
$this_section = SECTION_COURSES;
if ($lp_controller_touched != 1) {
header('location: lp_controller.php?action=view&item_id='.intval($_REQUEST['item_id']));
header('Location: lp_controller.php?action=view&item_id='.intval($_REQUEST['item_id']));
exit;
}
@ -66,7 +66,10 @@ if (!api_is_allowed_to_edit(false, true, false, false) &&
api_not_allowed(true);
}
if (empty($_SESSION['oLP'])) {
/** @var learnpath $lp */
$lp = Session::read('oLP');
if (empty($lp)) {
api_not_allowed(true);
}
@ -75,12 +78,11 @@ if ($debug) {
error_log('------ Entering lp_view.php -------');
}
$_SESSION['oLP']->error = '';
$lp_item_id = $_SESSION['oLP']->get_current_item_id();
$lpType = $_SESSION['oLP']->get_type();
$lp_item_id = $lp->get_current_item_id();
$lpType = $lp->get_type();
if (!$is_allowed_to_edit) {
$categoryId = $_SESSION['oLP']->getCategoryId();
$categoryId = $lp->getCategoryId();
$em = Database::getManager();
if (!empty($categoryId)) {
/** @var CLpCategory $category */
@ -130,15 +132,15 @@ var chamilo_xajax_handler = window.oxajax;
</script>';
// Impress js
if ($_SESSION['oLP']->mode == 'impress') {
$lp_id = $_SESSION['oLP']->get_id();
if ($lp->mode == 'impress') {
$lp_id = $lp->get_id();
$url = api_get_path(WEB_CODE_PATH)."lp/lp_impress.php?lp_id=$lp_id&".api_get_cidreq();
header("Location: $url");
exit;
}
// Prepare variables for the test tool (just in case) - honestly, this should disappear later on.
$_SESSION['scorm_view_id'] = $_SESSION['oLP']->get_view_id();
$_SESSION['scorm_view_id'] = $lp->get_view_id();
$_SESSION['scorm_item_id'] = $lp_item_id;
// Reinit exercises variables to avoid spacename clashes (see exercise tool)
@ -170,8 +172,8 @@ if ($debug) {
error_log(" lp_type: $lpType ");
}
$get_toc_list = $_SESSION['oLP']->get_toc();
$get_teacher_buttons = $_SESSION['oLP']->get_teacher_toc_buttons();
$get_toc_list = $lp->get_toc();
$get_teacher_buttons = $lp->get_teacher_toc_buttons();
$type_quiz = false;
foreach ($get_toc_list as $toc) {
@ -184,12 +186,12 @@ if (!isset($src)) {
$src = null;
switch ($lpType) {
case 1:
$_SESSION['oLP']->stop_previous_item();
$lp->stop_previous_item();
$htmlHeadXtra[] = '<script src="scorm_api.php" type="text/javascript" language="javascript"></script>';
$preReqCheck = $_SESSION['oLP']->prerequisites_match($lp_item_id);
$preReqCheck = $lp->prerequisites_match($lp_item_id);
if ($preReqCheck === true) {
$src = $_SESSION['oLP']->get_link(
$src = $lp->get_link(
'http',
$lp_item_id,
$get_toc_list
@ -207,37 +209,37 @@ if (!isset($src)) {
$src = api_get_path(WEB_CODE_PATH).'lp/lp_view_item.php?lp_item_id='.$lp_item_id.'&'.api_get_cidreq();
}
$src = $_SESSION['oLP']->fixBlockedLinks($src);
$src = $lp->fixBlockedLinks($src);
$_SESSION['oLP']->start_current_item(); // starts time counter manually if asset
$lp->start_current_item(); // starts time counter manually if asset
} else {
$src = 'blank.php?error=prerequisites';
}
break;
case 2:
// save old if asset
$_SESSION['oLP']->stop_previous_item(); // save status manually if asset
$lp->stop_previous_item(); // save status manually if asset
$htmlHeadXtra[] = '<script src="scorm_api.php" type="text/javascript" language="javascript"></script>';
$preReqCheck = $_SESSION['oLP']->prerequisites_match($lp_item_id);
$preReqCheck = $lp->prerequisites_match($lp_item_id);
if ($preReqCheck === true) {
$src = $_SESSION['oLP']->get_link('http', $lp_item_id, $get_toc_list);
$_SESSION['oLP']->start_current_item(); // starts time counter manually if asset
$src = $lp->get_link('http', $lp_item_id, $get_toc_list);
$lp->start_current_item(); // starts time counter manually if asset
} else {
$src = 'blank.php?error=prerequisites';
}
break;
case 3:
// aicc
$_SESSION['oLP']->stop_previous_item(); // save status manually if asset
$htmlHeadXtra[] = '<script src="'.$_SESSION['oLP']->get_js_lib().'" type="text/javascript" language="javascript"></script>';
$preReqCheck = $_SESSION['oLP']->prerequisites_match($lp_item_id);
$lp->stop_previous_item(); // save status manually if asset
$htmlHeadXtra[] = '<script src="'.$lp->get_js_lib().'" type="text/javascript" language="javascript"></script>';
$preReqCheck = $lp->prerequisites_match($lp_item_id);
if ($preReqCheck === true) {
$src = $_SESSION['oLP']->get_link(
$src = $lp->get_link(
'http',
$lp_item_id,
$get_toc_list
);
$_SESSION['oLP']->start_current_item(); // starts time counter manually if asset
$lp->start_current_item(); // starts time counter manually if asset
} else {
$src = 'blank.php';
}
@ -262,7 +264,7 @@ if (!empty($_REQUEST['exeId']) &&
isset($_GET['lp_item_id'])
) {
global $src;
$_SESSION['oLP']->items[$_SESSION['oLP']->current]->write_to_db();
$lp->items[$lp->current]->write_to_db();
$TBL_TRACK_EXERCICES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
$TBL_LP_ITEM_VIEW = Database::get_course_table(TABLE_LP_ITEM_VIEW);
@ -296,7 +298,7 @@ if (!empty($_REQUEST['exeId']) &&
WHERE
c_id = $course_id AND
lp_item_id = $safe_item_id AND
lp_view_id = ".$_SESSION['oLP']->lp_view_id."
lp_view_id = ".$lp->lp_view_id."
ORDER BY id DESC
LIMIT 1";
$res_last_attempt = Database::query($sql);
@ -349,37 +351,35 @@ if (!empty($_REQUEST['exeId']) &&
$autostart = 'false';
}
$_SESSION['oLP']->set_previous_item($lp_item_id);
$nameTools = Security::remove_XSS($_SESSION['oLP']->get_name());
$lp->set_previous_item($lp_item_id);
$nameTools = Security::remove_XSS($lp->get_name());
$save_setting = api_get_setting('show_navigation_menu');
global $_setting;
$_setting['show_navigation_menu'] = 'false';
$scorm_css_header = true;
$lp_theme_css = $_SESSION['oLP']->get_theme();
$lp_theme_css = $lp->get_theme();
// Sets the css theme of the LP this call is also use at the frames (toc, nav, message).
if ($_SESSION['oLP']->mode == 'fullscreen') {
if ($lp->mode == 'fullscreen') {
$htmlHeadXtra[] = "<script>window.open('$src','content_id','toolbar=0,location=0,status=0,scrollbars=1,resizable=1');</script>";
}
// Not in fullscreen mode.
// Check if audio recorder needs to be in studentview.
$audio_recorder_studentview = false;
if (isset($_SESSION['status']) && $_SESSION['status'][$course_code] == 5) {
$audio_recorder_studentview = true;
} else {
$audio_recorder_studentview = false;
}
// Set flag to ensure lp_header.php is loaded by this script (flag is unset in lp_header.php).
$_SESSION['loaded_lp_view'] = true;
$display_none = '';
$margin_left = '340px';
// Media player code
$display_mode = $_SESSION['oLP']->mode;
$display_mode = $lp->mode;
$scorm_css_header = true;
$lp_theme_css = $_SESSION['oLP']->get_theme();
$lp_theme_css = $lp->get_theme();
// Setting up the CSS theme if exists.
if (!empty($lp_theme_css) && !empty($mycourselptheme) && $mycourselptheme != -1 && $mycourselptheme == 1) {
@ -388,21 +388,21 @@ if (!empty($lp_theme_css) && !empty($mycourselptheme) && $mycourselptheme != -1
$lp_theme_css = $my_style;
}
$progress_bar = "";
$progress_bar = '';
if (!api_is_invitee()) {
$progress_bar = $_SESSION['oLP']->getProgressBar();
$progress_bar = $lp->getProgressBar();
}
$navigation_bar = $_SESSION['oLP']->get_navigation_bar();
$navigation_bar_bottom = $_SESSION['oLP']->get_navigation_bar("control-bottom", "display:none");
$mediaplayer = $_SESSION['oLP']->get_mediaplayer($_SESSION['oLP']->current, $autostart);
$navigation_bar = $lp->get_navigation_bar();
$navigation_bar_bottom = $lp->get_navigation_bar("control-bottom", "display:none");
$mediaplayer = $lp->get_mediaplayer($lp->current, $autostart);
$tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
$show_audioplayer = false;
// Getting all the information about the item.
$sql = "SELECT audio FROM $tbl_lp_item
WHERE c_id = $course_id AND lp_id = ".$_SESSION['oLP']->lp_id;
WHERE c_id = $course_id AND lp_id = ".$lp->lp_id;
$res_media = Database::query($sql);
$show_audioplayer = false;
if (Database::num_rows($res_media) > 0) {
while ($row_media = Database::fetch_array($res_media)) {
if (!empty($row_media['audio'])) {
@ -421,8 +421,8 @@ if ($is_allowed_to_edit) {
'name' => get_lang('LearningPaths')
);
$interbreadcrumb[] = array(
'url' => api_get_self()."?action=add_item&type=step&lp_id={$_SESSION['oLP']->lp_id}&isStudentView=false&".api_get_cidreq(true, true, 'course'),
'name' => $_SESSION['oLP']->get_name()
'url' => api_get_self()."?action=add_item&type=step&lp_id={$lp->lp_id}&isStudentView=false&".api_get_cidreq(true, true, 'course'),
'name' => $lp->get_name()
);
$interbreadcrumb[] = array(
@ -451,11 +451,11 @@ if (api_get_course_setting('lp_return_link') == 1) {
}
$lpPreviewImagePath = Display::returnIconPath('unknown.png', ICON_SIZE_BIG);
if ($_SESSION['oLP']->get_preview_image()) {
$lpPreviewImagePath = $_SESSION['oLP']->get_preview_image_path();
if ($lp->get_preview_image()) {
$lpPreviewImagePath = $lp->get_preview_image_path();
}
if ($_SESSION['oLP']->current == $_SESSION['oLP']->get_last()) {
if ($lp->current == $lp->get_last()) {
$categories = Category::load(
null,
null,
@ -472,7 +472,7 @@ if ($_SESSION['oLP']->current == $_SESSION['oLP']->get_last()) {
if (count($gradebookEvaluations) === 0 &&
count($gradebookLinks) === 1 &&
$gradebookLinks[0]->get_type() == LINK_LEARNPATH &&
$gradebookLinks[0]->get_ref_id() == $_SESSION['oLP']->lp_id
$gradebookLinks[0]->get_ref_id() == $lp->lp_id
) {
$gradebookMinScore = $categories[0]->getCertificateMinScore();
$userScore = $gradebookLinks[0]->calc_score($user_id, 'best');
@ -485,8 +485,6 @@ if ($_SESSION['oLP']->current == $_SESSION['oLP']->get_last()) {
}
$template = new Template('', false, false, true, true, false);
$template->assign('glossary_extra_tools', api_get_setting('show_glossary_in_extra_tools'));
$fixLinkSetting = api_get_configuration_value('lp_fix_embed_content');
$fixLink = '';
if ($fixLinkSetting) {
@ -494,22 +492,19 @@ if ($fixLinkSetting) {
}
$template->assign('fix_link', $fixLink);
$template->assign(
'glossary_tool_availables',
['true', 'lp', 'exercise_and_lp']
);
$template->assign('glossary_tool_available_list', ['true', 'lp', 'exercise_and_lp']);
// If the global gamification mode is enabled...
$gamificationMode = api_get_setting('gamification_mode');
// ...AND this learning path is set in gamification mode, then change the display
$gamificationMode = $gamificationMode && $_SESSION['oLP']->seriousgame_mode;
$gamificationMode = $gamificationMode && $lp->seriousgame_mode;
$template->assign('gamification_mode', $gamificationMode);
$template->assign('glossary_extra_tools', api_get_setting('show_glossary_in_extra_tools'));
$template->assign('show_glossary_in_documents', api_get_setting('show_glossary_in_documents'));
$template->assign('jquery_web_path', api_get_jquery_web_path());
$template->assign('jquery_ui_js_web_path', api_get_jquery_ui_js_web_path());
$template->assign('jquery_ui_css_web_path', api_get_jquery_ui_css_web_path());
$template->assign('is_allowed_to_edit', $is_allowed_to_edit);
$template->assign('gamification_mode', $gamificationMode);
$template->assign('button_home_url', $buttonHomeUrl);
$template->assign('button_home_text', $buttonHomeText);
$template->assign('navigation_bar', $navigation_bar);
@ -520,36 +515,30 @@ $template->assign('toc_list', $get_toc_list);
$template->assign('teacher_toc_buttons', $get_teacher_buttons);
$template->assign('iframe_src', $src);
$template->assign('navigation_bar_bottom', $navigation_bar_bottom);
$template->assign('show_left_column', $lp->getHideTableOfContents() == 0);
if ($gamificationMode == 1) {
$template->assign(
'gamification_stars',
$_SESSION['oLP']->getCalculateStars($sessionId)
);
$template->assign(
'gamification_points',
$_SESSION['oLP']->getCalculateScore($sessionId)
);
$template->assign('gamification_stars', $lp->getCalculateStars($sessionId));
$template->assign('gamification_points', $lp->getCalculateScore($sessionId));
}
$template->assign('lp_author', $lp->get_author());
$template->assign('lp_mode', $lp->mode);
$template->assign('lp_title_scorm', $lp->name);
$template->assign('data_list', $lp->getListArrayToc($get_toc_list));
$template->assign('lp_id', $lp->lp_id);
$template->assign('lp_current_item_id', $lp->get_current_item_id());
$template->assign('disable_js_in_lp_view', (int) api_get_configuration_value('disable_js_in_lp_view'));
$template->assign(
'lp_preview_image',
Display::img(
$lpPreviewImagePath,
$_SESSION['oLP']->name,
$lp->name,
[],
ICON_SIZE_BIG
)
);
$template->assign('lp_author', $_SESSION['oLP']->get_author());
$template->assign('lp_mode', $_SESSION['oLP']->mode);
$template->assign('lp_title_scorm', $_SESSION['oLP']->name);
$template->assign('data_list', $_SESSION['oLP']->getListArrayToc($get_toc_list));
$template->assign('lp_id', $_SESSION['oLP']->lp_id);
$template->assign('lp_current_item_id', $_SESSION['oLP']->get_current_item_id());
$template->assign('disable_js_in_lp_view', (int) api_get_configuration_value('disable_js_in_lp_view'));
$view = $template->get_template('learnpath/view.tpl');
$content = $template->fetch($view);
@ -559,6 +548,8 @@ $template->display_no_layout_template();
// Restore a global setting.
$_setting['show_navigation_menu'] = $save_setting;
Session::write('lp', $lp);
if ($debug) {
error_log(' ------- end lp_view.php ------');
}

@ -1,4 +1,5 @@
<div id="learning_path_main" class="{{ is_allowed_to_edit ? 'lp-view-include-breadcrumb' }} {{ lp_mode == 'embedframe' ? 'lp-view-collapsed' }}">
{% if show_left_column == 1 %}
<div id="learning_path_left_zone" class="sidebar-scorm">
<div class="lp-view-zone-container">
<div id="scorm-info">
@ -71,7 +72,10 @@
</div>
</div>
{# end left zone #}
{% endif %}
<div id="lp_navigation_elem" class="navegation-bar">
{% if show_left_column == 1 %}
<a href="#" title = "{{ 'Expand'|get_lang }}" id="lp-view-expand-toggle" class="icon-toolbar expand" role="button">
{% if lp_mode == 'embedframe' %}
<span class="fa fa-compress" aria-hidden="true"></span>
@ -81,26 +85,35 @@
<span class="sr-only">{{ 'Expand'|get_lang }}</span>
{% endif %}
</a>
{% endif %}
<a id="home-course" title = "{{ 'Home'|get_lang }}" href="{{ button_home_url }}" class="icon-toolbar" target="_self" onclick="javascript: window.parent.API.save_asset();">
<em class="fa fa-home"></em> <span class="hidden-xs hidden-sm"></span>
</a>
{{ navigation_bar }}
</div>
{# <div id="hide_bar" class="scorm-toggle" style="display:inline-block; width: 25px; height: 1000px;"></div> #}
{# right zone #}
<div id="learning_path_right_zone" class="content-scorm">
{% if show_left_column == 1 %}
<div id="learning_path_right_zone" class="content-scorm">
{% else %}
<div id="" class="content-scorm">
{% endif %}
<div class="lp-view-zone-container">
<div class="lp-view-tabs">
<div id="navTabsbar" class="nav-tabs-bar">
<ul id="navTabs" class="nav nav-tabs" role="tablist">
<li role="presentation" class="active">
<a href="#lp-view-content" title="{{ 'Lesson'|get_lang }}" aria-controls="lp-view-content" role="tab" data-toggle="tab">
<span class="fa fa-book fa-2x fa-fw" aria-hidden="true"></span><span class="sr-only">{{ 'Lesson'|get_lang }}</span>
<span class="fa fa-book fa-2x fa-fw" aria-hidden="true"></span>
<span class="sr-only">{{ 'Lesson'|get_lang }}</span>
</a>
</li>
<li role="presentation">
<a href="#lp-view-forum" title="{{ 'Forum'|get_lang }}" aria-controls="lp-view-forum" role="tab" data-toggle="tab">
<span class="fa fa-commenting-o fa-2x fa-fw" aria-hidden="true"></span><span class="sr-only">{{ 'Forum'|get_lang }}</span>
<span class="fa fa-commenting-o fa-2x fa-fw" aria-hidden="true"></span>
<span class="sr-only">{{ 'Forum'|get_lang }}</span>
</a>
</li>
</ul>
@ -116,7 +129,6 @@
</div>
</div>
<div role="tabpanel" class="tab-pane" id="lp-view-forum">
</div>
</div>
</div>
@ -189,9 +201,7 @@
} else {
$('#navTabsbar').hide();
}
});
{% endif %}
$('.lp-view-tabs').on('click', '.disabled', function (e) {
@ -227,7 +237,7 @@
loadForumThread({{ lp_id }}, {{ lp_current_item_id }});
checkCurrentItemPosition({{ lp_current_item_id }});
{% if glossary_extra_tools in glossary_tool_availables %}
{% if glossary_extra_tools in glossary_tool_available_list %}
// Loads the glossary library.
(function () {
{% if show_glossary_in_documents == 'ismanual' %}

Loading…
Cancel
Save