diff --git a/mod/scorm/locallib.php b/mod/scorm/locallib.php index ac2753f222d..626b63621bf 100644 --- a/mod/scorm/locallib.php +++ b/mod/scorm/locallib.php @@ -286,11 +286,13 @@ function scorm_parse($scorm, $full) { } } else { require_once("$CFG->dirroot/mod/scorm/datamodels/aicclib.php"); - // AICC - if (!scorm_parse_aicc($scorm)) { + $result = scorm_parse_aicc($scorm); + if (!$result) { $scorm->version = 'ERROR'; + } else { + $scorm->version = 'AICC'; + $scorm->launch = $result; } - $scorm->version = 'AICC'; } } else if ($scorm->scormtype === SCORM_TYPE_EXTERNAL and $cfg_scorm->allowtypeexternal) { @@ -303,11 +305,15 @@ function scorm_parse($scorm, $full) { } else if ($scorm->scormtype === SCORM_TYPE_AICCURL and $cfg_scorm->allowtypeexternalaicc) { require_once("$CFG->dirroot/mod/scorm/datamodels/aicclib.php"); - // AICC - if (!scorm_parse_aicc($scorm)) { + // AICC. + $result = scorm_parse_aicc($scorm); + if (!$result) { $scorm->version = 'ERROR'; + } else { + $scorm->version = 'AICC'; + $scorm->launch = $result; } - $scorm->version = 'AICC'; + } else { // sorry, disabled type return; @@ -1792,7 +1798,13 @@ function scorm_get_toc($user, $scorm, $cmid, $toclink=TOCJSLINK, $currentorg='', } if (empty($scoid)) { - $result->sco = $scoes['scoes'][0]->children[0]; + // If this is a normal package with an org sco and child scos get the first child. + if (!empty($scoes['scoes'][0]->children)) { + $result->sco = $scoes['scoes'][0]->children[0]; + } else { // This package only has one sco - it may be a simple external AICC package. + $result->sco = $scoes['scoes'][0]; + } + } else { $result->sco = scorm_get_sco($scoid); } diff --git a/mod/scorm/module.js b/mod/scorm/module.js index f64902113a3..c07ec2412f8 100644 --- a/mod/scorm/module.js +++ b/mod/scorm/module.js @@ -742,13 +742,15 @@ M.mod_scorm.init = function(Y, nav_display, navposition_left, navposition_top, h // finally activate the chosen item var scorm_first_url = null; - if (tree.rootNode.children[0].title !== scoes_nav[launch_sco].url) { - var node = tree.getNodeByAttribute('title', scoes_nav[launch_sco].url); - if (node !== null) { - scorm_first_url = node; + if (typeof tree.rootNode.children[0] !== 'undefined') { + if (tree.rootNode.children[0].title !== scoes_nav[launch_sco].url) { + var node = tree.getNodeByAttribute('title', scoes_nav[launch_sco].url); + if (node !== null) { + scorm_first_url = node; + } + } else { + scorm_first_url = tree.rootNode.children[0]; } - } else { - scorm_first_url = tree.rootNode.children[0]; } if (scorm_first_url == null) { // This is probably a single sco with no children (AICC Direct uses this).