From dfb20e0d0de5706dee655bfc99b227943567b009 Mon Sep 17 00:00:00 2001 From: Vitalii Shtykhno Date: Thu, 22 Sep 2022 14:58:50 +0200 Subject: [PATCH 01/13] feat: redister new html5 elements: Ruby, Rb, Rt, Rp --- qtism/data/content/xhtml/html5/Rb.php | 81 ++++++++++++ qtism/data/content/xhtml/html5/Rp.php | 81 ++++++++++++ qtism/data/content/xhtml/html5/Rt.php | 81 ++++++++++++ qtism/data/content/xhtml/html5/Ruby.php | 81 ++++++++++++ .../xml/marshalling/ContentMarshaller.php | 20 +++ .../xml/marshalling/Html5RbMarshaller.php | 83 +++++++++++++ .../xml/marshalling/Html5RpMarshaller.php | 83 +++++++++++++ .../xml/marshalling/Html5RtMarshaller.php | 83 +++++++++++++ .../xml/marshalling/Html5RubyMarshaller.php | 84 +++++++++++++ .../marshalling/Qti22MarshallerFactory.php | 13 +- .../rendering/markup/xhtml/RbRenderer.php | 46 +++++++ .../rendering/markup/xhtml/RpRenderer.php | 46 +++++++ .../rendering/markup/xhtml/RtRenderer.php | 46 +++++++ .../rendering/markup/xhtml/RubyRenderer.php | 46 +++++++ .../markup/xhtml/XhtmlRenderingEngine.php | 117 ++++++++++-------- 15 files changed, 938 insertions(+), 53 deletions(-) create mode 100644 qtism/data/content/xhtml/html5/Rb.php create mode 100644 qtism/data/content/xhtml/html5/Rp.php create mode 100644 qtism/data/content/xhtml/html5/Rt.php create mode 100644 qtism/data/content/xhtml/html5/Ruby.php create mode 100644 qtism/data/storage/xml/marshalling/Html5RbMarshaller.php create mode 100644 qtism/data/storage/xml/marshalling/Html5RpMarshaller.php create mode 100644 qtism/data/storage/xml/marshalling/Html5RtMarshaller.php create mode 100644 qtism/data/storage/xml/marshalling/Html5RubyMarshaller.php create mode 100644 qtism/runtime/rendering/markup/xhtml/RbRenderer.php create mode 100644 qtism/runtime/rendering/markup/xhtml/RpRenderer.php create mode 100644 qtism/runtime/rendering/markup/xhtml/RtRenderer.php create mode 100644 qtism/runtime/rendering/markup/xhtml/RubyRenderer.php diff --git a/qtism/data/content/xhtml/html5/Rb.php b/qtism/data/content/xhtml/html5/Rb.php new file mode 100644 index 000000000..d24397ec0 --- /dev/null +++ b/qtism/data/content/xhtml/html5/Rb.php @@ -0,0 +1,81 @@ +setContent(new InlineCollection()); + } + + public function getQtiClassName() + { + return self::QTI_CLASS_NAME; + } + + public function getComponents() + { + return $this->getContent(); + } + + /** + * Set the collection of Flow objects composing the Div. + * + * @param InlineCollection $content A collection of Flow objects. + */ + public function setContent(InlineCollection $content) + { + $this->content = $content; + } + + /** + * Get the collection of Flow objects composing the Div. + * + * @return InlineCollection + */ + public function getContent() + { + return $this->content; + } +} diff --git a/qtism/data/content/xhtml/html5/Rp.php b/qtism/data/content/xhtml/html5/Rp.php new file mode 100644 index 000000000..06e4b5220 --- /dev/null +++ b/qtism/data/content/xhtml/html5/Rp.php @@ -0,0 +1,81 @@ +setContent(new InlineCollection()); + } + + public function getQtiClassName() + { + return self::QTI_CLASS_NAME; + } + + public function getComponents() + { + return $this->getContent(); + } + + /** + * Set the collection of Flow objects composing the Div. + * + * @param InlineCollection $content A collection of Flow objects. + */ + public function setContent(InlineCollection $content) + { + $this->content = $content; + } + + /** + * Get the collection of Flow objects composing the Div. + * + * @return InlineCollection + */ + public function getContent() + { + return $this->content; + } +} diff --git a/qtism/data/content/xhtml/html5/Rt.php b/qtism/data/content/xhtml/html5/Rt.php new file mode 100644 index 000000000..58772cfed --- /dev/null +++ b/qtism/data/content/xhtml/html5/Rt.php @@ -0,0 +1,81 @@ +setContent(new InlineCollection()); + } + + public function getQtiClassName() + { + return self::QTI_CLASS_NAME; + } + + public function getComponents() + { + return $this->getContent(); + } + + /** + * Set the collection of Flow objects composing the Div. + * + * @param InlineCollection $content A collection of Flow objects. + */ + public function setContent(InlineCollection $content) + { + $this->content = $content; + } + + /** + * Get the collection of Flow objects composing the Div. + * + * @return InlineCollection + */ + public function getContent() + { + return $this->content; + } +} diff --git a/qtism/data/content/xhtml/html5/Ruby.php b/qtism/data/content/xhtml/html5/Ruby.php new file mode 100644 index 000000000..8e18e605b --- /dev/null +++ b/qtism/data/content/xhtml/html5/Ruby.php @@ -0,0 +1,81 @@ +setContent(new FlowCollection()); + } + + public function getQtiClassName() + { + return self::QTI_CLASS_NAME; + } + + public function getComponents() + { + return $this->getContent(); + } + + /** + * Set the collection of Flow objects composing the Div. + * + * @param FlowCollection $content A collection of Flow objects. + */ + public function setContent(FlowCollection $content) + { + $this->content = $content; + } + + /** + * Get the collection of Flow objects composing the Div. + * + * @return FlowCollection + */ + public function getContent() + { + return $this->content; + } +} diff --git a/qtism/data/storage/xml/marshalling/ContentMarshaller.php b/qtism/data/storage/xml/marshalling/ContentMarshaller.php index 70143f41e..9e8c1b507 100644 --- a/qtism/data/storage/xml/marshalling/ContentMarshaller.php +++ b/qtism/data/storage/xml/marshalling/ContentMarshaller.php @@ -54,6 +54,10 @@ use qtism\data\content\TemplateInline; use qtism\data\content\xhtml\html5\Figcaption; use qtism\data\content\xhtml\html5\Figure; +use qtism\data\content\xhtml\html5\Rb; +use qtism\data\content\xhtml\html5\Rp; +use qtism\data\content\xhtml\html5\Rt; +use qtism\data\content\xhtml\html5\Ruby; use qtism\data\content\xhtml\lists\Dl; use qtism\data\content\xhtml\lists\DlElement; use qtism\data\content\xhtml\lists\Li; @@ -141,6 +145,10 @@ public function __construct($version) 'i', 'kbd', 'q', + Ruby::QTI_CLASS_NAME, + Rb::QTI_CLASS_NAME, + Rp::QTI_CLASS_NAME, + Rt::QTI_CLASS_NAME, 'samp', 'small', 'span', @@ -292,6 +300,14 @@ protected function getChildrenComponents(QtiComponent $component) return $component->getContent()->getArrayCopy(); } elseif ($component instanceof Figcaption) { return $component->getContent()->getArrayCopy(); + } elseif ($component instanceof Ruby) { + return $component->getContent()->getArrayCopy(); + } elseif ($component instanceof Rb) { + return $component->getContent()->getArrayCopy(); + } elseif ($component instanceof Rp) { + return $component->getContent()->getArrayCopy(); + } elseif ($component instanceof Rt) { + return $component->getContent()->getArrayCopy(); } } @@ -338,6 +354,10 @@ protected function getChildrenElements(DOMElement $element) return self::getChildElements($element); } elseif ($localName === 'simpleMatchSet') { return $this->getChildElementsByTagName($element, 'simpleAssociableChoice'); + } elseif ($localName === Figure::QTI_CLASS_NAME_FIGURE) { + return $this->getChildElementsByTagName($element, [Figcaption::QTI_CLASS_NAME_FIGCAPTION, Img::QTI_CLASS_NAME_IMG]); + } elseif ($localName === Ruby::QTI_CLASS_NAME) { + return $this->getChildElementsByTagName($element, [Rb::QTI_CLASS_NAME, Rp::QTI_CLASS_NAME, Rt::QTI_CLASS_NAME]); } elseif ($localName === 'gapImg') { return $this->getChildElementsByTagName($element, 'object'); } elseif ($element->localName === 'infoControl') { diff --git a/qtism/data/storage/xml/marshalling/Html5RbMarshaller.php b/qtism/data/storage/xml/marshalling/Html5RbMarshaller.php new file mode 100644 index 000000000..c1e10b300 --- /dev/null +++ b/qtism/data/storage/xml/marshalling/Html5RbMarshaller.php @@ -0,0 +1,83 @@ +hasId()) { + $this->setDOMElementAttribute($element, 'id', $component->getId()); + } + + if ($component->hasClass()) { + $this->setDOMElementAttribute($element, 'class', $component->getClass()); + } + + return $component; + } + + /** + * @param QtiComponent $component + * @param array $elements + * @return DOMElement + */ + protected function marshallChildrenKnown(QtiComponent $component, array $elements) + { + $element = parent::marshallChildrenKnown($component, $elements); + + if ($component->hasId()) { + $this->setDOMElementAttribute($element, 'id', $component->getId()); + } + + if ($component->hasClass()) { + $this->setDOMElementAttribute($element, 'class', $component->getClass()); + } + + return $element; + } + + protected static function getContentCollectionClassName() + { + return InlineCollection::class; + } +} diff --git a/qtism/data/storage/xml/marshalling/Html5RpMarshaller.php b/qtism/data/storage/xml/marshalling/Html5RpMarshaller.php new file mode 100644 index 000000000..9bb6e80ec --- /dev/null +++ b/qtism/data/storage/xml/marshalling/Html5RpMarshaller.php @@ -0,0 +1,83 @@ +hasId()) { + $this->setDOMElementAttribute($element, 'id', $component->getId()); + } + + if ($component->hasClass()) { + $this->setDOMElementAttribute($element, 'class', $component->getClass()); + } + + return $component; + } + + /** + * @param QtiComponent $component + * @param array $elements + * @return DOMElement + */ + protected function marshallChildrenKnown(QtiComponent $component, array $elements) + { + $element = parent::marshallChildrenKnown($component, $elements); + + if ($component->hasId()) { + $this->setDOMElementAttribute($element, 'id', $component->getId()); + } + + if ($component->hasClass()) { + $this->setDOMElementAttribute($element, 'class', $component->getClass()); + } + + return $element; + } + + protected static function getContentCollectionClassName() + { + return InlineCollection::class; + } +} diff --git a/qtism/data/storage/xml/marshalling/Html5RtMarshaller.php b/qtism/data/storage/xml/marshalling/Html5RtMarshaller.php new file mode 100644 index 000000000..19b124724 --- /dev/null +++ b/qtism/data/storage/xml/marshalling/Html5RtMarshaller.php @@ -0,0 +1,83 @@ +hasId()) { + $this->setDOMElementAttribute($element, 'id', $component->getId()); + } + + if ($component->hasClass()) { + $this->setDOMElementAttribute($element, 'class', $component->getClass()); + } + + return $component; + } + + /** + * @param QtiComponent $component + * @param array $elements + * @return DOMElement + */ + protected function marshallChildrenKnown(QtiComponent $component, array $elements) + { + $element = parent::marshallChildrenKnown($component, $elements); + + if ($component->hasId()) { + $this->setDOMElementAttribute($element, 'id', $component->getId()); + } + + if ($component->hasClass()) { + $this->setDOMElementAttribute($element, 'class', $component->getClass()); + } + + return $element; + } + + protected static function getContentCollectionClassName() + { + return InlineCollection::class; + } +} diff --git a/qtism/data/storage/xml/marshalling/Html5RubyMarshaller.php b/qtism/data/storage/xml/marshalling/Html5RubyMarshaller.php new file mode 100644 index 000000000..657aaa6f7 --- /dev/null +++ b/qtism/data/storage/xml/marshalling/Html5RubyMarshaller.php @@ -0,0 +1,84 @@ +hasId()) { + $this->setDOMElementAttribute($element, 'id', $component->getId()); + } + + if ($component->hasClass()) { + $this->setDOMElementAttribute($element, 'class', $component->getClass()); + } + + return $component; + } + + /** + * @param QtiComponent $component + * @param array $elements + * @return DOMElement + */ + protected function marshallChildrenKnown(QtiComponent $component, array $elements) + { + $element = parent::marshallChildrenKnown($component, $elements); + + if ($component->hasId()) { + $this->setDOMElementAttribute($element, 'id', $component->getId()); + } + + if ($component->hasClass()) { + $this->setDOMElementAttribute($element, 'class', $component->getClass()); + } + + return $element; + } + + protected static function getContentCollectionClassName() + { + return FlowCollection::class; + } +} diff --git a/qtism/data/storage/xml/marshalling/Qti22MarshallerFactory.php b/qtism/data/storage/xml/marshalling/Qti22MarshallerFactory.php index 6281e1c13..e393817b3 100644 --- a/qtism/data/storage/xml/marshalling/Qti22MarshallerFactory.php +++ b/qtism/data/storage/xml/marshalling/Qti22MarshallerFactory.php @@ -26,6 +26,10 @@ use qtism\common\utils\Reflection; use qtism\data\content\xhtml\html5\Figcaption; use qtism\data\content\xhtml\html5\Figure; +use qtism\data\content\xhtml\html5\Rb; +use qtism\data\content\xhtml\html5\Rp; +use qtism\data\content\xhtml\html5\Rt; +use qtism\data\content\xhtml\html5\Ruby; use ReflectionClass; /** @@ -40,8 +44,13 @@ class Qti22MarshallerFactory extends MarshallerFactory public function __construct() { parent::__construct(); - $this->addMappingEntry(Figure::QTI_CLASS_NAME_FIGURE, Html5ContentMarshaller::class); - $this->addMappingEntry(Figcaption::QTI_CLASS_NAME_FIGCAPTION, Html5ContentMarshaller::class); + $this->addMappingEntry('bdo', SimpleInlineMarshaller::class); + $this->addMappingEntry(Figure::QTI_CLASS_NAME_FIGURE, Html5FigureMarshaller::class); + $this->addMappingEntry(Figcaption::QTI_CLASS_NAME_FIGCAPTION, Html5FigcaptionMarshaller::class); + $this->addMappingEntry(Ruby::QTI_CLASS_NAME, Html5RubyMarshaller::class); + $this->addMappingEntry(Rb::QTI_CLASS_NAME, Html5RbMarshaller::class); + $this->addMappingEntry(Rp::QTI_CLASS_NAME, Html5RpMarshaller::class); + $this->addMappingEntry(Rt::QTI_CLASS_NAME, Html5RtMarshaller::class); } /** diff --git a/qtism/runtime/rendering/markup/xhtml/RbRenderer.php b/qtism/runtime/rendering/markup/xhtml/RbRenderer.php new file mode 100644 index 000000000..ed7bf2d0f --- /dev/null +++ b/qtism/runtime/rendering/markup/xhtml/RbRenderer.php @@ -0,0 +1,46 @@ +hasId()) { + $fragment->firstChild->setAttribute('id', $component->getId()); + } + if ($component->hasClass()) { + $fragment->firstChild->setAttribute('class', $component->getClass()); + } + } +} diff --git a/qtism/runtime/rendering/markup/xhtml/RpRenderer.php b/qtism/runtime/rendering/markup/xhtml/RpRenderer.php new file mode 100644 index 000000000..e32105115 --- /dev/null +++ b/qtism/runtime/rendering/markup/xhtml/RpRenderer.php @@ -0,0 +1,46 @@ +hasId()) { + $fragment->firstChild->setAttribute('id', $component->getId()); + } + if ($component->hasClass()) { + $fragment->firstChild->setAttribute('class', $component->getClass()); + } + } +} diff --git a/qtism/runtime/rendering/markup/xhtml/RtRenderer.php b/qtism/runtime/rendering/markup/xhtml/RtRenderer.php new file mode 100644 index 000000000..9ceaa1156 --- /dev/null +++ b/qtism/runtime/rendering/markup/xhtml/RtRenderer.php @@ -0,0 +1,46 @@ +hasId()) { + $fragment->firstChild->setAttribute('id', $component->getId()); + } + if ($component->hasClass()) { + $fragment->firstChild->setAttribute('class', $component->getClass()); + } + } +} diff --git a/qtism/runtime/rendering/markup/xhtml/RubyRenderer.php b/qtism/runtime/rendering/markup/xhtml/RubyRenderer.php new file mode 100644 index 000000000..f480855c3 --- /dev/null +++ b/qtism/runtime/rendering/markup/xhtml/RubyRenderer.php @@ -0,0 +1,46 @@ +hasId()) { + $fragment->firstChild->setAttribute('id', $component->getId()); + } + if ($component->hasClass()) { + $fragment->firstChild->setAttribute('class', $component->getClass()); + } + } +} diff --git a/qtism/runtime/rendering/markup/xhtml/XhtmlRenderingEngine.php b/qtism/runtime/rendering/markup/xhtml/XhtmlRenderingEngine.php index 1af27086e..d0637d411 100644 --- a/qtism/runtime/rendering/markup/xhtml/XhtmlRenderingEngine.php +++ b/qtism/runtime/rendering/markup/xhtml/XhtmlRenderingEngine.php @@ -23,6 +23,12 @@ namespace qtism\runtime\rendering\markup\xhtml; +use qtism\data\content\xhtml\html5\Figcaption; +use qtism\data\content\xhtml\html5\Figure; +use qtism\data\content\xhtml\html5\Rb; +use qtism\data\content\xhtml\html5\Rt; +use qtism\data\content\xhtml\html5\Rp; +use qtism\data\content\xhtml\html5\Ruby; use qtism\runtime\rendering\markup\AbstractMarkupRenderingEngine; /** @@ -55,11 +61,18 @@ public function __construct() $this->registerRenderer('abbr', $bodyElementRenderer); $this->registerRenderer('acronym', $bodyElementRenderer); $this->registerRenderer('address', $bodyElementRenderer); + $this->registerRenderer('b', $bodyElementRenderer); + $this->registerRenderer('bdo', $bodyElementRenderer); + $this->registerRenderer('big', $bodyElementRenderer); $this->registerRenderer('br', $bodyElementRenderer); + $this->registerRenderer('caption', $bodyElementRenderer); $this->registerRenderer('cite', $bodyElementRenderer); $this->registerRenderer('code', $bodyElementRenderer); + $this->registerRenderer('dd', $bodyElementRenderer); $this->registerRenderer('dfn', $bodyElementRenderer); $this->registerRenderer('div', $bodyElementRenderer); + $this->registerRenderer('dl', $bodyElementRenderer); + $this->registerRenderer('dt', $bodyElementRenderer); $this->registerRenderer('em', $bodyElementRenderer); $this->registerRenderer('h1', $bodyElementRenderer); $this->registerRenderer('h2', $bodyElementRenderer); @@ -67,32 +80,26 @@ public function __construct() $this->registerRenderer('h4', $bodyElementRenderer); $this->registerRenderer('h5', $bodyElementRenderer); $this->registerRenderer('h6', $bodyElementRenderer); + $this->registerRenderer('hr', $bodyElementRenderer); + $this->registerRenderer('i', $bodyElementRenderer); $this->registerRenderer('kbd', $bodyElementRenderer); + $this->registerRenderer('li', $bodyElementRenderer); + $this->registerRenderer('ol', $bodyElementRenderer); $this->registerRenderer('p', $bodyElementRenderer); $this->registerRenderer('pre', $bodyElementRenderer); $this->registerRenderer('samp', $bodyElementRenderer); + $this->registerRenderer('small', $bodyElementRenderer); $this->registerRenderer('span', $bodyElementRenderer); $this->registerRenderer('strong', $bodyElementRenderer); - $this->registerRenderer('var', $bodyElementRenderer); - $this->registerRenderer('dl', $bodyElementRenderer); - $this->registerRenderer('dt', $bodyElementRenderer); - $this->registerRenderer('dd', $bodyElementRenderer); - $this->registerRenderer('ol', $bodyElementRenderer); - $this->registerRenderer('ul', $bodyElementRenderer); - $this->registerRenderer('li', $bodyElementRenderer); - $this->registerRenderer('b', $bodyElementRenderer); - $this->registerRenderer('big', $bodyElementRenderer); - $this->registerRenderer('hr', $bodyElementRenderer); - $this->registerRenderer('i', $bodyElementRenderer); - $this->registerRenderer('small', $bodyElementRenderer); $this->registerRenderer('sub', $bodyElementRenderer); $this->registerRenderer('sup', $bodyElementRenderer); - $this->registerRenderer('tt', $bodyElementRenderer); - $this->registerRenderer('caption', $bodyElementRenderer); $this->registerRenderer('tbody', $bodyElementRenderer); $this->registerRenderer('tfoot', $bodyElementRenderer); $this->registerRenderer('thead', $bodyElementRenderer); $this->registerRenderer('tr', $bodyElementRenderer); + $this->registerRenderer('tt', $bodyElementRenderer); + $this->registerRenderer('ul', $bodyElementRenderer); + $this->registerRenderer('var', $bodyElementRenderer); // Both col and components elements can be rendered // by the ColRenderer. @@ -107,55 +114,63 @@ public function __construct() $this->registerRenderer('th', $tableCellRenderer); // Other bindings... - $this->registerRenderer('textRun', new TextRunRenderer()); $this->registerRenderer('a', new ARenderer()); + $this->registerRenderer('assessmentItem', new AssessmentItemRenderer()); + $this->registerRenderer('associableHotspot', new AssociableHotspotRenderer()); + $this->registerRenderer('associateInteraction', new AssociateInteractionRenderer()); $this->registerRenderer('blockquote', new BlockquoteRenderer()); + $this->registerRenderer('choiceInteraction', new ChoiceInteractionRenderer()); + $this->registerRenderer('drawingInteraction', new DrawingInteractionRenderer()); + $this->registerRenderer('endAttemptInteraction', new EndAttemptInteractionRenderer()); + $this->registerRenderer('extendedTextInteraction', new ExtendedTextInteractionRenderer()); + $this->registerRenderer('feedbackBlock', new FeedbackBlockRenderer()); + $this->registerRenderer('feedbackInline', new FeedbackInlineRenderer()); + $this->registerRenderer(Figure::QTI_CLASS_NAME_FIGURE, new FigureRenderer()); + $this->registerRenderer(Figcaption::QTI_CLASS_NAME_FIGCAPTION, new FigcaptionRenderer()); + $this->registerRenderer('gap', new GapRenderer()); + $this->registerRenderer('gapImg', new GapImgRenderer()); + $this->registerRenderer('gapMatchInteraction', new GapMatchInteractionRenderer()); + $this->registerRenderer('gapText', new GapTextRenderer()); + $this->registerRenderer('graphicAssociateInteraction', new GraphicAssociateInteractionRenderer()); + $this->registerRenderer('graphicGapMatchInteraction', new GraphicGapMatchInteractionRenderer()); + $this->registerRenderer('graphicOrderInteraction', new GraphicOrderInteractionRenderer()); + $this->registerRenderer('hotspotChoice', new HotspotChoiceRenderer()); + $this->registerRenderer('hotspotInteraction', new HotspotInteractionRenderer()); + $this->registerRenderer('hottext', new HottextRenderer()); + $this->registerRenderer('hottextInteraction', new HottextInteractionRenderer()); $this->registerRenderer('img', new ImgRenderer()); + $this->registerRenderer('inlineChoice', new InlineChoiceRenderer()); + $this->registerRenderer('inlineChoiceInteraction', new InlineChoiceInteractionRenderer()); + $this->registerRenderer('itemBody', new ItemBodyRenderer()); + $this->registerRenderer('matchInteraction', new MatchInteractionRenderer()); + $this->registerRenderer('mediaInteraction', new MediaInteractionRenderer()); + $this->registerRenderer('modalFeedback', new ModalFeedbackRenderer()); $this->registerRenderer('object', new ObjectRenderer()); + $this->registerRenderer('orderInteraction', new OrderInteractionRenderer()); $this->registerRenderer('param', new ParamRenderer()); - $this->registerRenderer('q', new QRenderer()); - $this->registerRenderer('stylesheet', new StylesheetRenderer()); - $this->registerRenderer('itemBody', new ItemBodyRenderer()); + $this->registerRenderer('positionObjectInteraction', new PositionObjectInteractionRenderer()); + $this->registerRenderer('positionObjectStage', new PositionObjectStageRenderer()); + $this->registerRenderer('printedVariable', new PrintedVariableRenderer()); $this->registerRenderer('prompt', new PromptRenderer()); - $this->registerRenderer('table', new TableRenderer()); + $this->registerRenderer('q', new QRenderer()); + $this->registerRenderer(Ruby::QTI_CLASS_NAME, new RubyRenderer()); + $this->registerRenderer(Rb::QTI_CLASS_NAME, new RbRenderer()); + $this->registerRenderer(Rt::QTI_CLASS_NAME, new RtRenderer()); + $this->registerRenderer(Rp::QTI_CLASS_NAME, new RpRenderer()); $this->registerRenderer('rubricBlock', new RubricBlockRenderer()); - $this->registerRenderer('feedbackInline', new FeedbackInlineRenderer()); - $this->registerRenderer('feedbackBlock', new FeedbackBlockRenderer()); - $this->registerRenderer('modalFeedback', new ModalFeedbackRenderer()); - $this->registerRenderer('choiceInteraction', new ChoiceInteractionRenderer()); - $this->registerRenderer('orderInteraction', new OrderInteractionRenderer()); - $this->registerRenderer('associateInteraction', new AssociateInteractionRenderer()); - $this->registerRenderer('matchInteraction', new MatchInteractionRenderer()); - $this->registerRenderer('gapMatchInteraction', new GapMatchInteractionRenderer()); - $this->registerRenderer('inlineChoiceInteraction', new InlineChoiceInteractionRenderer()); - $this->registerRenderer('textEntryInteraction', new TextEntryInteractionRenderer()); - $this->registerRenderer('extendedTextInteraction', new ExtendedTextInteractionRenderer()); - $this->registerRenderer('hottextInteraction', new HottextInteractionRenderer()); - $this->registerRenderer('hotspotInteraction', new HotspotInteractionRenderer()); $this->registerRenderer('selectPointInteraction', new SelectPointInteractionRenderer()); - $this->registerRenderer('graphicOrderInteraction', new GraphicOrderInteractionRenderer()); - $this->registerRenderer('graphicGapMatchInteraction', new GraphicGapMatchInteractionRenderer()); - $this->registerRenderer('positionObjectInteraction', new PositionObjectInteractionRenderer()); - $this->registerRenderer('sliderInteraction', new SliderInteractionRenderer()); - $this->registerRenderer('mediaInteraction', new MediaInteractionRenderer()); - $this->registerRenderer('drawingInteraction', new DrawingInteractionRenderer()); - $this->registerRenderer('uploadInteraction', new UploadInteractionRenderer()); - $this->registerRenderer('endAttemptInteraction', new EndAttemptInteractionRenderer()); - $this->registerRenderer('simpleChoice', new SimpleChoiceRenderer()); $this->registerRenderer('simpleAssociableChoice', new SimpleAssociableChoiceRenderer()); - $this->registerRenderer('inlineChoice', new InlineChoiceRenderer()); + $this->registerRenderer('simpleChoice', new SimpleChoiceRenderer()); $this->registerRenderer('simpleMatchSet', new SimpleMatchSetRenderer()); - $this->registerRenderer('hottext', new HottextRenderer()); - $this->registerRenderer('gapText', new GapTextRenderer()); - $this->registerRenderer('gapImg', new GapImgRenderer()); - $this->registerRenderer('gap', new GapRenderer()); - $this->registerRenderer('hotspotChoice', new HotspotChoiceRenderer()); - $this->registerRenderer('associableHotspot', new AssociableHotspotRenderer()); - $this->registerRenderer('positionObjectStage', new PositionObjectStageRenderer()); - $this->registerRenderer('assessmentItem', new AssessmentItemRenderer()); - $this->registerRenderer('printedVariable', new PrintedVariableRenderer()); + $this->registerRenderer('sliderInteraction', new SliderInteractionRenderer()); + $this->registerRenderer('stylesheet', new StylesheetRenderer()); + $this->registerRenderer('table', new TableRenderer()); + $this->registerRenderer('textEntryInteraction', new TextEntryInteractionRenderer()); + $this->registerRenderer('textRun', new TextRunRenderer()); + $this->registerRenderer('uploadInteraction', new UploadInteractionRenderer()); // External QTI Components. $this->registerRenderer('math', new MathRenderer()); + $this->registerRenderer('sub', new SsmlSubRenderer(), 'http://www.w3.org/2010/10/synthesis'); } } From d08c0adb5636883ef066dd5f361b27d82c2e9419 Mon Sep 17 00:00:00 2001 From: Vitalii Shtykhno Date: Thu, 22 Sep 2022 15:52:28 +0200 Subject: [PATCH 02/13] test: cover new html5 element: Ruby, Rb, Rt, Rp --- .../data/content/xhtml/html5/RbTest.php | 55 +++++++ .../data/content/xhtml/html5/RpTest.php | 55 +++++++ .../data/content/xhtml/html5/RtTest.php | 55 +++++++ .../data/content/xhtml/html5/RubyTest.php | 55 +++++++ .../xml/marshalling/Html5RbMarshallerTest.php | 133 ++++++++++++++++ .../xml/marshalling/Html5RpMarshallerTest.php | 133 ++++++++++++++++ .../xml/marshalling/Html5RtMarshallerTest.php | 133 ++++++++++++++++ .../marshalling/Html5RubyMarshallerTest.php | 145 ++++++++++++++++++ test/samples/custom/items/2_2/ruby_html5.xml | 49 ++++++ 9 files changed, 813 insertions(+) create mode 100644 test/qtismtest/data/content/xhtml/html5/RbTest.php create mode 100644 test/qtismtest/data/content/xhtml/html5/RpTest.php create mode 100644 test/qtismtest/data/content/xhtml/html5/RtTest.php create mode 100644 test/qtismtest/data/content/xhtml/html5/RubyTest.php create mode 100644 test/qtismtest/data/storage/xml/marshalling/Html5RbMarshallerTest.php create mode 100644 test/qtismtest/data/storage/xml/marshalling/Html5RpMarshallerTest.php create mode 100644 test/qtismtest/data/storage/xml/marshalling/Html5RtMarshallerTest.php create mode 100644 test/qtismtest/data/storage/xml/marshalling/Html5RubyMarshallerTest.php create mode 100644 test/samples/custom/items/2_2/ruby_html5.xml diff --git a/test/qtismtest/data/content/xhtml/html5/RbTest.php b/test/qtismtest/data/content/xhtml/html5/RbTest.php new file mode 100644 index 000000000..49aa65284 --- /dev/null +++ b/test/qtismtest/data/content/xhtml/html5/RbTest.php @@ -0,0 +1,55 @@ +getId()); + self::assertEquals($class, $subject->getClass()); + } + + public function testCreateWithDefaultValues(): void + { + $subject = new Rb(); + + self::assertEquals('', $subject->getId()); + self::assertEquals('', $subject->getClass()); + } + + public function testGetQtiClassName(): void + { + $subject = new Rb(); + + self::assertEquals(Rb::QTI_CLASS_NAME, $subject->getQtiClassName()); + } +} diff --git a/test/qtismtest/data/content/xhtml/html5/RpTest.php b/test/qtismtest/data/content/xhtml/html5/RpTest.php new file mode 100644 index 000000000..07da33c70 --- /dev/null +++ b/test/qtismtest/data/content/xhtml/html5/RpTest.php @@ -0,0 +1,55 @@ +getId()); + self::assertEquals($class, $subject->getClass()); + } + + public function testCreateWithDefaultValues(): void + { + $subject = new Rp(); + + self::assertEquals('', $subject->getId()); + self::assertEquals('', $subject->getClass()); + } + + public function testGetQtiClassName(): void + { + $subject = new Rp(); + + self::assertEquals(Rp::QTI_CLASS_NAME, $subject->getQtiClassName()); + } +} diff --git a/test/qtismtest/data/content/xhtml/html5/RtTest.php b/test/qtismtest/data/content/xhtml/html5/RtTest.php new file mode 100644 index 000000000..33f3b7e06 --- /dev/null +++ b/test/qtismtest/data/content/xhtml/html5/RtTest.php @@ -0,0 +1,55 @@ +getId()); + self::assertEquals($class, $subject->getClass()); + } + + public function testCreateWithDefaultValues(): void + { + $subject = new Rt(); + + self::assertEquals('', $subject->getId()); + self::assertEquals('', $subject->getClass()); + } + + public function testGetQtiClassName(): void + { + $subject = new Rt(); + + self::assertEquals(Rt::QTI_CLASS_NAME, $subject->getQtiClassName()); + } +} diff --git a/test/qtismtest/data/content/xhtml/html5/RubyTest.php b/test/qtismtest/data/content/xhtml/html5/RubyTest.php new file mode 100644 index 000000000..1e3c962b0 --- /dev/null +++ b/test/qtismtest/data/content/xhtml/html5/RubyTest.php @@ -0,0 +1,55 @@ +getId()); + self::assertEquals($class, $subject->getClass()); + } + + public function testCreateWithDefaultValues(): void + { + $subject = new Ruby(); + + self::assertEquals('', $subject->getId()); + self::assertEquals('', $subject->getClass()); + } + + public function testGetQtiClassName(): void + { + $subject = new Ruby(); + + self::assertEquals(Ruby::QTI_CLASS_NAME, $subject->getQtiClassName()); + } +} diff --git a/test/qtismtest/data/storage/xml/marshalling/Html5RbMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/Html5RbMarshallerTest.php new file mode 100644 index 000000000..0df28fc2e --- /dev/null +++ b/test/qtismtest/data/storage/xml/marshalling/Html5RbMarshallerTest.php @@ -0,0 +1,133 @@ +assertHtml5MarshallingOnlyInQti22AndAbove(new Rb(), Rb::QTI_CLASS_NAME); + } + + /** + * @throws MarshallerNotFoundException + * @throws MarshallingException + */ + public function testMarshall22(): void + { + $id = 'id'; + $class = 'testclass'; + + $expected = sprintf( + '<%1$s id="%2$s" class="%3$s">text content', + $this->namespaceTag(Rb::QTI_CLASS_NAME), + $id, + $class, + $this->prefixTag(Rb::QTI_CLASS_NAME) + ); + + $object = new Rb(null, null, $id, $class); + $object->setContent(new InlineCollection([new TextRun('text content')])); + + $this->assertMarshalling($expected, $object); + } + + /** + * @throws MarshallerNotFoundException + * @throws MarshallingException + */ + public function testMarshall22WithDefaultValues(): void + { + $expected = sprintf( + '<%s>text content', + $this->namespaceTag(Rb::QTI_CLASS_NAME), + $this->prefixTag(Rb::QTI_CLASS_NAME) + ); + + $object = new Rb(); + $object->setContent(new InlineCollection([new TextRun('text content')])); + + $this->assertMarshalling($expected, $object); + } + + /** + * @throws MarshallerNotFoundException + */ + public function testUnMarshallerDoesNotExistInQti21(): void + { + $this->assertHtml5UnmarshallingOnlyInQti22AndAbove( + sprintf( + '<%s>', + $this->namespaceTag(Rb::QTI_CLASS_NAME), + $this->prefixTag(Rb::QTI_CLASS_NAME) + ), + Rb::QTI_CLASS_NAME + ); + } + + /** + * @throws MarshallerNotFoundException + */ + public function testUnmarshall22(): void + { + $id = 'id'; + $class = 'testclass'; + + $xml = sprintf( + '<%1$s id="%2$s" class="%3$s">text content', + $this->namespaceTag(Rb::QTI_CLASS_NAME), + $id, + $class, + $this->prefixTag(Rb::QTI_CLASS_NAME) + ); + + $expected = new Rb(null, null, $id, $class); + $expected->setContent(new InlineCollection([new TextRun('text content')])); + + $this->assertUnmarshalling($expected, $xml); + } + + public function testUnmarshall22WithDefaultValues(): void + { + $xml = sprintf( + '<%s>text content', + $this->namespaceTag(Rb::QTI_CLASS_NAME), + $this->prefixTag(Rb::QTI_CLASS_NAME) + ); + + $expected = new Rb(); + $expected->setContent(new InlineCollection([new TextRun('text content')])); + + $this->assertUnmarshalling($expected, $xml); + } +} diff --git a/test/qtismtest/data/storage/xml/marshalling/Html5RpMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/Html5RpMarshallerTest.php new file mode 100644 index 000000000..895b0d614 --- /dev/null +++ b/test/qtismtest/data/storage/xml/marshalling/Html5RpMarshallerTest.php @@ -0,0 +1,133 @@ +assertHtml5MarshallingOnlyInQti22AndAbove(new Rp(), Rp::QTI_CLASS_NAME); + } + + /** + * @throws MarshallerNotFoundException + * @throws MarshallingException + */ + public function testMarshall22(): void + { + $id = 'id'; + $class = 'testclass'; + + $expected = sprintf( + '<%1$s id="%2$s" class="%3$s">text content', + $this->namespaceTag(Rp::QTI_CLASS_NAME), + $id, + $class, + $this->prefixTag(Rp::QTI_CLASS_NAME) + ); + + $object = new Rp(null, null, $id, $class); + $object->setContent(new InlineCollection([new TextRun('text content')])); + + $this->assertMarshalling($expected, $object); + } + + /** + * @throws MarshallerNotFoundException + * @throws MarshallingException + */ + public function testMarshall22WithDefaultValues(): void + { + $expected = sprintf( + '<%s>text content', + $this->namespaceTag(Rp::QTI_CLASS_NAME), + $this->prefixTag(Rp::QTI_CLASS_NAME) + ); + + $object = new Rp(); + $object->setContent(new InlineCollection([new TextRun('text content')])); + + $this->assertMarshalling($expected, $object); + } + + /** + * @throws MarshallerNotFoundException + */ + public function testUnMarshallerDoesNotExistInQti21(): void + { + $this->assertHtml5UnmarshallingOnlyInQti22AndAbove( + sprintf( + '<%s>', + $this->namespaceTag(Rp::QTI_CLASS_NAME), + $this->prefixTag(Rp::QTI_CLASS_NAME) + ), + Rp::QTI_CLASS_NAME + ); + } + + /** + * @throws MarshallerNotFoundException + */ + public function testUnmarshall22(): void + { + $id = 'id'; + $class = 'testclass'; + + $xml = sprintf( + '<%1$s id="%2$s" class="%3$s">text content', + $this->namespaceTag(Rp::QTI_CLASS_NAME), + $id, + $class, + $this->prefixTag(Rp::QTI_CLASS_NAME) + ); + + $expected = new Rp(null, null, $id, $class); + $expected->setContent(new InlineCollection([new TextRun('text content')])); + + $this->assertUnmarshalling($expected, $xml); + } + + public function testUnmarshall22WithDefaultValues(): void + { + $xml = sprintf( + '<%s>text content', + $this->namespaceTag(Rp::QTI_CLASS_NAME), + $this->prefixTag(Rp::QTI_CLASS_NAME) + ); + + $expected = new Rp(); + $expected->setContent(new InlineCollection([new TextRun('text content')])); + + $this->assertUnmarshalling($expected, $xml); + } +} diff --git a/test/qtismtest/data/storage/xml/marshalling/Html5RtMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/Html5RtMarshallerTest.php new file mode 100644 index 000000000..9a52e4a6d --- /dev/null +++ b/test/qtismtest/data/storage/xml/marshalling/Html5RtMarshallerTest.php @@ -0,0 +1,133 @@ +assertHtml5MarshallingOnlyInQti22AndAbove(new Rt(), Rt::QTI_CLASS_NAME); + } + + /** + * @throws MarshallerNotFoundException + * @throws MarshallingException + */ + public function testMarshall22(): void + { + $id = 'id'; + $class = 'testclass'; + + $expected = sprintf( + '<%1$s id="%2$s" class="%3$s">text content', + $this->namespaceTag(Rt::QTI_CLASS_NAME), + $id, + $class, + $this->prefixTag(Rt::QTI_CLASS_NAME) + ); + + $object = new Rt(null, null, $id, $class); + $object->setContent(new InlineCollection([new TextRun('text content')])); + + $this->assertMarshalling($expected, $object); + } + + /** + * @throws MarshallerNotFoundException + * @throws MarshallingException + */ + public function testMarshall22WithDefaultValues(): void + { + $expected = sprintf( + '<%s>text content', + $this->namespaceTag(Rt::QTI_CLASS_NAME), + $this->prefixTag(Rt::QTI_CLASS_NAME) + ); + + $object = new Rt(); + $object->setContent(new InlineCollection([new TextRun('text content')])); + + $this->assertMarshalling($expected, $object); + } + + /** + * @throws MarshallerNotFoundException + */ + public function testUnMarshallerDoesNotExistInQti21(): void + { + $this->assertHtml5UnmarshallingOnlyInQti22AndAbove( + sprintf( + '<%s>', + $this->namespaceTag(Rt::QTI_CLASS_NAME), + $this->prefixTag(Rt::QTI_CLASS_NAME) + ), + Rt::QTI_CLASS_NAME + ); + } + + /** + * @throws MarshallerNotFoundException + */ + public function testUnmarshall22(): void + { + $id = 'id'; + $class = 'testclass'; + + $xml = sprintf( + '<%1$s id="%2$s" class="%3$s">text content', + $this->namespaceTag(Rt::QTI_CLASS_NAME), + $id, + $class, + $this->prefixTag(Rt::QTI_CLASS_NAME) + ); + + $expected = new Rt(null, null, $id, $class); + $expected->setContent(new InlineCollection([new TextRun('text content')])); + + $this->assertUnmarshalling($expected, $xml); + } + + public function testUnmarshall22WithDefaultValues(): void + { + $xml = sprintf( + '<%s>text content', + $this->namespaceTag(Rt::QTI_CLASS_NAME), + $this->prefixTag(Rt::QTI_CLASS_NAME) + ); + + $expected = new Rt(); + $expected->setContent(new InlineCollection([new TextRun('text content')])); + + $this->assertUnmarshalling($expected, $xml); + } +} diff --git a/test/qtismtest/data/storage/xml/marshalling/Html5RubyMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/Html5RubyMarshallerTest.php new file mode 100644 index 000000000..de57cdd3b --- /dev/null +++ b/test/qtismtest/data/storage/xml/marshalling/Html5RubyMarshallerTest.php @@ -0,0 +1,145 @@ +assertHtml5MarshallingOnlyInQti22AndAbove(new Ruby(), Ruby::QTI_CLASS_NAME); + } + + /** + * @throws MarshallerNotFoundException + * @throws MarshallingException + */ + public function testMarshall22(): void + { + $id = 'id'; + $class = 'testclass'; + + $expected = sprintf( + '<%1$s id="%2$s" class="%3$s><%4$s>真<%5$s>まこと<%6$s>真<%7$s>真', + $this->namespaceTag(Ruby::QTI_CLASS_NAME), + $id, + $class, + $this->prefixTag(Ruby::QTI_CLASS_NAME), + $this->prefixTag(Rb::QTI_CLASS_NAME), + $this->prefixTag(Rt::QTI_CLASS_NAME), + $this->prefixTag(Rp::QTI_CLASS_NAME) + ); + + $rb = new Rb(); + $rb->setContent(new InlineCollection([new TextRun('まこと')])); + + $rt = new Rt(); + $rt->setContent(new InlineCollection([new TextRun('真')])); + + $rp = new Rp(); + $rp->setContent(new InlineCollection([new TextRun('真')])); + + $object = new Ruby(null, null, $id, $class); + $object->setContent(new FlowCollection([$rb, $rt, $rp])); + + $this->assertMarshalling($expected, $object); + } + + /** + * @throws MarshallerNotFoundException + * @throws MarshallingException + */ + public function testMarshall22WithDefaultValues(): void + { + $expected = sprintf( + '<%s/>', + $this->namespaceTag(Ruby::QTI_CLASS_NAME) + ); + + $ruby = new Ruby(); + + $this->assertMarshalling($expected, $ruby); + } + + /** + * @throws MarshallerNotFoundException + */ + public function testUnMarshallerDoesNotExistInQti21(): void + { + $this->assertHtml5UnmarshallingOnlyInQti22AndAbove( + sprintf( + '<%s>', + $this->namespaceTag(Ruby::QTI_CLASS_NAME), + $this->prefixTag(Ruby::QTI_CLASS_NAME) + ), + Ruby::QTI_CLASS_NAME + ); + } + + /** + * @throws MarshallerNotFoundException + */ + public function testUnmarshall22(): void + { + $id = 'id'; + $class = 'testclass'; + + $xml = sprintf( + '<%1$s id="%2$s" class="%3$s">', + $this->namespaceTag(Ruby::QTI_CLASS_NAME), + $id, + $class, + $this->prefixTag(Ruby::QTI_CLASS_NAME) + ); + + $expected = new Ruby(null, null, $id, $class); + + $this->assertUnmarshalling($expected, $xml); + } + + public function testUnmarshall22WithDefaultValues(): void + { + $xml = sprintf( + '<%s>', + $this->namespaceTag(Ruby::QTI_CLASS_NAME), + $this->prefixTag(Ruby::QTI_CLASS_NAME) + ); + + $expected = new Ruby(); + + $this->assertUnmarshalling($expected, $xml); + } +} diff --git a/test/samples/custom/items/2_2/ruby_html5.xml b/test/samples/custom/items/2_2/ruby_html5.xml new file mode 100644 index 000000000..f8097d298 --- /dev/null +++ b/test/samples/custom/items/2_2/ruby_html5.xml @@ -0,0 +1,49 @@ + + + + + + + + + + 0 + + + +
+
+

