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 e609e6cf02
commit d92c406a51
2 changed files with 26 additions and 11 deletions

View File

@ -288,10 +288,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 $cfgscorm->allowtypeexternal) {
@ -305,10 +308,14 @@ function scorm_parse($scorm, $full) {
} else if ($scorm->scormtype === SCORM_TYPE_AICCURL and $cfgscorm->allowtypeexternalaicc) {
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 {
// Sorry, disabled type.
return;
@ -1855,7 +1862,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);
}

View File

@ -737,13 +737,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).