hotspot_actionscript.as.php 2.5 KB

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