protected function marshall(QtiComponent $component) { $element = static::getDOMCradle()->createElement($component->getQtiClassName()); self::setDOMElementAttribute($element, 'identifier', $component->getIdentifier()); self::setDOMElementAttribute($element, 'navigationMode', NavigationMode::getNameByConstant($component->getNavigationMode())); self::setDOMElementAttribute($element, 'submissionMode', SubmissionMode::getNameByConstant($component->getSubmissionMode())); foreach ($component->getPreConditions() as $preCondition) { $marshaller = $this->getMarshallerFactory()->createMarshaller($preCondition); $element->appendChild($marshaller->marshall($preCondition)); } foreach ($component->getBranchRules() as $branchRule) { $marshaller = $this->getMarshallerFactory()->createMarshaller($branchRule); $element->appendChild($marshaller->marshall($branchRule)); } $itemSessionControl = $component->getItemSessionControl(); if (!empty($itemSessionControl)) { $marshaller = $this->getMarshallerFactory()->createMarshaller($itemSessionControl); $element->appendChild($marshaller->marshall($itemSessionControl)); } $timeLimits = $component->getTimeLimits(); if (!empty($timeLimits)) { $marshaller = $this->getMarshallerFactory()->createMarshaller($timeLimits); $element->appendChild($marshaller->marshall($timeLimits)); } foreach ($component->getAssessmentSections() as $assessmentSection) { $marshaller = $this->getMarshallerFactory()->createMarshaller($assessmentSection); $element->appendChild($marshaller->marshall($assessmentSection)); } foreach ($component->getTestFeedbacks() as $testFeedback) { $marshaller = $this->getMarshallerFactory()->createMarshaller($testFeedback); $element->appendChild($marshaller->marshall($testFeedback)); } return $element; }
/** * Marshall a SectionPart object into a DOMElement object. * * @param QtiComponent $component A SectionPart object. * @return DOMElement The according DOMElement object. */ protected function marshall(QtiComponent $component) { $element = static::getDOMCradle()->createElement($component->getQtiClassName()); self::setDOMElementAttribute($element, 'identifier', $component->getIdentifier()); self::setDOMElementAttribute($element, 'required', $component->isRequired()); self::setDOMElementAttribute($element, 'fixed', $component->isFixed()); foreach ($component->getPreConditions() as $preCondition) { $marshaller = $this->getMarshallerFactory()->createMarshaller($preCondition); $element->appendChild($marshaller->marshall($preCondition)); } foreach ($component->getBranchRules() as $branchRule) { $marshaller = $this->getMarshallerFactory()->createMarshaller($branchRule); $element->appendChild($marshaller->marshall($branchRule)); } if ($component->getItemSessionControl() != null) { $marshaller = $this->getMarshallerFactory()->createMarshaller($component->getItemSessionControl()); $element->appendChild($marshaller->marshall($component->getItemSessionControl())); } if ($component->getTimeLimits() != null) { $marshaller = $this->getMarshallerFactory()->createMarshaller($component->getTimeLimits()); $element->appendChild($marshaller->marshall($component->getTimeLimits())); } return $element; }