/** * @see \qtism\data\storage\xml\marshalling\RecursiveMarshaller::unmarshallChildrenKnown() */ protected function unmarshallChildrenKnown(DOMElement $element, QtiComponentCollection $children) { if (($identifier = self::getDOMElementAttributeAs($element, 'identifier')) !== null) { $version = $this->getVersion(); $fqClass = $this->lookupClass($element); try { $component = new $fqClass($identifier); } catch (InvalidArgumentException $e) { $msg = "'{$identifier}' is not a valid identifier for an 'inlineChoice' element."; throw new UnmarshallingException($msg, $element, $e); } if (Version::compare($version, '2.1.0', '<') === true && $children->exclusivelyContainsComponentsWithClassName('textRun') === false) { $msg = "An 'inlineChoice' element must only contain text. Children elements found."; throw new UnmarshallingException($msg, $element); } try { $component->setContent(new TextOrVariableCollection($children->getArrayCopy())); } catch (InvalidArgumentException $e) { $msg = "'inlineChoice' elements must only contain text or 'printedVariable' elements."; throw new UnmarshallingException($msg, $element, $e); } if (($fixed = self::getDOMElementAttributeAs($element, 'fixed', 'boolean')) !== null) { $component->setFixed($fixed); } if (Version::compare($version, '2.1.0', '>=') === true && ($templateIdentifier = self::getDOMElementAttributeAs($element, 'templateIdentifier')) !== null) { $component->setTemplateIdentifier($templateIdentifier); } if (Version::compare($version, '2.1.0', '>=') === true && ($showHide = self::getDOMElementAttributeAs($element, 'showHide')) !== null) { $component->setShowHide(ShowHide::getConstantByName($showHide)); } $this->fillBodyElement($component, $element); return $component; } else { $msg = "The mandatory 'identifier' attribute is missing from the 'simpleChoice' element."; throw new UnmarshallingException($msg, $element); } }