Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
= committed Aug 3, 2016
2 parents 770013e + 8780243 commit 6dada5a
Show file tree
Hide file tree
Showing 20 changed files with 273 additions and 8 deletions.
19 changes: 15 additions & 4 deletions src/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 @@ -1052,20 +1053,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
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,24 @@ public function testRenderingProvider()
GoldilocksRenderingEngine::STYLESHEET_INLINE,
GoldilocksRenderingEngine::CSSCLASS_CONCRETE
),
// choiceInteraction-5
array(
self::samplesDir() . 'ims/items/2_2/orkney1.xml',
self::samplesDir() . 'rendering/goldilocks/rendered/choiceInteraction-5.html',
GoldilocksRenderingEngine::CONTEXT_STATIC,
GoldilocksRenderingEngine::XMLBASE_IGNORE,
GoldilocksRenderingEngine::STYLESHEET_INLINE,
GoldilocksRenderingEngine::CSSCLASS_CONCRETE
),
// choiceInteraction-6
array(
self::samplesDir() . 'ims/items/2_2/orkney2.xml',
self::samplesDir() . 'rendering/goldilocks/rendered/choiceInteraction-6.html',
GoldilocksRenderingEngine::CONTEXT_STATIC,
GoldilocksRenderingEngine::XMLBASE_IGNORE,
GoldilocksRenderingEngine::STYLESHEET_INLINE,
GoldilocksRenderingEngine::CSSCLASS_CONCRETE
),
// associateInteraction-0
array(
self::samplesDir() . 'ims/items/2_2/associate.xml',
Expand Down Expand Up @@ -150,10 +168,82 @@ public function testRenderingProvider()
GoldilocksRenderingEngine::STYLESHEET_INLINE,
GoldilocksRenderingEngine::CSSCLASS_CONCRETE
),
// math-0
array(
self::samplesDir() . 'ims/items/2_2/math.xml',
self::samplesDir() . 'rendering/goldilocks/rendered/math-0.html',
GoldilocksRenderingEngine::CONTEXT_STATIC,
GoldilocksRenderingEngine::XMLBASE_IGNORE,
GoldilocksRenderingEngine::STYLESHEET_INLINE,
GoldilocksRenderingEngine::CSSCLASS_CONCRETE
),
// nestedObject-0
array(
self::samplesDir() . 'ims/items/2_2/nested_object.xml',
self::samplesDir() . 'rendering/goldilocks/rendered/nestedObject-0.html',
GoldilocksRenderingEngine::CONTEXT_STATIC,
GoldilocksRenderingEngine::XMLBASE_IGNORE,
GoldilocksRenderingEngine::STYLESHEET_INLINE,
GoldilocksRenderingEngine::CSSCLASS_CONCRETE
),
// orderInteraction-0
array(
self::samplesDir() . 'ims/items/2_2/order.xml',
self::samplesDir() . 'rendering/goldilocks/rendered/orderInteraction-0.html',
GoldilocksRenderingEngine::CONTEXT_STATIC,
GoldilocksRenderingEngine::XMLBASE_IGNORE,
GoldilocksRenderingEngine::STYLESHEET_INLINE,
GoldilocksRenderingEngine::CSSCLASS_CONCRETE
),
// orderInteraction-1
array(
self::samplesDir() . 'ims/items/2_2/order_rtl.xml',
self::samplesDir() . 'rendering/goldilocks/rendered/orderInteraction-1.html',
GoldilocksRenderingEngine::CONTEXT_STATIC,
GoldilocksRenderingEngine::XMLBASE_IGNORE,
GoldilocksRenderingEngine::STYLESHEET_INLINE,
GoldilocksRenderingEngine::CSSCLASS_CONCRETE
),
// positionObjectInteraction-0
array(
self::samplesDir() . 'ims/items/2_2/position_object.xml',
self::samplesDir() . 'rendering/goldilocks/rendered/positionObjectInteraction-0.html',
GoldilocksRenderingEngine::CONTEXT_STATIC,
GoldilocksRenderingEngine::XMLBASE_IGNORE,
GoldilocksRenderingEngine::STYLESHEET_INLINE,
GoldilocksRenderingEngine::CSSCLASS_CONCRETE
),
// selectPointInteraction-0
array(
self::samplesDir() . 'ims/items/2_2/select_point.xml',
self::samplesDir() . 'rendering/goldilocks/rendered/selectPointInteraction-0.html',
GoldilocksRenderingEngine::CONTEXT_STATIC,
GoldilocksRenderingEngine::XMLBASE_IGNORE,
GoldilocksRenderingEngine::STYLESHEET_INLINE,
GoldilocksRenderingEngine::CSSCLASS_CONCRETE
),
// sliderInteraction-0
array(
self::samplesDir() . 'ims/items/2_2/slider.xml',
self::samplesDir() . 'rendering/goldilocks/rendered/sliderInteraction-0.html',
GoldilocksRenderingEngine::CONTEXT_STATIC,
GoldilocksRenderingEngine::XMLBASE_IGNORE,
GoldilocksRenderingEngine::STYLESHEET_INLINE,
GoldilocksRenderingEngine::CSSCLASS_CONCRETE
),
// textEntryInteraction-0
array(
self::samplesDir() . 'ims/items/2_2/text_entry.xml',
self::samplesDir() . 'rendering/goldilocks/rendered/textEntryInteraction-0.html',
GoldilocksRenderingEngine::CONTEXT_STATIC,
GoldilocksRenderingEngine::XMLBASE_IGNORE,
GoldilocksRenderingEngine::STYLESHEET_INLINE,
GoldilocksRenderingEngine::CSSCLASS_CONCRETE
),
);
}

