|
|
|
@ -3147,6 +3147,145 @@ class learnpath |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 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 |
|
|
|
|
* @param array $toc_list |
|
|
|
|