protected function unmarshall(DOMElement $element) { if (($identifier = static::getDOMElementAttributeAs($element, 'identifier')) !== null) { if (($navigationMode = static::getDOMElementAttributeAs($element, 'navigationMode')) !== null) { if (($submissionMode = static::getDOMElementAttributeAs($element, 'submissionMode')) !== null) { // We do not use the regular DOMElement::getElementsByTagName method // because it is recursive. We only want the first level elements with // tagname = 'assessmentSection'. $assessmentSectionElts = self::getChildElementsByTagName($element, 'assessmentSection'); $assessmentSections = new AssessmentSectionCollection(); foreach ($assessmentSectionElts as $sectElt) { $marshaller = $this->getMarshallerFactory()->createMarshaller($sectElt); $assessmentSections[] = $marshaller->unmarshall($sectElt); } if (count($assessmentSections) > 0) { // We can instantiate because all mandatory attributes/elements were found. $navigationMode = NavigationMode::getConstantByName($navigationMode); $submissionMode = SubmissionMode::getConstantByName($submissionMode); $object = new TestPart($identifier, $assessmentSections, $navigationMode, $submissionMode); // preConditions $preConditionElts = self::getChildElementsByTagName($element, 'preCondition'); $preConditions = new PreConditionCollection(); foreach ($preConditionElts as $preConditionElt) { $marshaller = $this->getMarshallerFactory()->createMarshaller($preConditionElt); $preConditions[] = $marshaller->unmarshall($preConditionElt); } $object->setPreConditions($preConditions); // branchRules $branchRuleElts = self::getChildElementsByTagName($element, 'branchRule'); $branchRules = new BranchRuleCollection(); foreach ($branchRuleElts as $branchRuleElt) { $marshaller = $this->getMarshallerFactory()->createMarshaller($branchRuleElt); $branchRules[] = $marshaller->unmarshall($branchRuleElt); } $object->setBranchRules($branchRules); // itemSessionControl $itemSessionControlElts = self::getChildElementsByTagName($element, 'itemSessionControl'); if (count($itemSessionControlElts) === 1) { $marshaller = $this->getMarshallerFactory()->createMarshaller($itemSessionControlElts[0]); $itemSessionControl = $marshaller->unmarshall($itemSessionControlElts[0]); $object->setItemSessionControl($itemSessionControl); } // timeLimits $timeLimitsElts = self::getChildElementsByTagName($element, 'timeLimits'); if (count($timeLimitsElts) === 1) { $marshaller = $this->getMarshallerFactory()->createMarshaller($timeLimitsElts[0]); $timeLimits = $marshaller->unmarshall($timeLimitsElts[0]); $object->setTimeLimits($timeLimits); } // testFeedbacks $testFeedbackElts = self::getChildElementsByTagName($element, 'testFeedback'); $testFeedbacks = new TestFeedbackCollection(); foreach ($testFeedbackElts as $testFeedbackElt) { $marshaller = $this->getMarshallerFactory()->createMarshaller($testFeedbackElt); $testFeedbacks[] = $marshaller->unmarshall($testFeedbackElt); } $object->setTestFeedbacks($testFeedbacks); return $object; } else { $msg = "A testPart element must contain at least one assessmentSection."; throw new UnmarshallingException($msg, $element); } } else { $msg = "The mandatory attribute 'submissionMode' is missing from element '" . $element->localName . "'."; throw new UnmarshallingException($msg, $element); } } else { $msg = "The mandatory attribute 'navigationMode' is missing from element '" . $element->localName . "'."; throw new UnmarshallingException($msg, $element); } } else { $msg = "The mandatory attribute 'identifier' is missing from element '" . $element->localName . "'."; throw new UnmarshallingException($msg, $element); } }