public function convert(BaseQuestionType $questionType, $interactionIdentifier, $interactionLabel)
 {
     /** @var orderlist $question */
     $question = $questionType;
     $simpleChoiceCollection = new SimpleChoiceCollection();
     $indexIdentifiersMap = [];
     foreach ($question->get_list() as $key => $item) {
         $simpleChoice = new SimpleChoice('CHOICE_' . $key);
         $choiceContent = new FlowStaticCollection();
         foreach (QtiMarshallerUtil::unmarshallElement($item) as $component) {
             $choiceContent->attach($component);
         }
         $simpleChoice->setContent($choiceContent);
         $simpleChoiceCollection->attach($simpleChoice);
         $indexIdentifiersMap[$key] = $simpleChoice->getIdentifier();
     }
     $interaction = new OrderInteraction($interactionIdentifier, $simpleChoiceCollection);
     $interaction->setLabel($interactionLabel);
     $interaction->setPrompt($this->convertStimulusForPrompt($question->get_stimulus()));
     $interaction->setShuffle(false);
     $interaction->setOrientation(Orientation::VERTICAL);
     $builder = new OrderlistValidationBuilder($indexIdentifiersMap);
     list($responseDeclaration, $responseProcessing) = $builder->buildValidation($interactionIdentifier, $question->get_validation());
     return [$interaction, $responseDeclaration, $responseProcessing];
 }
 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 OrderInteraction('RESPONSE', $choices);
     $prompt = new Prompt();
     $prompt->setContent(new FlowStaticCollection(array(new TextRun('Prompt...'))));
     $component->setPrompt($prompt);
     $component->setMinChoices(1);
     $component->setMaxChoices(2);
     $marshaller = $this->getMarshallerFactory()->createMarshaller($component);
     $element = $marshaller->marshall($component);
     $dom = new DOMDocument('1.0', 'UTF-8');
     $element = $dom->importNode($element, true);
     $this->assertEquals('<orderInteraction responseIdentifier="RESPONSE" maxChoices="2" minChoices="1"><prompt>Prompt...</prompt><simpleChoice identifier="choice_1">Choice #1</simpleChoice><simpleChoice identifier="choice_2">Choice #2</simpleChoice></orderInteraction>', $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;
 }