hotspot_actionscript.as.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. session_cache_limiter("none");
  23. include('exercise.class.php');
  24. include('question.class.php');
  25. include('answer.class.php');
  26. include('../inc/global.inc.php');
  27. // set vars
  28. $questionId = $_GET['modifyAnswers'];
  29. $objQuestion = Question::read($questionId);
  30. $TBL_ANSWERS = Database::get_course_table(TABLE_QUIZ_ANSWER);
  31. $documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
  32. $picturePath = $documentPath.'/images';
  33. $pictureName = $objQuestion->selectPicture();
  34. $pictureSize = getimagesize($picturePath.'/'.$objQuestion->selectPicture());
  35. $pictureWidth = $pictureSize[0];
  36. $pictureHeight = $pictureSize[1];
  37. $courseLang = $_course['language'];
  38. $courseCode = $_course['sysCode'];
  39. $coursePath = $_course['path'];
  40. // Query db for answers
  41. $sql = "SELECT id, answer, hotspot_coordinates, hotspot_type, ponderation FROM $TBL_ANSWERS WHERE question_id = '".Database::escape_string($questionId)."' ORDER BY id";
  42. $result = api_sql_query($sql,__FILE__,__LINE__);
  43. // Init
  44. $output = "hotspot_lang=$courseLang&hotspot_image=$pictureName&hotspot_image_width=$pictureWidth&hotspot_image_height=$pictureHeight&courseCode=$coursePath";
  45. $i = 0;
  46. $nmbrTries = 0;
  47. while ($hotspot = mysql_fetch_assoc($result))
  48. {
  49. $output .= "&hotspot_".$hotspot['id']."=true";
  50. $output .= "&hotspot_".$hotspot['id']."_answer=".str_replace('&','{amp}',$hotspot['answer']);
  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. // Delineation
  67. if ($hotspot['hotspot_type'] == 'delineation')
  68. {
  69. $output .= "&hotspot_".$hotspot['id']."_type=delineation";
  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. {
  83. $output .= "&hotspot_".$i."=false";
  84. }
  85. // Output
  86. echo $output."&nmbrTries=".$nmbrTries."&done=done";
  87. ?>