You are here

function opigno_scorm_ui_player_sco_attributes in Opigno 7

Parse the SCO attributes and return them in an HTML ready format.

Parameters

object $sco:

Return value

string

1 call to opigno_scorm_ui_player_sco_attributes()
opigno-scorm-ui--player-tree-item.tpl.php in modules/scorm/ui/theme/opigno-scorm-ui--player-tree-item.tpl.php

File

modules/scorm/ui/includes/opigno_scorm_ui.player.inc, line 146
Player logic.

Code

function opigno_scorm_ui_player_sco_attributes($sco) {
  $attributes = array();

  // Some default "attributes".
  $attributes["data-sco-id"] = $sco->id;
  $attributes["data-sco-can-launch"] = (int) (!empty($sco->launch));
  if (!empty($sco->attributes)) {
    foreach ($sco->attributes as $key => $value) {
      if (is_bool($value)) {
        $value = (int) $value;
      }
      elseif (is_array($value) || is_object($value)) {
        $value = drupal_json_encode($value);
      }
      $key = str_replace('_', '-', $key);
      $attributes["data-sco-{$key}"] = $value;
    }
  }
  return drupal_attributes($attributes);
}