Skip to content

Commit

Permalink
MDL-28311 SCORM tidy up php warnings and display warning message to t…
Browse files Browse the repository at this point in the history
…eacher that their manifest is invalid
  • Loading branch information
danmarsden committed Aug 3, 2011
1 parent 3fdc622 commit 03c3488
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
24 changes: 19 additions & 5 deletions mod/scorm/datamodels/scormlib.php
Expand Up @@ -17,7 +17,7 @@
function scorm_get_resources($blocks) {
$resources = array();
foreach ($blocks as $block) {
if ($block['name'] == 'RESOURCES') {
if ($block['name'] == 'RESOURCES' && isset($block['children'])) {
foreach ($block['children'] as $resource) {
if ($resource['name'] == 'RESOURCE') {
$resources[addslashes_js($resource['attrs']['IDENTIFIER'])] = $resource['attrs'];
Expand All @@ -29,12 +29,14 @@ function scorm_get_resources($blocks) {
}

function scorm_get_manifest($blocks, $scoes) {
global $OUTPUT;
static $parents = array();
static $resources;

static $manifest;
static $organization;

$manifestresourcesnotfound = array();
if (count($blocks) > 0) {
foreach ($blocks as $block) {
switch ($block['name']) {
Expand Down Expand Up @@ -130,11 +132,16 @@ function scorm_get_manifest($blocks, $scoes) {
if (isset($resources[$idref]['XML:BASE'])) {
$base = $resources[$idref]['XML:BASE'];
}
$scoes->elements[$manifest][$organization][$identifier]->launch = $base.$resources[$idref]['HREF'];
if (empty($resources[$idref]['ADLCP:SCORMTYPE'])) {
$resources[$idref]['ADLCP:SCORMTYPE'] = 'asset';
if (!isset($resources[$idref])) {
$manifestresourcesnotfound[] = $idref;
$scoes->elements[$manifest][$organization][$identifier]->launch = '';
} else {
$scoes->elements[$manifest][$organization][$identifier]->launch = $base.$resources[$idref]['HREF'];
if (empty($resources[$idref]['ADLCP:SCORMTYPE'])) {
$resources[$idref]['ADLCP:SCORMTYPE'] = 'asset';
}
$scoes->elements[$manifest][$organization][$identifier]->scormtype = $resources[$idref]['ADLCP:SCORMTYPE'];
}
$scoes->elements[$manifest][$organization][$identifier]->scormtype = $resources[$idref]['ADLCP:SCORMTYPE'];
}

$parent = new stdClass();
Expand Down Expand Up @@ -473,6 +480,13 @@ function scorm_get_manifest($blocks, $scoes) {
}
}
}
if (!empty($manifestresourcesnotfound)) {
//throw warning to user to let them know manifest contains references to resources that don't appear to exist.
if (!defined('DEBUGGING_PRINTED')) { //prevent redirect and display warning
define('DEBUGGING_PRINTED', 1);
}
echo $OUTPUT->notification(get_string('invalidmanifestresource', 'scorm').' '. implode(', ',$manifestresourcesnotfound));
}
return $scoes;
}

Expand Down
1 change: 1 addition & 0 deletions mod/scorm/lang/en/scorm.php
Expand Up @@ -146,6 +146,7 @@
$string['info'] = 'Info';
$string['interactions'] = 'Interactions';
$string['invalidactivity'] = 'Scorm activity is incorrect';
$string['invalidmanifestresource'] = 'WARNING: The following resources were referenced in your manifest but couldn\'t be found:';
$string['last'] = 'Last accessed on';
$string['lastaccess'] = 'Last access';
$string['lastattempt'] = 'Last attempt';
Expand Down

0 comments on commit 03c3488

Please sign in to comment.