|
|
|
@ -3111,12 +3111,11 @@ class learnpath |
|
|
|
|
'dir' |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Uses the table generated by get_toc() and returns an HTML-formatted string ready to display |
|
|
|
|
* @return string HTML TOC ready to display |
|
|
|
|
*/ |
|
|
|
|
public function get_html_toc($toc_list = null) |
|
|
|
|
public function getListArrayToc($toc_list = null) |
|
|
|
|
{ |
|
|
|
|
if ($this->debug > 0) { |
|
|
|
|
error_log('In learnpath::get_html_toc()', 0); |
|
|
|
@ -3124,81 +3123,75 @@ class learnpath |
|
|
|
|
if (empty($toc_list)) { |
|
|
|
|
$toc_list = $this->get_toc(); |
|
|
|
|
} |
|
|
|
|
$html = '<div class="scorm-body">'; |
|
|
|
|
$html .= '<div id="inner_lp_toc" class="inner_lp_toc scrollbar-light">'; |
|
|
|
|
|
|
|
|
|
// Temporary variables. |
|
|
|
|
$mycurrentitemid = $this->get_current_item_id(); |
|
|
|
|
$color_counter = 0; |
|
|
|
|
$i = 0; |
|
|
|
|
|
|
|
|
|
foreach ($toc_list as $item) { |
|
|
|
|
// Style Status |
|
|
|
|
$class_name = [ |
|
|
|
|
'not attempted' => 'scorm_not_attempted', |
|
|
|
|
'incomplete' => 'scorm_not_attempted', |
|
|
|
|
'failed' => 'scorm_failed', |
|
|
|
|
'completed' => 'scorm_completed', |
|
|
|
|
'passed' => 'scorm_completed', |
|
|
|
|
'succeeded' => 'scorm_completed', |
|
|
|
|
'browsed' => 'scorm_completed', |
|
|
|
|
$list = []; |
|
|
|
|
$arrayList = []; |
|
|
|
|
$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 ($toc_list as $item) { |
|
|
|
|
|
|
|
|
|
$rowColor = ' '; |
|
|
|
|
$list['id'] = $item['id']; |
|
|
|
|
$list['status'] = $item['status']; |
|
|
|
|
$cssStatus = null; |
|
|
|
|
|
|
|
|
|
if (isset($classStatus[$item['status']])) { |
|
|
|
|
$cssStatus = $classStatus[$item['status']]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$classStyle = ' '; |
|
|
|
|
$dirTypes = self::getChapterTypes(); |
|
|
|
|
|
|
|
|
|
if (in_array($item['type'], $dirTypes)) { |
|
|
|
|
$rowColor ='scorm_item_section '; |
|
|
|
|
$classStyle = 'scorm_item_section '; |
|
|
|
|
} |
|
|
|
|
if ($item['id'] == $this->current) { |
|
|
|
|
$rowColor = 'scorm_item_normal '.$rowColor.' scorm_highlight'; |
|
|
|
|
$classStyle = 'scorm_item_normal '.$classStyle.'scorm_highlight'; |
|
|
|
|
} elseif (!in_array($item['type'], $dirTypes)) { |
|
|
|
|
$rowColor = 'scorm_item_normal '.$rowColor.' '; |
|
|
|
|
$classStyle = 'scorm_item_normal '.$classStyle.' '; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$html .= '<div id="toc_' . $item['id'] . '" class="' . $rowColor . ' ' . $class_name[$item['status']] . '">'; |
|
|
|
|
|
|
|
|
|
// Learning path title |
|
|
|
|
$title = $item['title']; |
|
|
|
|
if (empty ($title)) { |
|
|
|
|
if (empty($title)) { |
|
|
|
|
$title = self::rl_get_resource_name(api_get_course_id(), $this->get_id(), $item['id']); |
|
|
|
|
} |
|
|
|
|
$title = Security::remove_XSS($title); |
|
|
|
|
|
|
|
|
|
// Learning path personalization |
|
|
|
|
// build the LP tree |
|
|
|
|
// The anchor atoc_ will let us center the TOC on the currently viewed item &^D |
|
|
|
|
$description = $item['description']; |
|
|
|
|
if (empty($description)) { |
|
|
|
|
$description = $title; |
|
|
|
|
} |
|
|
|
|
if (in_array($item['type'], $dirTypes)) { |
|
|
|
|
// Chapters |
|
|
|
|
$html .= '<div class="section level_'.$item['level'].'" title="'.$description.'" >'; |
|
|
|
|
$title = Security::remove_XSS($item['title']); |
|
|
|
|
|
|
|
|
|
if (empty($item['description'])) { |
|
|
|
|
$list['description'] = $title; |
|
|
|
|
} else { |
|
|
|
|
$html .= '<div class="item level_'.$item['level'].' scorm_type_'.self::format_scorm_type_item($item['type']).'" title="'.$description.'" >'; |
|
|
|
|
$html .= '<a name="atoc_'.$item['id'].'"></a>'; |
|
|
|
|
$list['description'] = $item['description']; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$list['class'] = $classStyle.' '.$cssStatus; |
|
|
|
|
$list['level'] = $item['level']; |
|
|
|
|
$list['type'] = $item['type']; |
|
|
|
|
|
|
|
|
|
if (in_array($item['type'], $dirTypes)) { |
|
|
|
|
// Chapter |
|
|
|
|
// if you want to put an image before, you should use css |
|
|
|
|
$html .= stripslashes($title); |
|
|
|
|
$list['css_level'] = 'level_'.$item['level']; |
|
|
|
|
} else { |
|
|
|
|
$this->get_link('http', $item['id'], $toc_list); |
|
|
|
|
$html .= '<a class="items-list" href="#" onclick="switch_item(' .$mycurrentitemid . ',' .$item['id'] . ');' .'return false;" >' . stripslashes($title) . '</a>'; |
|
|
|
|
$list['css_level'] = 'level_'.$item['level'] |
|
|
|
|
.' scorm_type_' |
|
|
|
|
.learnpath::format_scorm_type_item($item['type']); |
|
|
|
|
} |
|
|
|
|
$html .= "</div>"; |
|
|
|
|
|
|
|
|
|
if ($rowColor != '') { |
|
|
|
|
$html .= '</div>'; |
|
|
|
|
if (in_array($item['type'], $dirTypes)) { |
|
|
|
|
$list['title'] = stripslashes($title); |
|
|
|
|
} else { |
|
|
|
|
$list['title'] = stripslashes($title); |
|
|
|
|
$list['url'] = $this->get_link('http', $item['id'], $toc_list); |
|
|
|
|
$list['current_id'] = $mycurrentitemid; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$color_counter++; |
|
|
|
|
$arrayList[] = $list; |
|
|
|
|
} |
|
|
|
|
$html .= "</div>"; |
|
|
|
|
$html .= "</div>"; |
|
|
|
|
return $html; |
|
|
|
|
|
|
|
|
|
return $arrayList; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|