/** * Marshall a SliderInteraction object into a DOMElement object. * * @param QtiComponent $component A SliderInteraction object. * @return DOMElement The according DOMElement object. * @throws MarshallingException */ protected function marshall(QtiComponent $component) { $element = self::getDOMCradle()->createElement('sliderInteraction'); self::fillElement($element, $component); self::setDOMElementAttribute($element, 'responseIdentifier', $component->getResponseIdentifier()); self::setDOMElementAttribute($element, 'lowerBound', $component->getLowerBound()); self::setDOMElementAttribute($element, 'upperBound', $component->getUpperBound()); if ($component->hasStep() === true) { self::setDOMElementAttribute($element, 'step', $component->getStep()); } if ($component->mustStepLabel() === true) { self::setDOMElementAttribute($element, 'stepLabel', true); } if ($component->getOrientation() === Orientation::VERTICAL) { self::setDOMElementAttribute($element, 'orientation', Orientation::getNameByConstant(Orientation::VERTICAL)); } if ($component->mustReverse() === true) { self::setDOMElementAttribute($element, 'reverse', true); } if ($component->hasXmlBase() === true) { self::setXmlBase($element, $component->getXmlBase()); } if ($component->hasPrompt() === true) { $element->appendChild($this->getMarshallerFactory()->createMarshaller($component->getPrompt())->marshall($component->getPrompt())); } return $element; }
/** * @see \qtism\data\storage\xml\marshalling\RecursiveMarshaller::marshallChildrenKnown() */ protected function marshallChildrenKnown(QtiComponent $component, array $elements) { $version = $this->getVersion(); $isOrderInteraction = $component instanceof OrderInteraction; $isChoiceInteraction = $component instanceof ChoiceInteraction; $element = self::getDOMCradle()->createElement($component->getQtiClassName()); $this->fillElement($element, $component); self::setDOMElementAttribute($element, 'responseIdentifier', $component->getResponseIdentifier()); // prompt. if ($component->hasPrompt() === true) { $element->appendChild($this->getMarshallerFactory()->createMarshaller($component->getPrompt())->marshall($component->getPrompt())); } // shuffle. if (Version::compare($version, '2.0.0', '==') === true) { self::setDOMElementAttribute($element, 'shuffle', $component->mustShuffle()); } elseif ($component->mustShuffle() !== false) { self::setDOMElementAttribute($element, 'shuffle', true); } // maxChoices. if ($isChoiceInteraction && Version::compare($version, '2.0.0', '==') === true) { self::setDOMElementAttribute($element, 'maxChoices', $component->getMaxChoices()); } elseif ($isChoiceInteraction && $component->getMaxChoices() !== 0 || $isOrderInteraction && $component->getMaxChoices() !== -1 && Version::compare($version, '2.1.0', '>=') === true) { self::setDOMElementAttribute($element, 'maxChoices', $component->getMaxChoices()); } // minChoices. if (Version::compare($version, '2.1.0', '>=') === true) { if ($isChoiceInteraction && $component->getMinChoices() !== 0 || $isOrderInteraction && $component->getMinChoices() !== -1) { self::setDOMElementAttribute($element, 'minChoices', $component->getMinChoices()); } } // orientation. if (Version::compare($version, '2.0.0', '==') === true && $isOrderInteraction && $component->getOrientation() !== Orientation::VERTICAL) { self::setDOMElementAttribute($element, 'orientation', Orientation::getNameByConstant(Orientation::HORIZONTAL)); } elseif (Version::compare($version, '2.1.0', '>=') === true && $component->getOrientation() !== Orientation::VERTICAL) { self::setDOMElementAttribute($element, 'orientation', Orientation::getNameByConstant(Orientation::HORIZONTAL)); } // xml:base. if ($component->hasXmlBase() === true) { self::setXmlBase($element, $component->getXmlBase()); } foreach ($elements as $e) { $element->appendChild($e); } return $element; }
protected function marshallChildrenKnown(QtiComponent $component, array $elements) { $element = self::getDOMCradle()->createElement($component->getQtiClassName()); self::fillElement($element, $component); self::setDOMElementAttribute($element, 'responseIdentifier', $component->getResponseIdentifier()); if ($component->hasPrompt() === true) { $element->appendChild($this->getMarshallerFactory()->createMarshaller($component->getPrompt())->marshall($component->getPrompt())); } if ($component->mustShuffle() !== false) { self::setDOMElementAttribute($element, 'shuffle', true); } if ($component instanceof ChoiceInteraction && $component->getMaxChoices() !== 1 || $component instanceof OrderInteraction && $component->getMaxChoices() !== -1) { self::setDOMElementAttribute($element, 'maxChoices', $component->getMaxChoices()); } if ($component instanceof ChoiceInteraction && $component->getMinChoices() !== 0 || $component instanceof OrderInteraction && $component->getMinChoices() !== -1) { self::setDOMElementAttribute($element, 'minChoices', $component->getMinChoices()); } if ($component->getOrientation() !== Orientation::VERTICAL) { self::setDOMElementAttribute($element, 'orientation', Orientation::getNameByConstant(Orientation::HORIZONTAL)); } if ($component->hasXmlBase() === true) { self::setXmlBase($element, $component->getXmlBase()); } foreach ($elements as $e) { $element->appendChild($e); } return $element; }