/**
  * Marshall an OutcomeDeclaration object into a DOMElement object.
  *
  * @param \qtism\data\QtiComponent $component An OutcomeDeclaration object.
  * @return \DOMElement The according DOMElement object.
  */
 protected function marshall(QtiComponent $component)
 {
     $element = parent::marshall($component);
     $version = $this->getVersion();
     // deal with views.
     // !!! If $arrayViews contain all possible views, it means that the treated
     // !!! outcome is relevant to all views, as per QTI 2.1 spec.
     if (Version::compare($version, '2.1.0', '>=') === true && !in_array($component->getViews()->getArrayCopy(), View::asArray())) {
         $arrayViews = array();
         foreach ($component->getViews() as $view) {
             $arrayViews[] = View::getNameByConstant($view);
         }
         if (count($arrayViews) > 0) {
             static::setDOMElementAttribute($element, 'view', implode(" ", $arrayViews));
         }
     }
     // deal with interpretation.
     if ($component->getInterpretation() != '') {
         static::setDOMElementAttribute($element, 'interpretation', $component->getInterpretation());
     }
     // deal with long interpretation.
     if ($component->getLongInterpretation() != '') {
         static::setDOMElementAttribute($element, 'longInterpretation', $component->getLongInterpretation());
     }
     // Deal with normal maximum.
     if ($component->getNormalMaximum() !== false) {
         static::setDOMElementAttribute($element, 'normalMaximum', $component->getNormalMaximum());
     }
     // Deal with normal minimum.
     if (Version::compare($version, '2.1.0', '>=') === true && $component->getNormalMinimum() !== false) {
         static::setDOMElementAttribute($element, 'normalMinimum', $component->getNormalMinimum());
     }
     // Deal with mastery value.
     if (Version::compare($version, '2.1.0', '>=') === true && $component->getMasteryValue() !== false) {
         static::setDOMElementAttribute($element, 'masteryValue', $component->getMasteryValue());
     }
     // Deal with lookup table.
     if ($component->getLookupTable() != null) {
         $lookupTableMarshaller = $this->getMarshallerFactory()->createMarshaller($component->getLookupTable(), array($component->getBaseType()));
         $element->appendChild($lookupTableMarshaller->marshall($component->geTLookupTable()));
     }
     return $element;
 }
 /**
  * Converts a QTIComponent to an assoc array (instances variables to key/val), using reflection.
  *
  * @param \qtism\data\QtiComponent $component
  * @return array
  */
 private function componentToArray(QtiComponent $component)
 {
     $array = array('qti-type' => $component->getQtiClassName());
     $reflector = new ReflectionClass($component);
     foreach ($this->getProperties($reflector) as $property) {
         $value = $this->getValue($component, $property);
         if ($value !== null) {
             $key = $property->getName();
             if ($value instanceof QtiComponentCollection) {
                 $array[$key] = array();
                 foreach ($value as $item) {
                     $array[$key][] = $this->componentToArray($item);
                 }
             } else {
                 if ($value instanceof ViewCollection) {
                     $array[$property->getName()] = array();
                     foreach ($value as $item) {
                         $array[$property->getName()][] = View::getNameByConstant($item);
                     }
                 } else {
                     if ($value instanceof QtiComponent) {
                         $array[$property->getName()] = $this->componentToArray($value);
                     } else {
                         if ($value instanceof Duration) {
                             $array[$property->getName()] = $value->getSeconds(true);
                         } else {
                             if ($value instanceof IntegerCollection || $value instanceof StringCollection) {
                                 $array[$property->getName()] = array();
                                 foreach ($value as $item) {
                                     $array[$property->getName()][] = $item;
                                 }
                             } else {
                                 $array[$property->getName()] = $value;
                             }
                         }
                     }
                 }
             }
         }
     }
     return $array;
 }