Skip to content

Commit

Permalink
Added more information about unreferencing issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
= committed Mar 10, 2016
1 parent 8344c91 commit ac57575
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 6 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "qtism/qtism",
"description": "OAT QTI Software Module Library",
"type": "library",
"version": "0.9.20",
"version": "0.9.21",
"authors": [
{
"name": "Open Assessment Technologies S.A.",
Expand Down
3 changes: 2 additions & 1 deletion qtism/data/state/VariableDeclaration.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2013 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT);
* Copyright (c) 2013-2015 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT);
*
* @author Jérôme Bogaerts, <[email protected]>
* @license GPLv2
Expand All @@ -32,6 +32,7 @@
use qtism\common\enums\Cardinality;
use \SplObserver;
use \SplObjectStorage;
use \InvalidArgumentException;

/**
* From IMS QTI:
Expand Down
8 changes: 4 additions & 4 deletions qtism/data/storage/xml/XmlCompactDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2013 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT);
* Copyright (c) 2013-2016 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT);
*
* @author Jérôme Bogaerts, <[email protected]>
* @license GPLv2
Expand Down Expand Up @@ -242,7 +242,7 @@ protected static function resolveAssessmentItemRef(ExtendedAssessmentItemRef $co
$compactAssessmentItemRef->setTimeDependent($doc->getDocumentComponent()->isTimeDependent());
}
catch (Exception $e) {
$msg = "An error occured while unreferencing file '${href}'.";
$msg = "An error occured while unreferencing item reference with identifier '" . $compactAssessmentItemRef->getIdentifier() . "'.";
throw new XmlStorageException($msg, $e);
}
}
Expand All @@ -264,8 +264,8 @@ protected static function resolveAssessmentSectionRef(AssessmentSectionRef $asse
return $doc->getDocumentComponent();
}
catch (XmlStorageException $e) {
$msg = "An error occured while unreferencing file '${href}'.";
throw new XmlStorageException($msg);
$msg = "An error occured while unreferencing section reference with identifier '" . $assessmentSectionRef->getIdentifier() . "'.";
throw new XmlStorageException($msg, $e);
}
}

Expand Down
13 changes: 13 additions & 0 deletions test/qtism/data/storage/xml/XmlCompactAssessmentDocumentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use qtism\data\storage\LocalFileResolver;
use qtism\data\NavigationMode;
use qtism\data\storage\xml\XmlDocument;
use qtism\data\storage\xml\XmlStorageException;

require_once (dirname(__FILE__) . '/../../../../QtiSmTestCase.php');

Expand Down Expand Up @@ -215,4 +216,16 @@ public function testExplodeRubricBlocks() {

unlink($file);
}

public function testCreateFromAssessmentTestInvalidAssessmentItemRefResolution() {
$this->setExpectedException(
'\\qtism\\data\\storage\\xml\\XmlStorageException',
"An error occured while unreferencing item reference with identifier 'Q01'."
);

$doc = new XmlDocument('2.1');
$file = self::samplesDir() . 'custom/tests/invalidassessmentitemref.xml';
$doc->load($file);
$compactDoc = XmlCompactDocument::createFromXmlAssessmentTestDocument($doc, new LocalFileResolver());
}
}
11 changes: 11 additions & 0 deletions test/samples/custom/tests/invalidassessmentitemref.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<assessmentTest xmlns="http://www.imsglobal.org/xsd/imsqti_v2p1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.imsglobal.org/xsd/imsqti_v2p1 http://www.imsglobal.org/xsd/qti/qtiv2p1/imsqti_v2p1.xsd"
identifier="invalidassessmentitemref" title="Invalid AssessmentItemRef">
<testPart identifier="T01" navigationMode="nonlinear" submissionMode="individual">
<assessmentSection identifier="S01" title="Section 01" visible="true">
<assessmentItemRef identifier="Q01" href="../../invalid/invalidresponseidentifier.xml"/>
</assessmentSection>
</testPart>
</assessmentTest>
32 changes: 32 additions & 0 deletions test/samples/invalid/invalidresponseidentifier.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<assessmentItem xmlns="http://www.imsglobal.org/xsd/imsqti_v2p1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.imsglobal.org/xsd/imsqti_v2p1 http://www.imsglobal.org/xsd/qti/qtiv2p1/imsqti_v2p1.xsd"
identifier="choiceMultiple" title="Composition of Water" adaptive="false" timeDependent="false">
<!-- identifier of responseDeclaration is invalid for QTI-SDK because it has a leading "space" char. -->
<responseDeclaration identifier=" RESPONSE" cardinality="multiple" baseType="identifier">
<correctResponse>
<value>H</value>
<value>O</value>
</correctResponse>
<mapping lowerBound="0" upperBound="2" defaultValue="-2">
<mapEntry mapKey="H" mappedValue="1"/>
<mapEntry mapKey="O" mappedValue="1"/>
<mapEntry mapKey="Cl" mappedValue="-1"/>
</mapping>
</responseDeclaration>
<outcomeDeclaration identifier="SCORE" cardinality="single" baseType="float"/>
<itemBody>
<choiceInteraction responseIdentifier="RESPONSE" shuffle="true" maxChoices="0">
<prompt>Which of the following elements are used to form water?</prompt>
<simpleChoice identifier="H" fixed="false">Hydrogen</simpleChoice>
<simpleChoice identifier="He" fixed="false">Helium</simpleChoice>
<simpleChoice identifier="C" fixed="false">Carbon</simpleChoice>
<simpleChoice identifier="O" fixed="false">Oxygen</simpleChoice>
<simpleChoice identifier="N" fixed="false">Nitrogen</simpleChoice>
<simpleChoice identifier="Cl" fixed="false">Chlorine</simpleChoice>
</choiceInteraction>
</itemBody>
<responseProcessing
template="http://www.imsglobal.org/question/qti_v2p1/rptemplates/map_response"/>
</assessmentItem>

0 comments on commit ac57575

Please sign in to comment.