hotspot_actionscript_admin.as.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. $documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
  20. $picturePath = $documentPath.'/images';
  21. $pictureName = $objQuestion->selectPicture();
  22. $pictureSize = getimagesize($picturePath.'/'.$objQuestion->selectPicture());
  23. $pictureWidth = $pictureSize[0];
  24. $pictureHeight = $pictureSize[1];
  25. $courseLang = $_course['language'];
  26. $courseCode = $_course['sysCode'];
  27. $coursePath = $_course['path'];
  28. // Init
  29. $output = "hotspot_lang=$courseLang&hotspot_image=$pictureName&hotspot_image_width=$pictureWidth&hotspot_image_height=$pictureHeight&courseCode=$coursePath";
  30. $i = 0;
  31. $nmbrTries = 0;
  32. $answers = $_SESSION['tmp_answers'];
  33. $nbrAnswers = count($answers['answer']);
  34. for($i=1;$i <= $nbrAnswers;$i++) {
  35. $output .= "&hotspot_".$i."=true";
  36. $output .= "&hotspot_".$i."_answer=".$answers['answer'][$i];
  37. if ($answer_type==HOT_SPOT_DELINEATION) {
  38. if ($i==1)
  39. $output .= "&hotspot_".$i."_type=delineation";
  40. else
  41. $output .= "&hotspot_".$i."_type=oar";
  42. } else {
  43. // Square or rectancle
  44. if ($answers['hotspot_type'][$i] == 'square' )
  45. {
  46. $output .= "&hotspot_".$i."_type=square";
  47. }
  48. // Circle or ovale
  49. if ($answers['hotspot_type'][$i] == 'circle')
  50. {
  51. $output .= "&hotspot_".$i."_type=circle";
  52. }
  53. // Polygon
  54. if ($answers['hotspot_type'][$i] == 'poly')
  55. {
  56. $output .= "&hotspot_".$i."_type=poly";
  57. }
  58. /*// Delineation
  59. if ($answers['hotspot_type'][$i] == 'delineation')
  60. {
  61. $output .= "&hotspot_".$i."_type=delineation";
  62. }*/
  63. }
  64. // This is a good answer, count + 1 for nmbr of clicks
  65. if ($answers['weighting'][$i] > 0)
  66. {
  67. $nmbrTries++;
  68. }
  69. $output .= "&hotspot_".$i."_coord=".$answers['hotspot_coordinates'][$i]."";
  70. }
  71. // Generate empty
  72. $i++;
  73. for ($i; $i <= 12; $i++) {
  74. $output .= "&hotspot_".$i."=false";
  75. }
  76. // Output
  77. echo $output."&nmbrTries=".$nmbrTries."&done=done";