diff --git a/main/inc/lib/userportal.lib.php b/main/inc/lib/userportal.lib.php index b8d1f01ae9..e26dc39cd6 100755 --- a/main/inc/lib/userportal.lib.php +++ b/main/inc/lib/userportal.lib.php @@ -1191,7 +1191,7 @@ class IndexManager $listCourse = ''; $specialCourseList = ''; $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'); $coursesWithoutCategoryTemplate = '/user_portal/classic_courses_without_category.tpl'; @@ -1798,7 +1798,7 @@ class IndexManager if ($viewGridCourses) { $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 { $sessions_with_no_category = $this->tpl->fetch( diff --git a/main/lp/learnpath.class.php b/main/lp/learnpath.class.php index 7ad81af09c..98880ae061 100755 --- a/main/lp/learnpath.class.php +++ b/main/lp/learnpath.class.php @@ -2992,7 +2992,8 @@ class learnpath 'type' => $this->items[$item_id]->get_type(), 'description' => $this->items[$item_id]->get_description(), 'path' => $this->items[$item_id]->get_path(), - ); + 'parent' => $this->items[$item_id]->get_parent(), + ); } if ($this->debug > 2) { error_log('New LP - In learnpath::get_toc() - TOC array: '.print_r($toc, true), 0); @@ -3111,6 +3112,147 @@ class learnpath '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 * @return string HTML TOC ready to display diff --git a/main/lp/lp_view.php b/main/lp/lp_view.php index ce76f3ed3b..fe959101e0 100755 --- a/main/lp/lp_view.php +++ b/main/lp/lp_view.php @@ -545,7 +545,8 @@ $template->assign( $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)); +// supprimer pour OFAJ +//$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()); diff --git a/main/template/rainbow/learnpath/scorm_list.tpl b/main/template/rainbow/learnpath/scorm_list.tpl index 2e0bc046cd..98304023f2 100644 --- a/main/template/rainbow/learnpath/scorm_list.tpl +++ b/main/template/rainbow/learnpath/scorm_list.tpl @@ -1,7 +1,6 @@ {% if data_list is not empty %}
-

{{ lp_title_scorm }}

{% for item in data_list %}
@@ -23,4 +22,50 @@
{% endif %} -{{ accorden_toc }} \ No newline at end of file +{% if data_panel is not empty %} +
+ {% for item in data_panel.are_parents %} +
+ +
+
+
    + {% set counter = 0 %} + {% set final = item.children|length %} + {% for subitem in item.children %} + {% set counter = counter + 1 %} +
  • + +
  • + + {% endfor %} +
+
+
+
+ {% endfor %} + +
+{% endif %} diff --git a/main/template/rainbow/learnpath/view.tpl b/main/template/rainbow/learnpath/view.tpl index c1e6d914cd..7f9b25d635 100644 --- a/main/template/rainbow/learnpath/view.tpl +++ b/main/template/rainbow/learnpath/view.tpl @@ -85,10 +85,13 @@ {# TOC layout #}
+ + {% include template ~ '/learnpath/scorm_list.tpl' %}
{# end TOC layout #}