hotspot_actionscript_admin.as.php 2.6 KB

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