From ec0df618a2a441cdaf34283c83a06ded91eee95e Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Fri, 30 Sep 2016 11:29:50 -0500 Subject: [PATCH] Using iid for hotspots - refs BT#11764 --- main/exercise/hotspot_actionscript.as.php | 9 +++++---- main/exercise/hotspot_answers.as.php | 7 ++++++- main/inc/lib/events.lib.php | 1 - main/inc/lib/javascript/hotspot/js/hotspot.js | 9 +++------ 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/main/exercise/hotspot_actionscript.as.php b/main/exercise/hotspot_actionscript.as.php index 7cae1ef9b9..c096b4522a 100755 --- a/main/exercise/hotspot_actionscript.as.php +++ b/main/exercise/hotspot_actionscript.as.php @@ -32,11 +32,11 @@ $course_id = api_get_course_int_id(); // Query db for answers if ($answer_type==HOT_SPOT_DELINEATION) { - $sql = "SELECT id, answer, hotspot_coordinates, hotspot_type, ponderation FROM $TBL_ANSWERS - WHERE c_id = $course_id AND question_id = ".intval($questionId)." AND hotspot_type = 'delineation' ORDER BY id"; + $sql = "SELECT iid, id, answer, hotspot_coordinates, hotspot_type, ponderation FROM $TBL_ANSWERS + WHERE c_id = $course_id AND question_id = ".intval($questionId)." AND hotspot_type = 'delineation' ORDER BY iid"; } else { - $sql = "SELECT id, answer, hotspot_coordinates, hotspot_type, ponderation FROM $TBL_ANSWERS - WHERE c_id = $course_id AND question_id = ".intval($questionId)." ORDER BY id"; + $sql = "SELECT iid, id, answer, hotspot_coordinates, hotspot_type, ponderation FROM $TBL_ANSWERS + WHERE c_id = $course_id AND question_id = ".intval($questionId)." ORDER BY iid"; } $result = Database::query($sql); @@ -74,6 +74,7 @@ while ($hotspot = Database::fetch_assoc($result)) { $hotSpot = []; $hotSpot['id'] = $hotspot['id']; + $hotSpot['iid'] = $hotspot['iid']; $hotSpot['answer'] = $hotspot['answer']; // Square or rectancle diff --git a/main/exercise/hotspot_answers.as.php b/main/exercise/hotspot_answers.as.php index 7ef8d962ba..e082f14701 100755 --- a/main/exercise/hotspot_answers.as.php +++ b/main/exercise/hotspot_answers.as.php @@ -1,6 +1,9 @@ results_disabled != RESULT_DISABLE_SHOW_SCORE_ONLY) { ->getQuery() ->getResult(); + /** @var CQuizAnswer $hotspotAnswer */ foreach ($result as $hotspotAnswer) { $hotSpot = []; - $hotSpot['id'] = $hotspotAnswer->getId(); + $hotSpot['id'] = $hotspotAnswer->getIid(); $hotSpot['answer'] = $hotspotAnswer->getAnswer(); switch ($hotspotAnswer->getHotspotType()) { @@ -118,6 +122,7 @@ $rs = $em ['hotspotId' => 'ASC'] ); +/** @var TrackEHotspot $row */ foreach ($rs as $row) { $data['answers'][] = $row->getHotspotCoordinate(); } diff --git a/main/inc/lib/events.lib.php b/main/inc/lib/events.lib.php index 4696730a2c..28fb295ede 100644 --- a/main/inc/lib/events.lib.php +++ b/main/inc/lib/events.lib.php @@ -623,7 +623,6 @@ class Event api_get_user_id(), $exe_id, $question_id, - $answer_id, $answer_id ) ) diff --git a/main/inc/lib/javascript/hotspot/js/hotspot.js b/main/inc/lib/javascript/hotspot/js/hotspot.js index 6375d964fd..0de778be92 100755 --- a/main/inc/lib/javascript/hotspot/js/hotspot.js +++ b/main/inc/lib/javascript/hotspot/js/hotspot.js @@ -53,7 +53,6 @@ window.HotspotQuestion = (function () { this.set('height', y - startY); } }; - SquareModel.decode = function (hotspotInfo) { var coords = hotspotInfo.coord.split('|'), position = coords[0].split(';'), @@ -64,7 +63,7 @@ window.HotspotQuestion = (function () { height: parseInt(coords[2]) }); - hotspot.id = hotspotInfo.id; + hotspot.id = hotspotInfo.iid; hotspot.name = hotspotInfo.answer; return hotspot; @@ -124,7 +123,7 @@ window.HotspotQuestion = (function () { radiusY: parseInt(coords[2]) }); - hotspot.id = hotspotInfo.id; + hotspot.id = hotspotInfo.iid; hotspot.name = hotspotInfo.answer; return hotspot; @@ -170,7 +169,7 @@ window.HotspotQuestion = (function () { var hotspot = new PolygonModel({ points: points }); - hotspot.id = hotspotInfo.id; + hotspot.id = hotspotInfo.iid; hotspot.name = hotspotInfo.answer; return hotspot; @@ -269,7 +268,6 @@ window.HotspotQuestion = (function () { self.render(); }); }; - HotspotSVG.prototype.render = function () { var newEl = null; @@ -323,7 +321,6 @@ window.HotspotQuestion = (function () { self.render(); }); }; - AnswerSVG.prototype.render = function () { this.circleEl.setAttribute('cx', this.model.get('x')); this.circleEl.setAttribute('cy', this.model.get('y'));