hotspot_actionscript.as.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. $course_id = api_get_course_int_id();
  32. // Query db for answers
  33. if ($answer_type==HOT_SPOT_DELINEATION) {
  34. $sql = "SELECT id, answer, hotspot_coordinates, hotspot_type, ponderation FROM $TBL_ANSWERS
  35. WHERE c_id = $course_id AND question_id = ".intval($questionId)." AND hotspot_type = 'delineation' ORDER BY id";
  36. } else {
  37. $sql = "SELECT id, answer, hotspot_coordinates, hotspot_type, ponderation FROM $TBL_ANSWERS
  38. WHERE c_id = $course_id AND question_id = ".intval($questionId)." ORDER BY id";
  39. }
  40. $result = Database::query($sql);
  41. // Init
  42. $output = "hotspot_lang=$courseLang&hotspot_image=$pictureName&hotspot_image_width=$pictureWidth&hotspot_image_height=$pictureHeight&courseCode=$coursePath";
  43. $i = 0;
  44. $nmbrTries = 0;
  45. while ($hotspot = Database::fetch_assoc($result))
  46. {
  47. $output .= "&hotspot_".$hotspot['id']."=true";
  48. $output .= "&hotspot_".$hotspot['id']."_answer=".str_replace('&','{amp}',$hotspot['answer']);
  49. // Square or rectancle
  50. if ($hotspot['hotspot_type'] == 'square' )
  51. {
  52. $output .= "&hotspot_".$hotspot['id']."_type=square";
  53. }
  54. // Circle or ovale
  55. if ($hotspot['hotspot_type'] == 'circle')
  56. {
  57. $output .= "&hotspot_".$hotspot['id']."_type=circle";
  58. }
  59. // Polygon
  60. if ($hotspot['hotspot_type'] == 'poly')
  61. {
  62. $output .= "&hotspot_".$hotspot['id']."_type=poly";
  63. }
  64. // Delineation
  65. if ($hotspot['hotspot_type'] == 'delineation')
  66. {
  67. $output .= "&hotspot_".$hotspot['id']."_type=delineation";
  68. }
  69. // No error
  70. if ($hotspot['hotspot_type'] == 'noerror')
  71. {
  72. $output .= "&hotspot_".$hotspot['id']."_type=noerror";
  73. }
  74. // This is a good answer, count + 1 for nmbr of clicks
  75. if ($hotspot['hotspot_type'] > 0)
  76. {
  77. $nmbrTries++;
  78. }
  79. $output .= "&hotspot_".$hotspot['id']."_coord=".$hotspot['hotspot_coordinates']."";
  80. $i++;
  81. }
  82. // Generate empty
  83. $i++;
  84. for ($i; $i <= 12; $i++) {
  85. $output .= "&hotspot_".$i."=false";
  86. }
  87. // Output
  88. echo $output."&nmbrTries=".$nmbrTries."&done=done";