hotspot_actionscript.as.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  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. session_cache_limiter("none");
  10. include('../inc/global.inc.php');
  11. // set vars
  12. $questionId = intval($_GET['modifyAnswers']);
  13. $objQuestion = Question::read($questionId);
  14. $answer_type = $objQuestion->selectType(); //very important
  15. $TBL_ANSWERS = Database::get_course_table(TABLE_QUIZ_ANSWER);
  16. $documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
  17. $picturePath = $documentPath.'/images';
  18. $pictureName = $objQuestion->selectPicture();
  19. $pictureSize = getimagesize($picturePath.'/'.$objQuestion->selectPicture());
  20. $pictureWidth = $pictureSize[0];
  21. $pictureHeight = $pictureSize[1];
  22. $courseLang = $_course['language'];
  23. $courseCode = $_course['sysCode'];
  24. $coursePath = $_course['path'];
  25. $course_id = api_get_course_int_id();
  26. // Query db for answers
  27. if ($answer_type==HOT_SPOT_DELINEATION) {
  28. $sql = "SELECT id, answer, hotspot_coordinates, hotspot_type, ponderation FROM $TBL_ANSWERS
  29. WHERE c_id = $course_id AND question_id = ".intval($questionId)." AND hotspot_type = 'delineation' ORDER BY id";
  30. } else {
  31. $sql = "SELECT id, answer, hotspot_coordinates, hotspot_type, ponderation FROM $TBL_ANSWERS
  32. WHERE c_id = $course_id AND question_id = ".intval($questionId)." ORDER BY id";
  33. }
  34. $result = Database::query($sql);
  35. // Init
  36. $output = "hotspot_lang=$courseLang&hotspot_image=$pictureName&hotspot_image_width=$pictureWidth&hotspot_image_height=$pictureHeight&courseCode=$coursePath";
  37. $i = 0;
  38. $nmbrTries = 0;
  39. while ($hotspot = Database::fetch_assoc($result))
  40. {
  41. $output .= "&hotspot_".$hotspot['id']."=true";
  42. $output .= "&hotspot_".$hotspot['id']."_answer=".str_replace('&','{amp}',$hotspot['answer']);
  43. // Square or rectancle
  44. if ($hotspot['hotspot_type'] == 'square' )
  45. {
  46. $output .= "&hotspot_".$hotspot['id']."_type=square";
  47. }
  48. // Circle or ovale
  49. if ($hotspot['hotspot_type'] == 'circle')
  50. {
  51. $output .= "&hotspot_".$hotspot['id']."_type=circle";
  52. }
  53. // Polygon
  54. if ($hotspot['hotspot_type'] == 'poly')
  55. {
  56. $output .= "&hotspot_".$hotspot['id']."_type=poly";
  57. }
  58. // Delineation
  59. if ($hotspot['hotspot_type'] == 'delineation')
  60. {
  61. $output .= "&hotspot_".$hotspot['id']."_type=delineation";
  62. }
  63. // No error
  64. if ($hotspot['hotspot_type'] == 'noerror')
  65. {
  66. $output .= "&hotspot_".$hotspot['id']."_type=noerror";
  67. }
  68. // This is a good answer, count + 1 for nmbr of clicks
  69. if ($hotspot['hotspot_type'] > 0)
  70. {
  71. $nmbrTries++;
  72. }
  73. $output .= "&hotspot_".$hotspot['id']."_coord=".$hotspot['hotspot_coordinates']."";
  74. $i++;
  75. }
  76. // Generate empty
  77. $i++;
  78. for ($i; $i <= 12; $i++) {
  79. $output .= "&hotspot_".$i."=false";
  80. }
  81. // Output
  82. echo $output."&nmbrTries=".$nmbrTries."&done=done";