Skip to content

Commit

Permalink
New AssessmentItemSessions Tests with juggling/nonjuggling.
Browse files Browse the repository at this point in the history
  • Loading branch information
= committed Jul 28, 2016
1 parent d8495ac commit e4b3db3
Show file tree
Hide file tree
Showing 3 changed files with 207 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/qtism/runtime/tests/AssessmentItemSessionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use qtism\runtime\tests\AssessmentItemSession;
use qtism\runtime\tests\AssessmentItemSessionException;
use qtism\data\storage\xml\marshalling\ExtendedAssessmentItemRefMarshaller;
use qtism\runtime\common\MultipleContainer;

class AssessmentItemSessionTest extends QtiSmAssessmentItemTestCase {

Expand Down Expand Up @@ -387,4 +388,32 @@ public function testRunCallback() {
$itemSession->interact();
$itemSession->endAttempt();
}

public function testSetOutcomeValuesWithSum() {
$doc = new XmlDocument();
$doc->load(self::samplesDir() . 'custom/items/set_outcome_values_with_sum.xml');

$itemSession = new AssessmentItemSession($doc->getDocumentComponent(), new SessionManager());
$itemSession->beginItemSession();
$itemSession->beginAttempt();

$responses = new State(array(new ResponseVariable('response-X', Cardinality::MULTIPLE, BaseType::IDENTIFIER, new MultipleContainer(BaseType::IDENTIFIER, array(new QtiIdentifier('ChoiceB'), new QtiIdentifier('ChoiceC'))))));
$itemSession->endAttempt($responses);

$this->assertEquals(1., $itemSession['score-X']->getValue());
}

public function testSetOutcomeValuesWithSumJuggling() {
$doc = new XmlDocument();
$doc->load(self::samplesDir() . 'custom/items/set_outcome_values_with_sum_juggling.xml');

$itemSession = new AssessmentItemSession($doc->getDocumentComponent(), new SessionManager());
$itemSession->beginItemSession();
$itemSession->beginAttempt();

$responses = new State(array(new ResponseVariable('response-X', Cardinality::MULTIPLE, BaseType::IDENTIFIER, new MultipleContainer(BaseType::IDENTIFIER, array(new QtiIdentifier('ChoiceB'), new QtiIdentifier('ChoiceC'))))));
$itemSession->endAttempt($responses);

$this->assertEquals(1., $itemSession['score-X']->getValue());
}
}
89 changes: 89 additions & 0 deletions test/samples/custom/items/set_outcome_values_with_sum.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?xml version="1.0" encoding="utf-8"?>
<assessmentItem title="Set Outcome Values with Sum" identifier="set_outcome_values_with_sum" timeDependent="false" xsi:schemaLocation="http://www.imsglobal.org/xsd/imsqti_v2p1 http://www.imsglobal.org/xsd/qti/qtiv2p1/imsqti_v2p1p1.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.imsglobal.org/xsd/imsqti_v2p1">
<responseDeclaration baseType="identifier" cardinality="multiple" identifier="response-X">
<correctResponse>
<value>ChoiceB</value>
<value>ChoiceC</value>
</correctResponse>
</responseDeclaration>
<outcomeDeclaration cardinality="single" baseType="float" identifier="SCORE">
<defaultValue>
<value>0</value>
</defaultValue>
</outcomeDeclaration>
<outcomeDeclaration cardinality="single" baseType="float" identifier="MAXSCORE">
<defaultValue>
<value>0</value>
</defaultValue>
</outcomeDeclaration>
<outcomeDeclaration baseType="float" cardinality="single" identifier="score-X">
<defaultValue>
<value>0</value>
</defaultValue>
</outcomeDeclaration>
<outcomeDeclaration baseType="float" cardinality="single" identifier="maxscore-X">
<defaultValue>
<value>1</value>
</defaultValue>
</outcomeDeclaration>
<itemBody>
<div>
<div>
<choiceInteraction id="interaction-1" minChoices="1" maxChoices="2" responseIdentifier="response-X" orientation="vertical">
<prompt>
<p>What is the correct response?</p>
</prompt>
<simpleChoice identifier="ChoiceA">
Choice A 
</simpleChoice>
<simpleChoice identifier="ChoiceB">
Choice B
</simpleChoice>
<simpleChoice identifier="ChoiceC">
Choice C
</simpleChoice>
<simpleChoice identifier="ChoiceD">
Choice D
</simpleChoice>
</choiceInteraction>
</div>
</div>
</itemBody>
<responseProcessing>
<responseCondition>
<responseIf>
<isNull>
<variable identifier="response-X" />
</isNull>
<setOutcomeValue identifier="score-X">
<baseValue baseType="integer">0</baseValue>
</setOutcomeValue>
</responseIf>
<responseElseIf>
<match>
<variable identifier="response-X" />
<correct identifier="response-X" />
</match>
<setOutcomeValue identifier="score-X">
<variable identifier="maxscore-X" />
</setOutcomeValue>
</responseElseIf>
<responseElse>
<setOutcomeValue identifier="score-X">
<baseValue baseType="integer">0</baseValue>
</setOutcomeValue>
</responseElse>
</responseCondition>
<setOutcomeValue identifier="SCORE">
<sum>
<variable identifier="score-X" />
</sum>
</setOutcomeValue>
<setOutcomeValue identifier="MAXSCORE">
<sum>
<variable identifier="maxscore-X" />
</sum>
</setOutcomeValue>
</responseProcessing>
<apipAccessibility xmlns="http://www.imsglobal.org/xsd/apip/apipv1p0/imsapip_qtiv1p0" />
</assessmentItem>
89 changes: 89 additions & 0 deletions test/samples/custom/items/set_outcome_values_with_sum_juggling.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?xml version="1.0" encoding="utf-8"?>
<assessmentItem title="Set Outcome Values with Sum Juggling" identifier="set_outcome_values_with_sum_juggling" timeDependent="false" xsi:schemaLocation="http://www.imsglobal.org/xsd/imsqti_v2p1 http://www.imsglobal.org/xsd/qti/qtiv2p1/imsqti_v2p1p1.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.imsglobal.org/xsd/imsqti_v2p1">
<responseDeclaration baseType="identifier" cardinality="multiple" identifier="response-X">
<correctResponse>
<value>ChoiceB</value>
<value>ChoiceC</value>
</correctResponse>
</responseDeclaration>
<outcomeDeclaration cardinality="single" baseType="float" identifier="SCORE">
<defaultValue>
<value>0</value>
</defaultValue>
</outcomeDeclaration>
<outcomeDeclaration cardinality="single" baseType="float" identifier="MAXSCORE">
<defaultValue>
<value>0</value>
</defaultValue>
</outcomeDeclaration>
<outcomeDeclaration baseType="float" cardinality="single" identifier="score-X">
<defaultValue>
<value>0</value>
</defaultValue>
</outcomeDeclaration>
<outcomeDeclaration baseType="float" cardinality="multiple" identifier="maxscore-X">
<defaultValue>
<value>1</value>
</defaultValue>
</outcomeDeclaration>
<itemBody>
<div>
<div>
<choiceInteraction id="interaction-1" minChoices="1" maxChoices="2" responseIdentifier="response-X" orientation="vertical">
<prompt>
<p>What is the correct response?</p>
</prompt>
<simpleChoice identifier="ChoiceA">
Choice A 
</simpleChoice>
<simpleChoice identifier="ChoiceB">
Choice B
</simpleChoice>
<simpleChoice identifier="ChoiceC">
Choice C
</simpleChoice>
<simpleChoice identifier="ChoiceD">
Choice D
</simpleChoice>
</choiceInteraction>
</div>
</div>
</itemBody>
<responseProcessing>
<responseCondition>
<responseIf>
<isNull>
<variable identifier="response-X" />
</isNull>
<setOutcomeValue identifier="score-X">
<baseValue baseType="integer">0</baseValue>
</setOutcomeValue>
</responseIf>
<responseElseIf>
<match>
<variable identifier="response-X" />
<correct identifier="response-X" />
</match>
<setOutcomeValue identifier="score-X">
<variable identifier="maxscore-X" />
</setOutcomeValue>
</responseElseIf>
<responseElse>
<setOutcomeValue identifier="score-X">
<baseValue baseType="integer">0</baseValue>
</setOutcomeValue>
</responseElse>
</responseCondition>
<setOutcomeValue identifier="SCORE">
<sum>
<variable identifier="score-X" />
</sum>
</setOutcomeValue>
<setOutcomeValue identifier="MAXSCORE">
<sum>
<variable identifier="maxscore-X" />
</sum>
</setOutcomeValue>
</responseProcessing>
<apipAccessibility xmlns="http://www.imsglobal.org/xsd/apip/apipv1p0/imsapip_qtiv1p0" />
</assessmentItem>

0 comments on commit e4b3db3

Please sign in to comment.