hotspot_actionscript.as.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php //$id:$
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * This file generates the ActionScript variables code used by the HotSpot .swf
  5. * @package chamilo.exercise
  6. * @author Toon Keppens
  7. * @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
  8. */
  9. /**
  10. * Code
  11. */
  12. session_cache_limiter("none");
  13. include('exercise.class.php');
  14. include('question.class.php');
  15. include('answer.class.php');
  16. include('../inc/global.inc.php');
  17. // set vars
  18. $questionId = intval($_GET['modifyAnswers']);
  19. $objQuestion = Question::read($questionId);
  20. $answer_type = $objQuestion->selectType(); //very important
  21. $TBL_ANSWERS = Database::get_course_table(TABLE_QUIZ_ANSWER);
  22. $documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
  23. $picturePath = $documentPath.'/images';
  24. $pictureName = $objQuestion->selectPicture();
  25. $pictureSize = getimagesize($picturePath.'/'.$objQuestion->selectPicture());
  26. $pictureWidth = $pictureSize[0];
  27. $pictureHeight = $pictureSize[1];
  28. $courseLang = $_course['language'];
  29. $courseCode = $_course['sysCode'];
  30. $coursePath = $_course['path'];
  31. // Query db for answers
  32. if ($answer_type==HOT_SPOT_DELINEATION) {
  33. $sql = "SELECT id, answer, hotspot_coordinates, hotspot_type, ponderation FROM $TBL_ANSWERS WHERE question_id = '".Database::escape_string($questionId)."' AND hotspot_type = 'delineation' ORDER BY id";
  34. } else {
  35. $sql = "SELECT id, answer, hotspot_coordinates, hotspot_type, ponderation FROM $TBL_ANSWERS WHERE question_id = '".Database::escape_string($questionId)."' ORDER BY id";
  36. }
  37. $result = Database::query($sql);
  38. // Init
  39. $output = "hotspot_lang=$courseLang&hotspot_image=$pictureName&hotspot_image_width=$pictureWidth&hotspot_image_height=$pictureHeight&courseCode=$coursePath";
  40. $i = 0;
  41. $nmbrTries = 0;
  42. while ($hotspot = Database::fetch_assoc($result))
  43. {
  44. $output .= "&hotspot_".$hotspot['id']."=true";
  45. $output .= "&hotspot_".$hotspot['id']."_answer=".str_replace('&','{amp}',$hotspot['answer']);
  46. // Square or rectancle
  47. if ($hotspot['hotspot_type'] == 'square' )
  48. {
  49. $output .= "&hotspot_".$hotspot['id']."_type=square";
  50. }
  51. // Circle or ovale
  52. if ($hotspot['hotspot_type'] == 'circle')
  53. {
  54. $output .= "&hotspot_".$hotspot['id']."_type=circle";
  55. }
  56. // Polygon
  57. if ($hotspot['hotspot_type'] == 'poly')
  58. {
  59. $output .= "&hotspot_".$hotspot['id']."_type=poly";
  60. }
  61. // Delineation
  62. if ($hotspot['hotspot_type'] == 'delineation')
  63. {
  64. $output .= "&hotspot_".$hotspot['id']."_type=delineation";
  65. }
  66. // No error
  67. if ($hotspot['hotspot_type'] == 'noerror')
  68. {
  69. $output .= "&hotspot_".$hotspot['id']."_type=noerror";
  70. }
  71. // This is a good answer, count + 1 for nmbr of clicks
  72. if ($hotspot['hotspot_type'] > 0)
  73. {
  74. $nmbrTries++;
  75. }
  76. $output .= "&hotspot_".$hotspot['id']."_coord=".$hotspot['hotspot_coordinates']."";
  77. $i++;
  78. }
  79. // Generate empty
  80. $i++;
  81. for ($i; $i <= 12; $i++) {
  82. $output .= "&hotspot_".$i."=false";
  83. }
  84. // Output
  85. echo $output."&nmbrTries=".$nmbrTries."&done=done";