hotspot_answers.as.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. include('exercise.class.php');
  23. include('question.class.php');
  24. include('answer.class.php');
  25. include('../inc/global.inc.php');
  26. // set vars
  27. $userId = $_user['user_id'];
  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 FROM $TBL_ANSWERS WHERE question_id = '$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. while ($hotspot = mysql_fetch_array($result))
  47. {
  48. $output .= "&hotspot_".$hotspot['id']."=true";
  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. $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. // set vars
  74. $questionId = $_GET['modifyAnswers'];
  75. $courseCode = $_course['sysCode'];
  76. // Get clicks
  77. foreach ($_SESSION['exerciseResultCoordinates'][$questionId] as $coordinate)
  78. {
  79. $output2 .= $coordinate."|";
  80. }
  81. $output .= "&p_hotspot_answers=".substr($output2,0,-1)."&done=done";
  82. $explode = explode('&', $output);
  83. echo $output;
  84. ?>