hotspot_actionscript_admin.as.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. $answers=$_SESSION['tmp_answers'];
  47. $nbrAnswers = count($answers['answer']);
  48. for($i=1;$i <= $nbrAnswers;$i++)
  49. {
  50. $output .= "&hotspot_".$i."=true";
  51. $output .= "&hotspot_".$i."_answer=".$answers['answer'][$i];
  52. // Square or rectancle
  53. if ($answers['hotspot_type'][$i] == 'square' )
  54. {
  55. $output .= "&hotspot_".$i."_type=square";
  56. }
  57. // Circle or ovale
  58. if ($answers['hotspot_type'][$i] == 'circle')
  59. {
  60. $output .= "&hotspot_".$i."_type=circle";
  61. }
  62. // Polygon
  63. if ($answers['hotspot_type'][$i] == 'poly')
  64. {
  65. $output .= "&hotspot_".$i."_type=poly";
  66. }
  67. // This is a good answer, count + 1 for nmbr of clicks
  68. if ($answers['weighting'][$i] > 0)
  69. {
  70. $nmbrTries++;
  71. }
  72. $output .= "&hotspot_".$i."_coord=".$answers['hotspot_coordinates'][$i]."";
  73. }
  74. // Generate empty
  75. $i++;
  76. for ($i; $i <= 12; $i++)
  77. {
  78. $output .= "&hotspot_".$i."=false";
  79. }
  80. // Output
  81. echo $output."&nmbrTries=".$nmbrTries."&done=done";
  82. ?>