/** * Feed the pci instance with data provided in the pci dom node * * @param \oat\taoQtiItem\model\qti\ParserFactory $parser * @param DOMElement $data */ public function feed(ParserFactory $parser, DOMElement $data) { $ns = $parser->getPciNamespace(); $pciNodes = $parser->queryXPathChildren(array('portableCustomInteraction'), $data, $ns); if ($pciNodes->length) { $typeIdentifier = $pciNodes->item(0)->getAttribute('customInteractionTypeIdentifier'); if (empty($typeIdentifier)) { throw new QtiModelException('the type identifier of the pci is missing'); } else { $this->setTypeIdentifier($typeIdentifier); } $entryPoint = $pciNodes->item(0)->getAttribute('hook'); if (empty($entryPoint)) { throw new QtiModelException('the entry point of the pci is missing'); } else { $this->setEntryPoint($entryPoint); } } $libNodes = $parser->queryXPathChildren(array('portableCustomInteraction', 'resources', 'libraries', 'lib'), $data, $ns); $libs = array(); foreach ($libNodes as $libNode) { $libs[] = $libNode->getAttribute('id'); } $this->setLibraries($libs); $propertyNodes = $parser->queryXPathChildren(array('portableCustomInteraction', 'properties'), $data, $ns); if ($propertyNodes->length) { $properties = $this->extractPciProperties($propertyNodes->item(0), $ns); $this->setProperties($properties); } $markupNodes = $parser->queryXPathChildren(array('portableCustomInteraction', 'markup'), $data, $ns); if ($markupNodes->length) { $markup = $parser->getBodyData($markupNodes->item(0), true); $this->setMarkup($markup); } }
public function feed(ParserFactory $parser, DOMElement $data) { $ns = $parser->getPicNamespace(); $pciNodes = $parser->queryXPathChildren(array('portableInfoControl'), $data, $ns); if (!$pciNodes->length) { throw new QtiModelException('no portableInfoControl node found'); } $typeIdentifier = $pciNodes->item(0)->getAttribute('infoControlTypeIdentifier'); if (empty($typeIdentifier)) { throw new QtiModelException('the type identifier of the pic is missing'); } else { $this->setTypeIdentifier($typeIdentifier); } $this->setEntryPoint($pciNodes->item(0)->getAttribute('hook')); $version = $pciNodes->item(0)->getAttribute('version'); if ($version) { $this->setVersion($version); } $libNodes = $parser->queryXPathChildren(array('portableInfoControl', 'resources', 'libraries', 'lib'), $data, $ns); $libs = array(); foreach ($libNodes as $libNode) { $libs[] = $libNode->getAttribute('id'); } $this->setLibraries($libs); $stylesheetNodes = $parser->queryXPathChildren(array('portableInfoControl', 'resources', 'stylesheets', 'link'), $data, $ns); $stylesheets = array(); foreach ($stylesheetNodes as $styleNode) { $stylesheets[] = $styleNode->getAttribute('href'); } $this->setStylesheets($stylesheets); $mediaNodes = $parser->queryXPathChildren(array('portableInfoControl', 'resources', 'mediaFiles', 'file'), $data, $ns); $media = array(); foreach ($mediaNodes as $mediaNode) { $media[] = $mediaNode->getAttribute('src'); } $this->setMediaFiles($media); $propertyNodes = $parser->queryXPathChildren(array('portableInfoControl', 'properties'), $data, $ns); if ($propertyNodes->length) { $properties = $this->extractProperties($propertyNodes->item(0), $ns); $this->setProperties($properties); } $markupNodes = $parser->queryXPathChildren(array('portableInfoControl', 'markup'), $data, $ns); if ($markupNodes->length) { $markup = $parser->getBodyData($markupNodes->item(0), true, true); $this->setMarkup($markup); } }
public function feed(ParserFactory $parser, DOMElement $data) { $ns = $parser->getPicNamespace(); $pciNodes = $parser->queryXPathChildren(array('portableInfoControl'), $data, $ns); if ($pciNodes->length) { $typeIdentifier = $pciNodes->item(0)->getAttribute('infoControlTypeIdentifier'); $this->setTypeIdentifier($typeIdentifier); $entryPoint = $pciNodes->item(0)->getAttribute('hook'); $this->setEntryPoint($entryPoint); } $libNodes = $parser->queryXPathChildren(array('portableInfoControl', 'resources', 'libraries', 'lib'), $data, $ns); $libs = array(); foreach ($libNodes as $libNode) { $libs[] = $libNode->getAttribute('id'); } $this->setLibraries($libs); $propertyNodes = $parser->queryXPathChildren(array('portableInfoControl', 'properties'), $data, $ns); if ($propertyNodes->length) { $properties = $this->extractPciProperties($propertyNodes->item(0), $ns); $this->setProperties($properties); } $markupNodes = $parser->queryXPathChildren(array('portableInfoControl', 'markup'), $data, $ns); if ($markupNodes->length) { $markup = $parser->getBodyData($markupNodes->item(0), true, true); $this->setMarkup($markup); } }