diff --git a/test/qtism/runtime/tests/AssessmentItemSessionTest.php b/test/qtism/runtime/tests/AssessmentItemSessionTest.php index 066f98a58..9e16fd06e 100644 --- a/test/qtism/runtime/tests/AssessmentItemSessionTest.php +++ b/test/qtism/runtime/tests/AssessmentItemSessionTest.php @@ -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 { @@ -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()); + } } diff --git a/test/samples/custom/items/set_outcome_values_with_sum.xml b/test/samples/custom/items/set_outcome_values_with_sum.xml new file mode 100644 index 000000000..e8dd18ed5 --- /dev/null +++ b/test/samples/custom/items/set_outcome_values_with_sum.xml @@ -0,0 +1,89 @@ + + + + + ChoiceB + ChoiceC + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 1 + + + + + + + + What is the correct response? + + + Choice A + + + Choice B + + + Choice C + + + Choice D + + + + + + + + + + + + + 0 + + + + + + + + + + + + + + 0 + + + + + + + + + + + + + + + + diff --git a/test/samples/custom/items/set_outcome_values_with_sum_juggling.xml b/test/samples/custom/items/set_outcome_values_with_sum_juggling.xml new file mode 100644 index 000000000..bcd5ed168 --- /dev/null +++ b/test/samples/custom/items/set_outcome_values_with_sum_juggling.xml @@ -0,0 +1,89 @@ + + + + + ChoiceB + ChoiceC + + + + + 0 + + + + + 0 + + + + + 0 + + + + + 1 + + + + + + + + What is the correct response? + + + Choice A + + + Choice B + + + Choice C + + + Choice D + + + + + + + + + + + + + 0 + + + + + + + + + + + + + + 0 + + + + + + + + + + + + + + + +
What is the correct response?