Skip to content

Commit

Permalink
Some fixes for nextRouteItem.
Browse files Browse the repository at this point in the history
  • Loading branch information
= committed Nov 15, 2015
1 parent 9d3bec7 commit 98b23ce
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 12 deletions.
14 changes: 2 additions & 12 deletions src/qtism/runtime/tests/AssessmentTestSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -2173,10 +2173,8 @@ protected function nextRouteItem($ignoreBranchings = false, $ignorePreConditions
if ($target === 'EXIT_TEST') {
$this->endTestSession();
} elseif ($target === 'EXIT_TESTPART') {
$route->next();
$this->moveNextTestPart();
} elseif ($target === 'EXIT_SECTION') {
$route->next();
$this->moveNextAssessmentSection();
} else {
$route->branch($branchRules[$i]->getTarget());
Expand Down Expand Up @@ -2240,11 +2238,7 @@ protected function moveNextTestPart()
$from = $route->current();

while ($route->valid() === true && $route->current()->getTestPart() === $from->getTestPart()) {
$this->nextRouteItem();
}

if ($this->isRunning() === true) {
$this->interactWithItemSession();
$route->next();
}
}

Expand All @@ -2267,11 +2261,7 @@ protected function moveNextAssessmentSection()
$from = $route->current();

while ($route->valid() === true && $route->current()->getAssessmentSection() === $from->getAssessmentSection()) {
$this->nextRouteItem();
}

if ($this->isRunning() === true) {
$this->interactWithItemSession();
$route->next();
}
}

Expand Down
19 changes: 19 additions & 0 deletions test/qtismtest/runtime/tests/AssessmentTestSessionExitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,25 @@ public function testExitSectionEndOfTest() {
$this->assertEquals(false, $itemSessions);
}

public function testExitSectionFromEndOfSection() {
$url = self::samplesDir() . 'custom/runtime/exits/exitsectionfromendofsection.xml';
$testSession = self::instantiate($url);

$testSession->beginTestSession();

// If we get correct to the first question, we will EXIT_SECTION. We should
// be then redirected to next S02 section (Q02).
$testSession->beginAttempt();
$testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA')))));

// We should be at section S02, item Q02.
$testSession->moveNext();

$this->assertEquals('Q02', $testSession->getCurrentAssessmentItemRef()->getIdentifier());
$testSession->moveNext();
$this->assertEquals(AssessmentTestSessionState::CLOSED, $testSession->getState());
}

public function testExitSectionPreconditionsEndOfTest() {
$url = self::samplesDir() . 'custom/runtime/exits/exitsectionpreconditions.xml';
$testSession = self::instantiate($url);
Expand Down
49 changes: 49 additions & 0 deletions test/samples/custom/runtime/exits/exitsectionfromendofsection.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?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.taotesting.com/xsd/qticompact_v1p0.xsd"
identifier="exitsectionfromendofsection" title="Exit Section End of Test">
<!-- In this example, If Q01 is correctly responded, the candidate is redirected to the
to the end of the section via EXIT_SECTION. -->
<testPart identifier="P01" navigationMode="linear" submissionMode="individual">
<assessmentSection identifier="S01" title="Section1" visible="true">
<assessmentItemRef identifier="Q01" href="./Q01.xml" timeDependent="false">
<branchRule target="EXIT_SECTION">
<gt>
<max>
<testVariables sectionIdentifier="S01" variableIdentifier="SCORE"/>
</max>
<baseValue baseType="float">0</baseValue>
</gt>
</branchRule>
<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>
<responseProcessing template="http://www.imsglobal.org/question/qti_v2p1/rptemplates/match_correct"/>
</assessmentItemRef>
</assessmentSection>

<assessmentSection identifier="S02" title="Section2" visible="true">
<assessmentItemRef identifier="Q02" href="./Q02.xml" timeDependent="false">
<responseDeclaration identifier="RESPONSE" cardinality="single" baseType="identifier">
<correctResponse>
<value>ChoiceB</value>
</correctResponse>
</responseDeclaration>
<outcomeDeclaration identifier="SCORE" cardinality="single" baseType="float">
<defaultValue>
<value>0</value>
</defaultValue>
</outcomeDeclaration>
<responseProcessing template="http://www.imsglobal.org/question/qti_v2p1/rptemplates/match_correct"/>
</assessmentItemRef>
</assessmentSection>
</testPart>
</assessmentTest>

0 comments on commit 98b23ce

Please sign in to comment.