/**
  * Marshall a RubricBlock object into a DOMElement object.
  * 
  * @param QtiComponent $component A RubricBlock object.
  * @return DOMElement The according DOMElement object.
  */
 protected function marshall(QtiComponent $component)
 {
     $element = static::getDOMCradle()->createElement($component->getQtiClassName());
     $arrayViews = array();
     foreach ($component->getViews() as $view) {
         $key = array_search($view, View::asArray());
         // replace '_' by the space char.
         $arrayViews[] = strtolower(str_replace("ò", " ", $key));
     }
     if (count($arrayViews) > 0) {
         static::setDOMElementAttribute($element, 'view', implode(" ", $arrayViews));
     }
     if ($component->getUse() != '') {
         static::setDOMElementAttribute($element, 'use', $component->getUse());
     }
     if ($component->hasXmlBase() === true) {
         static::setXmlBase($element, $component->getXmlBase());
     }
     foreach ($component->getContent() as $block) {
         $marshaller = $this->getMarshallerFactory()->createMarshaller($block);
         $element->appendChild($marshaller->marshall($block));
     }
     foreach ($component->getStylesheets() as $stylesheet) {
         $stylesheetMarshaller = $this->getMarshallerFactory()->createMarshaller($stylesheet);
         $element->appendChild($stylesheetMarshaller->marshall($stylesheet));
     }
     self::fillElement($element, $component);
     return $element;
 }
 /**
  * Marshall a Tbody/Thead/Tfoot object into a DOMElement object.
  * 
  * @param QtiComponent $component A TBody/Thead/Tfoot object.
  * @return DOMElement The according DOMElement object.
  * @throws MarshallingException
  */
 protected function marshall(QtiComponent $component)
 {
     $element = self::getDOMCradle()->createElement($component->getQtiClassName());
     foreach ($component->getContent() as $tr) {
         $marshaller = $this->getMarshallerFactory()->createMarshaller($tr);
         $element->appendChild($marshaller->marshall($tr));
     }
     self::fillElement($element, $component);
     return $element;
 }
 /**
  * Marshall a Colgroup object into a DOMElement object.
  * 
  * @param QtiComponent $component A Colgroup object.
  * @return DOMElement The according DOMElement object.
  * @throws MarshallingException
  */
 protected function marshall(QtiComponent $component)
 {
     $element = self::getDOMCradle()->createElement('colgroup');
     self::setDOMElementAttribute($element, 'span', $component->getSpan());
     foreach ($component->getContent() as $col) {
         $marshaller = $this->getMarshallerFactory()->createMarshaller($col);
         $element->appendChild($marshaller->marshall());
     }
     self::fillElement($element, $component);
     return $element;
 }
 /**
  * Marshall a TestFeedback object into a DOMElement object.
  * 
  * @param QtiComponent $component A TestFeedback object.
  * @return DOMElement The according DOMElement object.
  */
 protected function marshall(QtiComponent $component)
 {
     $element = static::getDOMCradle()->createElement($component->getQtiClassName());
     $access = $component->getAccess() == TestFeedbackAccess::AT_END ? 'atEnd' : 'during';
     $showHide = $component->getShowHide() == ShowHide::SHOW ? 'show' : 'hide';
     self::setDOMElementAttribute($element, 'access', $access);
     self::setDOMElementAttribute($element, 'outcomeIdentifier', $component->getOutcomeIdentifier());
     self::setDOMElementAttribute($element, 'showHide', $showHide);
     self::setDOMElementAttribute($element, 'identifier', $component->getIdentifier());
     $title = $component->getTitle();
     if (!empty($title)) {
         self::setDOMElementAttribute($element, 'title', $title);
     }
     $flowStatic = static::getDOMCradle()->createDocumentFragment();
     $flowStatic->appendXML($component->getContent());
     $element->appendChild($flowStatic);
     return $element;
 }
Exemplo n.º 5
0
 /**
  * @see \qtism\data\storage\xml\marshalling\RecursiveMarshaller::marshallChildrenKnown()
  */
 protected function marshallChildrenKnown(QtiComponent $component, array $elements)
 {
     $element = self::getDOMCradle()->createElement($component->getQtiClassName());
     $headers = $component->getHeaders();
     if (count($headers) > 0) {
         self::setDOMElementAttribute($element, 'headers', implode(" ", $headers->getArrayCopy()));
     }
     if ($component->hasScope() === true) {
         self::setDOMElementAttribute($element, 'scope', TableCellScope::getNameByConstant($component->getScope()));
     }
     if ($component->hasAbbr() === true) {
         self::setDOMElementAttribute($element, 'abbr', $component->getAbbr());
     }
     if ($component->hasAxis() === true) {
         self::setDOMElementAttribute($element, 'axis', $component->getAxis());
     }
     if ($component->hasRowspan() === true) {
         self::setDOMElementAttribute($element, 'rowspan', $component->getRowspan());
     }
     if ($component->hasColspan() === true) {
         self::setDOMElementAttribute($element, 'colspan', $component->getColspan());
     }
     foreach ($component->getContent() as $c) {
         $marshaller = $this->getMarshallerFactory()->createMarshaller($c);
         $element->appendChild($marshaller->marshall($c));
     }
     $this->fillElement($element, $component);
     return $element;
 }
 protected function appendElement(DOMDocumentFragment $fragment, QtiComponent $component, $base = '')
 {
     $fragment->appendChild($this->getRenderingEngine()->getDocument()->createTextNode($component->getContent()));
 }
