* @package taoQTI */ class QtiObject extends Element { /** * the QTI tag name as defined in QTI standard * * @access protected * @var string */ protected static $qtiTagName = 'object'; /** * The alternate object to be displayed, can be a nested object or some text/html * * @var mixed */ protected $alt = null; public function getUsedAttributes() { return [ 'oat\\taoQtiItem\\model\\qti\\attribute\\Data', 'oat\\taoQtiItem\\model\\qti\\attribute\\Type', 'oat\\taoQtiItem\\model\\qti\\attribute\\Width', 'oat\\taoQtiItem\\model\\qti\\attribute\\Height' ]; } public function setAlt($object) { if ($object instanceof Object || is_string($object)) { $this->alt = $object; } } protected function getTemplateQtiVariables() { $variables = parent::getTemplateQtiVariables(); if (!is_null($this->alt)) { if ($this->alt instanceof Object) { $variables['_alt'] = $this->alt->toQTI(); } else { $variables['_alt'] = (string) $this->alt; } } return $variables; } public function toArray($filterVariableContent = false, &$filtered = []) { $data = parent::toArray($filterVariableContent, $filtered); if (!is_null($this->alt)) { if ($this->alt instanceof Object) { $data['_alt'] = $this->alt->toArray($filterVariableContent, $filtered); } else { $data['_alt'] = (string) $this->alt; } } return $data; } }