/**
  * Marshall a CustomInteraction object into a DOMElement object.
  *
  * @param \qtism\data\QtiComponent $component A CustomInteraction object.
  * @return \DOMElement The according DOMElement object.
  */
 protected function marshall(QtiComponent $component)
 {
     $element = static::getDOMCradle()->createElement('customInteraction');
     $this->fillElement($element, $component);
     self::setDOMElementAttribute($element, 'responseIdentifier', $component->getResponseIdentifier());
     if ($component->hasXmlBase() === true) {
         self::setXmlBase($element, $component->getXmlBase());
     }
     $xml = $component->getXml();
     Utils::importChildNodes($xml->documentElement, $element);
     Utils::importAttributes($xml->documentElement, $element);
     return $element;
 }
Ejemplo n.º 2
0
 /**
  * @see \qtism\data\storage\xml\marshalling\RecursiveMarshaller::marshallChildrenKnown()
  */
 protected function marshallChildrenKnown(QtiComponent $component, array $elements)
 {
     $element = self::getDOMCradle()->createElement($component->getQtiClassName());
     foreach ($elements as $elt) {
         $element->appendChild($elt);
     }
     if ($component instanceof CustomOperator) {
         if ($component->hasClass() === true) {
             self::setDOMElementAttribute($element, 'class', $component->getClass());
         }
         if ($component->hasDefinition() === true) {
             self::setDOMElementAttribute($element, 'definition', $component->getDefinition());
         }
         // Now, we have to extract the LAX content of the custom operator and put it into
         // what we are putting out. (It is possible to have no LAX content at all, it is not mandatory).
         $xml = $component->getXml();
         $operatorElt = $xml->documentElement->cloneNode(true);
         $qtiOperatorElts = self::getChildElementsByTagName($operatorElt, array_merge(self::getOperators(), self::getExpressions()));
         foreach ($qtiOperatorElts as $qtiOperatorElt) {
             $operatorElt->removeChild($qtiOperatorElt);
         }
         Utils::importChildNodes($operatorElt, $element);
         Utils::importAttributes($operatorElt, $element);
     }
     return $element;
 }