村田

+ + + まこと + +

の出身地はどこですか

+
+
+ + 選びなさい + + + 北海道 + ほっかいどう + + + 東北 + 北陸 + 関東 + 甲信越 + 近畿 + 関西 + 四国 + 中国 + 九州 + +
+ +
\ No newline at end of file From e21de7a7b99f798be971feabfc7504e1fbdb9654 Mon Sep 17 00:00:00 2001 From: Vitalii Shtykhno Date: Fri, 23 Sep 2022 14:05:46 +0200 Subject: [PATCH 03/13] test: udpate execution tests --- .../xml/marshalling/Html5RubyMarshallerTest.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/qtismtest/data/storage/xml/marshalling/Html5RubyMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/Html5RubyMarshallerTest.php index de57cdd3b..197e6d4ed 100644 --- a/test/qtismtest/data/storage/xml/marshalling/Html5RubyMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/Html5RubyMarshallerTest.php @@ -53,14 +53,14 @@ public function testMarshall22(): void $class = 'testclass'; $expected = sprintf( - '<%1$s id="%2$s" class="%3$s><%4$s>真<%5$s>まこと<%6$s>真<%7$s>真', + '<%1$s id="%2$s" class="%3$s"><%4$s>真<%5$s>まこと<%6$s>真', $this->namespaceTag(Ruby::QTI_CLASS_NAME), $id, $class, - $this->prefixTag(Ruby::QTI_CLASS_NAME), - $this->prefixTag(Rb::QTI_CLASS_NAME), $this->prefixTag(Rt::QTI_CLASS_NAME), - $this->prefixTag(Rp::QTI_CLASS_NAME) + $this->prefixTag(Rb::QTI_CLASS_NAME), + $this->prefixTag(Rp::QTI_CLASS_NAME), + $this->prefixTag(Ruby::QTI_CLASS_NAME) ); $rb = new Rb(); @@ -73,7 +73,7 @@ public function testMarshall22(): void $rp->setContent(new InlineCollection([new TextRun('真')])); $object = new Ruby(null, null, $id, $class); - $object->setContent(new FlowCollection([$rb, $rt, $rp])); + $object->setContent(new FlowCollection([ $rt, $rb, $rp])); $this->assertMarshalling($expected, $object); } From 6418e8e90bb535b9285fc00b2420ad9ae4532eb1 Mon Sep 17 00:00:00 2001 From: Vitalii Shtykhno Date: Fri, 23 Sep 2022 17:19:18 +0200 Subject: [PATCH 04/13] test: add unified test class --- .../Html5ElementMarshallerTest.php | 256 ++++++++++++++++++ 1 file changed, 256 insertions(+) create mode 100644 test/qtismtest/data/storage/xml/marshalling/Html5ElementMarshallerTest.php diff --git a/test/qtismtest/data/storage/xml/marshalling/Html5ElementMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/Html5ElementMarshallerTest.php new file mode 100644 index 000000000..3753b093b --- /dev/null +++ b/test/qtismtest/data/storage/xml/marshalling/Html5ElementMarshallerTest.php @@ -0,0 +1,256 @@ +', + $this->namespaceTag('html5'), + $id, + $class, + $lang, + $label, + $title, + $role + ); + + $html5Element = new FakeHtml5Element($title, Role::getConstantByName($role), $id, $class, $lang, $label); + + $marshaller = new FakeHtml5ElementMarshaller('2.2.0'); + + $this->assertMarshalling($expected, $html5Element, $marshaller); + } + + /** + * @throws MarshallerNotFoundException + * @throws MarshallingException + */ + public function testMarshall22WithDefaultValues(): void + { + $expected = '<' . $this->namespaceTag('html5') . '/>'; + + $html5Element = new FakeHtml5Element(); + + $marshaller = new FakeHtml5ElementMarshaller('2.2.0'); + + $this->assertMarshalling($expected, $html5Element, $marshaller); + } + + /** + * @throws MarshallerNotFoundException + */ + public function testUnmarshall22(): void + { + $title = 'the title'; + $role = 'note'; + $id = 'Identifier'; + $class = 'a css class'; + $lang = 'es'; + $label = 'A label'; + + $xml = sprintf( + '<%s id="%s" class="%s" xml:lang="%s" label="%s" title="%s" role="%s"/>', + $this->namespaceTag('html5'), + $id, + $class, + $lang, + $label, + $title, + $role + ); + + $marshaller = new FakeHtml5ElementMarshaller('2.2.0'); + + $expected = new FakeHtml5Element( + $title, + Role::getConstantByName($role), + $id, + $class, + $lang, + $label + ); + $this->assertUnmarshalling($expected, $xml, $marshaller); + } + + /** + * @throws MarshallerNotFoundException + */ + public function testUnmarshall22WithDefaultValues(): void + { + $xml = '<' . $this->namespaceTag('html5') . '/>'; + + $marshaller = new FakeHtml5ElementMarshaller('2.2.0'); + + $expected = new FakeHtml5Element(); + $this->assertUnmarshalling($expected, $xml, $marshaller); + } + + /** + * @param Html5Element $object + * @param string $elementName + * @throws MarshallerNotFoundException + * @throws MarshallingException + */ + protected function assertHtml5MarshallingOnlyInQti22AndAbove(Html5Element $object, string $elementName): void + { + $this->expectException(MarshallerNotFoundException::class); + $this->expectExceptionMessage('No mapping entry found for QTI class name \'' . $elementName . '\'.'); + $marshaller = $this->getMarshallerFactory('2.1.0')->createMarshaller($object); + $marshaller->marshall($object); + } + + /** + * @param string $xml + * @param string $elementName + * @throws MarshallerNotFoundException + */ + public function assertHtml5UnmarshallingOnlyInQti22AndAbove(string $xml, string $elementName): void + { + $element = $this->createDOMElement($xml); + $this->expectException(MarshallerNotFoundException::class); + $this->expectExceptionMessage('No mapping entry found for QTI class name \'' . $elementName . '\'.'); + $marshaller = $this->getMarshallerFactory('2.1.0')->createMarshaller($element); + $marshaller->unmarshall($element); + } + + /** + * @param string $expected + * @param Html5Element $object + * @param Marshaller|null $marshaller Optional marshaller to use for marshalling he object. + * @throws MarshallerNotFoundException + * @throws MarshallingException + */ + protected function assertMarshalling(string $expected, Html5Element $object, Marshaller $marshaller = null): void + { + if ($marshaller === null) { + $marshaller = $this->getMarshallerFactory('2.2.0')->createMarshaller($object); + } + $element = $marshaller->marshall($object); + + $dom = new DOMDocument('1.0', 'UTF-8'); + $element = $dom->importNode($element, true); + $this->assertEquals($expected, $dom->saveXML($element)); + } + + /** + * @param Html5Element $expected + * @param string $xml + * @param Marshaller|null $marshaller Optional marshaller to use for marshalling he object. + * @throws MarshallerNotFoundException + */ + protected function assertUnmarshalling(Html5Element $expected, string $xml, Marshaller $marshaller = null): void + { + $element = $this->createDOMElement($xml); + + if ($marshaller === null) { + $marshaller = $this->getMarshallerFactory('2.2.0')->createMarshaller($element); + } + + $component = $marshaller->unmarshall($element); + $this::assertEquals($expected, $component); + } + + /** + * @param string $xml + * @param string $exception + * @param string $message + * @throws MarshallerNotFoundException + */ + public function assertUnmarshallingException(string $xml, string $exception, string $message): void + { + $element = $this->createDOMElement($xml); + $marshaller = $this->getMarshallerFactory('2.2.0')->createMarshaller($element); + + $this->expectException($exception); + $this->expectExceptionMessage($message); + + $marshaller->unmarshall($element); + } + + protected function namespaceTag(string $tagName): string + { + return $this->prefixTag($tagName) . ' xmlns:' . self::HTML5_PREFIX . '="' . self::HTML5_NAMESPACE . '"'; + } + + protected function prefixTag(string $tagName): string + { + return self::HTML5_PREFIX . ':' . $tagName; + } +} + +class FakeHtml5Element extends Html5Element +{ + public function getQtiClassName(): string + { + return 'html5'; + } + + public function getComponents(): QtiComponentCollection + { + return new QtiComponentCollection(); + } +} + +class FakeHtml5ElementMarshaller extends Html5ElementMarshaller +{ + /** + * @throws MarshallingException + * @throws UnmarshallingException + */ + public function __call($method, $args) + { + if ($method === 'marshall') { + return $this->marshall($args[0]); + } + if ($method === 'unmarshall') { + return $this->unmarshall($args[0]); + } + } + + /** + * @param DOMElement $element + * @return QtiComponent + * @throws UnmarshallingException + */ + protected function unmarshall(DOMElement $element) + { + $component = new FakeHtml5Element(); + $this->fillBodyElement($component, $element); + return $component; + } + + public function getExpectedQtiClassName() + { + } +} From 2c765952b042991a7546dbabbe29fdca29965e14 Mon Sep 17 00:00:00 2001 From: Vitalii Shtykhno Date: Fri, 23 Sep 2022 17:26:12 +0200 Subject: [PATCH 05/13] test: fix parent name --- .../storage/xml/marshalling/Html5ElementMarshallerTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/qtismtest/data/storage/xml/marshalling/Html5ElementMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/Html5ElementMarshallerTest.php index 3753b093b..953102b58 100644 --- a/test/qtismtest/data/storage/xml/marshalling/Html5ElementMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/Html5ElementMarshallerTest.php @@ -8,7 +8,7 @@ use qtism\data\content\xhtml\html5\Html5Element; use qtism\data\QtiComponent; use qtism\data\QtiComponentCollection; -use qtism\data\storage\xml\marshalling\Html5ElementMarshaller; +use qtism\data\storage\xml\marshalling\Html5ContentMarshaller; use qtism\data\storage\xml\marshalling\Marshaller; use qtism\data\storage\xml\marshalling\MarshallerNotFoundException; use qtism\data\storage\xml\marshalling\MarshallingException; @@ -222,7 +222,7 @@ public function getComponents(): QtiComponentCollection } } -class FakeHtml5ElementMarshaller extends Html5ElementMarshaller +class FakeHtml5ElementMarshaller extends Html5ContentMarshaller { /** * @throws MarshallingException From e0f220ed1f6cdfae905e1d1a783ea94aeeafed65 Mon Sep 17 00:00:00 2001 From: Vitalii Shtykhno Date: Fri, 23 Sep 2022 17:33:15 +0200 Subject: [PATCH 06/13] fix: cover with new parent class --- qtism/data/content/xhtml/html5/Rb.php | 48 +------------------------ qtism/data/content/xhtml/html5/Rp.php | 48 +------------------------ qtism/data/content/xhtml/html5/Rt.php | 48 +------------------------ qtism/data/content/xhtml/html5/Ruby.php | 48 +------------------------ 4 files changed, 4 insertions(+), 188 deletions(-) diff --git a/qtism/data/content/xhtml/html5/Rb.php b/qtism/data/content/xhtml/html5/Rb.php index d24397ec0..72a50a8f6 100644 --- a/qtism/data/content/xhtml/html5/Rb.php +++ b/qtism/data/content/xhtml/html5/Rb.php @@ -23,59 +23,13 @@ namespace qtism\data\content\xhtml\html5; use qtism\data\content\FlowStatic; -use qtism\data\content\FlowTrait; -use qtism\data\content\InlineCollection; -class Rb extends Html5Element implements FlowStatic +class Rb extends Html5LayoutElement implements FlowStatic { - use FlowTrait; - public const QTI_CLASS_NAME = 'rb'; - /** - * The Block components composing the SimpleBlock object. - * - * @var InlineCollection - * @qtism-bean-property - */ - private $content; - - /** - * Create a new figcaption object. - */ - public function __construct($title = null, $role = null, $id = null, $class = null, $lang = null, $label = null) - { - parent::__construct($title, $role, $id, $class, $lang, $label); - $this->setContent(new InlineCollection()); - } - public function getQtiClassName() { return self::QTI_CLASS_NAME; } - - public function getComponents() - { - return $this->getContent(); - } - - /** - * Set the collection of Flow objects composing the Div. - * - * @param InlineCollection $content A collection of Flow objects. - */ - public function setContent(InlineCollection $content) - { - $this->content = $content; - } - - /** - * Get the collection of Flow objects composing the Div. - * - * @return InlineCollection - */ - public function getContent() - { - return $this->content; - } } diff --git a/qtism/data/content/xhtml/html5/Rp.php b/qtism/data/content/xhtml/html5/Rp.php index 06e4b5220..f284969da 100644 --- a/qtism/data/content/xhtml/html5/Rp.php +++ b/qtism/data/content/xhtml/html5/Rp.php @@ -23,59 +23,13 @@ namespace qtism\data\content\xhtml\html5; use qtism\data\content\FlowStatic; -use qtism\data\content\FlowTrait; -use qtism\data\content\InlineCollection; -class Rp extends Html5Element implements FlowStatic +class Rp extends Html5LayoutElement implements FlowStatic { - use FlowTrait; - public const QTI_CLASS_NAME = 'rp'; - /** - * The Block components composing the SimpleBlock object. - * - * @var InlineCollection - * @qtism-bean-property - */ - private $content; - - /** - * Create a new figcaption object. - */ - public function __construct($title = null, $role = null, $id = null, $class = null, $lang = null, $label = null) - { - parent::__construct($title, $role, $id, $class, $lang, $label); - $this->setContent(new InlineCollection()); - } - public function getQtiClassName() { return self::QTI_CLASS_NAME; } - - public function getComponents() - { - return $this->getContent(); - } - - /** - * Set the collection of Flow objects composing the Div. - * - * @param InlineCollection $content A collection of Flow objects. - */ - public function setContent(InlineCollection $content) - { - $this->content = $content; - } - - /** - * Get the collection of Flow objects composing the Div. - * - * @return InlineCollection - */ - public function getContent() - { - return $this->content; - } } diff --git a/qtism/data/content/xhtml/html5/Rt.php b/qtism/data/content/xhtml/html5/Rt.php index 58772cfed..c255adb24 100644 --- a/qtism/data/content/xhtml/html5/Rt.php +++ b/qtism/data/content/xhtml/html5/Rt.php @@ -23,59 +23,13 @@ namespace qtism\data\content\xhtml\html5; use qtism\data\content\FlowStatic; -use qtism\data\content\FlowTrait; -use qtism\data\content\InlineCollection; -class Rt extends Html5Element implements FlowStatic +class Rt extends Html5LayoutElement implements FlowStatic { - use FlowTrait; - public const QTI_CLASS_NAME = 'rt'; - /** - * The Block components composing the SimpleBlock object. - * - * @var InlineCollection - * @qtism-bean-property - */ - private $content; - - /** - * Create a new figcaption object. - */ - public function __construct($title = null, $role = null, $id = null, $class = null, $lang = null, $label = null) - { - parent::__construct($title, $role, $id, $class, $lang, $label); - $this->setContent(new InlineCollection()); - } - public function getQtiClassName() { return self::QTI_CLASS_NAME; } - - public function getComponents() - { - return $this->getContent(); - } - - /** - * Set the collection of Flow objects composing the Div. - * - * @param InlineCollection $content A collection of Flow objects. - */ - public function setContent(InlineCollection $content) - { - $this->content = $content; - } - - /** - * Get the collection of Flow objects composing the Div. - * - * @return InlineCollection - */ - public function getContent() - { - return $this->content; - } } diff --git a/qtism/data/content/xhtml/html5/Ruby.php b/qtism/data/content/xhtml/html5/Ruby.php index 8e18e605b..473530377 100644 --- a/qtism/data/content/xhtml/html5/Ruby.php +++ b/qtism/data/content/xhtml/html5/Ruby.php @@ -22,60 +22,14 @@ namespace qtism\data\content\xhtml\html5; -use qtism\data\content\FlowCollection; use qtism\data\content\FlowStatic; -use qtism\data\content\FlowTrait; -class Ruby extends Html5Element implements FlowStatic +class Ruby extends Html5LayoutElement implements FlowStatic { - use FlowTrait; - public const QTI_CLASS_NAME = 'ruby'; - /** - * The Block components composing the SimpleBlock object. - * - * @var FlowCollection - * @qtism-bean-property - */ - private $content; - - /** - * Create a new figure object. - */ - public function __construct($title = null, $role = null, $id = null, $class = null, $lang = null, $label = null) - { - parent::__construct($title, $role, $id, $class, $lang, $label); - $this->setContent(new FlowCollection()); - } - public function getQtiClassName() { return self::QTI_CLASS_NAME; } - - public function getComponents() - { - return $this->getContent(); - } - - /** - * Set the collection of Flow objects composing the Div. - * - * @param FlowCollection $content A collection of Flow objects. - */ - public function setContent(FlowCollection $content) - { - $this->content = $content; - } - - /** - * Get the collection of Flow objects composing the Div. - * - * @return FlowCollection - */ - public function getContent() - { - return $this->content; - } } From aace1ac9500c45ff9771c5462edae233bbe0917a Mon Sep 17 00:00:00 2001 From: Vitalii Shtykhno Date: Fri, 23 Sep 2022 17:57:14 +0200 Subject: [PATCH 07/13] fix: use common marshaller for html5 --- .../xml/marshalling/Html5RbMarshaller.php | 83 ------------------ .../xml/marshalling/Html5RpMarshaller.php | 83 ------------------ .../xml/marshalling/Html5RtMarshaller.php | 83 ------------------ .../xml/marshalling/Html5RubyMarshaller.php | 84 ------------------- .../marshalling/Qti22MarshallerFactory.php | 12 +-- 5 files changed, 6 insertions(+), 339 deletions(-) delete mode 100644 qtism/data/storage/xml/marshalling/Html5RbMarshaller.php delete mode 100644 qtism/data/storage/xml/marshalling/Html5RpMarshaller.php delete mode 100644 qtism/data/storage/xml/marshalling/Html5RtMarshaller.php delete mode 100644 qtism/data/storage/xml/marshalling/Html5RubyMarshaller.php diff --git a/qtism/data/storage/xml/marshalling/Html5RbMarshaller.php b/qtism/data/storage/xml/marshalling/Html5RbMarshaller.php deleted file mode 100644 index c1e10b300..000000000 --- a/qtism/data/storage/xml/marshalling/Html5RbMarshaller.php +++ /dev/null @@ -1,83 +0,0 @@ -hasId()) { - $this->setDOMElementAttribute($element, 'id', $component->getId()); - } - - if ($component->hasClass()) { - $this->setDOMElementAttribute($element, 'class', $component->getClass()); - } - - return $component; - } - - /** - * @param QtiComponent $component - * @param array $elements - * @return DOMElement - */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) - { - $element = parent::marshallChildrenKnown($component, $elements); - - if ($component->hasId()) { - $this->setDOMElementAttribute($element, 'id', $component->getId()); - } - - if ($component->hasClass()) { - $this->setDOMElementAttribute($element, 'class', $component->getClass()); - } - - return $element; - } - - protected static function getContentCollectionClassName() - { - return InlineCollection::class; - } -} diff --git a/qtism/data/storage/xml/marshalling/Html5RpMarshaller.php b/qtism/data/storage/xml/marshalling/Html5RpMarshaller.php deleted file mode 100644 index 9bb6e80ec..000000000 --- a/qtism/data/storage/xml/marshalling/Html5RpMarshaller.php +++ /dev/null @@ -1,83 +0,0 @@ -hasId()) { - $this->setDOMElementAttribute($element, 'id', $component->getId()); - } - - if ($component->hasClass()) { - $this->setDOMElementAttribute($element, 'class', $component->getClass()); - } - - return $component; - } - - /** - * @param QtiComponent $component - * @param array $elements - * @return DOMElement - */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) - { - $element = parent::marshallChildrenKnown($component, $elements); - - if ($component->hasId()) { - $this->setDOMElementAttribute($element, 'id', $component->getId()); - } - - if ($component->hasClass()) { - $this->setDOMElementAttribute($element, 'class', $component->getClass()); - } - - return $element; - } - - protected static function getContentCollectionClassName() - { - return InlineCollection::class; - } -} diff --git a/qtism/data/storage/xml/marshalling/Html5RtMarshaller.php b/qtism/data/storage/xml/marshalling/Html5RtMarshaller.php deleted file mode 100644 index 19b124724..000000000 --- a/qtism/data/storage/xml/marshalling/Html5RtMarshaller.php +++ /dev/null @@ -1,83 +0,0 @@ -hasId()) { - $this->setDOMElementAttribute($element, 'id', $component->getId()); - } - - if ($component->hasClass()) { - $this->setDOMElementAttribute($element, 'class', $component->getClass()); - } - - return $component; - } - - /** - * @param QtiComponent $component - * @param array $elements - * @return DOMElement - */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) - { - $element = parent::marshallChildrenKnown($component, $elements); - - if ($component->hasId()) { - $this->setDOMElementAttribute($element, 'id', $component->getId()); - } - - if ($component->hasClass()) { - $this->setDOMElementAttribute($element, 'class', $component->getClass()); - } - - return $element; - } - - protected static function getContentCollectionClassName() - { - return InlineCollection::class; - } -} diff --git a/qtism/data/storage/xml/marshalling/Html5RubyMarshaller.php b/qtism/data/storage/xml/marshalling/Html5RubyMarshaller.php deleted file mode 100644 index 657aaa6f7..000000000 --- a/qtism/data/storage/xml/marshalling/Html5RubyMarshaller.php +++ /dev/null @@ -1,84 +0,0 @@ -hasId()) { - $this->setDOMElementAttribute($element, 'id', $component->getId()); - } - - if ($component->hasClass()) { - $this->setDOMElementAttribute($element, 'class', $component->getClass()); - } - - return $component; - } - - /** - * @param QtiComponent $component - * @param array $elements - * @return DOMElement - */ - protected function marshallChildrenKnown(QtiComponent $component, array $elements) - { - $element = parent::marshallChildrenKnown($component, $elements); - - if ($component->hasId()) { - $this->setDOMElementAttribute($element, 'id', $component->getId()); - } - - if ($component->hasClass()) { - $this->setDOMElementAttribute($element, 'class', $component->getClass()); - } - - return $element; - } - - protected static function getContentCollectionClassName() - { - return FlowCollection::class; - } -} diff --git a/qtism/data/storage/xml/marshalling/Qti22MarshallerFactory.php b/qtism/data/storage/xml/marshalling/Qti22MarshallerFactory.php index e393817b3..7f5dcbd2f 100644 --- a/qtism/data/storage/xml/marshalling/Qti22MarshallerFactory.php +++ b/qtism/data/storage/xml/marshalling/Qti22MarshallerFactory.php @@ -45,12 +45,12 @@ public function __construct() { parent::__construct(); $this->addMappingEntry('bdo', SimpleInlineMarshaller::class); - $this->addMappingEntry(Figure::QTI_CLASS_NAME_FIGURE, Html5FigureMarshaller::class); - $this->addMappingEntry(Figcaption::QTI_CLASS_NAME_FIGCAPTION, Html5FigcaptionMarshaller::class); - $this->addMappingEntry(Ruby::QTI_CLASS_NAME, Html5RubyMarshaller::class); - $this->addMappingEntry(Rb::QTI_CLASS_NAME, Html5RbMarshaller::class); - $this->addMappingEntry(Rp::QTI_CLASS_NAME, Html5RpMarshaller::class); - $this->addMappingEntry(Rt::QTI_CLASS_NAME, Html5RtMarshaller::class); + $this->addMappingEntry(Figure::QTI_CLASS_NAME_FIGURE, Html5ContentMarshaller::class); + $this->addMappingEntry(Figcaption::QTI_CLASS_NAME_FIGCAPTION, Html5ContentMarshaller::class); + $this->addMappingEntry(Ruby::QTI_CLASS_NAME, Html5ContentMarshaller::class); + $this->addMappingEntry(Rb::QTI_CLASS_NAME, Html5ContentMarshaller::class); + $this->addMappingEntry(Rp::QTI_CLASS_NAME, Html5ContentMarshaller::class); + $this->addMappingEntry(Rt::QTI_CLASS_NAME, Html5ContentMarshaller::class); } /** From acd28ca198371beafcfbd1a0b669b8eab85bca5c Mon Sep 17 00:00:00 2001 From: Vitalii Shtykhno Date: Fri, 23 Sep 2022 17:57:38 +0200 Subject: [PATCH 08/13] test: remove class declaration more than one file --- .../xhtml/html5/Html5LayoutElementTest.php | 8 ---- .../Html5ElementMarshallerTest.php | 48 +------------------ .../xml/marshalling/MarshallerTest.php | 29 ----------- 3 files changed, 1 insertion(+), 84 deletions(-) diff --git a/test/qtismtest/data/content/xhtml/html5/Html5LayoutElementTest.php b/test/qtismtest/data/content/xhtml/html5/Html5LayoutElementTest.php index 8f0ed57f3..8ec141570 100644 --- a/test/qtismtest/data/content/xhtml/html5/Html5LayoutElementTest.php +++ b/test/qtismtest/data/content/xhtml/html5/Html5LayoutElementTest.php @@ -61,11 +61,3 @@ public function testSetContent(): void self::assertEquals($content, $subject->getComponents()); } } - -class FakeHtml5LayoutElement extends Html5LayoutElement -{ - public function getQtiClassName(): string - { - return ''; - } -} diff --git a/test/qtismtest/data/storage/xml/marshalling/Html5ElementMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/Html5ElementMarshallerTest.php index 953102b58..70c3e99c5 100644 --- a/test/qtismtest/data/storage/xml/marshalling/Html5ElementMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/Html5ElementMarshallerTest.php @@ -207,50 +207,4 @@ protected function prefixTag(string $tagName): string { return self::HTML5_PREFIX . ':' . $tagName; } -} - -class FakeHtml5Element extends Html5Element -{ - public function getQtiClassName(): string - { - return 'html5'; - } - - public function getComponents(): QtiComponentCollection - { - return new QtiComponentCollection(); - } -} - -class FakeHtml5ElementMarshaller extends Html5ContentMarshaller -{ - /** - * @throws MarshallingException - * @throws UnmarshallingException - */ - public function __call($method, $args) - { - if ($method === 'marshall') { - return $this->marshall($args[0]); - } - if ($method === 'unmarshall') { - return $this->unmarshall($args[0]); - } - } - - /** - * @param DOMElement $element - * @return QtiComponent - * @throws UnmarshallingException - */ - protected function unmarshall(DOMElement $element) - { - $component = new FakeHtml5Element(); - $this->fillBodyElement($component, $element); - return $component; - } - - public function getExpectedQtiClassName() - { - } -} +} \ No newline at end of file diff --git a/test/qtismtest/data/storage/xml/marshalling/MarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/MarshallerTest.php index 039259ec9..823a57b8d 100644 --- a/test/qtismtest/data/storage/xml/marshalling/MarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/MarshallerTest.php @@ -178,32 +178,3 @@ public function testNoSuchMagicMethod() $marshaller->hello(); } } - - - - - - -class FakeMarshaller extends Marshaller -{ - /** - * @inheritDoc - */ - protected function marshall(QtiComponent $component) - { - } - - /** - * @inheritDoc - */ - protected function unmarshall(DOMElement $element) - { - } - - /** - * @inheritDoc - */ - public function getExpectedQtiClassName() - { - } -} From bc65371839e8bf15af0e9ede2d352252e0436376 Mon Sep 17 00:00:00 2001 From: Vitalii Shtykhno Date: Tue, 27 Sep 2022 12:46:11 +0200 Subject: [PATCH 09/13] test: adopt test to work with qti2.2 --- .../rendering/markup/xhtml/RbRenderer.php | 46 ------ .../rendering/markup/xhtml/RpRenderer.php | 46 ------ .../rendering/markup/xhtml/RtRenderer.php | 46 ------ .../rendering/markup/xhtml/RubyRenderer.php | 46 ------ .../xhtml/html5/Html5LayoutElementTest.php | 8 +- .../Html5ElementMarshallerTest.php | 146 ++++++++++++++---- .../xml/marshalling/Html5RbMarshallerTest.php | 133 ---------------- .../xml/marshalling/Html5RpMarshallerTest.php | 133 ---------------- .../xml/marshalling/Html5RtMarshallerTest.php | 133 ---------------- .../marshalling/Html5RubyMarshallerTest.php | 145 ----------------- .../xml/marshalling/MarshallerTest.php | 8 +- 11 files changed, 126 insertions(+), 764 deletions(-) delete mode 100644 qtism/runtime/rendering/markup/xhtml/RbRenderer.php delete mode 100644 qtism/runtime/rendering/markup/xhtml/RpRenderer.php delete mode 100644 qtism/runtime/rendering/markup/xhtml/RtRenderer.php delete mode 100644 qtism/runtime/rendering/markup/xhtml/RubyRenderer.php delete mode 100644 test/qtismtest/data/storage/xml/marshalling/Html5RbMarshallerTest.php delete mode 100644 test/qtismtest/data/storage/xml/marshalling/Html5RpMarshallerTest.php delete mode 100644 test/qtismtest/data/storage/xml/marshalling/Html5RtMarshallerTest.php delete mode 100644 test/qtismtest/data/storage/xml/marshalling/Html5RubyMarshallerTest.php diff --git a/qtism/runtime/rendering/markup/xhtml/RbRenderer.php b/qtism/runtime/rendering/markup/xhtml/RbRenderer.php deleted file mode 100644 index ed7bf2d0f..000000000 --- a/qtism/runtime/rendering/markup/xhtml/RbRenderer.php +++ /dev/null @@ -1,46 +0,0 @@ -hasId()) { - $fragment->firstChild->setAttribute('id', $component->getId()); - } - if ($component->hasClass()) { - $fragment->firstChild->setAttribute('class', $component->getClass()); - } - } -} diff --git a/qtism/runtime/rendering/markup/xhtml/RpRenderer.php b/qtism/runtime/rendering/markup/xhtml/RpRenderer.php deleted file mode 100644 index e32105115..000000000 --- a/qtism/runtime/rendering/markup/xhtml/RpRenderer.php +++ /dev/null @@ -1,46 +0,0 @@ -hasId()) { - $fragment->firstChild->setAttribute('id', $component->getId()); - } - if ($component->hasClass()) { - $fragment->firstChild->setAttribute('class', $component->getClass()); - } - } -} diff --git a/qtism/runtime/rendering/markup/xhtml/RtRenderer.php b/qtism/runtime/rendering/markup/xhtml/RtRenderer.php deleted file mode 100644 index 9ceaa1156..000000000 --- a/qtism/runtime/rendering/markup/xhtml/RtRenderer.php +++ /dev/null @@ -1,46 +0,0 @@ -hasId()) { - $fragment->firstChild->setAttribute('id', $component->getId()); - } - if ($component->hasClass()) { - $fragment->firstChild->setAttribute('class', $component->getClass()); - } - } -} diff --git a/qtism/runtime/rendering/markup/xhtml/RubyRenderer.php b/qtism/runtime/rendering/markup/xhtml/RubyRenderer.php deleted file mode 100644 index f480855c3..000000000 --- a/qtism/runtime/rendering/markup/xhtml/RubyRenderer.php +++ /dev/null @@ -1,46 +0,0 @@ -hasId()) { - $fragment->firstChild->setAttribute('id', $component->getId()); - } - if ($component->hasClass()) { - $fragment->firstChild->setAttribute('class', $component->getClass()); - } - } -} diff --git a/test/qtismtest/data/content/xhtml/html5/Html5LayoutElementTest.php b/test/qtismtest/data/content/xhtml/html5/Html5LayoutElementTest.php index 8ec141570..355fb981c 100644 --- a/test/qtismtest/data/content/xhtml/html5/Html5LayoutElementTest.php +++ b/test/qtismtest/data/content/xhtml/html5/Html5LayoutElementTest.php @@ -21,7 +21,9 @@ public function testCreateWithValues(): void $lang = 'en'; $label = 'This is the label.'; - $subject = new FakeHtml5LayoutElement($title, $role, $id, $class, $lang, $label); + $subject = $this->getMockForAbstractClass(Html5LayoutElement::class, [ + $title, $role, $id, $class, $lang, $label + ]); self::assertSame($title, $subject->getTitle()); self::assertEquals(Role::getConstantByName($role), $subject->getRole()); @@ -34,7 +36,7 @@ public function testCreateWithValues(): void public function testCreateWithDefaultValues(): void { - $subject = new FakeHtml5LayoutElement(); + $subject = $this->getMockForAbstractClass(Html5LayoutElement::class); self::assertSame('', $subject->getTitle()); self::assertSame('', $subject->getId()); @@ -46,7 +48,7 @@ public function testCreateWithDefaultValues(): void public function testSetContent(): void { - $subject = new FakeHtml5LayoutElement(); + $subject = $this->getMockForAbstractClass(Html5LayoutElement::class); $content = new FlowCollection( [ new P(), diff --git a/test/qtismtest/data/storage/xml/marshalling/Html5ElementMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/Html5ElementMarshallerTest.php index 70c3e99c5..9a6a4cb3c 100644 --- a/test/qtismtest/data/storage/xml/marshalling/Html5ElementMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/Html5ElementMarshallerTest.php @@ -3,16 +3,21 @@ namespace qtismtest\data\storage\xml\marshalling; use DOMDocument; -use DOMElement; +use PHPUnit\Exception; use qtism\data\content\enums\Role; +use qtism\data\content\FlowCollection; +use qtism\data\content\InlineCollection; +use qtism\data\content\TextRun; +use qtism\data\content\xhtml\html5\Figure; use qtism\data\content\xhtml\html5\Html5Element; -use qtism\data\QtiComponent; -use qtism\data\QtiComponentCollection; +use qtism\data\content\xhtml\html5\Rb; +use qtism\data\content\xhtml\html5\Rp; +use qtism\data\content\xhtml\html5\Rt; +use qtism\data\content\xhtml\html5\Ruby; use qtism\data\storage\xml\marshalling\Html5ContentMarshaller; use qtism\data\storage\xml\marshalling\Marshaller; use qtism\data\storage\xml\marshalling\MarshallerNotFoundException; use qtism\data\storage\xml\marshalling\MarshallingException; -use qtism\data\storage\xml\marshalling\UnmarshallingException; use qtismtest\QtiSmTestCase; class Html5ElementMarshallerTest extends QtiSmTestCase @@ -36,7 +41,7 @@ public function testMarshall22(): void $expected = sprintf( '<%s id="%s" class="%s" xml:lang="%s" label="%s" title="%s" role="%s"/>', - $this->namespaceTag('html5'), + $this->namespaceTag(Figure::QTI_CLASS_NAME_FIGURE), $id, $class, $lang, @@ -45,11 +50,9 @@ public function testMarshall22(): void $role ); - $html5Element = new FakeHtml5Element($title, Role::getConstantByName($role), $id, $class, $lang, $label); + $html5Element = new Figure($title, Role::getConstantByName($role), $id, $class, $lang, $label); - $marshaller = new FakeHtml5ElementMarshaller('2.2.0'); - - $this->assertMarshalling($expected, $html5Element, $marshaller); + $this->assertMarshalling($expected, $html5Element); } /** @@ -58,13 +61,11 @@ public function testMarshall22(): void */ public function testMarshall22WithDefaultValues(): void { - $expected = '<' . $this->namespaceTag('html5') . '/>'; - - $html5Element = new FakeHtml5Element(); + $expected = '<' . $this->namespaceTag(Figure::QTI_CLASS_NAME_FIGURE) . '/>'; - $marshaller = new FakeHtml5ElementMarshaller('2.2.0'); + $html5Element = new Figure(); - $this->assertMarshalling($expected, $html5Element, $marshaller); + $this->assertMarshalling($expected, $html5Element); } /** @@ -81,7 +82,7 @@ public function testUnmarshall22(): void $xml = sprintf( '<%s id="%s" class="%s" xml:lang="%s" label="%s" title="%s" role="%s"/>', - $this->namespaceTag('html5'), + $this->namespaceTag(Figure::QTI_CLASS_NAME_FIGURE), $id, $class, $lang, @@ -90,30 +91,116 @@ public function testUnmarshall22(): void $role ); - $marshaller = new FakeHtml5ElementMarshaller('2.2.0'); + $expected = new Figure($title, Role::getConstantByName($role), $id, $class, $lang, $label); - $expected = new FakeHtml5Element( - $title, - Role::getConstantByName($role), + $this->assertUnmarshalling($expected, $xml); + } + + /** + * @throws MarshallerNotFoundException + */ + public function testUnmarshall22WithDefaultValues(): void + { + $xml = '<' . $this->namespaceTag(Figure::QTI_CLASS_NAME_FIGURE) . '/>'; + + $expected = new Figure(); + + $this->assertUnmarshalling($expected, $xml); + } + + public function testRubyMarshaller() + { + $id = 'id'; + $class = 'testclass'; + + $expected = sprintf( + '<%1$s id="%2$s" class="%3$s"><%4$s>真<%5$s>まこと<%6$s>真', + $this->namespaceTag(Ruby::QTI_CLASS_NAME), $id, $class, - $lang, - $label + $this->prefixTag(Rt::QTI_CLASS_NAME), + $this->prefixTag(Rb::QTI_CLASS_NAME), + $this->prefixTag(Rp::QTI_CLASS_NAME), + $this->prefixTag(Ruby::QTI_CLASS_NAME) + ); + + $rb = new Rb(); + $rb->setContent(new FlowCollection([new TextRun('まこと')])); + + $rt = new Rt(); + $rt->setContent(new FlowCollection([new TextRun('真')])); + + $rp = new Rp(); + $rp->setContent(new FlowCollection([new TextRun('真')])); + + $object = new Ruby(null, null, $id, $class); + $object->setContent(new FlowCollection([ $rt, $rb, $rp])); + + $this->assertMarshalling($expected, $object); + } + /** + * @throws MarshallerNotFoundException + * @throws MarshallingException + */ + public function testRubyMarshall22WithDefaultValues(): void + { + $expected = sprintf( + '<%s/>', + $this->namespaceTag(Ruby::QTI_CLASS_NAME) ); - $this->assertUnmarshalling($expected, $xml, $marshaller); + + $ruby = new Ruby(); + + $this->assertMarshalling($expected, $ruby); } /** * @throws MarshallerNotFoundException */ - public function testUnmarshall22WithDefaultValues(): void + public function testRubyUnMarshallerDoesNotExistInQti21(): void { - $xml = '<' . $this->namespaceTag('html5') . '/>'; + $this->assertHtml5UnmarshallingOnlyInQti22AndAbove( + sprintf( + '<%s>', + $this->namespaceTag(Ruby::QTI_CLASS_NAME), + $this->prefixTag(Ruby::QTI_CLASS_NAME) + ), + Ruby::QTI_CLASS_NAME + ); + } - $marshaller = new FakeHtml5ElementMarshaller('2.2.0'); + /** + * @throws MarshallerNotFoundException + */ + public function testRubyUnmarshall22(): void + { + $id = 'id'; + $class = 'testclass'; - $expected = new FakeHtml5Element(); - $this->assertUnmarshalling($expected, $xml, $marshaller); + $xml = sprintf( + '<%1$s id="%2$s" class="%3$s">', + $this->namespaceTag(Ruby::QTI_CLASS_NAME), + $id, + $class, + $this->prefixTag(Ruby::QTI_CLASS_NAME) + ); + + $expected = new Ruby(null, null, $id, $class); + + $this->assertUnmarshalling($expected, $xml); + } + + public function testRubyUnmarshall22WithDefaultValues(): void + { + $xml = sprintf( + '<%s>', + $this->namespaceTag(Ruby::QTI_CLASS_NAME), + $this->prefixTag(Ruby::QTI_CLASS_NAME) + ); + + $expected = new Ruby(); + + $this->assertUnmarshalling($expected, $xml); } /** @@ -139,7 +226,10 @@ public function assertHtml5UnmarshallingOnlyInQti22AndAbove(string $xml, string { $element = $this->createDOMElement($xml); $this->expectException(MarshallerNotFoundException::class); - $this->expectExceptionMessage('No mapping entry found for QTI class name \'' . $elementName . '\'.'); + $this->expectExceptionMessage(sprintf( + "No marshaller implementation could be found for component '%s'.", + $elementName + )); $marshaller = $this->getMarshallerFactory('2.1.0')->createMarshaller($element); $marshaller->unmarshall($element); } diff --git a/test/qtismtest/data/storage/xml/marshalling/Html5RbMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/Html5RbMarshallerTest.php deleted file mode 100644 index 0df28fc2e..000000000 --- a/test/qtismtest/data/storage/xml/marshalling/Html5RbMarshallerTest.php +++ /dev/null @@ -1,133 +0,0 @@ -assertHtml5MarshallingOnlyInQti22AndAbove(new Rb(), Rb::QTI_CLASS_NAME); - } - - /** - * @throws MarshallerNotFoundException - * @throws MarshallingException - */ - public function testMarshall22(): void - { - $id = 'id'; - $class = 'testclass'; - - $expected = sprintf( - '<%1$s id="%2$s" class="%3$s">text content', - $this->namespaceTag(Rb::QTI_CLASS_NAME), - $id, - $class, - $this->prefixTag(Rb::QTI_CLASS_NAME) - ); - - $object = new Rb(null, null, $id, $class); - $object->setContent(new InlineCollection([new TextRun('text content')])); - - $this->assertMarshalling($expected, $object); - } - - /** - * @throws MarshallerNotFoundException - * @throws MarshallingException - */ - public function testMarshall22WithDefaultValues(): void - { - $expected = sprintf( - '<%s>text content', - $this->namespaceTag(Rb::QTI_CLASS_NAME), - $this->prefixTag(Rb::QTI_CLASS_NAME) - ); - - $object = new Rb(); - $object->setContent(new InlineCollection([new TextRun('text content')])); - - $this->assertMarshalling($expected, $object); - } - - /** - * @throws MarshallerNotFoundException - */ - public function testUnMarshallerDoesNotExistInQti21(): void - { - $this->assertHtml5UnmarshallingOnlyInQti22AndAbove( - sprintf( - '<%s>', - $this->namespaceTag(Rb::QTI_CLASS_NAME), - $this->prefixTag(Rb::QTI_CLASS_NAME) - ), - Rb::QTI_CLASS_NAME - ); - } - - /** - * @throws MarshallerNotFoundException - */ - public function testUnmarshall22(): void - { - $id = 'id'; - $class = 'testclass'; - - $xml = sprintf( - '<%1$s id="%2$s" class="%3$s">text content', - $this->namespaceTag(Rb::QTI_CLASS_NAME), - $id, - $class, - $this->prefixTag(Rb::QTI_CLASS_NAME) - ); - - $expected = new Rb(null, null, $id, $class); - $expected->setContent(new InlineCollection([new TextRun('text content')])); - - $this->assertUnmarshalling($expected, $xml); - } - - public function testUnmarshall22WithDefaultValues(): void - { - $xml = sprintf( - '<%s>text content', - $this->namespaceTag(Rb::QTI_CLASS_NAME), - $this->prefixTag(Rb::QTI_CLASS_NAME) - ); - - $expected = new Rb(); - $expected->setContent(new InlineCollection([new TextRun('text content')])); - - $this->assertUnmarshalling($expected, $xml); - } -} diff --git a/test/qtismtest/data/storage/xml/marshalling/Html5RpMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/Html5RpMarshallerTest.php deleted file mode 100644 index 895b0d614..000000000 --- a/test/qtismtest/data/storage/xml/marshalling/Html5RpMarshallerTest.php +++ /dev/null @@ -1,133 +0,0 @@ -assertHtml5MarshallingOnlyInQti22AndAbove(new Rp(), Rp::QTI_CLASS_NAME); - } - - /** - * @throws MarshallerNotFoundException - * @throws MarshallingException - */ - public function testMarshall22(): void - { - $id = 'id'; - $class = 'testclass'; - - $expected = sprintf( - '<%1$s id="%2$s" class="%3$s">text content', - $this->namespaceTag(Rp::QTI_CLASS_NAME), - $id, - $class, - $this->prefixTag(Rp::QTI_CLASS_NAME) - ); - - $object = new Rp(null, null, $id, $class); - $object->setContent(new InlineCollection([new TextRun('text content')])); - - $this->assertMarshalling($expected, $object); - } - - /** - * @throws MarshallerNotFoundException - * @throws MarshallingException - */ - public function testMarshall22WithDefaultValues(): void - { - $expected = sprintf( - '<%s>text content', - $this->namespaceTag(Rp::QTI_CLASS_NAME), - $this->prefixTag(Rp::QTI_CLASS_NAME) - ); - - $object = new Rp(); - $object->setContent(new InlineCollection([new TextRun('text content')])); - - $this->assertMarshalling($expected, $object); - } - - /** - * @throws MarshallerNotFoundException - */ - public function testUnMarshallerDoesNotExistInQti21(): void - { - $this->assertHtml5UnmarshallingOnlyInQti22AndAbove( - sprintf( - '<%s>', - $this->namespaceTag(Rp::QTI_CLASS_NAME), - $this->prefixTag(Rp::QTI_CLASS_NAME) - ), - Rp::QTI_CLASS_NAME - ); - } - - /** - * @throws MarshallerNotFoundException - */ - public function testUnmarshall22(): void - { - $id = 'id'; - $class = 'testclass'; - - $xml = sprintf( - '<%1$s id="%2$s" class="%3$s">text content', - $this->namespaceTag(Rp::QTI_CLASS_NAME), - $id, - $class, - $this->prefixTag(Rp::QTI_CLASS_NAME) - ); - - $expected = new Rp(null, null, $id, $class); - $expected->setContent(new InlineCollection([new TextRun('text content')])); - - $this->assertUnmarshalling($expected, $xml); - } - - public function testUnmarshall22WithDefaultValues(): void - { - $xml = sprintf( - '<%s>text content', - $this->namespaceTag(Rp::QTI_CLASS_NAME), - $this->prefixTag(Rp::QTI_CLASS_NAME) - ); - - $expected = new Rp(); - $expected->setContent(new InlineCollection([new TextRun('text content')])); - - $this->assertUnmarshalling($expected, $xml); - } -} diff --git a/test/qtismtest/data/storage/xml/marshalling/Html5RtMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/Html5RtMarshallerTest.php deleted file mode 100644 index 9a52e4a6d..000000000 --- a/test/qtismtest/data/storage/xml/marshalling/Html5RtMarshallerTest.php +++ /dev/null @@ -1,133 +0,0 @@ -assertHtml5MarshallingOnlyInQti22AndAbove(new Rt(), Rt::QTI_CLASS_NAME); - } - - /** - * @throws MarshallerNotFoundException - * @throws MarshallingException - */ - public function testMarshall22(): void - { - $id = 'id'; - $class = 'testclass'; - - $expected = sprintf( - '<%1$s id="%2$s" class="%3$s">text content', - $this->namespaceTag(Rt::QTI_CLASS_NAME), - $id, - $class, - $this->prefixTag(Rt::QTI_CLASS_NAME) - ); - - $object = new Rt(null, null, $id, $class); - $object->setContent(new InlineCollection([new TextRun('text content')])); - - $this->assertMarshalling($expected, $object); - } - - /** - * @throws MarshallerNotFoundException - * @throws MarshallingException - */ - public function testMarshall22WithDefaultValues(): void - { - $expected = sprintf( - '<%s>text content', - $this->namespaceTag(Rt::QTI_CLASS_NAME), - $this->prefixTag(Rt::QTI_CLASS_NAME) - ); - - $object = new Rt(); - $object->setContent(new InlineCollection([new TextRun('text content')])); - - $this->assertMarshalling($expected, $object); - } - - /** - * @throws MarshallerNotFoundException - */ - public function testUnMarshallerDoesNotExistInQti21(): void - { - $this->assertHtml5UnmarshallingOnlyInQti22AndAbove( - sprintf( - '<%s>', - $this->namespaceTag(Rt::QTI_CLASS_NAME), - $this->prefixTag(Rt::QTI_CLASS_NAME) - ), - Rt::QTI_CLASS_NAME - ); - } - - /** - * @throws MarshallerNotFoundException - */ - public function testUnmarshall22(): void - { - $id = 'id'; - $class = 'testclass'; - - $xml = sprintf( - '<%1$s id="%2$s" class="%3$s">text content', - $this->namespaceTag(Rt::QTI_CLASS_NAME), - $id, - $class, - $this->prefixTag(Rt::QTI_CLASS_NAME) - ); - - $expected = new Rt(null, null, $id, $class); - $expected->setContent(new InlineCollection([new TextRun('text content')])); - - $this->assertUnmarshalling($expected, $xml); - } - - public function testUnmarshall22WithDefaultValues(): void - { - $xml = sprintf( - '<%s>text content', - $this->namespaceTag(Rt::QTI_CLASS_NAME), - $this->prefixTag(Rt::QTI_CLASS_NAME) - ); - - $expected = new Rt(); - $expected->setContent(new InlineCollection([new TextRun('text content')])); - - $this->assertUnmarshalling($expected, $xml); - } -} diff --git a/test/qtismtest/data/storage/xml/marshalling/Html5RubyMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/Html5RubyMarshallerTest.php deleted file mode 100644 index 197e6d4ed..000000000 --- a/test/qtismtest/data/storage/xml/marshalling/Html5RubyMarshallerTest.php +++ /dev/null @@ -1,145 +0,0 @@ -assertHtml5MarshallingOnlyInQti22AndAbove(new Ruby(), Ruby::QTI_CLASS_NAME); - } - - /** - * @throws MarshallerNotFoundException - * @throws MarshallingException - */ - public function testMarshall22(): void - { - $id = 'id'; - $class = 'testclass'; - - $expected = sprintf( - '<%1$s id="%2$s" class="%3$s"><%4$s>真<%5$s>まこと<%6$s>真', - $this->namespaceTag(Ruby::QTI_CLASS_NAME), - $id, - $class, - $this->prefixTag(Rt::QTI_CLASS_NAME), - $this->prefixTag(Rb::QTI_CLASS_NAME), - $this->prefixTag(Rp::QTI_CLASS_NAME), - $this->prefixTag(Ruby::QTI_CLASS_NAME) - ); - - $rb = new Rb(); - $rb->setContent(new InlineCollection([new TextRun('まこと')])); - - $rt = new Rt(); - $rt->setContent(new InlineCollection([new TextRun('真')])); - - $rp = new Rp(); - $rp->setContent(new InlineCollection([new TextRun('真')])); - - $object = new Ruby(null, null, $id, $class); - $object->setContent(new FlowCollection([ $rt, $rb, $rp])); - - $this->assertMarshalling($expected, $object); - } - - /** - * @throws MarshallerNotFoundException - * @throws MarshallingException - */ - public function testMarshall22WithDefaultValues(): void - { - $expected = sprintf( - '<%s/>', - $this->namespaceTag(Ruby::QTI_CLASS_NAME) - ); - - $ruby = new Ruby(); - - $this->assertMarshalling($expected, $ruby); - } - - /** - * @throws MarshallerNotFoundException - */ - public function testUnMarshallerDoesNotExistInQti21(): void - { - $this->assertHtml5UnmarshallingOnlyInQti22AndAbove( - sprintf( - '<%s>', - $this->namespaceTag(Ruby::QTI_CLASS_NAME), - $this->prefixTag(Ruby::QTI_CLASS_NAME) - ), - Ruby::QTI_CLASS_NAME - ); - } - - /** - * @throws MarshallerNotFoundException - */ - public function testUnmarshall22(): void - { - $id = 'id'; - $class = 'testclass'; - - $xml = sprintf( - '<%1$s id="%2$s" class="%3$s">', - $this->namespaceTag(Ruby::QTI_CLASS_NAME), - $id, - $class, - $this->prefixTag(Ruby::QTI_CLASS_NAME) - ); - - $expected = new Ruby(null, null, $id, $class); - - $this->assertUnmarshalling($expected, $xml); - } - - public function testUnmarshall22WithDefaultValues(): void - { - $xml = sprintf( - '<%s>', - $this->namespaceTag(Ruby::QTI_CLASS_NAME), - $this->prefixTag(Ruby::QTI_CLASS_NAME) - ); - - $expected = new Ruby(); - - $this->assertUnmarshalling($expected, $xml); - } -} diff --git a/test/qtismtest/data/storage/xml/marshalling/MarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/MarshallerTest.php index 823a57b8d..c987a1f64 100644 --- a/test/qtismtest/data/storage/xml/marshalling/MarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/MarshallerTest.php @@ -7,13 +7,11 @@ use qtism\common\enums\BaseType; use qtism\data\expressions\BaseValue; use qtism\data\ItemSessionControl; -use qtism\data\QtiComponent; use qtism\data\storage\xml\marshalling\ItemSessionControlMarshaller; use qtism\data\storage\xml\marshalling\Marshaller; use qtismtest\QtiSmTestCase; use ReflectionClass; use RuntimeException; -use stdClass; /** * Class MarshallerTest @@ -87,7 +85,7 @@ public function testGetChildElementsByTagName() // We should find only 2 direct child elements. $dom->loadXML(''); $element = $dom->documentElement; - $marshaller = new FakeMarshaller('2.1.0'); + $marshaller = $this->getMockForAbstractClass(Marshaller::class, ['2.1.0']); $this::assertCount(2, $marshaller->getChildElementsByTagName($element, 'child')); } @@ -97,7 +95,7 @@ public function testGetChildElementsByTagNameMultiple() $dom = new DOMDocument('1.0', 'UTF-8'); $dom->loadXML(''); $element = $dom->documentElement; - $marshaller = new FakeMarshaller('2.1.0'); + $marshaller = $this->getMockForAbstractClass(Marshaller::class, ['2.1.0']); $this::assertCount(3, $marshaller->getChildElementsByTagName($element, ['child', 'grandChild'])); } @@ -110,7 +108,7 @@ public function testGetChildElementsByTagNameEmpty() // should be found. $dom->loadXML(''); $element = $dom->documentElement; - $marshaller = new FakeMarshaller('2.1.0'); + $marshaller = $this->getMockForAbstractClass(Marshaller::class, ['2.1.0']); $this::assertCount(0, $marshaller->getChildElementsByTagName($element, 'child')); } From 17f3ee637a9bfa416f5c25fbfd2bb7b39f60fed9 Mon Sep 17 00:00:00 2001 From: Vitalii Shtykhno Date: Tue, 27 Sep 2022 12:47:00 +0200 Subject: [PATCH 10/13] fix: correct elemnt creation in legacy --- .../xml/marshalling/MarshallerFactory.php | 2 +- .../xml/marshalling/RecursiveMarshaller.php | 8 ++-- .../markup/xhtml/XhtmlRenderingEngine.php | 43 +++++++++---------- 3 files changed, 26 insertions(+), 27 deletions(-) diff --git a/qtism/data/storage/xml/marshalling/MarshallerFactory.php b/qtism/data/storage/xml/marshalling/MarshallerFactory.php index 377b6ee27..1ef5068e5 100644 --- a/qtism/data/storage/xml/marshalling/MarshallerFactory.php +++ b/qtism/data/storage/xml/marshalling/MarshallerFactory.php @@ -421,7 +421,7 @@ public function createMarshaller($object, array $args = []) } } catch (ReflectionException $e) { $msg = "No marshaller implementation could be found for component '${qtiClassName}'."; - throw new RuntimeException($msg, 0, $e); + throw new MarshallerNotFoundException($msg, 0, $e); } $marshaller = $this->instantiateMarshaller($class, $args); diff --git a/qtism/data/storage/xml/marshalling/RecursiveMarshaller.php b/qtism/data/storage/xml/marshalling/RecursiveMarshaller.php index 9c339aea1..76c6909a6 100644 --- a/qtism/data/storage/xml/marshalling/RecursiveMarshaller.php +++ b/qtism/data/storage/xml/marshalling/RecursiveMarshaller.php @@ -221,14 +221,16 @@ protected function marshall(QtiComponent $component) // Hierarchical node, 1st pass. $this->mark($node); $this->pushTrail($node); // repush for a further pass. - $children = array_reverse($this->getChildrenComponents($node)); // next nodes to explore. + $childrenComponentList = $this->getChildrenComponents($node) ?? []; + $children = array_reverse($childrenComponentList); // next nodes to explore. foreach ($children as $c) { $this->pushTrail($c); } - } elseif ($this->isMarked($node)) { + } elseif ($this->isMarked($node) && !$node instanceof DOMElement) { // Push the result on the trail. - $finals = $this->emptyFinal(count($this->getChildrenComponents($node))); + $childrenComponentList = $this->getChildrenComponents($node) ?? []; + $finals = $this->emptyFinal(count($childrenComponentList)); $marshaller = $this->getMarshallerFactory()->createMarshaller($node); $element = $marshaller->marshallChildrenKnown($node, $finals); $this->pushProcessed($element); diff --git a/qtism/runtime/rendering/markup/xhtml/XhtmlRenderingEngine.php b/qtism/runtime/rendering/markup/xhtml/XhtmlRenderingEngine.php index d0637d411..f73cacd4d 100644 --- a/qtism/runtime/rendering/markup/xhtml/XhtmlRenderingEngine.php +++ b/qtism/runtime/rendering/markup/xhtml/XhtmlRenderingEngine.php @@ -61,18 +61,11 @@ public function __construct() $this->registerRenderer('abbr', $bodyElementRenderer); $this->registerRenderer('acronym', $bodyElementRenderer); $this->registerRenderer('address', $bodyElementRenderer); - $this->registerRenderer('b', $bodyElementRenderer); - $this->registerRenderer('bdo', $bodyElementRenderer); - $this->registerRenderer('big', $bodyElementRenderer); $this->registerRenderer('br', $bodyElementRenderer); - $this->registerRenderer('caption', $bodyElementRenderer); $this->registerRenderer('cite', $bodyElementRenderer); $this->registerRenderer('code', $bodyElementRenderer); - $this->registerRenderer('dd', $bodyElementRenderer); $this->registerRenderer('dfn', $bodyElementRenderer); $this->registerRenderer('div', $bodyElementRenderer); - $this->registerRenderer('dl', $bodyElementRenderer); - $this->registerRenderer('dt', $bodyElementRenderer); $this->registerRenderer('em', $bodyElementRenderer); $this->registerRenderer('h1', $bodyElementRenderer); $this->registerRenderer('h2', $bodyElementRenderer); @@ -80,26 +73,32 @@ public function __construct() $this->registerRenderer('h4', $bodyElementRenderer); $this->registerRenderer('h5', $bodyElementRenderer); $this->registerRenderer('h6', $bodyElementRenderer); - $this->registerRenderer('hr', $bodyElementRenderer); - $this->registerRenderer('i', $bodyElementRenderer); $this->registerRenderer('kbd', $bodyElementRenderer); - $this->registerRenderer('li', $bodyElementRenderer); - $this->registerRenderer('ol', $bodyElementRenderer); $this->registerRenderer('p', $bodyElementRenderer); $this->registerRenderer('pre', $bodyElementRenderer); $this->registerRenderer('samp', $bodyElementRenderer); - $this->registerRenderer('small', $bodyElementRenderer); $this->registerRenderer('span', $bodyElementRenderer); $this->registerRenderer('strong', $bodyElementRenderer); + $this->registerRenderer('var', $bodyElementRenderer); + $this->registerRenderer('dl', $bodyElementRenderer); + $this->registerRenderer('dt', $bodyElementRenderer); + $this->registerRenderer('dd', $bodyElementRenderer); + $this->registerRenderer('ol', $bodyElementRenderer); + $this->registerRenderer('ul', $bodyElementRenderer); + $this->registerRenderer('li', $bodyElementRenderer); + $this->registerRenderer('b', $bodyElementRenderer); + $this->registerRenderer('big', $bodyElementRenderer); + $this->registerRenderer('hr', $bodyElementRenderer); + $this->registerRenderer('i', $bodyElementRenderer); + $this->registerRenderer('small', $bodyElementRenderer); $this->registerRenderer('sub', $bodyElementRenderer); $this->registerRenderer('sup', $bodyElementRenderer); + $this->registerRenderer('tt', $bodyElementRenderer); + $this->registerRenderer('caption', $bodyElementRenderer); $this->registerRenderer('tbody', $bodyElementRenderer); $this->registerRenderer('tfoot', $bodyElementRenderer); $this->registerRenderer('thead', $bodyElementRenderer); $this->registerRenderer('tr', $bodyElementRenderer); - $this->registerRenderer('tt', $bodyElementRenderer); - $this->registerRenderer('ul', $bodyElementRenderer); - $this->registerRenderer('var', $bodyElementRenderer); // Both col and components elements can be rendered // by the ColRenderer. @@ -125,13 +124,12 @@ public function __construct() $this->registerRenderer('extendedTextInteraction', new ExtendedTextInteractionRenderer()); $this->registerRenderer('feedbackBlock', new FeedbackBlockRenderer()); $this->registerRenderer('feedbackInline', new FeedbackInlineRenderer()); - $this->registerRenderer(Figure::QTI_CLASS_NAME_FIGURE, new FigureRenderer()); - $this->registerRenderer(Figcaption::QTI_CLASS_NAME_FIGCAPTION, new FigcaptionRenderer()); + $this->registerRenderer(Figure::QTI_CLASS_NAME_FIGURE, new ExternalQtiComponentRenderer()); + $this->registerRenderer(Figcaption::QTI_CLASS_NAME_FIGCAPTION, new ExternalQtiComponentRenderer()); $this->registerRenderer('gap', new GapRenderer()); $this->registerRenderer('gapImg', new GapImgRenderer()); $this->registerRenderer('gapMatchInteraction', new GapMatchInteractionRenderer()); $this->registerRenderer('gapText', new GapTextRenderer()); - $this->registerRenderer('graphicAssociateInteraction', new GraphicAssociateInteractionRenderer()); $this->registerRenderer('graphicGapMatchInteraction', new GraphicGapMatchInteractionRenderer()); $this->registerRenderer('graphicOrderInteraction', new GraphicOrderInteractionRenderer()); $this->registerRenderer('hotspotChoice', new HotspotChoiceRenderer()); @@ -153,10 +151,10 @@ public function __construct() $this->registerRenderer('printedVariable', new PrintedVariableRenderer()); $this->registerRenderer('prompt', new PromptRenderer()); $this->registerRenderer('q', new QRenderer()); - $this->registerRenderer(Ruby::QTI_CLASS_NAME, new RubyRenderer()); - $this->registerRenderer(Rb::QTI_CLASS_NAME, new RbRenderer()); - $this->registerRenderer(Rt::QTI_CLASS_NAME, new RtRenderer()); - $this->registerRenderer(Rp::QTI_CLASS_NAME, new RpRenderer()); + $this->registerRenderer(Ruby::QTI_CLASS_NAME, new ExternalQtiComponentRenderer()); + $this->registerRenderer(Rb::QTI_CLASS_NAME, new ExternalQtiComponentRenderer()); + $this->registerRenderer(Rt::QTI_CLASS_NAME, new ExternalQtiComponentRenderer()); + $this->registerRenderer(Rp::QTI_CLASS_NAME, new ExternalQtiComponentRenderer()); $this->registerRenderer('rubricBlock', new RubricBlockRenderer()); $this->registerRenderer('selectPointInteraction', new SelectPointInteractionRenderer()); $this->registerRenderer('simpleAssociableChoice', new SimpleAssociableChoiceRenderer()); @@ -171,6 +169,5 @@ public function __construct() // External QTI Components. $this->registerRenderer('math', new MathRenderer()); - $this->registerRenderer('sub', new SsmlSubRenderer(), 'http://www.w3.org/2010/10/synthesis'); } } From a5df12f1a8a7ed1a00e456d3469eb1f0e8b9a173 Mon Sep 17 00:00:00 2001 From: Vitalii Shtykhno Date: Tue, 27 Sep 2022 13:16:23 +0200 Subject: [PATCH 11/13] test: provide correct exceptiong --- .../storage/xml/marshalling/Html5LayoutMarshallerTest.php | 3 ++- .../runtime/expressions/VariableProcessorTest.php | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/test/qtismtest/data/storage/xml/marshalling/Html5LayoutMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/Html5LayoutMarshallerTest.php index 80e2bea36..24c90f6f3 100644 --- a/test/qtismtest/data/storage/xml/marshalling/Html5LayoutMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/Html5LayoutMarshallerTest.php @@ -3,6 +3,7 @@ namespace qtismtest\data\storage\xml\marshalling; use DOMDocument; +use qtism\data\storage\xml\marshalling\MarshallerNotFoundException; use \RuntimeException; use qtism\data\content\FlowCollection; use qtism\data\content\TextRun; @@ -78,7 +79,7 @@ public function testMarshallerBelow2p2Fails(): void $figure = new Figure(); $figure->setContent(new FlowCollection([$figCaption])); - $this->expectException(RuntimeException::class); + $this->expectException(MarshallerNotFoundException::class); $this->expectExceptionMessage( "No marshaller implementation could be found for component 'figure'." ); diff --git a/test/qtismtest/runtime/expressions/VariableProcessorTest.php b/test/qtismtest/runtime/expressions/VariableProcessorTest.php index 3b69068a2..8f8ca62b3 100644 --- a/test/qtismtest/runtime/expressions/VariableProcessorTest.php +++ b/test/qtismtest/runtime/expressions/VariableProcessorTest.php @@ -105,12 +105,12 @@ public function testWeighted() $variableExpr = $this->createComponentFromXml(''); $variableProcessor->setExpression($variableExpr); $result = $variableProcessor->process(); - $this::assertEquals(11.11, $result[0]->getValue()); - $this::assertEquals(13.31, $result[1]->getValue()); + $this::assertEquals(11.11, round($result[0]->getValue(), 2)); + $this::assertEquals(13.31, round($result[1]->getValue(), 2)); // The value in the state must be unchanged. $stateVal = $assessmentTestSession['Q01.var2']; - $this::assertEquals(10.1, $stateVal[0]->getValue()); - $this::assertEquals(12.1, $stateVal[1]->getValue()); + $this::assertEquals(10.1, round($stateVal[0]->getValue(), 1)); + $this::assertEquals(12.1, round($stateVal[1]->getValue(), 1)); } public function testMultipleOccurences() From e6e726ba23033f147efae3bcdcc26b00e962fb78 Mon Sep 17 00:00:00 2001 From: Vitalii Shtykhno Date: Fri, 30 Sep 2022 13:25:27 +0200 Subject: [PATCH 12/13] test: update test use QTI constant --- .../markup/xhtml/XhtmlRenderingEngine.php | 85 +++++++++---------- .../data/content/xhtml/html5/RbTest.php | 4 +- .../data/content/xhtml/html5/RpTest.php | 4 +- .../data/content/xhtml/html5/RtTest.php | 4 +- .../data/content/xhtml/html5/RubyTest.php | 4 +- .../Html5ElementMarshallerTest.php | 2 +- 6 files changed, 55 insertions(+), 48 deletions(-) diff --git a/qtism/runtime/rendering/markup/xhtml/XhtmlRenderingEngine.php b/qtism/runtime/rendering/markup/xhtml/XhtmlRenderingEngine.php index f73cacd4d..a092e757f 100644 --- a/qtism/runtime/rendering/markup/xhtml/XhtmlRenderingEngine.php +++ b/qtism/runtime/rendering/markup/xhtml/XhtmlRenderingEngine.php @@ -23,10 +23,10 @@ namespace qtism\runtime\rendering\markup\xhtml; +use OAT\Library\QtiItemJsonCompilation\Rt; use qtism\data\content\xhtml\html5\Figcaption; use qtism\data\content\xhtml\html5\Figure; use qtism\data\content\xhtml\html5\Rb; -use qtism\data\content\xhtml\html5\Rt; use qtism\data\content\xhtml\html5\Rp; use qtism\data\content\xhtml\html5\Ruby; use qtism\runtime\rendering\markup\AbstractMarkupRenderingEngine; @@ -113,61 +113,60 @@ public function __construct() $this->registerRenderer('th', $tableCellRenderer); // Other bindings... + $this->registerRenderer('textRun', new TextRunRenderer()); $this->registerRenderer('a', new ARenderer()); - $this->registerRenderer('assessmentItem', new AssessmentItemRenderer()); - $this->registerRenderer('associableHotspot', new AssociableHotspotRenderer()); - $this->registerRenderer('associateInteraction', new AssociateInteractionRenderer()); $this->registerRenderer('blockquote', new BlockquoteRenderer()); - $this->registerRenderer('choiceInteraction', new ChoiceInteractionRenderer()); - $this->registerRenderer('drawingInteraction', new DrawingInteractionRenderer()); - $this->registerRenderer('endAttemptInteraction', new EndAttemptInteractionRenderer()); - $this->registerRenderer('extendedTextInteraction', new ExtendedTextInteractionRenderer()); - $this->registerRenderer('feedbackBlock', new FeedbackBlockRenderer()); - $this->registerRenderer('feedbackInline', new FeedbackInlineRenderer()); - $this->registerRenderer(Figure::QTI_CLASS_NAME_FIGURE, new ExternalQtiComponentRenderer()); - $this->registerRenderer(Figcaption::QTI_CLASS_NAME_FIGCAPTION, new ExternalQtiComponentRenderer()); - $this->registerRenderer('gap', new GapRenderer()); - $this->registerRenderer('gapImg', new GapImgRenderer()); - $this->registerRenderer('gapMatchInteraction', new GapMatchInteractionRenderer()); - $this->registerRenderer('gapText', new GapTextRenderer()); - $this->registerRenderer('graphicGapMatchInteraction', new GraphicGapMatchInteractionRenderer()); - $this->registerRenderer('graphicOrderInteraction', new GraphicOrderInteractionRenderer()); - $this->registerRenderer('hotspotChoice', new HotspotChoiceRenderer()); - $this->registerRenderer('hotspotInteraction', new HotspotInteractionRenderer()); - $this->registerRenderer('hottext', new HottextRenderer()); - $this->registerRenderer('hottextInteraction', new HottextInteractionRenderer()); $this->registerRenderer('img', new ImgRenderer()); - $this->registerRenderer('inlineChoice', new InlineChoiceRenderer()); - $this->registerRenderer('inlineChoiceInteraction', new InlineChoiceInteractionRenderer()); + $this->registerRenderer('object', new ObjectRenderer()); + $this->registerRenderer('param', new ParamRenderer()); + $this->registerRenderer('q', new QRenderer()); + $this->registerRenderer('stylesheet', new StylesheetRenderer()); $this->registerRenderer('itemBody', new ItemBodyRenderer()); - $this->registerRenderer('matchInteraction', new MatchInteractionRenderer()); - $this->registerRenderer('mediaInteraction', new MediaInteractionRenderer()); + $this->registerRenderer('prompt', new PromptRenderer()); + $this->registerRenderer('table', new TableRenderer()); + $this->registerRenderer('rubricBlock', new RubricBlockRenderer()); + $this->registerRenderer('feedbackInline', new FeedbackInlineRenderer()); + $this->registerRenderer('feedbackBlock', new FeedbackBlockRenderer()); $this->registerRenderer('modalFeedback', new ModalFeedbackRenderer()); - $this->registerRenderer('object', new ObjectRenderer()); + $this->registerRenderer('choiceInteraction', new ChoiceInteractionRenderer()); $this->registerRenderer('orderInteraction', new OrderInteractionRenderer()); - $this->registerRenderer('param', new ParamRenderer()); + $this->registerRenderer('associateInteraction', new AssociateInteractionRenderer()); + $this->registerRenderer('matchInteraction', new MatchInteractionRenderer()); + $this->registerRenderer('gapMatchInteraction', new GapMatchInteractionRenderer()); + $this->registerRenderer('inlineChoiceInteraction', new InlineChoiceInteractionRenderer()); + $this->registerRenderer('textEntryInteraction', new TextEntryInteractionRenderer()); + $this->registerRenderer('extendedTextInteraction', new ExtendedTextInteractionRenderer()); + $this->registerRenderer('hottextInteraction', new HottextInteractionRenderer()); + $this->registerRenderer('hotspotInteraction', new HotspotInteractionRenderer()); + $this->registerRenderer('selectPointInteraction', new SelectPointInteractionRenderer()); + $this->registerRenderer('graphicOrderInteraction', new GraphicOrderInteractionRenderer()); + $this->registerRenderer('graphicGapMatchInteraction', new GraphicGapMatchInteractionRenderer()); $this->registerRenderer('positionObjectInteraction', new PositionObjectInteractionRenderer()); + $this->registerRenderer('sliderInteraction', new SliderInteractionRenderer()); + $this->registerRenderer('mediaInteraction', new MediaInteractionRenderer()); + $this->registerRenderer('drawingInteraction', new DrawingInteractionRenderer()); + $this->registerRenderer('uploadInteraction', new UploadInteractionRenderer()); + $this->registerRenderer('endAttemptInteraction', new EndAttemptInteractionRenderer()); + $this->registerRenderer('simpleChoice', new SimpleChoiceRenderer()); + $this->registerRenderer('simpleAssociableChoice', new SimpleAssociableChoiceRenderer()); + $this->registerRenderer('inlineChoice', new InlineChoiceRenderer()); + $this->registerRenderer('simpleMatchSet', new SimpleMatchSetRenderer()); + $this->registerRenderer('hottext', new HottextRenderer()); + $this->registerRenderer('gapText', new GapTextRenderer()); + $this->registerRenderer('gapImg', new GapImgRenderer()); + $this->registerRenderer('gap', new GapRenderer()); + $this->registerRenderer('hotspotChoice', new HotspotChoiceRenderer()); + $this->registerRenderer('associableHotspot', new AssociableHotspotRenderer()); $this->registerRenderer('positionObjectStage', new PositionObjectStageRenderer()); + $this->registerRenderer('assessmentItem', new AssessmentItemRenderer()); $this->registerRenderer('printedVariable', new PrintedVariableRenderer()); - $this->registerRenderer('prompt', new PromptRenderer()); - $this->registerRenderer('q', new QRenderer()); + $this->registerRenderer(Figure::QTI_CLASS_NAME_FIGURE, new ExternalQtiComponentRenderer()); + $this->registerRenderer(Figcaption::QTI_CLASS_NAME_FIGCAPTION, new ExternalQtiComponentRenderer()); $this->registerRenderer(Ruby::QTI_CLASS_NAME, new ExternalQtiComponentRenderer()); $this->registerRenderer(Rb::QTI_CLASS_NAME, new ExternalQtiComponentRenderer()); - $this->registerRenderer(Rt::QTI_CLASS_NAME, new ExternalQtiComponentRenderer()); $this->registerRenderer(Rp::QTI_CLASS_NAME, new ExternalQtiComponentRenderer()); - $this->registerRenderer('rubricBlock', new RubricBlockRenderer()); - $this->registerRenderer('selectPointInteraction', new SelectPointInteractionRenderer()); - $this->registerRenderer('simpleAssociableChoice', new SimpleAssociableChoiceRenderer()); - $this->registerRenderer('simpleChoice', new SimpleChoiceRenderer()); - $this->registerRenderer('simpleMatchSet', new SimpleMatchSetRenderer()); - $this->registerRenderer('sliderInteraction', new SliderInteractionRenderer()); - $this->registerRenderer('stylesheet', new StylesheetRenderer()); - $this->registerRenderer('table', new TableRenderer()); - $this->registerRenderer('textEntryInteraction', new TextEntryInteractionRenderer()); - $this->registerRenderer('textRun', new TextRunRenderer()); - $this->registerRenderer('uploadInteraction', new UploadInteractionRenderer()); // External QTI Components. $this->registerRenderer('math', new MathRenderer()); } -} +} \ No newline at end of file diff --git a/test/qtismtest/data/content/xhtml/html5/RbTest.php b/test/qtismtest/data/content/xhtml/html5/RbTest.php index 49aa65284..923b1780c 100644 --- a/test/qtismtest/data/content/xhtml/html5/RbTest.php +++ b/test/qtismtest/data/content/xhtml/html5/RbTest.php @@ -27,6 +27,8 @@ class RbTest extends QtiSmTestCase { + public const SUBJECT_QTI_CLASS = 'rb'; + public function testCreateWithValues(): void { $id = 'testid'; @@ -50,6 +52,6 @@ public function testGetQtiClassName(): void { $subject = new Rb(); - self::assertEquals(Rb::QTI_CLASS_NAME, $subject->getQtiClassName()); + self::assertEquals(self::SUBJECT_QTI_CLASS, $subject->getQtiClassName()); } } diff --git a/test/qtismtest/data/content/xhtml/html5/RpTest.php b/test/qtismtest/data/content/xhtml/html5/RpTest.php index 07da33c70..e548e92cc 100644 --- a/test/qtismtest/data/content/xhtml/html5/RpTest.php +++ b/test/qtismtest/data/content/xhtml/html5/RpTest.php @@ -27,6 +27,8 @@ class RpTest extends QtiSmTestCase { + public const SUBJECT_QTI_CLASS = 'rp'; + public function testCreateWithValues(): void { $id = 'testid'; @@ -50,6 +52,6 @@ public function testGetQtiClassName(): void { $subject = new Rp(); - self::assertEquals(Rp::QTI_CLASS_NAME, $subject->getQtiClassName()); + self::assertEquals(self::SUBJECT_QTI_CLASS, $subject->getQtiClassName()); } } diff --git a/test/qtismtest/data/content/xhtml/html5/RtTest.php b/test/qtismtest/data/content/xhtml/html5/RtTest.php index 33f3b7e06..c6e034165 100644 --- a/test/qtismtest/data/content/xhtml/html5/RtTest.php +++ b/test/qtismtest/data/content/xhtml/html5/RtTest.php @@ -27,6 +27,8 @@ class RtTest extends QtiSmTestCase { + public const SUBJECT_QTI_CLASS = 'rt'; + public function testCreateWithValues(): void { $id = 'testid'; @@ -50,6 +52,6 @@ public function testGetQtiClassName(): void { $subject = new Rt(); - self::assertEquals(Rt::QTI_CLASS_NAME, $subject->getQtiClassName()); + self::assertEquals(self::SUBJECT_QTI_CLASS, $subject->getQtiClassName()); } } diff --git a/test/qtismtest/data/content/xhtml/html5/RubyTest.php b/test/qtismtest/data/content/xhtml/html5/RubyTest.php index 1e3c962b0..3226b331e 100644 --- a/test/qtismtest/data/content/xhtml/html5/RubyTest.php +++ b/test/qtismtest/data/content/xhtml/html5/RubyTest.php @@ -27,6 +27,8 @@ class RubyTest extends QtiSmTestCase { + public const SUBJECT_QTI_CLASS = 'ruby'; + public function testCreateWithValues(): void { $id = 'testid'; @@ -50,6 +52,6 @@ public function testGetQtiClassName(): void { $subject = new Ruby(); - self::assertEquals(Ruby::QTI_CLASS_NAME, $subject->getQtiClassName()); + self::assertEquals(self::SUBJECT_QTI_CLASS, $subject->getQtiClassName()); } } diff --git a/test/qtismtest/data/storage/xml/marshalling/Html5ElementMarshallerTest.php b/test/qtismtest/data/storage/xml/marshalling/Html5ElementMarshallerTest.php index 9a6a4cb3c..88626032a 100644 --- a/test/qtismtest/data/storage/xml/marshalling/Html5ElementMarshallerTest.php +++ b/test/qtismtest/data/storage/xml/marshalling/Html5ElementMarshallerTest.php @@ -297,4 +297,4 @@ protected function prefixTag(string $tagName): string { return self::HTML5_PREFIX . ':' . $tagName; } -} \ No newline at end of file +} From f02ab7fcbf7753e9b17b114c7b372cba08f2fe92 Mon Sep 17 00:00:00 2001 From: Vitalii Shtykhno Date: Fri, 30 Sep 2022 13:30:37 +0200 Subject: [PATCH 13/13] fix: remove extra elemnt add empty line --- qtism/data/storage/xml/marshalling/Qti22MarshallerFactory.php | 1 - qtism/runtime/rendering/markup/xhtml/XhtmlRenderingEngine.php | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/qtism/data/storage/xml/marshalling/Qti22MarshallerFactory.php b/qtism/data/storage/xml/marshalling/Qti22MarshallerFactory.php index 7f5dcbd2f..85a36a9b2 100644 --- a/qtism/data/storage/xml/marshalling/Qti22MarshallerFactory.php +++ b/qtism/data/storage/xml/marshalling/Qti22MarshallerFactory.php @@ -44,7 +44,6 @@ class Qti22MarshallerFactory extends MarshallerFactory public function __construct() { parent::__construct(); - $this->addMappingEntry('bdo', SimpleInlineMarshaller::class); $this->addMappingEntry(Figure::QTI_CLASS_NAME_FIGURE, Html5ContentMarshaller::class); $this->addMappingEntry(Figcaption::QTI_CLASS_NAME_FIGCAPTION, Html5ContentMarshaller::class); $this->addMappingEntry(Ruby::QTI_CLASS_NAME, Html5ContentMarshaller::class); diff --git a/qtism/runtime/rendering/markup/xhtml/XhtmlRenderingEngine.php b/qtism/runtime/rendering/markup/xhtml/XhtmlRenderingEngine.php index a092e757f..42ec91fe5 100644 --- a/qtism/runtime/rendering/markup/xhtml/XhtmlRenderingEngine.php +++ b/qtism/runtime/rendering/markup/xhtml/XhtmlRenderingEngine.php @@ -169,4 +169,4 @@ public function __construct() // External QTI Components. $this->registerRenderer('math', new MathRenderer()); } -} \ No newline at end of file +}