protected function convertStimulusForPrompt($stimulusString) { $stimulusComponents = QtiMarshallerUtil::unmarshallElement($stimulusString); $prompt = new Prompt(); $prompt->setContent(ContentCollectionBuilder::buildFlowStaticCollectionContent($stimulusComponents)); return $prompt; }
private function buildExtendedTextInteraction($identifier) { $prompt = new Prompt(); $collection = new FlowStaticCollection(); $collection->attach(new TextRun('Please describe yourself in few words')); $prompt->setContent($collection); $interaction = new ExtendedTextInteraction($identifier); $interaction->setPrompt($prompt); return $interaction; }
private function buildHottextInteraction($responseIdentifier) { $interaction = HottextInteractionBuilder::buildSimple($responseIdentifier, ['Hello, my name ', ['A' => 'are'], ' James. I ', ['B' => 'have'], ' five brothers. and all of them ', ['C' => 'is'], ' girls.']); $prompt = new Prompt(); $promptCollection = new FlowStaticCollection(); $promptCollection->attach(new TextRun('Select the error in the following passage of text')); $prompt->setContent($promptCollection); $interaction->setPrompt($prompt); return $interaction; }
public function testMarshall() { $component = new Prompt('my-prompt', 'qti-prompt'); $component->setContent(new FlowStaticCollection(array(new TextRun('This is a prompt')))); $marshaller = $this->getMarshallerFactory('2.1.0')->createMarshaller($component); $element = $marshaller->marshall($component); $dom = new DOMDocument('1.0', 'UTF-8'); $element = $dom->importNode($element, true); $this->assertEquals('<prompt id="my-prompt" class="qti-prompt">This is a prompt</prompt>', $dom->saveXML($element)); }
public function testMarshall() { $uploadInteraction = new UploadInteraction('RESPONSE', 'my-upload'); $prompt = new Prompt(); $prompt->setContent(new FlowStaticCollection(array(new TextRun('Prompt...')))); $uploadInteraction->setPrompt($prompt); $element = $this->getMarshallerFactory('2.1.0')->createMarshaller($uploadInteraction)->marshall($uploadInteraction); $dom = new DOMDocument('1.0', 'UTF-8'); $element = $dom->importNode($element, true); $this->assertEquals('<uploadInteraction id="my-upload" responseIdentifier="RESPONSE"><prompt>Prompt...</prompt></uploadInteraction>', $dom->saveXML($element)); }
public function testMarshall() { $object = new Object('my-canvas.png', 'image/png'); $drawingInteraction = new DrawingInteraction('RESPONSE', $object, 'my-drawings', 'draw-it'); $prompt = new Prompt(); $prompt->setContent(new FlowStaticCollection(array(new TextRun('Prompt...')))); $drawingInteraction->setPrompt($prompt); $element = $this->getMarshallerFactory('2.1.0')->createMarshaller($drawingInteraction)->marshall($drawingInteraction); $dom = new DOMDocument('1.0', 'UTF-8'); $element = $dom->importNode($element, true); $this->assertEquals('<drawingInteraction id="my-drawings" class="draw-it" responseIdentifier="RESPONSE"><prompt>Prompt...</prompt><object data="my-canvas.png" type="image/png"/></drawingInteraction>', $dom->saveXML($element)); }
public function testMarshall() { $object = new Object('./myimg.png', 'image/png'); $prompt = new Prompt(); $prompt->setContent(new FlowStaticCollection(array(new TextRun('Prompt...')))); $selectPointInteraction = new SelectPointInteraction('RESPONSE', $object, 1); $selectPointInteraction->setPrompt($prompt); $element = $this->getMarshallerFactory()->createMarshaller($selectPointInteraction)->marshall($selectPointInteraction); $dom = new DOMDocument('1.0', 'UTF-8'); $element = $dom->importNode($element, true); $this->assertEquals('<selectPointInteraction responseIdentifier="RESPONSE" maxChoices="1"><prompt>Prompt...</prompt><object data="./myimg.png" type="image/png"/></selectPointInteraction>', $dom->saveXML($element)); }
public function testMarshall() { $sliderInteraction = new SliderInteraction('RESPONSE', 0.0, 100.0, 'my-slider', 'slide-it'); $sliderInteraction->setStep(1); $sliderInteraction->setStepLabel(true); $sliderInteraction->setOrientation(Orientation::VERTICAL); $sliderInteraction->setReverse(true); $prompt = new Prompt(); $prompt->setContent(new FlowStaticCollection(array(new TextRun('Prompt...')))); $sliderInteraction->setPrompt($prompt); $element = $this->getMarshallerFactory('2.1.0')->createMarshaller($sliderInteraction)->marshall($sliderInteraction); $dom = new DOMDocument('1.0', 'UTF-8'); $element = $dom->importNode($element, true); $this->assertEquals('<sliderInteraction id="my-slider" class="slide-it" responseIdentifier="RESPONSE" lowerBound="0" upperBound="100" step="1" stepLabel="true" orientation="vertical" reverse="true"><prompt>Prompt...</prompt></sliderInteraction>', $dom->saveXML($element)); }
public function testMarshall() { $prompt = new Prompt(); $prompt->setContent(new FlowStaticCollection(array(new TextRun('Prompt...')))); $choice1 = new HotspotChoice('hotspotchoice1', Shape::CIRCLE, new Coords(Shape::CIRCLE, array(77, 115, 8))); $choice2 = new HotspotChoice('hotspotchoice2', Shape::CIRCLE, new Coords(Shape::CIRCLE, array(118, 184, 8))); $choice3 = new HotspotChoice('hotspotchoice3', Shape::CIRCLE, new Coords(Shape::CIRCLE, array(150, 235, 8))); $object = new Object('./img/img.png', 'image/png'); $hotspotInteraction = new HotspotInteraction('RESPONSE', $object, 1, new HotspotChoiceCollection(array($choice1, $choice2, $choice3)), 'my-hotspot'); $hotspotInteraction->setPrompt($prompt); $element = $this->getMarshallerFactory()->createMarshaller($hotspotInteraction)->marshall($hotspotInteraction); $dom = new DOMDocument('1.0', 'UTF-8'); $element = $dom->importNode($element, true); $this->assertEquals('<hotspotInteraction id="my-hotspot" responseIdentifier="RESPONSE" maxChoices="1"><prompt>Prompt...</prompt><object data="./img/img.png" type="image/png"/><hotspotChoice identifier="hotspotchoice1" shape="circle" coords="77,115,8"/><hotspotChoice identifier="hotspotchoice2" shape="circle" coords="118,184,8"/><hotspotChoice identifier="hotspotchoice3" shape="circle" coords="150,235,8"/></hotspotInteraction>', $dom->saveXML($element)); }
public function testMarshall() { $object = new Object('myimg.jpg', 'image/jpeg'); $object->setWidth(400); $object->setHeight(300); $prompt = new Prompt(); $prompt->setContent(new FlowStaticCollection(array(new TextRun('Prompt...')))); $positionObjectInteraction = new PositionObjectInteraction('RESPONSE', $object, 'my-pos'); $positionObjectInteraction->setCenterPoint(new Point(150, 74)); $positionObjectInteraction->setMaxChoices(2); $positionObjectInteraction->setMinChoices(1); $element = $this->getMarshallerFactory()->createMarshaller($positionObjectInteraction)->marshall($positionObjectInteraction); $dom = new DOMDocument('1.0', 'UTF-8'); $element = $dom->importNode($element, true); $this->assertEquals('<positionObjectInteraction responseIdentifier="RESPONSE" maxChoices="2" minChoices="1" centerPoint="150 74" id="my-pos"><object data="myimg.jpg" type="image/jpeg" width="400" height="300"/></positionObjectInteraction>', $dom->saveXML($element)); }
public function testMarshall() { $hottext = new Hottext('hottext1'); $hottext->setContent(new InlineStaticCollection(array(new TextRun('hot')))); $div = new Div(); $div->setContent(new FlowCollection(array(new TextRun('This is a '), new Hottext('hot1'), new TextRun(' text...')))); $content = new BlockStaticCollection(array($div)); $hottextInteraction = new HottextInteraction('RESPONSE', $content); $prompt = new Prompt(); $prompt->setContent(new FlowStaticCollection(array(new TextRun('Prompt...')))); $hottextInteraction->setPrompt($prompt); $element = $this->getMarshallerFactory()->createMarshaller($hottextInteraction)->marshall($hottextInteraction); $dom = new DOMDocument('1.0', 'UTF-8'); $element = $dom->importNode($element, true); $this->assertEquals('<hottextInteraction responseIdentifier="RESPONSE"><prompt>Prompt...</prompt><div>This is a <hottext identifier="hot1"/> text...</div></hottextInteraction>', $dom->saveXML($element)); }
public function testMarshall() { $prompt = new Prompt(); $prompt->setContent(new FlowStaticCollection(array(new TextRun('Prompt...')))); $object = new Object('myimg.png', 'image/png'); $choice1 = new AssociableHotspot('choice1', 2, Shape::CIRCLE, new Coords(Shape::CIRCLE, array(0, 0, 15))); $choice1->setMatchMin(1); $choice2 = new AssociableHotspot('choice2', 1, Shape::CIRCLE, new Coords(Shape::CIRCLE, array(2, 2, 15))); $choice3 = new AssociableHotspot('choice3', 1, Shape::CIRCLE, new Coords(Shape::CIRCLE, array(4, 4, 15))); $choices = new AssociableHotspotCollection(array($choice1, $choice2, $choice3)); $graphicAssociateInteraction = new GraphicAssociateInteraction('RESPONSE', $object, $choices, 'prout'); $graphicAssociateInteraction->setPrompt($prompt); $element = $this->getMarshallerFactory()->createMarshaller($graphicAssociateInteraction)->marshall($graphicAssociateInteraction); $dom = new DOMDocument('1.0', 'UTF-8'); $element = $dom->importNode($element, true); $this->assertEquals('<graphicAssociateInteraction id="prout" responseIdentifier="RESPONSE"><prompt>Prompt...</prompt><object data="myimg.png" type="image/png"/><associableHotspot identifier="choice1" shape="circle" coords="0,0,15" matchMax="2" matchMin="1"/><associableHotspot identifier="choice2" shape="circle" coords="2,2,15" matchMax="1"/><associableHotspot identifier="choice3" shape="circle" coords="4,4,15" matchMax="1"/></graphicAssociateInteraction>', $dom->saveXML($element)); }
public function testMarshall() { $object = new Object('my-video.mp4', 'video/mp4'); $object->setWidth(400); $object->setHeight(300); $mediaInteraction = new MediaInteraction('RESPONSE', false, $object, 'my-media'); $mediaInteraction->setMinPlays(1); $mediaInteraction->setMaxPlays(2); $mediaInteraction->setLoop(true); $prompt = new Prompt(); $prompt->setContent(new FlowStaticCollection(array(new TextRun('Prompt...')))); $mediaInteraction->setPrompt($prompt); $element = $this->getMarshallerFactory('2.1.0')->createMarshaller($mediaInteraction)->marshall($mediaInteraction); $dom = new DOMDocument('1.0', 'UTF-8'); $element = $dom->importNode($element, true); $this->assertEquals('<mediaInteraction id="my-media" responseIdentifier="RESPONSE" autostart="false" minPlays="1" maxPlays="2" loop="true"><prompt>Prompt...</prompt><object data="my-video.mp4" type="video/mp4" width="400" height="300"/></mediaInteraction>', $dom->saveXML($element)); }
public function testMarshall() { $choice1 = new SimpleChoice('choice_1'); $choice1->setContent(new FlowStaticCollection(array(new TextRun('Choice #1')))); $choice2 = new SimpleChoice('choice_2'); $choice2->setContent(new FlowStaticCollection(array(new TextRun('Choice #2')))); $choices = new SimpleChoiceCollection(array($choice1, $choice2)); $component = new ChoiceInteraction('RESPONSE', $choices); $prompt = new Prompt(); $prompt->setContent(new FlowStaticCollection(array(new TextRun('Prompt...')))); $component->setPrompt($prompt); $marshaller = $this->getMarshallerFactory()->createMarshaller($component); $element = $marshaller->marshall($component); $dom = new DOMDocument('1.0', 'UTF-8'); $element = $dom->importNode($element, true); $this->assertEquals('<choiceInteraction responseIdentifier="RESPONSE"><prompt>Prompt...</prompt><simpleChoice identifier="choice_1">Choice #1</simpleChoice><simpleChoice identifier="choice_2">Choice #2</simpleChoice></choiceInteraction>', $dom->saveXML($element)); }
public function testMarshall21() { $prompt = new Prompt(); $prompt->setContent(new FlowStaticCollection(array(new TextRun('Prompt...')))); $choice1 = new HotspotChoice('choice1', QtiShape::CIRCLE, new QtiCoords(QtiShape::CIRCLE, array(0, 0, 15))); $choice2 = new HotspotChoice('choice2', QtiShape::CIRCLE, new QtiCoords(QtiShape::CIRCLE, array(2, 2, 15))); $choice3 = new HotspotChoice('choice3', QtiShape::CIRCLE, new QtiCoords(QtiShape::CIRCLE, array(4, 4, 15))); $choices = new HotspotChoiceCollection(array($choice1, $choice2, $choice3)); $object = new Object('my-img.png', 'image/png'); $graphicOrderInteraction = new GraphicOrderInteraction('RESPONSE', $object, $choices, 'my-graphicOrder'); $graphicOrderInteraction->setPrompt($prompt); $graphicOrderInteraction->setMinChoices(2); $graphicOrderInteraction->setMaxChoices(3); $element = $this->getMarshallerFactory('2.1.0')->createMarshaller($graphicOrderInteraction)->marshall($graphicOrderInteraction); $dom = new DOMDocument('1.0', 'UTF-8'); $element = $dom->importNode($element, true); $this->assertEquals('<graphicOrderInteraction id="my-graphicOrder" responseIdentifier="RESPONSE" minChoices="2" maxChoices="3"><prompt>Prompt...</prompt><object data="my-img.png" type="image/png"/><hotspotChoice identifier="choice1" shape="circle" coords="0,0,15"/><hotspotChoice identifier="choice2" shape="circle" coords="2,2,15"/><hotspotChoice identifier="choice3" shape="circle" coords="4,4,15"/></graphicOrderInteraction>', $dom->saveXML($element)); }
public static function buildOrderInteraction($identifier, $choices, $promptText = null) { $simpleChoiceCollection = new SimpleChoiceCollection(); foreach ($choices as $identifier => $value) { $simpleChoice = new SimpleChoice($identifier); $contentCollection = new FlowStaticCollection(); $contentCollection->attach(new TextRun($value)); $simpleChoice->setContent($contentCollection); $simpleChoiceCollection->attach($simpleChoice); } $orderInteraction = new OrderInteraction($identifier, $simpleChoiceCollection); if ($promptText) { $prompt = new Prompt(); $contentCollection = new FlowStaticCollection(); $contentCollection->attach(new TextRun($promptText)); $prompt->setContent($contentCollection); $orderInteraction->setPrompt($prompt); } return $orderInteraction; }
public function testMarshall() { $choice1A = new SimpleAssociableChoice('choice1A', 1); $choice1A->setContent(new FlowStaticCollection(array(new TextRun('choice1A')))); $choice1B = new SimpleAssociableChoice('choice1B', 1); $choice1B->setContent(new FlowStaticCollection(array(new TextRun('choice1B')))); $choice2A = new SimpleAssociableChoice('choice2A', 1); $choice2A->setContent(new FlowStaticCollection(array(new TextRun('choice2A')))); $choice2B = new SimpleAssociableChoice('choice2B', 1); $choice2B->setContent(new FlowStaticCollection(array(new TextRun('choice2B')))); $set1 = new SimpleMatchSet(new SimpleAssociableChoiceCollection(array($choice1A, $choice1B))); $set2 = new SimpleMatchSet(new SimpleAssociableChoiceCollection(array($choice2A, $choice2B))); $matchInteraction = new MatchInteraction('RESPONSE', new SimpleMatchSetCollection(array($set1, $set2))); $prompt = new Prompt(); $prompt->setContent(new FlowStaticCollection(array(new TextRun('Prompt...')))); $matchInteraction->setPrompt($prompt); $matchInteraction->setShuffle(true); $marshaller = $this->getMarshallerFactory()->createMarshaller($matchInteraction); $element = $marshaller->marshall($matchInteraction); $dom = new DOMDocument('1.0', 'UTF-8'); $element = $dom->importNode($element, true); $this->assertEquals('<matchInteraction responseIdentifier="RESPONSE" shuffle="true"><prompt>Prompt...</prompt><simpleMatchSet><simpleAssociableChoice identifier="choice1A" matchMax="1">choice1A</simpleAssociableChoice><simpleAssociableChoice identifier="choice1B" matchMax="1">choice1B</simpleAssociableChoice></simpleMatchSet><simpleMatchSet><simpleAssociableChoice identifier="choice2A" matchMax="1">choice2A</simpleAssociableChoice><simpleAssociableChoice identifier="choice2B" matchMax="1">choice2B</simpleAssociableChoice></simpleMatchSet></matchInteraction>', $dom->saveXML($element)); }
public function testPrompt() { $interaction = ChoiceInteractionBuilder::buildSimple('testIdentifier', ['choiceA' => 'Choice A']); $prompt = new Prompt(); $promptContent = new FlowStaticCollection(); $promptContent->attach(new TextRun('Test')); $htmlCollection = new InlineCollection(); $htmlCollection->attach(new TextRun('123')); $p = new P(); $p->setContent($htmlCollection); $promptContent->attach($p); $prompt->setContent($promptContent); $interaction->setPrompt($prompt); $interactionMapper = new ChoiceInteractionMapper($interaction); $questionType = $interactionMapper->getQuestionType(); $this->assertTrue($questionType->get_stimulus() === 'Test<p>123</p>'); }