From 096a523b97c506929f7fc9e1ddacc231e3f21527 Mon Sep 17 00:00:00 2001 From: Vitalii Shtykhno Date: Fri, 9 Dec 2022 15:51:53 +0100 Subject: [PATCH 1/4] feat: allow to use dir attr in itemBody element --- src/qtism/data/content/ItemBody.php | 2 ++ src/qtism/data/storage/xml/marshalling/Marshaller.php | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/qtism/data/content/ItemBody.php b/src/qtism/data/content/ItemBody.php index ef009d1be..a98cad91b 100644 --- a/src/qtism/data/content/ItemBody.php +++ b/src/qtism/data/content/ItemBody.php @@ -47,6 +47,8 @@ */ class ItemBody extends BodyElement { + public const QTI_CLASS_NAME = 'itemBody'; + /** * The blocks composing the itemBody. * diff --git a/src/qtism/data/storage/xml/marshalling/Marshaller.php b/src/qtism/data/storage/xml/marshalling/Marshaller.php index a16185013..d13469644 100644 --- a/src/qtism/data/storage/xml/marshalling/Marshaller.php +++ b/src/qtism/data/storage/xml/marshalling/Marshaller.php @@ -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; @@ -120,6 +121,7 @@ abstract class Marshaller 'infoControl', 'inlineChoice', 'inlineChoiceInteraction', + ItemBody::QTI_CLASS_NAME, 'kbd', 'label', 'li', From bff0ffdd43a754b3bd29ae8d95d7cfc2e3429c25 Mon Sep 17 00:00:00 2001 From: Vitalii Shtykhno Date: Mon, 12 Dec 2022 14:46:49 +0100 Subject: [PATCH 2/4] test: add test for use dir attribute in item body --- .../custom/items/item_body_dir_attr.xml | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 test/samples/custom/items/item_body_dir_attr.xml diff --git a/test/samples/custom/items/item_body_dir_attr.xml b/test/samples/custom/items/item_body_dir_attr.xml new file mode 100644 index 000000000..33ea439fe --- /dev/null +++ b/test/samples/custom/items/item_body_dir_attr.xml @@ -0,0 +1,26 @@ + + + + + + 0 + + + +
+
+ + 東北 + 北陸 + 甲信越 + +
+
+
+ +
\ No newline at end of file From 02ae25c259081c8e138483aa61216fe4db7f2263 Mon Sep 17 00:00:00 2001 From: Vitalii Shtykhno Date: Tue, 13 Dec 2022 09:39:02 +0100 Subject: [PATCH 3/4] test: validate that dir param present --- .../xml/XmlAssessmentTestDocumentTest.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/qtismtest/data/storage/xml/XmlAssessmentTestDocumentTest.php b/test/qtismtest/data/storage/xml/XmlAssessmentTestDocumentTest.php index fb0d56ad8..a47691d38 100644 --- a/test/qtismtest/data/storage/xml/XmlAssessmentTestDocumentTest.php +++ b/test/qtismtest/data/storage/xml/XmlAssessmentTestDocumentTest.php @@ -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; @@ -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 @@ -160,6 +162,8 @@ public function testIncludeAssessmentSectionRefsInTestParts($file, $filesystem) $this::assertEquals('../sections/../sections/../items/question3.xml', $assessmentItemRefs['Q03']->getHref()); } + + /** * @return array */ @@ -234,6 +238,21 @@ 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 From 5dbb94f59677e073fdfc15348eef24ea85ee2b6a Mon Sep 17 00:00:00 2001 From: Vitalii Shtykhno Date: Thu, 15 Dec 2022 09:48:25 +0100 Subject: [PATCH 4/4] fix: remove extra spaces --- .../data/storage/xml/XmlAssessmentTestDocumentTest.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/test/qtismtest/data/storage/xml/XmlAssessmentTestDocumentTest.php b/test/qtismtest/data/storage/xml/XmlAssessmentTestDocumentTest.php index a47691d38..59aace8f2 100644 --- a/test/qtismtest/data/storage/xml/XmlAssessmentTestDocumentTest.php +++ b/test/qtismtest/data/storage/xml/XmlAssessmentTestDocumentTest.php @@ -162,8 +162,6 @@ public function testIncludeAssessmentSectionRefsInTestParts($file, $filesystem) $this::assertEquals('../sections/../sections/../items/question3.xml', $assessmentItemRefs['Q03']->getHref()); } - - /** * @return array */ @@ -243,7 +241,6 @@ 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];