|
|
|
@ -1,42 +1,48 @@ |
|
|
|
|
<?php |
|
|
|
|
/* For licensing terms, see /license.txt */ |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* This file generates the ActionScript variables code used by the HotSpot .swf |
|
|
|
|
* @package chamilo.exercise |
|
|
|
|
* @author Toon Keppens |
|
|
|
|
* @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $ |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
use ChamiloSession as Session; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* This file generates the ActionScript variables code used by the HotSpot .swf |
|
|
|
|
* @package chamilo.exercise |
|
|
|
|
* @author Toon Keppens |
|
|
|
|
* @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $ |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
session_cache_limiter("none"); |
|
|
|
|
|
|
|
|
|
require_once __DIR__.'/../inc/global.inc.php'; |
|
|
|
|
require api_get_path(LIBRARY_PATH) . 'geometry.lib.php'; |
|
|
|
|
|
|
|
|
|
// set vars |
|
|
|
|
$questionId = intval($_GET['modifyAnswers']); |
|
|
|
|
$questionId = intval($_GET['modifyAnswers']); |
|
|
|
|
$exerciseId = isset($_GET['exe_id']) ? intval($_GET['exe_id']) : 0; |
|
|
|
|
$objQuestion = Question::read($questionId); |
|
|
|
|
$answer_type = $objQuestion->selectType(); //very important |
|
|
|
|
$TBL_ANSWERS = Database::get_course_table(TABLE_QUIZ_ANSWER); |
|
|
|
|
$documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'; |
|
|
|
|
$picturePath = $documentPath.'/images'; |
|
|
|
|
$pictureName = $objQuestion->selectPicture(); |
|
|
|
|
$pictureSize = getimagesize($picturePath.'/'.$objQuestion->selectPicture()); |
|
|
|
|
$pictureWidth = $pictureSize[0]; |
|
|
|
|
$objQuestion = Question::read($questionId); |
|
|
|
|
$answer_type = $objQuestion->selectType(); //very important |
|
|
|
|
$TBL_ANSWERS = Database::get_course_table(TABLE_QUIZ_ANSWER); |
|
|
|
|
$documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'; |
|
|
|
|
$picturePath = $documentPath.'/images'; |
|
|
|
|
$pictureName = $objQuestion->selectPicture(); |
|
|
|
|
$pictureSize = getimagesize($picturePath.'/'.$objQuestion->selectPicture()); |
|
|
|
|
$pictureWidth = $pictureSize[0]; |
|
|
|
|
$pictureHeight = $pictureSize[1]; |
|
|
|
|
|
|
|
|
|
$course_id = api_get_course_int_id(); |
|
|
|
|
|
|
|
|
|
// Query db for answers |
|
|
|
|
if ($answer_type==HOT_SPOT_DELINEATION) { |
|
|
|
|
$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"; |
|
|
|
|
if ($answer_type == HOT_SPOT_DELINEATION) { |
|
|
|
|
$sql = "SELECT iid, id, answer, hotspot_coordinates, hotspot_type, ponderation |
|
|
|
|
FROM $TBL_ANSWERS |
|
|
|
|
WHERE |
|
|
|
|
c_id = $course_id AND |
|
|
|
|
question_id = ".$questionId." AND |
|
|
|
|
hotspot_type = 'delineation' |
|
|
|
|
ORDER BY iid"; |
|
|
|
|
} else { |
|
|
|
|
$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"; |
|
|
|
|
$sql = "SELECT iid, id, answer, hotspot_coordinates, hotspot_type, ponderation |
|
|
|
|
FROM $TBL_ANSWERS |
|
|
|
|
WHERE c_id = $course_id AND question_id = ".$questionId." |
|
|
|
|
ORDER BY iid"; |
|
|
|
|
} |
|
|
|
|
$result = Database::query($sql); |
|
|
|
|
|
|
|
|
@ -70,47 +76,39 @@ $data['answers'] = []; |
|
|
|
|
|
|
|
|
|
$nmbrTries = 0; |
|
|
|
|
|
|
|
|
|
while ($hotspot = Database::fetch_assoc($result)) |
|
|
|
|
{ |
|
|
|
|
while ($hotspot = Database::fetch_assoc($result)) { |
|
|
|
|
$hotSpot = []; |
|
|
|
|
$hotSpot['id'] = $hotspot['id']; |
|
|
|
|
$hotSpot['iid'] = $hotspot['iid']; |
|
|
|
|
$hotSpot['answer'] = $hotspot['answer']; |
|
|
|
|
|
|
|
|
|
// Square or rectancle |
|
|
|
|
if ($hotspot['hotspot_type'] == 'square' ) |
|
|
|
|
{ |
|
|
|
|
// Square or rectancle |
|
|
|
|
if ($hotspot['hotspot_type'] == 'square') { |
|
|
|
|
$hotSpot['type'] = 'square'; |
|
|
|
|
} |
|
|
|
|
// Circle or ovale |
|
|
|
|
if ($hotspot['hotspot_type'] == 'circle') |
|
|
|
|
{ |
|
|
|
|
} |
|
|
|
|
// Circle or ovale |
|
|
|
|
if ($hotspot['hotspot_type'] == 'circle') { |
|
|
|
|
$hotSpot['type'] = 'circle'; |
|
|
|
|
} |
|
|
|
|
// Polygon |
|
|
|
|
if ($hotspot['hotspot_type'] == 'poly') |
|
|
|
|
{ |
|
|
|
|
} |
|
|
|
|
// Polygon |
|
|
|
|
if ($hotspot['hotspot_type'] == 'poly') { |
|
|
|
|
$hotSpot['type'] = 'poly'; |
|
|
|
|
} |
|
|
|
|
// Delineation |
|
|
|
|
if ($hotspot['hotspot_type'] == 'delineation') |
|
|
|
|
{ |
|
|
|
|
} |
|
|
|
|
// Delineation |
|
|
|
|
if ($hotspot['hotspot_type'] == 'delineation') { |
|
|
|
|
$hotSpot['type'] = 'delineation'; |
|
|
|
|
} |
|
|
|
|
// No error |
|
|
|
|
if ($hotspot['hotspot_type'] == 'noerror') |
|
|
|
|
{ |
|
|
|
|
} |
|
|
|
|
// No error |
|
|
|
|
if ($hotspot['hotspot_type'] == 'noerror') { |
|
|
|
|
$hotSpot['type'] = 'noerror'; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// This is a good answer, count + 1 for nmbr of clicks |
|
|
|
|
if ($hotspot['hotspot_type'] > 0) |
|
|
|
|
{ |
|
|
|
|
$nmbrTries++; |
|
|
|
|
} |
|
|
|
|
// This is a good answer, count + 1 for nmbr of clicks |
|
|
|
|
if ($hotspot['hotspot_type'] > 0) { |
|
|
|
|
$nmbrTries++; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$hotSpot['coord'] = $hotspot['hotspot_coordinates']; |
|
|
|
|
|
|
|
|
|
$data['hotspots'][] = $hotSpot; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -119,7 +117,6 @@ $attemptList = Event::getAllExerciseEventByExeId($exerciseId); |
|
|
|
|
if (!empty($attemptList)) { |
|
|
|
|
if (isset($attemptList[$questionId])) { |
|
|
|
|
$questionAttempt = $attemptList[$questionId][0]; |
|
|
|
|
|
|
|
|
|
if (!empty($questionAttempt['answer'])) { |
|
|
|
|
$coordinates = explode('|', $questionAttempt['answer']); |
|
|
|
|
|
|
|
|
|