hotspot_actionscript.as.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. $questionId = $_GET['modifyAnswers'];
  28. $objQuestion = Question::read($questionId);
  29. $TBL_ANSWERS = Database::get_course_table(TABLE_QUIZ_ANSWER);
  30. $documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
  31. $picturePath = $documentPath.'/images';
  32. $pictureName = $objQuestion->selectPicture();
  33. $pictureSize = getimagesize($picturePath.'/'.$objQuestion->selectPicture());
  34. $pictureWidth = $pictureSize[0];
  35. $pictureHeight = $pictureSize[1];
  36. $courseLang = $_course['language'];
  37. $courseCode = $_course['sysCode'];
  38. $coursePath = $_course['path'];
  39. // Query db for answers
  40. $sql = "SELECT id, answer, hotspot_coordinates, hotspot_type, ponderation FROM $TBL_ANSWERS WHERE question_id = '$questionId' ORDER BY id";
  41. $result = api_sql_query($sql,__FILE__,__LINE__);
  42. // Init
  43. $output = "hotspot_lang=$courseLang&hotspot_image=$pictureName&hotspot_image_width=$pictureWidth&hotspot_image_height=$pictureHeight&courseCode=$coursePath";
  44. $i = 0;
  45. $nmbrTries = 0;
  46. while ($hotspot = mysql_fetch_assoc($result))
  47. {
  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. {
  53. $output .= "&hotspot_".$hotspot['id']."_type=square";
  54. }
  55. // Circle or ovale
  56. if ($hotspot['hotspot_type'] == 'circle')
  57. {
  58. $output .= "&hotspot_".$hotspot['id']."_type=circle";
  59. }
  60. // Polygon
  61. if ($hotspot['hotspot_type'] == 'poly')
  62. {
  63. $output .= "&hotspot_".$hotspot['id']."_type=poly";
  64. }
  65. // This is a good answer, count + 1 for nmbr of clicks
  66. if ($hotspot['hotspot_type'] > 0)
  67. {
  68. $nmbrTries++;
  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. // Output
  80. echo $output."&nmbrTries=".$nmbrTries."&done=done";
  81. ?>