public function testMappingSimpleQuestionWithNoValidation() { $placeholder = 'placeholdertest'; $stimulus = '<strong>stimulushere</strong>'; $questionReference = 'questionReferenceOne'; $question = new longtext('longtext'); $question->set_placeholder($placeholder); $question->set_stimulus($stimulus); $mapper = new LongtextMapper(); /** @var ExtendedTextInteraction $interaction */ list($interaction, $responseDeclaration, $responseProcessing) = $mapper->convert($question, $questionReference, $questionReference); // No validation shall be mapped for longtext $this->assertNull($responseDeclaration); $this->assertNull($responseProcessing); // Assert question mapped correctly to ExtendedTextInteraction $this->assertTrue($interaction instanceof ExtendedTextInteraction); $this->assertEquals($questionReference, $interaction->getResponseIdentifier()); $this->assertEquals($questionReference, $interaction->getLabel()); $this->assertEquals($stimulus, QtiMarshallerUtil::marshallCollection($interaction->getPrompt()->getComponents())); $this->assertEquals($placeholder, $interaction->getPlaceholderText()); // Assert question mapped correctly with default values $this->assertEquals(TextFormat::XHTML, $interaction->getFormat()); $this->assertEquals(1, $interaction->getMinStrings()); $this->assertEquals(1, $interaction->getMaxStrings()); }
public function getQuestionType() { /* @var QtiExtendedTextInteraction $interaction */ $interaction = $this->interaction; $longtext = new longtext('longtext'); LogService::log('No validation mapping supported for this interaction. Ignoring any ' . '<responseProcessing> and <responseDeclaration> if any'); if (!empty($interaction->getPrompt())) { $promptContent = $interaction->getPrompt()->getContent(); $longtext->set_stimulus(QtiMarshallerUtil::marshallCollection($promptContent)); } if ($interaction->getPlaceholderText()) { $longtext->set_placeholder($interaction->getPlaceholderText()); } /** As per QTI spec * When multiple strings are accepted, expectedLength applies to each string. * `expectedLength` works as a only as a 'hint' to student so we do not want to force a hard limit */ if ($interaction->getExpectedLength() > 0) { $maxStrings = $interaction->getMaxStrings() > 0 ? $interaction->getMaxStrings() : 1; $expectedLength = $interaction->getExpectedLength() / 5; $longtext->set_max_length($maxStrings * $expectedLength); $longtext->set_submit_over_limit(true); } return $longtext; }