MDL-46639 mod_scorm: Fix load of simple AICC content

Thanks to Ian Wild for the report and suggested patch.
This commit is contained in:
Dan Marsden 2014-08-14 00:01:50 +12:00
parent fd72531964
commit 9dc8c0f8b1
2 changed files with 27 additions and 13 deletions

View file

@ -286,11 +286,13 @@ function scorm_parse($scorm, $full) {
} }
} else { } else {
require_once("$CFG->dirroot/mod/scorm/datamodels/aicclib.php"); require_once("$CFG->dirroot/mod/scorm/datamodels/aicclib.php");
// AICC $result = scorm_parse_aicc($scorm);
if (!scorm_parse_aicc($scorm)) { if (!$result) {
$scorm->version = 'ERROR'; $scorm->version = 'ERROR';
} else {
$scorm->version = 'AICC';
$scorm->launch = $result;
} }
$scorm->version = 'AICC';
} }
} else if ($scorm->scormtype === SCORM_TYPE_EXTERNAL and $cfg_scorm->allowtypeexternal) { } 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) { } else if ($scorm->scormtype === SCORM_TYPE_AICCURL and $cfg_scorm->allowtypeexternalaicc) {
require_once("$CFG->dirroot/mod/scorm/datamodels/aicclib.php"); require_once("$CFG->dirroot/mod/scorm/datamodels/aicclib.php");
// AICC // AICC.
if (!scorm_parse_aicc($scorm)) { $result = scorm_parse_aicc($scorm);
if (!$result) {
$scorm->version = 'ERROR'; $scorm->version = 'ERROR';
} else {
$scorm->version = 'AICC';
$scorm->launch = $result;
} }
$scorm->version = 'AICC';
} else { } else {
// sorry, disabled type // sorry, disabled type
return; return;
@ -1792,7 +1798,13 @@ function scorm_get_toc($user, $scorm, $cmid, $toclink=TOCJSLINK, $currentorg='',
} }
if (empty($scoid)) { 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 { } else {
$result->sco = scorm_get_sco($scoid); $result->sco = scorm_get_sco($scoid);
} }

View file

@ -742,13 +742,15 @@ M.mod_scorm.init = function(Y, nav_display, navposition_left, navposition_top, h
// finally activate the chosen item // finally activate the chosen item
var scorm_first_url = null; var scorm_first_url = null;
if (tree.rootNode.children[0].title !== scoes_nav[launch_sco].url) { if (typeof tree.rootNode.children[0] !== 'undefined') {
var node = tree.getNodeByAttribute('title', scoes_nav[launch_sco].url); if (tree.rootNode.children[0].title !== scoes_nav[launch_sco].url) {
if (node !== null) { var node = tree.getNodeByAttribute('title', scoes_nav[launch_sco].url);
scorm_first_url = node; 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). if (scorm_first_url == null) { // This is probably a single sco with no children (AICC Direct uses this).