Skip to content

Commit

Permalink
Merge pull request #350 from oat-sa/feat/PISA25-212/allow-dir-attr
Browse files Browse the repository at this point in the history
feat: allow to use dir attr in itemBody element
  • Loading branch information
wazelin authored Dec 15, 2022
2 parents 3275266 + 5dbb94f commit 360798c
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/qtism/data/content/ItemBody.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
*/
class ItemBody extends BodyElement
{
public const QTI_CLASS_NAME = 'itemBody';

/**
* The blocks composing the itemBody.
*
Expand Down
2 changes: 2 additions & 0 deletions src/qtism/data/storage/xml/marshalling/Marshaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
use qtism\data\content\Direction;
use qtism\data\content\enums\AriaLive;
use qtism\data\content\enums\AriaOrientation;
use qtism\data\content\ItemBody;
use qtism\data\QtiComponent;
use qtism\data\storage\xml\Utils as XmlUtils;
use qtism\data\storage\xml\versions\QtiVersion;
Expand Down Expand Up @@ -120,6 +121,7 @@ abstract class Marshaller
'infoControl',
'inlineChoice',
'inlineChoiceInteraction',
ItemBody::QTI_CLASS_NAME,
'kbd',
'label',
'li',
Expand Down
16 changes: 16 additions & 0 deletions test/qtismtest/data/storage/xml/XmlAssessmentTestDocumentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace qtismtest\data\storage\xml;

use qtism\data\content\Direction;
use qtism\data\storage\xml\XmlDocument;
use qtism\data\storage\xml\XmlStorageException;
use qtismtest\QtiSmTestCase;
Expand All @@ -11,6 +12,7 @@
use qtism\data\TestPart;
use qtism\data\AssessmentTest;
use qtism\data\storage\xml\LibXmlErrorCollection;
use qtism\data\content\ItemBody;

/**
* Class XmlAssessmentTestDocumentTest
Expand Down Expand Up @@ -234,6 +236,20 @@ public function includeAssessmentSectionRefsMixedProvider()
];
}

public function testParseItemBodyWithDirAttr(): void
{
$doc = new XmlDocument();
$doc->load(self::samplesDir() . 'custom/items/item_body_dir_attr.xml', true);

/** @var ItemBody $itemBody */
$itemBody = $doc->getDocumentComponent()->getComponentsByClassName('itemBody')[0];

$this::assertTrue(isset($itemBody));
$this::assertNotEmpty($itemBody->getDir());
$this::assertEquals(Direction::RTL, $itemBody->getDir());

}

/**
* @param $uri
* @return string
Expand Down
26 changes: 26 additions & 0 deletions test/samples/custom/items/item_body_dir_attr.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<assessmentItem xmlns="http://www.imsglobal.org/xsd/imsqti_v2p2" xmlns:m="http://www.w3.org/1998/Math/MathML"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.imsglobal.org/xsd/imsqti_v2p2 http://www.imsglobal.org/xsd/qti/qtiv2p2/imsqti_v2p2.xsd"
identifier="item_body_dir_attr" title="RTL Examples 5" label="RTL Hebrew" xml:lang="he-IL"
adaptive="false" timeDependent="false" toolName="TAO" toolVersion="2022.11">
<responseDeclaration identifier="RESPONSE" cardinality="multiple" baseType="identifier"/>
<outcomeDeclaration identifier="SCORE" cardinality="single" baseType="float" normalMaximum="0"/>
<outcomeDeclaration identifier="MAXSCORE" cardinality="single" baseType="float">
<defaultValue>
<value>0</value>
</defaultValue>
</outcomeDeclaration>
<itemBody dir="rtl">
<div class="grid-row">
<div class="col-12">
<choiceInteraction responseIdentifier="RESPONSE" shuffle="false" maxChoices="0" minChoices="0"
orientation="vertical">
<simpleChoice identifier="choice_1" fixed="false" showHide="show">東北</simpleChoice>
<simpleChoice identifier="choice_2" fixed="false" showHide="show">北陸</simpleChoice>
<simpleChoice identifier="choice_3" fixed="false" showHide="show">甲信越</simpleChoice>
</choiceInteraction>
</div>
</div>
</itemBody>
<responseProcessing template="http://www.imsglobal.org/question/qti_v2p2/rptemplates/match_correct"/>
</assessmentItem>

0 comments on commit 360798c

Please sign in to comment.