MDL-28311 SCORM tidy up php warnings and display warning message to teacher that their manifest is invalid
This commit is contained in:
@@ -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['incomplete'] = 'Incomplete';
|
||||
$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';
|
||||
|
||||
Reference in New Issue
Block a user