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; }
public static function build($identifier, $bgObject, $gapImgs, $hotspots) { $gapImgCollection = new GapImgCollection(); foreach ($gapImgs as $id => $data) { $obj = new Object($data, 'image/png'); $gapImg = new GapImg($id, 1, $obj); $gapImgCollection->attach($gapImg); } $associableHotspotCollection = new AssociableHotspotCollection(); foreach ($hotspots as $id => $data) { $coords = new QtiCoords(QtiShape::RECT, $data); $associableHotspot = new AssociableHotspot($id, 1, QtiShape::RECT, $coords); $associableHotspotCollection->attach($associableHotspot); } return new GraphicGapMatchInteraction($identifier, $bgObject, $gapImgCollection, $associableHotspotCollection); }