hotspot_answers.as.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2004 Dokeos S.A.
  6. Copyright (c) 2003 Ghent University (UGent)
  7. Copyright (c) 2001 Universite catholique de Louvain (UCL)
  8. Copyright (c) Olivier Brouckaert
  9. For a full list of contributors, see "credits.txt".
  10. The full license can be read in "license.txt".
  11. This program is free software; you can redistribute it and/or
  12. modify it under the terms of the GNU General Public License
  13. as published by the Free Software Foundation; either version 2
  14. of the License, or (at your option) any later version.
  15. See the GNU General Public License for more details.
  16. Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
  17. ==============================================================================
  18. */
  19. /**
  20. ==============================================================================
  21. * This file generates the ActionScript variables code used by the HotSpot .swf
  22. *
  23. * @author Toon Keppens
  24. * @package dokeos.exercise
  25. ==============================================================================
  26. */
  27. include('exercise.class.php');
  28. include('question.class.php');
  29. include('answer.class.php');
  30. include('../inc/global.inc.php');
  31. //include('../inc/lib/database.inc.lib');
  32. // set vars
  33. $userId = $_uid;
  34. $questionId = $_GET['modifyAnswers'];
  35. $objQuestion = new Question();
  36. $objQuestion->read($questionId);
  37. $TBL_ANSWERS = $_course['dbNameGlu'].'quiz_answer';
  38. $dbNameGlu = $_course['dbNameGlu'];
  39. $documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
  40. $picturePath = $documentPath.'/images';
  41. $pictureName = $objQuestion->selectPicture();
  42. $pictureSize = getimagesize($picturePath.'/'.$objQuestion->selectPicture());
  43. $pictureWidth = $pictureSize[0];
  44. $pictureHeight = $pictureSize[1];
  45. $courseLang = $_course['language'];
  46. $courseCode = $_course['sysCode'];
  47. // Query db for answers
  48. $sql = "SELECT id, answer, hotspot_coordinates, hotspot_type FROM `$TBL_ANSWERS` WHERE question_id = '$questionId' ORDER BY id";
  49. $result = api_sql_query($sql,__FILE__,__LINE__);
  50. // Init
  51. $output = "hotspot_lang=$courseLang&hotspot_image=$pictureName&hotspot_image_width=$pictureWidth&hotspot_image_height=$pictureHeight&dbNameGlu=$dbNameGlu&courseCode=$courseCode";
  52. $i = 0;
  53. while ($hotspot = mysql_fetch_array($result)) {
  54. $output .= "&hotspot_".$hotspot['id']."=true";
  55. // Square or rectancle
  56. if ($hotspot['hotspot_type'] == 'square' )
  57. {
  58. $output .= "&hotspot_".$hotspot['id']."_type=square";
  59. }
  60. // Circle or ovale
  61. if ($hotspot['hotspot_type'] == 'circle')
  62. {
  63. $output .= "&hotspot_".$hotspot['id']."_type=circle";
  64. }
  65. // Polygon
  66. if ($hotspot['hotspot_type'] == 'poly')
  67. {
  68. $output .= "&hotspot_".$hotspot['id']."_type=poly";
  69. }
  70. $output .= "&hotspot_".$hotspot['id']."_coord=".$hotspot['hotspot_coordinates']."";
  71. $i++;
  72. }
  73. // Generate empty
  74. $i++;
  75. for ($i; $i <= 12; $i++)
  76. {
  77. $output .= "&hotspot_".$i."=false";
  78. }
  79. // set vars
  80. $questionId = $_GET['modifyAnswers'];
  81. $courseCode = $_course['sysCode'];
  82. // Get clicks
  83. foreach ($_SESSION['exerciseResultCoordinates'][$questionId] as $coordinate)
  84. {
  85. $output2 .= $coordinate."|";
  86. }
  87. // Output
  88. $output .= "&p_hotspot_answers=".substr($output2,0,-1)."&done=done";
  89. echo $output;
  90. ?>