Skip to content

Commit

Permalink
Enhance Resolvers.
Browse files Browse the repository at this point in the history
  • Loading branch information
= committed Jul 1, 2016
1 parent be43be7 commit c194eb0
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions qtism/data/storage/xml/XmlCompactDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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());

Expand Down Expand Up @@ -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());

Expand Down

0 comments on commit c194eb0

Please sign in to comment.