private static function buildSimpleMatchSet(array $matchSets, $matchMax) { $matchChoiceAssociation = new SimpleAssociableChoiceCollection(); foreach ($matchSets as $identifier => $value) { $choice = new SimpleAssociableChoice($identifier, $matchMax); $contentCollection = new FlowStaticCollection(); $contentCollection->attach(new TextRun($value)); $choice->setContent($contentCollection); $matchChoiceAssociation->attach($choice); } return new SimpleMatchSet($matchChoiceAssociation); }
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]; }