private function getFeatureReplacementString($node) { // Process inline feature if (isset($node->attr['data-type']) && isset($node->attr['data-src'])) { $src = trim($node->attr['data-src']); $type = trim($node->attr['data-type']); if ($type === 'audioplayer' || $type === 'audioplayer') { return QtiMarshallerUtil::marshallValidQti(new Object($src, MimeUtil::guessMimeType(basename($src)))); } // Process regular question feature } else { $nodeClassAttribute = $node->attr['class']; $featureReference = $this->getFeatureReferenceFromClassName($nodeClassAttribute); $feature = $this->widgets[$featureReference]; $type = $feature['data']['type']; if ($type === 'audioplayer' || $type === 'audioplayer') { $src = $feature['data']['src']; $object = new Object($src, MimeUtil::guessMimeType(basename($src))); $object->setLabel($featureReference); return QtiMarshallerUtil::marshallValidQti($object); } else { if ($type === 'sharedpassage') { $content = $feature['data']['content']; $object = new Object('', 'text/html'); $object->setContent(ContentCollectionBuilder::buildObjectFlowCollectionContent(QtiMarshallerUtil::unmarshallElement($content))); $object->setLabel($featureReference); return QtiMarshallerUtil::marshallValidQti($object); } } } throw new MappingException($type . ' not supported'); }
private function buildMainImageObject(imageclozeassociation_image $image) { $imageSrc = $image->get_src(); list($imageWidth, $imageHeight) = CurlUtil::getImageSize(CurlUtil::prepareUrlForCurl($imageSrc)); $imageObject = new Object($imageSrc, MimeUtil::guessMimeType($imageSrc)); $imageObject->setWidth($imageWidth); $imageObject->setHeight($imageHeight); // Map `alt` to object content if (!is_null($image->get_alt())) { $objectFlowCollection = new ObjectFlowCollection(); $objectFlowCollection->attach(new TextRun($image->get_alt())); $imageObject->setContent($objectFlowCollection); } return $imageObject; }