hotspot_actionscript.as.php 3.0 KB

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