public function testGenerate() {
/*public function testGenerate() {
$renderingMode = GoldilocksRenderingEngine::CONTEXT_STATIC;
$xmlBasePolicy = GoldilocksRenderingEngine::XMLBASE_IGNORE;
$stylesheetPolicy = GoldilocksRenderingEngine::STYLESHEET_INLINE;
Expand All @@ -169,10 +259,10 @@ public function testGenerate() {
$engine->setCssClassPolicy($cssClassPolicy);
$doc = new XmlDocument();
$doc->load(self::samplesDir() . 'ims/items/2_2/match.xml');
$doc->load(self::samplesDir() . 'ims/items/2_2/text_entry.xml');
$rendered = $engine->render($doc->getDocumentComponent());
$strRendered = $rendered->saveXML($rendered->documentElement);
file_put_contents(self::samplesDir() . 'rendering/goldilocks/rendered/matchInteraction-0.html', $strRendered . "\n");
}
file_put_contents(self::samplesDir() . 'rendering/goldilocks/rendered/textEntryInteraction-0.html', $strRendered . "\n");
}*/
}
16 changes: 16 additions & 0 deletions test/qtismtest/runtime/tests/AssessmentTestSessionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use qtism\data\NavigationMode;
use qtism\data\SubmissionMode;
use qtism\data\storage\xml\XmlCompactDocument;
use qtism\data\storage\xml\XmlDocument;
use qtism\data\state\VariableDeclaration;
use qtism\data\state\OutcomeDeclarationCollection;
use qtism\runtime\common\VariableIdentifier;
Expand Down Expand Up @@ -1443,6 +1444,7 @@ public function testGetRouteCountAllWithResponseDeclaration() {
$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() {
Expand All @@ -1452,6 +1454,20 @@ public function testGetRouteCountMissingResponseDeclaration() {
$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(new FileSystemFileManager());
$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));
}

public function testVisitedTestPartsLinear1TestPart() {
Expand Down
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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<div data-identifier="orkney1" data-title="Orkney 1" data-adaptive="false" data-time-dependent="false" class="qti-assessmentItem"><link rel="stylesheet" href="shared/orkney.css" type="text/css" media="screen"/><div class="qti-itemBody"><div class="qti-div rightpane"><object data="shared/orkney.html" type="text/html" class="qti-object"></object></div><div class="qti-div leftpane"><p class="qti-p">Read the text about the Orkney Islands and then decide if the following sentence is
correct or incorrect.</p><div data-response-identifier="RESPONSE" data-shuffle="false" data-max-choices="1" data-min-choices="0" data-orientation="vertical" class="qti-choiceInteraction qti-vertical"><p class="qti-prompt">Some of the islands are home to animals rather than people.</p><ul><li data-identifier="T" data-fixed="false" class="qti-simpleChoice">Correct</li><li data-identifier="F" data-fixed="false" class="qti-simpleChoice">Incorrect</li></ul></div></div></div></div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<div data-identifier="orkney2" data-title="Orkney 2" data-adaptive="false" data-time-dependent="false" class="qti-assessmentItem"><link rel="stylesheet" href="shared/orkney.css" type="text/css" media="screen"/><div class="qti-itemBody"><div class="qti-div rightpane"><object data="shared/orkney.html" type="text/html" class="qti-object"></object></div><div class="qti-div leftpane"><p class="qti-p">Read the text about the Orkney Islands and then decide if the following sentence is
correct or incorrect.</p><div data-response-identifier="RESPONSE" data-shuffle="false" data-max-choices="1" data-min-choices="0" data-orientation="vertical" class="qti-choiceInteraction qti-vertical"><p class="qti-prompt">You can fly direct from London Heathrow to Kirkwall.</p><ul><li data-identifier="T" data-fixed="false" class="qti-simpleChoice">Correct</li><li data-identifier="F" data-fixed="false" class="qti-simpleChoice">Incorrect</li></ul></div></div></div></div>
Loading

0 comments on commit 6dada5a

Please sign in to comment.