diff --git a/mod/scorm/locallib.php b/mod/scorm/locallib.php
index c9bcc44fa26..4a59446c6aa 100644
--- a/mod/scorm/locallib.php
+++ b/mod/scorm/locallib.php
@@ -1294,7 +1294,6 @@ function scorm_get_toc($user,$scorm,$cmid,$toclink=TOCJSLINK,$currentorg='',$sco
$nextid = 0;
$findnext = false;
$parents[$level]='/';
-
foreach ($scoes as $pos => $sco) {
$isvisible = false;
$sco->title = $sco->title;
@@ -1311,11 +1310,15 @@ function scorm_get_toc($user,$scorm,$cmid,$toclink=TOCJSLINK,$currentorg='',$sco
$i = $level;
$closelist = '';
while (($i > 0) && ($parents[$level] != $sco->parent)) {
- $closelist .= "\t\t\n";
+ if ($i === 1) {
+ $closelist .= "\t\t\n";
+ } else {
+ $closelist .= "\t\n";
+ }
$i--;
}
if (($i == 0) && ($sco->parent != $currentorg)) {
- $result->toc .= "\t\t
\n";
+ $result->toc .= "\n\t\n";
$level++;
} else {
$result->toc .= $closelist;
@@ -1343,8 +1346,8 @@ function scorm_get_toc($user,$scorm,$cmid,$toclink=TOCJSLINK,$currentorg='',$sco
if (empty($sco->title)) {
$sco->title = $sco->identifier;
}
- if (!empty($sco->launch)) {
- if ($isvisible) {
+ if ($isvisible) {
+ if (!empty($sco->launch)) {
$score = '';
if (empty($scoid) && ($mode != 'normal')) {
$scoid = $sco->id;
@@ -1431,12 +1434,12 @@ function scorm_get_toc($user,$scorm,$cmid,$toclink=TOCJSLINK,$currentorg='',$sco
$result->toc .= $statusicon.' '.format_string($sco->title)."\n";
}
}
- if (($nextsco === false) || $nextsco->parent == $sco->parent) {
- $result->toc .= '';
- }
+ } else {
+ $result->toc .= ' '.format_string($sco->title);
+ }
+ if (($nextsco === false) || $nextsco->parent == $sco->parent) {
+ $result->toc .= "\n";
}
- } else {
- $result->toc .= ' '.format_string($sco->title)."\n";
}
if (($nextsco !== false) && ($nextid == 0) && ($findnext)) {
if (!empty($nextsco->launch)) {