/** * Marshall an AssessmentItemRef object into a DOMElement object. * * @param QtiComponent $component An assessmentItemRef object. * @return DOMElement The according DOMElement object. * @throws MarshallingException */ protected function marshall(QtiComponent $component) { $element = parent::marshall($component); self::setDOMElementAttribute($element, 'href', $component->getHref()); // Deal with categories. $categories = $component->getCategories(); if (count($categories) > 0) { self::setDOMElementAttribute($element, 'category', implode(" ", $categories->getArrayCopy())); } // Deal with variableMappings. $variableMappings = $component->getVariableMappings(); foreach ($variableMappings as $mapping) { $marshaller = $this->getMarshallerFactory()->createMarshaller($mapping); $element->appendChild($marshaller->marshall($mapping)); } // Deal with weights. $weights = $component->getWeights(); foreach ($weights as $weight) { $marshaller = $this->getMarshallerFactory()->createMarshaller($weight); $element->appendChild($marshaller->marshall($weight)); } // Deal with templateDefaults. $templateDefaults = $component->getTemplateDefaults(); foreach ($templateDefaults as $default) { $marshaller = $this->getMarshallerFactory()->createMarshaller($default); $element->appendChild($marshaller->marshall($default)); } return $element; }
/** * @see \qtism\data\storage\xml\marshalling\RecursiveMarshaller::marshallChildrenKnown() */ protected function marshallChildrenKnown(QtiComponent $component, array $elements) { $baseMarshaller = new SectionPartMarshaller($this->getVersion()); $element = $baseMarshaller->marshall($component); self::setDOMElementAttribute($element, 'title', $component->getTitle()); self::setDOMElementAttribute($element, 'visible', $component->isVisible()); self::setDOMElementAttribute($element, 'keepTogether', $component->mustKeepTogether()); // Deal with selection element $selection = $component->getSelection(); if (!empty($selection)) { $marshaller = $this->getMarshallerFactory()->createMarshaller($selection); $element->appendChild($marshaller->marshall($selection)); } // Deal with ordering element. $ordering = $component->getOrdering(); if (!empty($ordering)) { $marshaller = $this->getMarshallerFactory()->createMarshaller($ordering); $element->appendChild($marshaller->marshall($ordering)); } // Deal with rubricBlock elements. foreach ($component->getRubricBlocks() as $rubricBlock) { $marshaller = $this->getMarshallerFactory()->createMarshaller($rubricBlock); $element->appendChild($marshaller->marshall($rubricBlock)); } // And finally... // Deal with sectionPart elements that are actually known... foreach ($elements as $elt) { $element->appendChild($elt); } return $element; }
/** * Marshall an AssessmentSectionRef object into a DOMElement object. * * @param QtiComponent $component An AssessmentSectionRef object. * @return DOMElement The according DOMElement object. */ protected function marshall(QtiComponent $component) { $element = parent::marshall($component); self::setDOMElementAttribute($element, 'href', $component->getHref()); return $element; }