Permalink
Browse files

MDL-28311 SCORM tidy up php warnings and display warning message to t…

…eacher that their manifest is invalid
  • Loading branch information...
danmarsden committed Aug 2, 2011
1 parent 3fdc622 commit 03c348895731a83c5e087d472bf3f76e38f7ff97
Showing with 20 additions and 5 deletions.
  1. +19 −5 mod/scorm/datamodels/scormlib.php
  2. +1 −0 mod/scorm/lang/en/scorm.php
@@ -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'];
@@ -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']) {
@@ -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();
@@ -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;
}
@@ -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';

0 comments on commit 03c3488

Please sign in to comment.