/** * Marshall a RandomFloat object into a DOMElement object. * * @param \qtism\data\QtiComponent $component A RandomFloat object. * @return \DOMElement The according DOMElement object. */ protected function marshall(QtiComponent $component) { $element = static::getDOMCradle()->createElement($component->getQtiClassName()); self::setDOMElementAttribute($element, 'min', $component->getMin()); self::setDOMElementAttribute($element, 'max', $component->getMax()); return $element; }
/** * Unmarshall an AnyN object into a QTI anyN element. * * @param QtiComponent The AnyN object to marshall. * @param array An array of child DOMEelement objects. * @return DOMElement The marshalled QTI anyN element. */ protected function marshallChildrenKnown(QtiComponent $component, array $elements) { $element = self::getDOMCradle()->createElement($component->getQtiClassName()); self::setDOMElementAttribute($element, 'min', $component->getMin()); self::setDOMElementAttribute($element, 'max', $component->getMax()); foreach ($elements as $elt) { $element->appendChild($elt); } return $element; }
/** * Marshall a RandomInteger object into a DOMElement object. * * @param QtiComponent $component A RandomInteger object. * @return DOMElement The according DOMElement object. */ protected function marshall(QtiComponent $component) { $element = static::getDOMCradle()->createElement($component->getQtiClassName()); self::setDOMElementAttribute($element, 'min', $component->getMin()); self::setDOMElementAttribute($element, 'max', $component->getMax()); if ($component->getStep() !== 1) { // default value of the step attribute is 1. self::setDOMElementAttribute($element, 'step', $component->getStep()); } return $element; }