hotspot_actionscript_admin.as.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php //$id:$
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * This file generates the ActionScript variables code used by the HotSpot .swf
  5. * @package dokeos.exercise
  6. * @author Toon Keppens
  7. * @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
  8. */
  9. include('exercise.class.php');
  10. include('question.class.php');
  11. include('answer.class.php');
  12. include('../inc/global.inc.php');
  13. // set vars
  14. $questionId = intval($_GET['modifyAnswers']);
  15. $objQuestion = Question::read($questionId);
  16. $TBL_ANSWERS = Database::get_course_table(TABLE_QUIZ_ANSWER);
  17. $documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
  18. $picturePath = $documentPath.'/images';
  19. $pictureName = $objQuestion->selectPicture();
  20. $pictureSize = getimagesize($picturePath.'/'.$objQuestion->selectPicture());
  21. $pictureWidth = $pictureSize[0];
  22. $pictureHeight = $pictureSize[1];
  23. $courseLang = $_course['language'];
  24. $courseCode = $_course['sysCode'];
  25. $coursePath = $_course['path'];
  26. // Query db for answers
  27. //$sql = "SELECT id, answer, hotspot_coordinates, hotspot_type, ponderation FROM $TBL_ANSWERS WHERE question_id = '$questionId' ORDER BY id";
  28. //$result = Database::query($sql);
  29. // Init
  30. $output = "hotspot_lang=$courseLang&hotspot_image=$pictureName&hotspot_image_width=$pictureWidth&hotspot_image_height=$pictureHeight&courseCode=$coursePath";
  31. $i = 0;
  32. $nmbrTries = 0;
  33. $answers=$_SESSION['tmp_answers'];
  34. $nbrAnswers = count($answers['answer']);
  35. for($i=1;$i <= $nbrAnswers;$i++) {
  36. $output .= "&hotspot_".$i."=true";
  37. $output .= "&hotspot_".$i."_answer=".$answers['answer'][$i];
  38. if ($answer_type==HOT_SPOT_DELINEATION) {
  39. if ($i==1)
  40. $output .= "&hotspot_".$i."_type=delineation";
  41. else
  42. $output .= "&hotspot_".$i."_type=oar";
  43. } else {
  44. // Square or rectancle
  45. if ($answers['hotspot_type'][$i] == 'square' )
  46. {
  47. $output .= "&hotspot_".$i."_type=square";
  48. }
  49. // Circle or ovale
  50. if ($answers['hotspot_type'][$i] == 'circle')
  51. {
  52. $output .= "&hotspot_".$i."_type=circle";
  53. }
  54. // Polygon
  55. if ($answers['hotspot_type'][$i] == 'poly')
  56. {
  57. $output .= "&hotspot_".$i."_type=poly";
  58. }
  59. /*// Delineation
  60. if ($answers['hotspot_type'][$i] == 'delineation')
  61. {
  62. $output .= "&hotspot_".$i."_type=delineation";
  63. }*/
  64. }
  65. // This is a good answer, count + 1 for nmbr of clicks
  66. if ($answers['weighting'][$i] > 0)
  67. {
  68. $nmbrTries++;
  69. }
  70. $output .= "&hotspot_".$i."_coord=".$answers['hotspot_coordinates'][$i]."";
  71. }
  72. // Generate empty
  73. $i++;
  74. for ($i; $i <= 12; $i++) {
  75. $output .= "&hotspot_".$i."=false";
  76. }
  77. // Output
  78. echo $output."&nmbrTries=".$nmbrTries."&done=done";