From c194eb0c6df8ac5f197bd95d369559c3e74a7833 Mon Sep 17 00:00:00 2001 From: = Date: Fri, 1 Jul 2016 16:10:44 +0200 Subject: [PATCH] Enhance Resolvers. --- qtism/data/storage/xml/XmlCompactDocument.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/qtism/data/storage/xml/XmlCompactDocument.php b/qtism/data/storage/xml/XmlCompactDocument.php index c321a0749..d3d75a044 100644 --- a/qtism/data/storage/xml/XmlCompactDocument.php +++ b/qtism/data/storage/xml/XmlCompactDocument.php @@ -119,13 +119,13 @@ public static function createFromXmlAssessmentTestDocument(XmlDocument $xmlAsses // File resolution. if (is_null($itemResolver) === true) { $itemResolver = new LocalFileResolver($xmlAssessmentTestDocument->getUrl()); - } elseif ($itemResolver instanceof LocalFileResolver) { + } elseif ($itemResolver instanceof FileResolver) { $itemResolver->setBasePath($xmlAssessmentTestDocument->getUrl()); } if (is_null($sectionResolver) === true) { $sectionResolver = new LocalFileResolver($xmlAssessmentTestDocument->getUrl()); - } elseif ($sectionResolver instanceof LocalFileResolver) { + } elseif ($sectionResolver instanceof FileResolver) { $sectionResolver->setBasePath($xmlAssessmentTestDocument->getUrl()); } @@ -174,8 +174,11 @@ public static function createFromXmlAssessmentTestDocument(XmlDocument $xmlAsses if ($component instanceof XmlDocument && $component->getDocumentComponent() instanceof AssessmentSection) { $baseUri = $component->getUrl(); } - - $itemResolver->setBasePath($baseUri); + + if ($itemResolver instanceof FileResolver) { + $itemResolver->setBasePath($baseUri); + } + self::resolveAssessmentItemRef($compactRef, $itemResolver); $previousParts->replace($component, $compactRef); @@ -222,10 +225,10 @@ public static function createFromXmlAssessmentTestDocument(XmlDocument $xmlAsses * outcome/responseDeclarations to the compact one. * * @param ExtendedAssessmentItemRef $compactAssessmentItemRef A previously instantiated ExtendedAssessmentItemRef object. - * @param FileResolver $resolver The Resolver to be used to resolver AssessmentItemRef's href attribute. + * @param Resolver $resolver The Resolver to be used to resolver AssessmentItemRef's href attribute. * @throws XmlStorageException If an error occurs (e.g. file not found at URI or unmarshalling issue) during the dereferencing. */ - protected static function resolveAssessmentItemRef(ExtendedAssessmentItemRef $compactAssessmentItemRef, FileResolver $resolver) { + protected static function resolveAssessmentItemRef(ExtendedAssessmentItemRef $compactAssessmentItemRef, Resolver $resolver) { try { $href = $resolver->resolve($compactAssessmentItemRef->getHref()); @@ -257,11 +260,11 @@ protected static function resolveAssessmentItemRef(ExtendedAssessmentItemRef $co * 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. + * @param Resolver $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) { + protected static function resolveAssessmentSectionRef(AssessmentSectionRef $assessmentSectionRef, Resolver $resolver) { try { $href = $resolver->resolve($assessmentSectionRef->getHref());