hotspot_actionscript_admin.as.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. // set vars
  32. $questionId = $_GET['modifyAnswers'];
  33. $objQuestion = new Question();
  34. $objQuestion->read($questionId);
  35. $TBL_ANSWERS = $_course['dbNameGlu'].'quiz_answer';
  36. $dbNameGlu = $_course['dbNameGlu'];
  37. $documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
  38. $picturePath = $documentPath.'/images';
  39. $pictureName = $objQuestion->selectPicture();
  40. $pictureSize = getimagesize($picturePath.'/'.$objQuestion->selectPicture());
  41. $pictureWidth = $pictureSize[0];
  42. $pictureHeight = $pictureSize[1];
  43. $courseLang = $_course['language'];
  44. $courseCode = $_course['sysCode'];
  45. // Query db for answers
  46. //$sql = "SELECT id, answer, hotspot_coordinates, hotspot_type, ponderation FROM `$TBL_ANSWERS` WHERE question_id = '$questionId' ORDER BY id";
  47. //$result = api_sql_query($sql,__FILE__,__LINE__);
  48. // Init
  49. $output = "hotspot_lang=$courseLang&hotspot_image=$pictureName&hotspot_image_width=$pictureWidth&hotspot_image_height=$pictureHeight&dbNameGlu=$dbNameGlu&courseCode=$courseCode";
  50. $i = 0;
  51. $nmbrTries = 0;
  52. $answers=$_SESSION['tmp_answers'];
  53. $nbrAnswers = count($answers['answer']);
  54. for($i=1;$i <= $nbrAnswers;$i++)
  55. {
  56. $output .= "&hotspot_".$i."=true";
  57. $output .= "&hotspot_".$i."_answer=".$answers['answer'][$i];
  58. // Square or rectancle
  59. if ($answers['hotspot_type'][$i] == 'square' )
  60. {
  61. $output .= "&hotspot_".$i."_type=square";
  62. }
  63. // Circle or ovale
  64. if ($answers['hotspot_type'][$i] == 'circle')
  65. {
  66. $output .= "&hotspot_".$i."_type=circle";
  67. }
  68. // Polygon
  69. if ($answers['hotspot_type'][$i] == 'poly')
  70. {
  71. $output .= "&hotspot_".$i."_type=poly";
  72. }
  73. // This is a good answer, count + 1 for nmbr of clicks
  74. if ($answers['weighting'][$i] > 0)
  75. {
  76. $nmbrTries++;
  77. }
  78. $output .= "&hotspot_".$i."_coord=".$answers['hotspot_coordinates'][$i]."";
  79. }
  80. // Generate empty
  81. $i++;
  82. for ($i; $i <= 12; $i++)
  83. {
  84. $output .= "&hotspot_".$i."=false";
  85. }
  86. // Output
  87. echo $output."&nmbrTries=".$nmbrTries."&done=done";
  88. ?>