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');
 }
 public static function buildQtiImageObject($data, $type)
 {
     $object = new Object($data, $type);
     $objectFlowCollection = new ObjectFlowCollection();
     $objectFlowCollection->attach(new TextRun('qwe'));
     $object->setContent($objectFlowCollection);
     return $object;
 }
 public function testMarshallSimple()
 {
     $param1 = new Param('movie', 'movie.swf', ParamType::REF);
     $param2 = new Param('quality', 'high', ParamType::DATA);
     $object = new Object('http://mywebsite.com/movie.swf', 'application/x-shockwave-flash', 'flash-movie');
     $object->setContent(new ObjectFlowCollection(array($param1, $param2)));
     $element = $this->getMarshallerFactory()->createMarshaller($object)->marshall($object);
     $dom = new DOMDocument('1.0', 'UTF-8');
     $element = $dom->importNode($element, true);
     $this->assertEquals('<object data="http://mywebsite.com/movie.swf" type="application/x-shockwave-flash" id="flash-movie"><param name="movie" value="movie.swf" valuetype="REF"/><param name="quality" value="high" valuetype="DATA"/></object>', $dom->saveXml($element));
 }
 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;
 }