Skip to content

Commit

Permalink
Merge pull request #46 from oat-sa/fix/legacy-progress-item-count
Browse files Browse the repository at this point in the history
Fix/legacy progress item count
  • Loading branch information
Jérôme Bogaerts authored Aug 3, 2016
2 parents 0b6808f + 463ee8b commit d967ab2
Show file tree
Hide file tree
Showing 10 changed files with 158 additions and 7 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.10.6",
"version": "0.10.7",
"authors": [
{
"name": "Open Assessment Technologies S.A.",
Expand Down
19 changes: 15 additions & 4 deletions qtism/runtime/tests/AssessmentTestSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class AssessmentTestSession extends State {

const ROUTECOUNT_ALL = 0;
const ROUTECOUNT_EXCLUDENORESPONSE = 1;
const ROUTECOUNT_FLOW = 2;

/**
* A unique ID for this AssessmentTestSession.
Expand Down Expand Up @@ -1874,20 +1875,30 @@ public function getItemSubset($sectionIdentifier = '', IdentifierCollection $inc
* Get the number of items in the current Route. In other words, the total number
* of item occurences the candidate can take during the test.
*
* The $mode parameter can take two values:
* The $mode parameter can take three values:
*
* * AssessmentTestSession::ROUTECOUNT_ALL: consider all item occurences of the test
* * AssessmentTestSession::ROUTECOUNT_EXCLUDENORESPONSE: consider only item occurences containing at least one response declaration.
* * AssessmentTestSession::ROUTECOUNT_FLOW: ignore item occurences in non linear mode having no response declaration.
*
* @param integer $mode AssessmentTestSession::ROUTECOUNT_ALL | AssessmentTestSession::ROUTECOUNT_EXCLUDENORESPONSE
* @param integer $mode AssessmentTestSession::ROUTECOUNT_ALL | AssessmentTestSession::ROUTECOUNT_EXCLUDENORESPONSE | AssessmentTestSession::ROUTECOUNT_FLOW
* @return integer
*/
public function getRouteCount($mode = self::ROUTECOUNT_ALL)
{
if ($mode === self::ROUTECOUNT_ALL) {

return $this->getRoute()->count();
} else {
} elseif ($mode === self::ROUTECOUNT_FLOW) {
$i = 0;

foreach ($this->getRoute()->getAllRouteItems() as $routeItem) {
if (!($routeItem->getTestPart()->getNavigationMode() === NavigationMode::NONLINEAR && count($routeItem->getAssessmentItemRef()->getResponseDeclarations()) === 0)) {
$i++;
}
}

return $i;
} else {
$i = 0;

foreach ($this->getRoute()->getAssessmentItemRefs() as $assessmentItemRef) {
Expand Down
18 changes: 16 additions & 2 deletions test/qtism/runtime/tests/AssessmentTestSessionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use qtism\runtime\common\State;
use qtism\data\NavigationMode;
use qtism\data\SubmissionMode;
use qtism\data\storage\xml\XmlDocument;
use qtism\data\storage\xml\XmlCompactDocument;
use qtism\runtime\common\VariableIdentifier;
use qtism\common\enums\Cardinality;
Expand Down Expand Up @@ -1467,22 +1468,35 @@ public function testGetRouteCountAllWithResponseDeclaration() {
$doc->load(self::samplesDir() . 'custom/runtime/route_count/all_with_responsedeclaration.xml');
$manager = new SessionManager();
$session = $manager->createAssessmentTestSession($doc->getDocumentComponent());
$session->beginTestSession();

$this->assertEquals(3, $session->getRouteCount());
$this->assertEquals(3, $session->getRouteCount(AssessmentTestSession::ROUTECOUNT_ALL));
$this->assertEquals(3, $session->getRouteCount(AssessmentTestSession::ROUTECOUNT_EXCLUDENORESPONSE));
$this->assertEquals(3, $session->getRouteCount(AssessmentTestSession::ROUTECOUNT_FLOW));
}

public function testGetRouteCountMissingResponseDeclaration() {
$doc = new XmlCompactDocument();
$doc->load(self::samplesDir() . 'custom/runtime/route_count/missing_responsedeclaration.xml');
$manager = new SessionManager();
$session = $manager->createAssessmentTestSession($doc->getDocumentComponent());
$session->beginTestSession();

$this->assertEquals(3, $session->getRouteCount());
$this->assertEquals(3, $session->getRouteCount(AssessmentTestSession::ROUTECOUNT_ALL));
$this->assertEquals(2, $session->getRouteCount(AssessmentTestSession::ROUTECOUNT_EXCLUDENORESPONSE));
$this->assertEquals(3, $session->getRouteCount(AssessmentTestSession::ROUTECOUNT_FLOW));
}

public function testGetRouteCountMixed() {
$qti = new XmlDocument();
$qti->load(self::samplesDir() . 'custom/tests/linear_nonLinear_multiple_testparts/test.xml');
$doc = XmlCompactDocument::createFromXmlAssessmentTestDocument($qti);
$manager = new SessionManager();
$session = $manager->createAssessmentTestSession($doc->getDocumentComponent());

$this->assertEquals(6, $session->getRouteCount());
$this->assertEquals(6, $session->getRouteCount(AssessmentTestSession::ROUTECOUNT_ALL));
$this->assertEquals(4, $session->getRouteCount(AssessmentTestSession::ROUTECOUNT_EXCLUDENORESPONSE));
$this->assertEquals(5, $session->getRouteCount(AssessmentTestSession::ROUTECOUNT_FLOW));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?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="Q01" title="What is TAO?" adaptive="false" timeDependent="false">
<responseDeclaration identifier="RESPONSE" cardinality="single" baseType="identifier">
<correctResponse>
<value>tao</value>
</correctResponse>
</responseDeclaration>
<outcomeDeclaration identifier="SCORE" cardinality="single" baseType="float">
<defaultValue>
<value>0</value>
</defaultValue>
</outcomeDeclaration>
<itemBody>
<choiceInteraction id="interaction" responseIdentifier="RESPONSE" shuffle="false" maxChoices="1">
<prompt>What is TAO?</prompt>
<simpleChoice identifier="chinese">A metaphysical Chinese concept</simpleChoice>
<simpleChoice identifier="tao">A commercial-grade, open-source assessment platform.</simpleChoice>
<simpleChoice identifier="drink">A soft drink</simpleChoice>
</choiceInteraction>
</itemBody>
<responseProcessing template="http://www.imsglobal.org/question/qti_v2p1/rptemplates/match_correct"/>
</assessmentItem>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?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="Q02" title="Interlude" adaptive="false" timeDependent="false">
<itemBody>
<p><strong>Interlude!</strong></p>
</itemBody>
</assessmentItem>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?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="Q03" title="What does mean GT?" adaptive="false" timeDependent="false">
<responseDeclaration identifier="RESPONSE" cardinality="single" baseType="identifier">
<correctResponse>
<value>turismo</value>
</correctResponse>
</responseDeclaration>
<outcomeDeclaration identifier="SCORE" cardinality="single" baseType="float">
<defaultValue>
<value>0</value>
</defaultValue>
</outcomeDeclaration>
<itemBody>
<choiceInteraction id="interaction" responseIdentifier="RESPONSE" shuffle="false" maxChoices="1">
<prompt>What does mean GT within the concept of racing cars?</prompt>
<simpleChoice identifier="turbo">Great Turbo</simpleChoice>
<simpleChoice identifier="turbine">Gear Turbine</simpleChoice>
<simpleChoice identifier="turismo">Gran Turismo</simpleChoice>
</choiceInteraction>
</itemBody>
<responseProcessing template="http://www.imsglobal.org/question/qti_v2p1/rptemplates/match_correct"/>
</assessmentItem>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?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="Q04" title="The Sun?" adaptive="false" timeDependent="false">
<responseDeclaration identifier="RESPONSE" cardinality="single" baseType="identifier">
<correctResponse>
<value>correct</value>
</correctResponse>
</responseDeclaration>
<outcomeDeclaration identifier="SCORE" cardinality="single" baseType="float">
<defaultValue>
<value>0</value>
</defaultValue>
</outcomeDeclaration>
<itemBody>
<choiceInteraction id="interaction" responseIdentifier="RESPONSE" shuffle="false" maxChoices="1">
<prompt>Planet Earth turns around the Sun</prompt>
<simpleChoice identifier="correct">True</simpleChoice>
<simpleChoice identifier="incorrect">False</simpleChoice>
</choiceInteraction>
</itemBody>
<responseProcessing template="http://www.imsglobal.org/question/qti_v2p1/rptemplates/match_correct"/>
</assessmentItem>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?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="Q05" title="Interlude" adaptive="false" timeDependent="false">
<itemBody>
<p><strong>Interlude!</strong></p>
</itemBody>
</assessmentItem>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?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="Q06" title="A star?" adaptive="false" timeDependent="false">
<responseDeclaration identifier="RESPONSE" cardinality="single" baseType="identifier">
<correctResponse>
<value>correct</value>
</correctResponse>
</responseDeclaration>
<outcomeDeclaration identifier="SCORE" cardinality="single" baseType="float">
<defaultValue>
<value>0</value>
</defaultValue>
</outcomeDeclaration>
<itemBody>
<choiceInteraction id="interaction" responseIdentifier="RESPONSE" shuffle="false" maxChoices="1">
<prompt>The Sun is the star of our Solar System.</prompt>
<simpleChoice identifier="correct">True</simpleChoice>
<simpleChoice identifier="incorrect">False</simpleChoice>
</choiceInteraction>
</itemBody>
<responseProcessing template="http://www.imsglobal.org/question/qti_v2p1/rptemplates/match_correct"/>
</assessmentItem>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?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.imsglobal.org/xsd/qti/qtiv2p1/imsqti_v2p1.xsd"
identifier="T01" title="Linear Non Linear Multiple Test Parts">
<testPart navigationMode="linear" submissionMode="individual" identifier="TP01">
<itemSessionControl maxAttempts="0" allowSkipping="true"/>
<assessmentSection identifier="S01" title="Section 01" visible="true" required="true">
<assessmentItemRef identifier="Q01" href="./Q01.xml"/>
<assessmentItemRef identifier="Q02" href="./Q02.xml"/>
<assessmentItemRef identifier="Q03" href="./Q03.xml"/>
</assessmentSection>
</testPart>
<testPart navigationMode="nonlinear" submissionMode="individual" identifier="TP02">
<itemSessionControl maxAttempts="0" allowSkipping="true"/>
<assessmentSection identifier="S02" title="Section 02" visible="true" required="true">
<assessmentItemRef identifier="Q04" href="./Q04.xml"/>
<assessmentItemRef identifier="Q05" href="./Q05.xml"/>
<assessmentItemRef identifier="Q06" href="./Q06.xml"/>
</assessmentSection>
</testPart>
</assessmentTest>

0 comments on commit d967ab2

Please sign in to comment.