/**
  * Unmarshall an FieldValue object into a QTI fieldValue element.
  * 
  * @param QtiComponent The FieldValue object to marshall.
  * @param array An array of child DOMEelement objects.
  * @return DOMElement The marshalled QTI fieldValue element.
  */
 protected function marshallChildrenKnown(QtiComponent $component, array $elements)
 {
     $element = self::getDOMCradle()->createElement($component->getQtiClassName());
     self::setDOMElementAttribute($element, 'fieldIdentifier', $component->getFieldIdentifier());
     foreach ($elements as $elt) {
         $element->appendChild($elt);
     }
     return $element;
 }
Exemple #2
0
 /**
  * Marshall a Value object into a DOMElement object.
  *
  * @param \qtism\data\QtiComponent $component A Value object.
  * @return \DOMElement The according DOMElement object.
  */
 protected function marshall(QtiComponent $component)
 {
     $element = static::getDOMCradle()->createElement($component->getQtiClassName());
     $fieldIdentifer = $component->getFieldIdentifier();
     $baseType = $component->getBaseType();
     self::setDOMElementValue($element, $component->getValue());
     if (!empty($fieldIdentifer)) {
         static::setDOMElementAttribute($element, 'fieldIdentifier', $fieldIdentifer);
     }
     if ($component->isPartOfRecord() && $baseType >= 0) {
         static::setDOMElementAttribute($element, 'baseType', BaseType::getNameByConstant($baseType));
     }
     return $element;
 }