Skip to content

Commit

Permalink
chore: add unit test to cover pre-condition on test part and section
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielfs7 committed Sep 26, 2023
1 parent 1bd8c24 commit 24c9b35
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,28 @@ public function testKillerTestEpicWin(): void

$this::assertFalse($testSession->isRunning());
}

public function testSectionPreConditionOnLinearTestWorks(): void
{
$testSession = self::instantiate(self::samplesDir() . 'custom/runtime/preconditions/preconditions_on_section_prevails_linear.xml');
$testSession->beginTestSession();
$testSession->beginAttempt();
$testSession->moveNext();

// Q02 is skipped due precondition
$this::assertSame($testSession->getRoute()->current()->getAssessmentItemRef()->getIdentifier(), 'Q03');
}

public function testTestPartPreConditionOnLinearTestWorks(): void
{
$testSession = self::instantiate(self::samplesDir() . 'custom/runtime/preconditions/preconditions_on_test_part_prevails_linear.xml');
$testSession->beginTestSession();
$testSession->beginAttempt();
$testSession->moveNext();

// P02, S02, Q02 is skipped due precondition
$this::assertSame($testSession->getRoute()->current()->getTestPart()->getIdentifier(), 'P03');
$this::assertSame($testSession->getRoute()->current()->getAssessmentSection()->getIdentifier(), 'S03');
$this::assertSame($testSession->getRoute()->current()->getAssessmentItemRef()->getIdentifier(), 'Q03');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?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_v2p1.xsd"
identifier="preconditions" title="Preconditions">
<testPart identifier="P01" navigationMode="linear" submissionMode="individual">
<assessmentSection identifier="S01" title="Section1" visible="true">
<assessmentItemRef identifier="Q01" href="./Q01.xml" timeDependent="false"/>
</assessmentSection>
<assessmentSection identifier="S02" title="Section2" visible="true">
<preCondition>
<baseValue baseType="boolean">false</baseValue>
</preCondition>
<assessmentItemRef identifier="Q02" href="./Q02.xml" timeDependent="false"/>
</assessmentSection>
<assessmentSection identifier="S03" title="Section3" visible="true">
<assessmentItemRef identifier="Q03" href="./Q03.xml" timeDependent="false"/>
</assessmentSection>
</testPart>
</assessmentTest>
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_v2p1.xsd"
identifier="preconditions" title="Preconditions">
<testPart identifier="P01" navigationMode="linear" submissionMode="individual">
<assessmentSection identifier="S01" title="Section1" visible="true">
<assessmentItemRef identifier="Q01" href="./Q01.xml" timeDependent="false"/>
</assessmentSection>
</testPart>
<testPart identifier="P02" navigationMode="linear" submissionMode="individual">
<preCondition>
<baseValue baseType="boolean">false</baseValue>
</preCondition>
<assessmentSection identifier="S02" title="Section2" visible="true">
<assessmentItemRef identifier="Q02" href="./Q02.xml" timeDependent="false"/>
</assessmentSection>
</testPart>
<testPart identifier="P03" navigationMode="linear" submissionMode="individual">
<assessmentSection identifier="S03" title="Section3" visible="true">
<assessmentItemRef identifier="Q03" href="./Q03.xml" timeDependent="false"/>
</assessmentSection>
</testPart>
</assessmentTest>

0 comments on commit 24c9b35

Please sign in to comment.