/** * Marshall a TemplateDeclaration object into a DOMElement object. * * @param QtiComponent $component A TemplateDeclaration object. * @return DOMElement The according DOMElement object. */ protected function marshall(QtiComponent $component) { $element = parent::marshall($component); if ($component->isParamVariable() === true) { self::setDOMElementAttribute($element, 'paramVariable', true); } if ($component->isMathVariable() === true) { self::setDOMElementAttribute($element, 'mathVariable', true); } return $element; }
/** * Marshall a TemplateDeclaration object into a DOMElement object. * * @param \qtism\data\QtiComponent $component A TemplateDeclaration object. * @return \DOMElement The according DOMElement object. */ protected function marshall(QtiComponent $component) { $element = parent::marshall($component); $version = $this->getVersion(); if ($component->isParamVariable() === true) { self::setDOMElementAttribute($element, 'paramVariable', true); } elseif (Version::compare($version, '2.0.0', '==') === true && $component->isParamVariable() === false) { self::setDOMElementAttribute($element, 'paramVariable', false); } if ($component->isMathVariable() === true) { self::setDOMElementAttribute($element, 'mathVariable', true); } elseif (Version::compare($version, '2.0.0', '==') === true && $component->isMathVariable() === false) { self::setDOMElementAttribute($element, 'mathVariable', false); } return $element; }
/** * Marshall a ResponseDeclaration object into a DOMElement object. * * @param QtiComponent $component A ResponseDeclaration object. * @return DOMElement The according DOMElement object. */ protected function marshall(QtiComponent $component) { $element = parent::marshall($component); $baseType = $component->getBaseType(); if ($component->getCorrectResponse() !== null) { $marshaller = $this->getMarshallerFactory()->createMarshaller($component->getCorrectResponse(), array($baseType)); $element->appendChild($marshaller->marshall($component->getCorrectResponse())); } if ($component->getMapping() !== null) { $marshaller = $this->getMarshallerFactory()->createMarshaller($component->getMapping(), array($baseType)); $element->appendChild($marshaller->marshall($component->getMapping())); } if ($component->getAreaMapping() !== null) { $marshaller = $this->getMarshallerFactory()->createMarshaller($component->getAreaMapping()); $element->appendChild($marshaller->marshall($component->getAreaMapping())); } return $element; }
/** * 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; }