private function buildOptionCollection(choicematrix $question, $stemCount)
 {
     $optionIndexIdentifierMap = [];
     $optionCollection = new SimpleAssociableChoiceCollection();
     foreach ($question->get_options() as $key => $optionValue) {
         // Learnosity's `choicematrix` always have its options to have any number of associable choice, thus setting to stems count
         // Same as above, won't validate upon empty response, thus setting match min to 1
         $optionChoice = new SimpleAssociableChoice('OPTION_' . $key, $stemCount);
         $optionChoice->setMatchMin(1);
         $optionChoice->setContent(ContentCollectionBuilder::buildFlowStaticCollectionContent(QtiMarshallerUtil::unmarshallElement($optionValue)));
         $optionCollection->attach($optionChoice);
         $optionIndexIdentifierMap[$key] = $optionChoice->getIdentifier();
     }
     return [$optionCollection, $optionIndexIdentifierMap];
 }
 public function getQuestionType()
 {
     /* @var QtiMatchInteraction $interaction */
     $interaction = $this->interaction;
     if ($interaction->mustShuffle()) {
         LogService::log('Shuffle attribute is not supported');
     }
     $simpleMatchSetCollection = $interaction->getSimpleMatchSets();
     $stems = $this->buildOptions($simpleMatchSetCollection[0], $this->stemMapping);
     $options = $this->buildOptions($simpleMatchSetCollection[1], $this->optionsMapping);
     // Build validation
     $validationBuilder = new MatchInteractionValidationBuilder($this->stemMapping, $this->optionsMapping, $this->responseDeclaration);
     $validation = $validationBuilder->buildValidation($this->responseProcessingTemplate);
     if ($interaction->getMaxAssociations() !== count($stems)) {
         LogService::log('Max Association number not equals to number of stems is not supported');
     }
     $uiStyle = new choicematrix_ui_style();
     $uiStyle->set_type('table');
     $isMultipleResponse = $this->isMultipleResponse($interaction);
     $question = new choicematrix('choicematrix', $options, $stems);
     $question->set_multiple_responses($isMultipleResponse);
     $question->set_stimulus($this->getPrompt());
     $question->set_ui_style($uiStyle);
     if ($validation) {
         $question->set_validation($validation);
     }
     return $question;
 }
 private function buildSimpleChoiceMatrixQuestion()
 {
     $question = new choicematrix('choicematrix', ["Option 1", "Option 2", "Option 3"], ["Stem 1", "Stem 2"]);
     $question->set_multiple_responses(false);
     $question->set_stimulus('My stimulus string');
     return $question;
 }