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];
 }
Beispiel #2
0
 public function testCreateShufflingFromOrder()
 {
     $choiceCollection = new SimpleChoiceCollection();
     $choiceCollection[] = new SimpleChoice('id1');
     $choiceCollection[] = new SimpleChoice('id2');
     $choiceCollection[] = new SimpleChoice('id3');
     $orderInteraction = new OrderInteraction('RESPONSE', $choiceCollection);
     $orderInteraction->setShuffle(true);
     $shuffling = StateUtils::createShufflingFromInteraction($orderInteraction);
     $this->assertEquals('RESPONSE', $shuffling->getResponseIdentifier());
     $shufflingGroups = $shuffling->getShufflingGroups();
     $this->assertEquals(1, count($shufflingGroups));
     $this->assertEquals(array('id1', 'id2', 'id3'), $shufflingGroups[0]->getIdentifiers()->getArrayCopy());
 }