protected function buildTemplate(QtiGraphicGapMatchInteraction $interaction, Object $object) { $associableHotspots = []; foreach ($interaction->getAssociableHotspots() as $associableHotspot) { /** @var AssociableHotspot $associableHotspot */ $associableHotspots[$associableHotspot->getIdentifier()] = QtiCoordinateUtil::convertQtiCoordsToPercentage([$object->getWidth(), $object->getHeight()], explode(',', $associableHotspot->getCoords()), $associableHotspot->getShape()); } return $associableHotspots; }
private function buildAssociableHotspotCollection(array $responsePositions, $imageObjectWidth, $imageObjectHeight) { $associableHotspotCollection = new AssociableHotspotCollection(); foreach ($responsePositions as $index => $responsePosition) { // Let's just make an assumption these images will have width of 100px and height of 20px $rectangleWidth = 100; $rectangleHeight = 20; $coords = QtiCoordinateUtil::convertPercentageToQtiCoords($responsePosition, $imageObjectWidth, $imageObjectHeight, $rectangleWidth, $rectangleHeight); $associableHotspot = new AssociableHotspot(self::ASSOCIABLEHOTSPOT_IDENTIFIER_PREFIX . $index, 1, QtiShape::RECT, $coords); $associableHotspotCollection->attach($associableHotspot); } return $associableHotspotCollection; }