public function getQuestionType()
 {
     /** @var QtiGapMatchInteraction $interaction */
     $interaction = $this->interaction;
     $possibleResponseMapping = $this->buildPossibleResponseMapping($interaction);
     list($template, $gapIdentifiers) = $this->buildTemplate($interaction);
     $question = new clozeassociation('clozeassociation', $template, array_values($possibleResponseMapping));
     $container = new clozeassociation_response_container();
     $question->set_response_container($container);
     if ($interaction->getPrompt() instanceof Prompt) {
         $promptContent = $interaction->getPrompt()->getContent();
         $question->set_stimulus(QtiMarshallerUtil::marshallCollection($promptContent));
     }
     $validationBuilder = new GapMatchInteractionValidationBuilder('clozeassociation', $gapIdentifiers, $possibleResponseMapping, $this->responseDeclaration);
     $validation = $validationBuilder->buildValidation($this->responseProcessingTemplate);
     if ($validation) {
         $question->set_validation($validation);
     }
     $question->set_duplicate_responses($validationBuilder->isDuplicatedResponse());
     return $question;
 }
 public function getQuestionType()
 {
     /** @var QtiGraphicGapMatchInteraction $interaction */
     $interaction = $this->interaction;
     /** @var Object $imageObject */
     $imageObject = $interaction->getObject();
     // Yes, width and height is necessary unfortunately
     if ($imageObject->getHeight() < 0 || $imageObject->getWidth() < 0) {
         throw new MappingException('Hotspot interaction image object need to specifiy both width and height for conversion');
     }
     $possibleResponseMapping = $this->buildPossibleResponseMapping($interaction);
     $associableHotspots = $this->buildTemplate($interaction, $imageObject);
     $image = new imageclozeassociation_image();
     $image->set_src($imageObject->getData());
     $responseContainers = [];
     $responsePosition = [];
     foreach ($associableHotspots as $associableHotspot) {
         $responsePosition[] = ['x' => $associableHotspot['x'], 'y' => $associableHotspot['y']];
         $responseContainer = new imageclozedropdown_response_containers_item();
         $responseContainer->set_height($associableHotspot['height'] . 'px');
         $responseContainer->set_width($associableHotspot['width'] . 'px');
         $responseContainers[] = $responseContainer;
     }
     $question = new imageclozeassociation($image, $responsePosition, 'imageclozeassociation', array_values($possibleResponseMapping));
     $question->set_response_containers($responseContainers);
     $question->set_stimulus($this->getPrompt());
     // Build dah` validation
     $hotspotIdentifiers = array_keys($associableHotspots);
     $validationBuilder = new GapMatchInteractionValidationBuilder('imageclozeassociation', $hotspotIdentifiers, $possibleResponseMapping, $this->responseDeclaration);
     $validation = $validationBuilder->buildValidation($this->responseProcessingTemplate);
     if ($validation) {
         $question->set_validation($validation);
     }
     $question->set_duplicate_responses($validationBuilder->isDuplicatedResponse());
     return $question;
 }