* @package taoQTI * @see http://www.imsglobal.org/question/qtiv2p1/imsqti_infov2p1.html#element10243 */ abstract class Feedback extends IdentifiedElement implements FlowContainer, ContentVariable { protected $body; /** * Feedback constructor. * * @param array $attributes * @param Item|null $relatedItem * @param string $serial * * @throws QtiModelException */ public function __construct($attributes = [], Item $relatedItem = null, $serial = '') { parent::__construct($attributes, $relatedItem, $serial); $this->body = new ContainerStatic('', $relatedItem); //@todo: implement interactive container } public function getBody() { return $this->body; } protected function getUsedAttributes() { return [ OutcomeIdentifier::class, ShowHideTemplateElement::class ]; } /** * Check if the given new identifier is valid in the current state of the qti element * * @param string $newIdentifier * @return bool * @throws InvalidArgumentException */ public function isIdentifierAvailable($newIdentifier) { if (empty($newIdentifier) || is_null($newIdentifier)) { throw new InvalidArgumentException("newIdentifier must be set"); } if (!empty($this->identifier) && $newIdentifier === $this->identifier) { return true; } $relatedItem = $this->getRelatedItem(); if (is_null($relatedItem)) { return true; // no restriction on identifier since not attached to any qti item } $collection = $relatedItem->getIdentifiedElements(); try { return null === $collection->getUnique($newIdentifier, self::class); } catch (QtiModelException $e) { } return false; } public function toArray($filterVariableContent = false, &$filtered = []) { $data = parent::toArray($filterVariableContent, $filtered); if ($filterVariableContent) { $filtered[$this->getSerial()] = $data; $data = [ 'serial' => $data['serial'], 'qtiClass' => $data['qtiClass'] ]; } return $data; } public function toFilteredArray() { return $this->toArray(true); } }