public function getQuestionType() { /* @var \qtism\data\content\interactions\InlineChoiceInteraction $interaction */ $interaction = $this->validateInteraction($this->interaction); $template = '{{response}}'; foreach ($interaction->getContent() as $inlineChoice) { $this->choicesMapping[$inlineChoice->getIdentifier()] = QtiMarshallerUtil::marshallCollection($inlineChoice->getContent()); } $question = new clozedropdown('clozedropdown', $template, [array_values($this->choicesMapping)]); $validation = $this->buildValidation(); if ($validation) { $question->set_validation($validation); } return $question; }
public function getQuestionType() { $interactionComponents = $this->itemBody->getComponentsByClassName('inlineChoiceInteraction', true); $interactionXmls = []; $possibleResponsesMap = []; foreach ($interactionComponents as $component) { /** @var Interaction $component */ $interactionXmls[] = QtiMarshallerUtil::marshall($component); /** @var InlineChoice $inlineChoice */ foreach ($component->getComponents() as $inlineChoice) { $possibleResponsesMap[$component->getResponseIdentifier()][$inlineChoice->getIdentifier()] = QtiMarshallerUtil::marshallCollection($inlineChoice->getContent()); } } $template = $this->buildTemplate($this->itemBody, $interactionXmls); $clozedropdown = new clozedropdown('clozedropdown', $template, array_values(array_map('array_values', $possibleResponsesMap))); $validationBuilder = new InlineChoiceInteractionValidationBuilder($this->responseDeclarations, $possibleResponsesMap); // Build `validation` $validation = $validationBuilder->buildValidation($this->responseProcessingTemplate); if (!empty($validation)) { $clozedropdown->set_validation($validation); } return $clozedropdown; }