hotspot_answers.as.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php //$id:$
  2. /* For licensing terms, see /dokeos_license.txt */
  3. /**
  4. * This file generates the ActionScript variables code used by the HotSpot .swf
  5. * @package dokeos.exercise
  6. * @author Toon Keppens
  7. * @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
  8. */
  9. include('exercise.class.php');
  10. include('question.class.php');
  11. include('answer.class.php');
  12. include('../inc/global.inc.php');
  13. // set vars
  14. $userId = $_user['user_id'];
  15. $questionId = $_GET['modifyAnswers'];
  16. $exe_id = $_GET['exe_id'];
  17. $from_db = isset($_GET['from_db']) ? $_GET['from_db'] : 0;
  18. $objQuestion = Question :: read($questionId);
  19. $TBL_ANSWERS = Database::get_course_table(TABLE_QUIZ_ANSWER);
  20. $documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
  21. $picturePath = $documentPath.'/images';
  22. $pictureName = $objQuestion->selectPicture();
  23. $pictureSize = getimagesize($picturePath.'/'.$objQuestion->selectPicture());
  24. $pictureWidth = $pictureSize[0];
  25. $pictureHeight = $pictureSize[1];
  26. $courseLang = $_course['language'];
  27. $courseCode = $_course['sysCode'];
  28. $coursePath = $_course['path'];
  29. // Query db for answers
  30. $sql = "SELECT id, answer, hotspot_coordinates, hotspot_type FROM $TBL_ANSWERS WHERE question_id = '".Database::escape_string($questionId)."' ORDER BY id";
  31. $result = api_sql_query($sql,__FILE__,__LINE__);
  32. // Init
  33. $output = "hotspot_lang=$courseLang&hotspot_image=$pictureName&hotspot_image_width=$pictureWidth&hotspot_image_height=$pictureHeight&courseCode=$coursePath";
  34. $i = 0;
  35. while ($hotspot = mysql_fetch_array($result))
  36. {
  37. $output .= "&hotspot_".$hotspot['id']."=true";
  38. // Square or rectancle
  39. if ($hotspot['hotspot_type'] == 'square' )
  40. {
  41. $output .= "&hotspot_".$hotspot['id']."_type=square";
  42. }
  43. // Circle or ovale
  44. if ($hotspot['hotspot_type'] == 'circle')
  45. {
  46. $output .= "&hotspot_".$hotspot['id']."_type=circle";
  47. }
  48. // Polygon
  49. if ($hotspot['hotspot_type'] == 'poly')
  50. {
  51. $output .= "&hotspot_".$hotspot['id']."_type=poly";
  52. }
  53. // Delineation
  54. if ($hotspot['hotspot_type'] == 'delineation')
  55. {
  56. $output .= "&hotspot_".$hotspot['id']."_type=delineation";
  57. }
  58. $output .= "&hotspot_".$hotspot['id']."_coord=".$hotspot['hotspot_coordinates']."";
  59. $i++;
  60. }
  61. // Generate empty (the maximum number of points is 12 - it is said so in the user interface)
  62. $i++;
  63. for ($i; $i <= 12; $i++) {
  64. $output .= "&hotspot_".$i."=false";
  65. }
  66. // set vars
  67. $questionId = $_GET['modifyAnswers'];
  68. $course_code = $_course['id'];
  69. // Get clicks
  70. if(isset($_SESSION['exerciseResultCoordinates']) && $from_db==0) {
  71. foreach ($_SESSION['exerciseResultCoordinates'][$questionId] as $coordinate) {
  72. $output2 .= $coordinate."|";
  73. }
  74. } else {
  75. // get it from db
  76. $tbl_track_e_hotspot = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTSPOT);
  77. $sql = 'SELECT hotspot_coordinate '.
  78. ' FROM '.$tbl_track_e_hotspot.
  79. ' WHERE hotspot_question_id = '.intval($questionId).
  80. ' AND hotspot_course_code = "'.Database::escape_string($course_code).'"'.
  81. ' AND hotspot_exe_id='.intval($exe_id);
  82. $rs = @api_sql_query($sql); // don't output error because we are in Flash execution.
  83. while($row = Database :: fetch_array($rs)) {
  84. $output2 .= $row['hotspot_coordinate']."|";
  85. }
  86. }
  87. $output .= "&p_hotspot_answers=".api_substr($output2,0,-1)."&done=done";
  88. $explode = explode('&', $output);
  89. echo $output;
  90. ?>