Exemplo n.º 7
0
 /**
  * @see \qtism\data\storage\xml\marshalling\RecursiveMarshaller::getChildrenComponents()
  */
 protected function getChildrenComponents(QtiComponent $component)
 {
     if ($component instanceof SimpleInline) {
         return $component->getContent()->getArrayCopy();
     } elseif ($component instanceof AtomicBlock) {
         return $component->getContent()->getArrayCopy();
     } elseif ($component instanceof Tr) {
         return $component->getContent()->getArrayCopy();
     } elseif ($component instanceof Td) {
         return $component->getContent()->getArrayCopy();
     } elseif ($component instanceof Th) {
         return $component->getContent()->getArrayCopy();
     } elseif ($component instanceof Caption) {
         return $component->getContent()->getArrayCopy();
     } elseif ($component instanceof Ul) {
         return $component->getContent()->getArrayCopy();
     } elseif ($component instanceof Ol) {
         return $component->getContent()->getArrayCopy();
     } elseif ($component instanceof Li) {
         return $component->getContent()->getArrayCopy();
     } elseif ($component instanceof Dl) {
         return $component->getContent()->getArrayCopy();
     } elseif ($component instanceof DlElement) {
         return $component->getContent()->getArrayCopy();
     } elseif ($component instanceof Object) {
         return $component->getContent()->getArrayCopy();
     } elseif ($component instanceof Div) {
         return $component->getContent()->getArrayCopy();
     } elseif ($component instanceof ItemBody) {
         return $component->getContent()->getArrayCopy();
     } elseif ($component instanceof Blockquote) {
         return $component->getContent()->getArrayCopy();
     } elseif ($component instanceof SimpleChoice) {
         return $component->getContent()->getArrayCopy();
     } elseif ($component instanceof SimpleAssociableChoice) {
         return $component->getContent()->getArrayCopy();
     } elseif ($component instanceof SimpleMatchSet) {
         return $component->getSimpleAssociableChoices()->getArrayCopy();
     } elseif ($component instanceof GapText) {
         return $component->getContent()->getArrayCopy();
     } elseif ($component instanceof GapImg) {
         return array($component->getObject());
     } elseif ($component instanceof ChoiceInteraction) {
         return $component->getSimpleChoices()->getArrayCopy();
     } elseif ($component instanceof OrderInteraction) {
         return $component->getSimpleChoices()->getArrayCopy();
     } elseif ($component instanceof AssociateInteraction) {
         return $component->getSimpleAssociableChoices()->getArrayCopy();
     } elseif ($component instanceof GapMatchInteraction) {
         return $component->getContent()->getArrayCopy();
     } elseif ($component instanceof InlineChoiceInteraction) {
         return $component->getContent()->getArrayCopy();
     } elseif ($component instanceof HotspotInteraction) {
         return $component->getHotspotChoices()->getArrayCopy();
     } elseif ($component instanceof GraphicAssociateInteraction) {
         return $component->getAssociableHotspots()->getArrayCopy();
     } elseif ($component instanceof InlineChoice) {
         return $component->getContent()->getArrayCopy();
     } elseif ($component instanceof MatchInteraction) {
         return $component->getSimpleMatchSets()->getArrayCopy();
     } elseif ($component instanceof Prompt) {
         return $component->getContent()->getArrayCopy();
     } elseif ($component instanceof FeedbackBlock) {
         return $component->getContent()->getArrayCopy();
     } elseif ($component instanceof TemplateBlock) {
         return $component->getContent()->getArrayCopy();
     } elseif ($component instanceof TemplateInline) {
         return $component->getContent()->getArrayCopy();
     } elseif ($component instanceof Hottext) {
         return $component->getContent()->getArrayCopy();
     } elseif ($component instanceof HottextInteraction) {
         return $component->getContent()->getArrayCopy();
     } elseif ($component instanceof GraphicOrderInteraction) {
         return $component->getHotspotChoices()->getArrayCopy();
     } elseif ($component instanceof ModalFeedback) {
         return $component->getContent()->getArrayCopy();
     } elseif ($component instanceof InfoControl) {
         return $component->getContent()->getArrayCopy();
     }
 }
Exemplo n.º 8
0
 /**
  * Marshall a TextRun object into a DOMElement object.
  *
  * @param \qtism\data\QtiComponent $component A TextRun object.
  * @return \DOMElement The according DOMElement object.
  */
 protected function marshall(QtiComponent $component)
 {
     $element = static::getDOMCradle()->createTextNode($component->getContent());
     return $element;
 }