Skip to content

Commit

Permalink
Merge pull request #14 from hutnikau/legacy-last-section-item-timeout…
Browse files Browse the repository at this point in the history
…-issue

Legacy last section item timeout issue
  • Loading branch information
Jérôme Bogaerts committed Sep 23, 2015
2 parents 5f692c1 + 9fa58ea commit 8c8a359
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 24 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.12",
"version": "0.9.13",
"authors": [
{
"name": "Open Assessment Technologies S.A.",
Expand Down
44 changes: 22 additions & 22 deletions qtism/runtime/tests/AssessmentTestSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -1585,9 +1585,11 @@ protected function nextRouteItem($ignoreBranchings = false, $ignorePreConditions
$this->endTestSession();
}
else if ($target === 'EXIT_TESTPART') {
$route->next();
$this->moveNextTestPart();
}
else if ($target === 'EXIT_SECTION') {
$route->next();
$this->moveNextAssessmentSection();
}
else {
Expand Down Expand Up @@ -1653,42 +1655,40 @@ public function moveNextTestPart() {
$route = $this->getRoute();
$from = $route->current();

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

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

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

/**
* Set the position in the Route at the very next assessmentSection in the route sequence.
*
*
* * If there is no assessmentSection left in the flow, the test session ends gracefully.
* * If there are still pending responses, they are processed.
*
*
* @throws AssessmentTestSessionException If the test is not running.
*/
public function moveNextAssessmentSection() {

if ($this->isRunning() === false) {
$msg = "Cannot move to the next assessmentSection while the state of the test session is INITIAL or CLOSED.";
throw new AssessmentTestSessionException($msg, AssessmentTestSessionException::STATE_VIOLATION);
}

$route = $this->getRoute();
$from = $route->current();

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

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

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

/**
Expand Down Expand Up @@ -2526,4 +2526,4 @@ protected function buildCurrentItemSessionIdentifier() {
protected function timeLimitsInForce($excludeItem = false) {
return count($this->getCurrentRouteItem()->getTimeLimits($excludeItem)) !== 0;
}
}
}
33 changes: 32 additions & 1 deletion test/qtism/runtime/tests/AssessmentTestSessionTimingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -334,4 +334,35 @@ public function testMultipleOccurences() {
$this->assertEquals(2, $session['Q01.2.duration']->getSeconds(true));
$this->assertEquals(0, $session['Q01.3.duration']->getSeconds(true));
}
}

public function testLastItemTimeout() {
$session = self::instantiate(self::samplesDir() . 'custom/runtime/timings/last_item_timeout.xml');
$session->beginTestSession();

$session->beginAttempt();
sleep(2);
$session->moveNext();
$this->assertEquals(AssessmentTestSessionState::CLOSED, $session->getState());
}

public function testLastItemSectionTimeout() {
$session = self::instantiate(self::samplesDir() . 'custom/runtime/timings/last_item_section_timeout.xml');
$session->beginTestSession();

$session->beginAttempt();
sleep(2);
$session->moveNextAssessmentSection();
$this->assertEquals(AssessmentTestSessionState::CLOSED, $session->getState());
}

public function testLastItemTestPartTimeout() {
$session = self::instantiate(self::samplesDir() . 'custom/runtime/timings/last_item_testpart_timeout.xml');
$session->beginTestSession();

$session->beginAttempt();
sleep(2);
$session->moveNextTestPart();
$this->assertEquals(AssessmentTestSessionState::CLOSED, $session->getState());
}
}

24 changes: 24 additions & 0 deletions test/samples/custom/runtime/timings/last_item_section_timeout.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?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="last_item_section_timeout" title="Last Item Section Timeout">
<testPart identifier="TP01" navigationMode="nonlinear" submissionMode="individual">
<assessmentSection identifier="S01" fixed="false" title="Section 01" visible="true">
<timeLimits maxTime="1"/>
<assessmentItemRef identifier="Q01" href="Q01.xml" fixed="false" adaptive="false" 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.0</value>
</defaultValue>
</outcomeDeclaration>
<responseProcessing template="http://www.imsglobal.org/question/qti_v2p1/rptemplates/match_correct"/>
</assessmentItemRef>
</assessmentSection>
</testPart>
</assessmentTest>
24 changes: 24 additions & 0 deletions test/samples/custom/runtime/timings/last_item_testpart_timeout.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?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="last_item_testpart_timeout" title="Last Item Test Part Timeout">
<testPart identifier="TP01" navigationMode="nonlinear" submissionMode="individual">
<timeLimits maxTime="1"/>
<assessmentSection identifier="S01" fixed="false" title="Section 01" visible="true">
<assessmentItemRef identifier="Q01" href="Q01.xml" fixed="false" adaptive="false" 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.0</value>
</defaultValue>
</outcomeDeclaration>
<responseProcessing template="http://www.imsglobal.org/question/qti_v2p1/rptemplates/match_correct"/>
</assessmentItemRef>
</assessmentSection>
</testPart>
</assessmentTest>
24 changes: 24 additions & 0 deletions test/samples/custom/runtime/timings/last_item_timeout.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?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="last_item_timeout" title="Last Item Timeout">
<testPart identifier="TP01" navigationMode="nonlinear" submissionMode="individual">
<assessmentSection identifier="S01" fixed="false" title="Section 01" visible="true">
<assessmentItemRef identifier="Q01" href="Q01.xml" fixed="false" adaptive="false" timeDependent="false">
<timeLimits maxTime="1"/>
<responseDeclaration identifier="RESPONSE" cardinality="single" baseType="identifier">
<correctResponse>
<value>ChoiceB</value>
</correctResponse>
</responseDeclaration>
<outcomeDeclaration identifier="SCORE" cardinality="single" baseType="float">
<defaultValue>
<value>0.0</value>
</defaultValue>
</outcomeDeclaration>
<responseProcessing template="http://www.imsglobal.org/question/qti_v2p1/rptemplates/match_correct"/>
</assessmentItemRef>
</assessmentSection>
</testPart>
</assessmentTest>

0 comments on commit 8c8a359

Please sign in to comment.