fix scorm tpl in merge - refs BT#12681

Conflicts:
	main/lp/learnpath.class.php
	main/lp/lp_view.php
	main/template/rainbow/learnpath/view.tpl
pull/3063/head
Alex Aragon 9 years ago committed by Nicolas Ducoulombier
parent 11805e826e
commit 5ba51f0909
  1. 4
      main/inc/lib/userportal.lib.php
  2. 142
      main/lp/learnpath.class.php
  3. 3
      main/lp/lp_view.php
  4. 49
      main/template/rainbow/learnpath/scorm_list.tpl
  5. 3
      main/template/rainbow/learnpath/view.tpl

@ -1191,7 +1191,7 @@ class IndexManager
$listCourse = ''; $listCourse = '';
$specialCourseList = ''; $specialCourseList = '';
$load_history = isset($_GET['history']) && intval($_GET['history']) == 1 ? true : false; $load_history = isset($_GET['history']) && intval($_GET['history']) == 1 ? true : false;
$viewGridCourses = api_get_configuration_value('view_grid_courses') === 'true'; $viewGridCourses = api_get_configuration_value('view_grid_courses') === true;
$showSimpleSessionInfo = api_get_configuration_value('show_simple_session_info'); $showSimpleSessionInfo = api_get_configuration_value('show_simple_session_info');
$coursesWithoutCategoryTemplate = '/user_portal/classic_courses_without_category.tpl'; $coursesWithoutCategoryTemplate = '/user_portal/classic_courses_without_category.tpl';
@ -1798,7 +1798,7 @@ class IndexManager
if ($viewGridCourses) { if ($viewGridCourses) {
$sessions_with_no_category = $this->tpl->fetch( $sessions_with_no_category = $this->tpl->fetch(
$this->tpl->get_template('/user_portal/grid_session.tpl') $this->tpl->get_template('user_portal/grid_session.tpl')
); );
} else { } else {
$sessions_with_no_category = $this->tpl->fetch( $sessions_with_no_category = $this->tpl->fetch(

@ -2992,6 +2992,7 @@ class learnpath
'type' => $this->items[$item_id]->get_type(), 'type' => $this->items[$item_id]->get_type(),
'description' => $this->items[$item_id]->get_description(), 'description' => $this->items[$item_id]->get_description(),
'path' => $this->items[$item_id]->get_path(), 'path' => $this->items[$item_id]->get_path(),
'parent' => $this->items[$item_id]->get_parent(),
); );
} }
if ($this->debug > 2) { if ($this->debug > 2) {
@ -3111,6 +3112,147 @@ class learnpath
'dir' 'dir'
); );
} }
/**
* Uses the table generated by get_toc() and returns an HTML-formattedstring ready to display
* @return string HTML TOC ready to display
*/
public function getParentToc($tree)
{
if ($this->debug > 0) {
error_log('In learnpath::get_html_toc()', 0);
}
if (empty($tree)) {
$tree = $this->get_toc();
}
$dirTypes = self::getChapterTypes();
$myCurrentId = $this->get_current_item_id();
$listParent = [];
$listChildren = [];
$listNotParent = [];
$list = [];
foreach ($tree as $subtree) {
if (in_array($subtree['type'], $dirTypes)){
$listChildren = $this->getChildrenToc($tree, $subtree['id']);
$subtree['children'] = $listChildren;
if (!empty($subtree['children'])) {
foreach ($subtree['children'] as $subItem) {
if ($subItem['id'] == $this->current) {
$subtree['parent_current'] = 'in';
$subtree['current'] = 'on';
}
}
}
$listParent[] = $subtree;
}
if (!in_array($subtree['type'], $dirTypes) && $subtree['parent'] == null ) {
$classStatus = [
'not attempted' => 'scorm_not_attempted',
'incomplete' => 'scorm_not_attempted',
'failed' => 'scorm_failed',
'completed' => 'scorm_completed',
'passed' => 'scorm_completed',
'succeeded' => 'scorm_completed',
'browsed' => 'scorm_completed',
];
if (isset($classStatus[$subtree['status']])) {
$cssStatus = $classStatus[$subtree['status']];
}
$title = Security::remove_XSS($subtree['title']);
unset($subtree['title']);
if (empty ($title)) {
$title = self::rl_get_resource_name(api_get_course_id(), $this->get_id(), $subtree['id']);
}
$classStyle = null;
if ($subtree['id'] == $this->current) {
$classStyle = 'scorm_item_normal '. $classStyle . 'scorm_highlight';
} elseif (!in_array($subtree['type'], $dirTypes)) {
$classStyle = 'scorm_item_normal '. $classStyle . ' ';
}
$subtree['title'] = $title;
$subtree['class'] = $cssStatus . ' ' .$classStyle;
$subtree['url'] = $this->get_link('http', $subtree['id'], $tree);
$subtree['current_id'] = $myCurrentId;
$listNotParent[] = $subtree;
}
}
$list['are_parents'] = $listParent;
$list['not_parents'] = $listNotParent;
return $list;
}
/**
* Uses the table generated by get_toc() and returns an HTML-formattedstring ready to display
* @return string HTML TOC ready to display
*/
public function getChildrenToc($tree, $id, $parent = true)
{
if ($this->debug > 0) {
error_log('In learnpath::get_html_toc()', 0);
}
if (empty($tree)) {
$tree = $this->get_toc();
}
$dirTypes = self::getChapterTypes();
$mycurrentitemid = $this->get_current_item_id();
$list = [];
$classStatus = [
'not attempted' => 'scorm_not_attempted',
'incomplete' => 'scorm_not_attempted',
'failed' => 'scorm_failed',
'completed' => 'scorm_completed',
'passed' => 'scorm_completed',
'succeeded' => 'scorm_completed',
'browsed' => 'scorm_completed',
];
foreach ($tree as $subtree) {
$subtree['tree'] = null;
if (!in_array($subtree['type'], $dirTypes) && $subtree['parent'] == $id ) {
if ($subtree['id'] == $this->current) {
$subtree['current'] = 'active';
} else {
$subtree['current'] = null;
}
if (isset($classStatus[$subtree['status']])) {
$cssStatus = $classStatus[$subtree['status']];
}
$title = Security::remove_XSS($subtree['title']);
unset($subtree['title']);
if (empty ($title)) {
$title = self::rl_get_resource_name(api_get_course_id(), $this->get_id(), $subtree['id']);
}
$classStyle = null;
if ($subtree['id'] == $this->current) {
$classStyle = 'scorm_item_normal '. $classStyle . 'scorm_highlight';
} elseif (!in_array($subtree['type'], $dirTypes)) {
$classStyle = 'scorm_item_normal '. $classStyle . ' ';
}
if (in_array($subtree['type'], $dirTypes)) {
$subtree['title'] = stripslashes($title);
} else {
$subtree['title'] = $title;
$subtree['class'] = $cssStatus . ' ' .$classStyle;
$subtree['url'] = $this->get_link('http', $subtree['id'], $tree);
$subtree['current_id'] = $mycurrentitemid;
}
$list[] = $subtree;
}
}
return $list;
}
/** /**
* Uses the table generated by get_toc() and returns an HTML-formatted string ready to display * Uses the table generated by get_toc() and returns an HTML-formatted string ready to display
* @return string HTML TOC ready to display * @return string HTML TOC ready to display

@ -545,7 +545,8 @@ $template->assign(
$template->assign('lp_author', $_SESSION['oLP']->get_author()); $template->assign('lp_author', $_SESSION['oLP']->get_author());
$template->assign('lp_mode', $_SESSION['oLP']->mode); $template->assign('lp_mode', $_SESSION['oLP']->mode);
$template->assign('lp_title_scorm', $_SESSION['oLP']->name); $template->assign('lp_title_scorm', $_SESSION['oLP']->name);
$template->assign('data_list', $_SESSION['oLP']->getListArrayToc($get_toc_list)); // supprimer pour OFAJ
//$template->assign('data_list', $_SESSION['oLP']->getListArrayToc($get_toc_list));
$template->assign('lp_id', $_SESSION['oLP']->lp_id); $template->assign('lp_id', $_SESSION['oLP']->lp_id);
$template->assign('lp_current_item_id', $_SESSION['oLP']->get_current_item_id()); $template->assign('lp_current_item_id', $_SESSION['oLP']->get_current_item_id());

@ -1,7 +1,6 @@
{% if data_list is not empty %} {% if data_list is not empty %}
<div id="learning_path_toc" class="scorm-list"> <div id="learning_path_toc" class="scorm-list">
<div class="scorm-body"> <div class="scorm-body">
<h1 class="scorm-title">{{ lp_title_scorm }}</h1>
<div id="inner_lp_toc" class="inner_lp_toc scrollbar-light"> <div id="inner_lp_toc" class="inner_lp_toc scrollbar-light">
{% for item in data_list %} {% for item in data_list %}
<div id="toc_{{ item.id }}" class="{{ item.class }}"> <div id="toc_{{ item.id }}" class="{{ item.class }}">
@ -23,4 +22,50 @@
</div> </div>
</div> </div>
{% endif %} {% endif %}
{{ accorden_toc }} {% if data_panel is not empty %}
<div class="panel-group" id="scorm-panel" role="tablist" aria-multiselectable="true">
{% for item in data_panel.are_parents %}
<div class="panel panel-default">
<div class="status-heading">
<div class="panel-heading {{ item.current }}" role="tab" id="heading-{{ item.id }}">
<a role="button" data-toggle="collapse" data-parent="#scorm-panel" href="#collapse-{{ item.id }}" aria-expanded="true" aria-controls="collapse-{{ item.id }}">
{{ item.title }}
</a>
</div>
</div>
<div id="collapse-{{ item.id }}" class="panel-collapse collapse {{ item.parent_current }}" role="tabpanel" aria-labelledby="heading-{{ item.id }}">
<div class="panel-body">
<ul class="section-list">
{% set counter = 0 %}
{% set final = item.children|length %}
{% for subitem in item.children %}
{% set counter = counter + 1 %}
<li id="toc_{{ subitem.id }}" class="{{ subitem.class }} {{ counter == final ? 'final':'' }}">
<div class="sub-item type-{{ subitem.type }}">
<a name="atoc_{{ subitem.id }}"></a>
<a class="item-action" href="#" onclick="switch_item('{{ subitem.current_id }}','{{ subitem.id }}'); return false;" >
{{ subitem.title }}
</a>
</div>
</li>
{% endfor %}
</ul>
</div>
</div>
</div>
{% endfor %}
<ul class="section-list" style="margin-top: 5px;">
{% for item in data_panel.not_parents %}
<li id="toc_{{ item.id }}" class="{{ item.class }}">
<div class="sub-item type-{{ item.type }}">
<a name="atoc_{{ item.id }}"></a>
<a class="item-action" href="#" onclick="switch_item('{{ item.current_id }}','{{ item.id }}'); return false;" >
{{ item.title }}
</a>
</div>
</li>
{% endfor %}
</ul>
</div>
{% endif %}

@ -85,10 +85,13 @@
{# TOC layout #} {# TOC layout #}
<div id="toc_id" class="scorm-body" name="toc_name"> <div id="toc_id" class="scorm-body" name="toc_name">
<!--- supprimer pour OFAJ
<div id="learning_path_toc" class="scorm-list"> <div id="learning_path_toc" class="scorm-list">
<h1 class="scorm-title">{{ lp_title_scorm }}</h1> <h1 class="scorm-title">{{ lp_title_scorm }}</h1>
{{ lp_html_toc }} {{ lp_html_toc }}
</div> </div>
-->
{% include template ~ '/learnpath/scorm_list.tpl' %}
</div> </div>
{# end TOC layout #} {# end TOC layout #}
</div> </div>

Loading…
Cancel
Save