You are here

function opigno_scorm_extract_item_sequencing_control_modes in Opigno 7

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:

Return value

array

1 call to opigno_scorm_extract_item_sequencing_control_modes()
_opigno_scorm_extract_manifest_scos_items in modules/scorm/includes/opigno_scorm.manifest.inc
Helper function to recursively extract the manifest SCO items.

File

modules/scorm/includes/opigno_scorm.manifest.inc, line 451
Manifest file extraction logic.

Code

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

      // 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'][OPIGNO_SCORM_MANIFEST_CHOICE_ATTR])) {
        $control_modes['control_mode_choice'] = strtolower($child['attrs'][OPIGNO_SCORM_MANIFEST_CHOICE_ATTR]) === 'true';
      }
      if (!empty($child['attrs'][OPIGNO_SCORM_MANIFEST_FLOW_ATTR])) {
        $control_modes['control_mode_flow'] = strtolower($child['attrs'][OPIGNO_SCORM_MANIFEST_FLOW_ATTR]) === 'true';
      }
      if (!empty($child['attrs'][OPIGNO_SCORM_MANIFEST_CHOICE_EXIT_ATTR])) {
        $control_modes['control_mode_choice_exit'] = strtolower($child['attrs'][OPIGNO_SCORM_MANIFEST_CHOICE_EXIT_ATTR]) === 'true';
      }
    }
  }
  return $control_modes + $defaults;
}