You are here

private function OpignoScorm::scormExtractManifestResources in Opigno SCORM 3.x

Same name and namespace in other branches
  1. 8 src/OpignoScorm.php \Drupal\opigno_scorm\OpignoScorm::scormExtractManifestResources()

Extract the manifest SCO resources.

We only extract resource information that is relevant to us. We don't care about references files, dependencies, etc. Only about the href attribute, type and identifier.

Parameters

array $manifest: Manifest.

Return value

array Manifest SCO resources.

1 call to OpignoScorm::scormExtractManifestResources()
OpignoScorm::scormExtractManifestData in src/OpignoScorm.php
Extract manifest data from the manifest file.

File

src/OpignoScorm.php, line 567

Class

OpignoScorm
Class OpignoScorm.

Namespace

Drupal\opigno_scorm

Code

private function scormExtractManifestResources(array $manifest) {
  $items = [];
  foreach ($manifest['children'] as $child) {
    if ($child['name'] == 'RESOURCES') {
      foreach ($child['children'] as $resource) {
        if ($resource['name'] == 'RESOURCE') {
          if (!empty($resource['attrs']['IDENTIFIER'])) {
            $identifier = $resource['attrs']['IDENTIFIER'];
          }
          else {
            $identifier = uniqid();
          }
          if (!empty($resource['attrs']['HREF'])) {
            $href = $resource['attrs']['HREF'];
          }
          else {
            $href = '';
          }
          if (!empty($resource['attrs']['TYPE'])) {
            $type = $resource['attrs']['TYPE'];
          }
          else {
            $type = '';
          }
          if (!empty($resource['attrs']['ADLCP:SCORMTYPE'])) {
            $scorm_type = $resource['attrs']['ADLCP:SCORMTYPE'];
          }
          else {
            $scorm_type = '';
          }
          $items[] = [
            'identifier' => $identifier,
            'href' => $href,
            'type' => $type,
            'scorm_type' => $scorm_type,
          ];
        }
      }
    }
  }
  return $items;
}