-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added capability to resolve response processing template locations
- Loading branch information
=
committed
Jan 18, 2016
1 parent
150dd39
commit 50cf68c
Showing
8 changed files
with
188 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
test/qtismtest/data/storage/xml/XmlDocumentTemplateLocationTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
namespace qtismtest\data\storage\xml; | ||
|
||
use qtismtest\QtiSmTestCase; | ||
use qtism\data\storage\xml\XmlDocument; | ||
use qtism\data\storage\xml\XmlStorageException; | ||
|
||
class XmlDocumentTemplateLocationTest extends QtiSmTestCase { | ||
|
||
public function testCorrectlyFormed() { | ||
$doc = new XmlDocument(); | ||
$doc->load(self::samplesDir() . 'custom/items/template_location/template_location_item.xml', true); | ||
|
||
$responseProcessings = $doc->getDocumentComponent()->getComponentsByClassName('responseProcessing'); | ||
$this->assertEquals(1, count($responseProcessings)); | ||
$this->assertEquals('template_location_rp.xml', $responseProcessings[0]->getTemplateLocation()); | ||
|
||
$doc->resolveTemplateLocation(true); | ||
|
||
$responseProcessings = $doc->getDocumentComponent()->getComponentsByClassName('responseProcessing'); | ||
$this->assertEquals(1, count($responseProcessings)); | ||
$this->assertEquals('http://www.imsglobal.org/question/qti_v2p1/rptemplates/match_correct', $responseProcessings[0]->getTemplate()); | ||
} | ||
|
||
public function testNotLoaded() { | ||
$doc = new XmlDocument(); | ||
|
||
$this->setExpectedException('\\LogicException', 'Cannot resolve template location loading any file.'); | ||
$doc->resolveTemplateLocation(); | ||
} | ||
|
||
public function testWrongTarget() { | ||
$doc = new XmlDocument(); | ||
$doc->load(self::samplesDir() . 'custom/items/template_location/template_location_item_wrong_target.xml', true); | ||
|
||
$this->setExpectedException('qtism\\data\\storage\\xml\\XmlStorageException'); | ||
$doc->resolveTemplateLocation(); | ||
} | ||
|
||
public function testInvalidTargetNoValidation() { | ||
$doc = new XmlDocument(); | ||
$doc->load(self::samplesDir() . 'custom/items/template_location/template_location_item_invalid_target.xml', true); | ||
|
||
$this->setExpectedException('qtism\\data\\storage\\xml\\XmlStorageException', "'responseProcessingZ' components are not supported in QTI version '2.1.0'.", XmlStorageException::VERSION); | ||
$doc->resolveTemplateLocation(); | ||
} | ||
|
||
public function testInvalidTargetValidation() { | ||
$doc = new XmlDocument(); | ||
$doc->load(self::samplesDir() . 'custom/items/template_location/template_location_item_invalid_target.xml', true); | ||
|
||
$this->setExpectedException('qtism\\data\\storage\\xml\\XmlStorageException', null, XmlStorageException::XSD_VALIDATION); | ||
$doc->resolveTemplateLocation(true); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
test/samples/custom/items/template_location/template_location_item.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?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="telephone" title="Inventor of Telephone" adaptive="false" timeDependent="false"> | ||
<responseDeclaration identifier="RESPONSE" cardinality="single" baseType="identifier"> | ||
<correctResponse> | ||
<value>ChoiceA</value> | ||
</correctResponse> | ||
</responseDeclaration> | ||
<outcomeDeclaration identifier="SCORE" cardinality="single" baseType="float"> | ||
<defaultValue> | ||
<value>0</value> | ||
</defaultValue> | ||
</outcomeDeclaration> | ||
<itemBody> | ||
<choiceInteraction responseIdentifier="RESPONSE" shuffle="false" maxChoices="1"> | ||
<prompt>Who is the inventor of the telephone?</prompt> | ||
<simpleChoice identifier="ChoiceA">Alexander Graham Bell</simpleChoice> | ||
<simpleChoice identifier="ChoiceB">Henri Owen Tudor</simpleChoice> | ||
<simpleChoice identifier="ChoiceC">Bill Gates</simpleChoice> | ||
</choiceInteraction> | ||
</itemBody> | ||
<responseProcessing templateLocation="template_location_rp.xml"/> | ||
</assessmentItem> |
25 changes: 25 additions & 0 deletions
25
test/samples/custom/items/template_location/template_location_item_invalid_target.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?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="telephone" title="Inventor of Telephone" adaptive="false" timeDependent="false"> | ||
<responseDeclaration identifier="RESPONSE" cardinality="single" baseType="identifier"> | ||
<correctResponse> | ||
<value>ChoiceA</value> | ||
</correctResponse> | ||
</responseDeclaration> | ||
<outcomeDeclaration identifier="SCORE" cardinality="single" baseType="float"> | ||
<defaultValue> | ||
<value>0</value> | ||
</defaultValue> | ||
</outcomeDeclaration> | ||
<itemBody> | ||
<choiceInteraction responseIdentifier="RESPONSE" shuffle="false" maxChoices="1"> | ||
<prompt>Who is the inventor of the telephone?</prompt> | ||
<simpleChoice identifier="ChoiceA">Alexander Graham Bell</simpleChoice> | ||
<simpleChoice identifier="ChoiceB">Henri Owen Tudor</simpleChoice> | ||
<simpleChoice identifier="ChoiceC">Bill Gates</simpleChoice> | ||
</choiceInteraction> | ||
</itemBody> | ||
<responseProcessing templateLocation="template_location_rp_invalid.xml"/> | ||
</assessmentItem> |
26 changes: 26 additions & 0 deletions
26
test/samples/custom/items/template_location/template_location_item_wrong_target.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?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="telephone" title="Inventor of Telephone" adaptive="false" timeDependent="false"> | ||
<responseDeclaration identifier="RESPONSE" cardinality="single" baseType="identifier"> | ||
<correctResponse> | ||
<value>ChoiceA</value> | ||
</correctResponse> | ||
</responseDeclaration> | ||
<outcomeDeclaration identifier="SCORE" cardinality="single" baseType="float"> | ||
<defaultValue> | ||
<value>0</value> | ||
</defaultValue> | ||
</outcomeDeclaration> | ||
<itemBody> | ||
<choiceInteraction responseIdentifier="RESPONSE" shuffle="false" maxChoices="1"> | ||
<prompt>Who is the inventor of the telephone?</prompt> | ||
<simpleChoice identifier="ChoiceA">Alexander Graham Bell</simpleChoice> | ||
<simpleChoice identifier="ChoiceB">Henri Owen Tudor</simpleChoice> | ||
<simpleChoice identifier="ChoiceC">Bill Gates</simpleChoice> | ||
</choiceInteraction> | ||
</itemBody> | ||
<!-- templateLocation refers to an item and will then not be included. --> | ||
<responseProcessing templateLocation="infocontrol.xml"/> | ||
</assessmentItem> |
2 changes: 2 additions & 0 deletions
2
test/samples/custom/items/template_location/template_location_rp.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<responseProcessing 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" template="http://www.imsglobal.org/question/qti_v2p1/rptemplates/match_correct"/> |
3 changes: 3 additions & 0 deletions
3
test/samples/custom/items/template_location/template_location_rp_invalid.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- Invalid QTI 2.1 File. --> | ||
<responseProcessingZ 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" template="http://www.imsglobal.org/question/qti_v2p1/rptemplates/match_correct"/> |