/** * Unmarshall a DOMElement object corresponding to a QTI assessmentSectionRef element. * * @param DOMElement $element A DOMElement object. * @return QtiComponent An AssessmentSectionRef object. * @throws UnmarshallingException If the mandatory attribute 'href' is missing. */ protected function unmarshall(DOMElement $element) { $baseComponent = parent::unmarshall($element); if (($href = static::getDOMElementAttributeAs($element, 'href', 'string')) !== null) { $object = new AssessmentSectionRef($baseComponent->getIdentifier(), $href); $object->setRequired($baseComponent->isRequired()); $object->setFixed($baseComponent->isFixed()); $object->setPreConditions($baseComponent->getPreConditions()); $object->setBranchRules($baseComponent->getBranchRules()); $object->setItemSessionControl($baseComponent->getItemSessionControl()); $object->setTimeLimits($baseComponent->getTimeLimits()); return $object; } else { $msg = "Mandatory attribute 'href' is missing from element '" . $element->localName . "'."; throw new UnmarshallingException($msg, $element); } }
/** * Dereference the file referenced by an assessmentSectionRef. * * @param AssessmentSectionRef $assessmentSectionRef An AssessmentSectionRef object to dereference. * @param FileResolver $resolver The Resolver object to be used to resolve AssessmentSectionRef's href attribute. * @throws XmlStorageException If an error occurs while dereferencing the referenced file. * @return XmlAssessmentSection The AssessmentSection referenced by $assessmentSectionRef. */ protected static function resolveAssessmentSectionRef(AssessmentSectionRef $assessmentSectionRef, FileResolver $resolver) { try { $href = $resolver->resolve($assessmentSectionRef->getHref()); $doc = new XmlDocument(); $doc->load($href); return $doc->getDocumentComponent(); } catch (XmlStorageException $e) { $msg = "An error occured while unreferencing file '{$href}'."; throw new XmlStorageException($msg); } }