/**
  * Unmarshall a DOMElement object corresponding to a QTI templateDeclaration element.
  *
  * @param \DOMElement $element A DOMElement object.
  * @return \qtism\data\QtiComponent A TemplateDeclaration object.
  * @throws \qtism\data\storage\xml\marshalling\UnmarshallingException
  */
 protected function unmarshall(DOMElement $element)
 {
     try {
         $baseComponent = parent::unmarshall($element);
         $object = new TemplateDeclaration($baseComponent->getIdentifier());
         $object->setBaseType($baseComponent->getBaseType());
         $object->setCardinality($baseComponent->getCardinality());
         $object->setDefaultValue($baseComponent->getDefaultValue());
         $version = $this->getVersion();
         if (($paramVariable = self::getDOMElementAttributeAs($element, 'paramVariable', 'boolean')) !== null) {
             $object->setParamVariable($paramVariable);
         } elseif (Version::compare($version, '2.0.0', '==') === true) {
             $msg = "The mandatory attribute 'paramVariable' is missing from element '" . $element->localName . "'.";
             throw new UnmarshallingException($msg, $element);
         }
         if (($mathVariable = self::getDOMElementAttributeAs($element, 'mathVariable', 'boolean')) !== null) {
             $object->setMathVariable($mathVariable);
         } elseif (Version::compare($version, '2.0.0', '==') === true) {
             $msg = "The mandatory attribute 'mathVariable' is missing from element '" . $element->localName . "'.";
             throw new UnmarshallingException($msg, $element);
         }
         return $object;
     } catch (InvalidArgumentException $e) {
         $msg = "An unexpected error occured while unmarshalling the templateDeclaration.";
         throw new UnmarshallingException($msg, $element, $e);
     }
 }
 /**
  * Unmarshall a DOMElement object corresponding to a QTI responseDeclaration element.
  * 
  * @param DOMElement $element A DOMElement object.
  * @return QtiComponent A ResponseDeclaration object.
  * @throws UnmarshallingException 
  */
 protected function unmarshall(DOMElement $element)
 {
     try {
         $baseComponent = parent::unmarshall($element);
         $object = new ResponseDeclaration($baseComponent->getIdentifier());
         $object->setBaseType($baseComponent->getBaseType());
         $object->setCardinality($baseComponent->getCardinality());
         $object->setDefaultValue($baseComponent->getDefaultValue());
         $correctResponseElts = self::getChildElementsByTagName($element, 'correctResponse');
         if (count($correctResponseElts) === 1) {
             $correctResponseElt = $correctResponseElts[0];
             $marshaller = $this->getMarshallerFactory()->createMarshaller($correctResponseElt, array($baseComponent->getBaseType()));
             $object->setCorrectResponse($marshaller->unmarshall($correctResponseElt));
         }
         $mappingElts = self::getChildElementsByTagName($element, 'mapping');
         if (count($mappingElts) === 1) {
             $mappingElt = $mappingElts[0];
             $marshaller = $this->getMarshallerFactory()->createMarshaller($mappingElt, array($baseComponent->getBaseType()));
             $object->setMapping($marshaller->unmarshall($mappingElt));
         }
         $areaMappingElts = self::getChildElementsByTagName($element, 'areaMapping');
         if (count($areaMappingElts) === 1) {
             $areaMappingElt = $areaMappingElts[0];
             $marshaller = $this->getMarshallerFactory()->createMarshaller($areaMappingElt);
             $object->setAreaMapping($marshaller->unmarshall($areaMappingElt));
         }
         return $object;
     } catch (InvalidArgumentException $e) {
         $msg = "An unexpected error occured while unmarshalling the responseDeclaration.";
         throw new UnmarshallingException($msg, $element, $e);
     }
 }
 /**
  * Unmarshall a DOMElement object corresponding to a QTI templateDeclaration element.
  * 
  * @param DOMElement $element A DOMElement object.
  * @return QtiComponent A TemplateDeclaration object.
  * @throws UnmarshallingException 
  */
 protected function unmarshall(DOMElement $element)
 {
     try {
         $baseComponent = parent::unmarshall($element);
         $object = new TemplateDeclaration($baseComponent->getIdentifier());
         $object->setBaseType($baseComponent->getBaseType());
         $object->setCardinality($baseComponent->getCardinality());
         $object->setDefaultValue($baseComponent->getDefaultValue());
         if (($paramVariable = self::getDOMElementAttributeAs($element, 'paramVariable', 'boolean')) !== null) {
             $object->setParamVariable($paramVariable);
         }
         if (($mathVariable = self::getDOMElementAttributeAs($element, 'mathVariable', 'boolean')) !== null) {
             $object->setMathVariable($mathVariable);
         }
         return $object;
     } catch (InvalidArgumentException $e) {
         $msg = "An unexpected error occured while unmarshalling the templateDeclaration.";
         throw new UnmarshallingException($msg, $element, $e);
     }
 }
 /**
  * Unmarshall a DOMElement object corresponding to a QTI outcomeDeclaration element.
  * 
  * @param DOMElement $element A DOMElement object.
  * @return QtiComponent An OutcomeDeclaration object.
  * @throws UnmarshallingException 
  */
 protected function unmarshall(DOMElement $element)
 {
     try {
         $baseComponent = parent::unmarshall($element);
         $object = new OutcomeDeclaration($baseComponent->getIdentifier());
         $object->setBaseType($baseComponent->getBaseType());
         $object->setCardinality($baseComponent->getCardinality());
         $object->setDefaultValue($baseComponent->getDefaultValue());
         // deal with views.
         if (($views = static::getDOMElementAttributeAs($element, 'view')) != null) {
             $viewCollection = new ViewCollection();
             foreach (explode(" ", $views) as $viewName) {
                 $viewCollection[] = View::getConstantByName($viewName);
             }
             $object->setViews($viewCollection);
         }
         // deal with interpretation.
         if (($interpretation = static::getDOMElementAttributeAs($element, 'interpretation')) != null) {
             $object->setInterpretation($interpretation);
         }
         // deal with longInterpretation.
         if (($longInterpretation = static::getDOMElementAttributeAs($element, 'longInterpretation')) != null) {
             $object->setLongInterpretation($longInterpretation);
         }
         // deal with normalMaximum.
         if (($normalMaximum = static::getDOMElementAttributeAs($element, 'normalMaximum', 'float')) !== null) {
             $object->setNormalMaximum($normalMaximum);
         }
         // deal with normalMinimum.
         if (($normalMinimum = static::getDOMElementAttributeAs($element, 'normalMinimum', 'float')) !== null) {
             $object->setNormalMinimum($normalMinimum);
         }
         // deal with matseryValue.
         if (($masteryValue = static::getDOMElementAttributeAs($element, 'masteryValue', 'float')) !== null) {
             $object->setMasteryValue($masteryValue);
         }
         // deal with lookupTable.
         $interpolationTables = $element->getElementsByTagName('interpolationTable');
         $matchTable = $element->getElementsByTagName('matchTable');
         if ($interpolationTables->length == 1 || $matchTable->length == 1) {
             // we have a lookupTable defined.
             $lookupTable = null;
             if ($interpolationTables->length == 1) {
                 $lookupTable = $interpolationTables->item(0);
             } else {
                 $lookupTable = $matchTable->item(0);
             }
             $lookupTableMarshaller = $this->getMarshallerFactory()->createMarshaller($lookupTable, array($object->getBaseType()));
             $object->setLookupTable($lookupTableMarshaller->unmarshall($lookupTable));
         }
         return $object;
     } catch (InvalidArgumentException $e) {
         $msg = "An unexpected error occured while unmarshalling the outcomeDeclaration.";
         throw new UnmarshallingException($msg, $element, $e);
     }
 }