hotspot_answers.as.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <?php
  2. /*
  3. DOKEOS - elearning and course management software
  4. For a full list of contributors, see documentation/credits.html
  5. This program is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU General Public License
  7. as published by the Free Software Foundation; either version 2
  8. of the License, or (at your option) any later version.
  9. See "documentation/licence.html" more details.
  10. Contact:
  11. Dokeos
  12. Rue des Palais 44 Paleizenstraat
  13. B-1030 Brussels - Belgium
  14. Tel. +32 (2) 211 34 56
  15. */
  16. /**
  17. * This file generates the ActionScript variables code used by the HotSpot .swf
  18. * @package dokeos.exercise
  19. * @author Toon Keppens
  20. * @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
  21. */
  22. include('exercise.class.php');
  23. include('question.class.php');
  24. include('answer.class.php');
  25. include('../inc/global.inc.php');
  26. // set vars
  27. $userId = $_user['user_id'];
  28. $questionId = $_GET['modifyAnswers'];
  29. $exe_id = $_GET['exe_id'];
  30. $from_db = isset($_GET['from_db']) ? $_GET['from_db'] : 0;
  31. $objQuestion = Question :: read($questionId);
  32. $TBL_ANSWERS = Database::get_course_table(TABLE_QUIZ_ANSWER);
  33. $documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
  34. $picturePath = $documentPath.'/images';
  35. $pictureName = $objQuestion->selectPicture();
  36. $pictureSize = getimagesize($picturePath.'/'.$objQuestion->selectPicture());
  37. $pictureWidth = $pictureSize[0];
  38. $pictureHeight = $pictureSize[1];
  39. $courseLang = $_course['language'];
  40. $courseCode = $_course['sysCode'];
  41. $coursePath = $_course['path'];
  42. // Query db for answers
  43. $sql = "SELECT id, answer, hotspot_coordinates, hotspot_type FROM $TBL_ANSWERS WHERE question_id = '$questionId' ORDER BY id";
  44. $result = api_sql_query($sql,__FILE__,__LINE__);
  45. // Init
  46. $output = "hotspot_lang=$courseLang&hotspot_image=$pictureName&hotspot_image_width=$pictureWidth&hotspot_image_height=$pictureHeight&courseCode=$coursePath";
  47. $i = 0;
  48. while ($hotspot = mysql_fetch_array($result))
  49. {
  50. $output .= "&hotspot_".$hotspot['id']."=true";
  51. // Square or rectancle
  52. if ($hotspot['hotspot_type'] == 'square' )
  53. {
  54. $output .= "&hotspot_".$hotspot['id']."_type=square";
  55. }
  56. // Circle or ovale
  57. if ($hotspot['hotspot_type'] == 'circle')
  58. {
  59. $output .= "&hotspot_".$hotspot['id']."_type=circle";
  60. }
  61. // Polygon
  62. if ($hotspot['hotspot_type'] == 'poly')
  63. {
  64. $output .= "&hotspot_".$hotspot['id']."_type=poly";
  65. }
  66. $output .= "&hotspot_".$hotspot['id']."_coord=".$hotspot['hotspot_coordinates']."";
  67. $i++;
  68. }
  69. // Generate empty
  70. $i++;
  71. for ($i; $i <= 12; $i++)
  72. {
  73. $output .= "&hotspot_".$i."=false";
  74. }
  75. // set vars
  76. $questionId = $_GET['modifyAnswers'];
  77. $course_code = $_course['id'];
  78. // Get clicks
  79. if(isset($_SESSION['exerciseResultCoordinates']) && $from_db==0)
  80. {
  81. foreach ($_SESSION['exerciseResultCoordinates'][$questionId] as $coordinate)
  82. {
  83. $output2 .= $coordinate."|";
  84. }
  85. }
  86. else
  87. {
  88. // get it from db
  89. $tbl_track_e_hotspot = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTSPOT);
  90. $sql = 'SELECT hotspot_coordinate
  91. FROM '.$tbl_track_e_hotspot.'
  92. WHERE hotspot_question_id = '.intval($questionId).'
  93. AND hotspot_course_code = "'.Database::escape_string($course_code).'"
  94. AND hotspot_exe_id='.intval($exe_id);
  95. $rs = @api_sql_query($sql); // don't output error because we are in Flash execution.
  96. while($row = Database :: fetch_array($rs))
  97. {
  98. $output2 .= $row['hotspot_coordinate']."|";
  99. }
  100. }
  101. $output .= "&p_hotspot_answers=".substr($output2,0,-1)."&done=done";
  102. $explode = explode('&', $output);
  103. echo $output;
  104. ?>