You are here

private function OpignoScorm::scormExtractItemSequencingControlModes in Opigno SCORM 8

Same name and namespace in other branches
  1. 3.x src/OpignoScorm.php \Drupal\opigno_scorm\OpignoScorm::scormExtractItemSequencingControlModes()

Extract the manifest SCO item sequencing control modes.

This extracts sequencing control modes from an item. Control modes describe how the user can navigate around the course (e.g.: display the tree or not, skip SCOs, etc).

Parameters

array $item_manifest: Manifest.

Return value

array SCO item sequencing control modes.

1 call to OpignoScorm::scormExtractItemSequencingControlModes()
OpignoScorm::scormExtractManifestScosItems in src/OpignoScorm.php
Helper function to recursively extract the manifest SCO items.

File

src/OpignoScorm.php, line 706

Class

OpignoScorm
Class OpignoScorm.

Namespace

Drupal\opigno_scorm

Code

private function scormExtractItemSequencingControlModes(array $item_manifest) {
  $defaults = [
    'control_mode_choice' => TRUE,
    'control_mode_flow' => FALSE,
    'control_mode_choice_exit' => TRUE,
    'control_mode_forward_only' => FALSE,
  ];
  $control_modes = [];
  foreach ($item_manifest['children'] as $child) {
    if ($child['name'] == 'IMSSS:CONTROLMODE') {

      // Note: boolean attributes are stored as a strings. PHP does not know
      // how to cast 'false' to FALSE. Use string comparisons to bypass
      // this limitation by PHP. See below.
      if (!empty($child['attrs']['CHOICE'])) {
        $control_modes['control_mode_choice'] = strtolower($child['attrs']['CHOICE']) === 'true';
      }
      if (!empty($child['attrs']['FLOW'])) {
        $control_modes['control_mode_flow'] = strtolower($child['attrs']['FLOW']) === 'true';
      }
      if (!empty($child['attrs']['CHOICEEXIT'])) {
        $control_modes['control_mode_choice_exit'] = strtolower($child['attrs']['CHOICEEXIT']) === 'true';
      }
    }
  }
  return $control_modes + $defaults;
}