public function testMarshallNoOutputMinStringsFormat20() { // Make sure minStrings and format attributes are never // in the output in a QTI 2.0 context. $extendedTextInteraction = new ExtendedTextInteraction('RESPONSE'); $extendedTextInteraction->setMinStrings(2); $extendedTextInteraction->setFormat(TextFormat::PRE_FORMATTED); $element = $this->getMarshallerFactory('2.0.0')->createMarshaller($extendedTextInteraction)->marshall($extendedTextInteraction); $dom = new DOMDocument('1.0', 'UTF-8'); $element = $dom->importNode($element, true); $this->assertEquals('<extendedTextInteraction responseIdentifier="RESPONSE"/>', $dom->saveXML($element)); }
public function convert(BaseQuestionType $questionType, $interactionIdentifier, $interactionLabel) { /** @var longtext $question */ $question = $questionType; $interaction = new ExtendedTextInteraction($interactionIdentifier); $interaction->setLabel($interactionLabel); $interaction->setPrompt($this->convertStimulusForPrompt($question->get_stimulus())); $interaction->setFormat(TextFormat::XHTML); $interaction->setMinStrings(1); $interaction->setMaxStrings(1); $placeholderText = $question->get_placeholder(); if (!empty($placeholderText)) { $interaction->setPlaceholderText($placeholderText); } return [$interaction, null, null]; }
public function testMarshallMaximal() { $extendedTextInteraction = new ExtendedTextInteraction('RESPONSE'); $extendedTextInteraction->setBase(2); $extendedTextInteraction->setStringIdentifier('mystring'); $extendedTextInteraction->setExpectedLength(35); $extendedTextInteraction->setPatternMask('[0-9]+'); $extendedTextInteraction->setPlaceholderText('input here...'); $extendedTextInteraction->setMinStrings(2); $extendedTextInteraction->setMaxStrings(10); $extendedTextInteraction->setExpectedLines(1); $extendedTextInteraction->setFormat(TextFormat::PRE_FORMATTED); $element = $this->getMarshallerFactory()->createMarshaller($extendedTextInteraction)->marshall($extendedTextInteraction); $dom = new DOMDocument('1.0', 'UTF-8'); $element = $dom->importNode($element, true); $this->assertEquals('<extendedTextInteraction responseIdentifier="RESPONSE" base="2" stringIdentifier="mystring" expectedLength="35" patternMask="[0-9]+" placeholderText="input here..." maxStrings="10" minStrings="2" expectedLines="1" format="preFormatted"/>', $dom->saveXML($element)); }