hotspot_actionscript_admin.as.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  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. $output .= "&hotspot_".$i."_type=square";
  46. }
  47. // Circle or ovale
  48. if ($answers['hotspot_type'][$i] == 'circle') {
  49. $output .= "&hotspot_".$i."_type=circle";
  50. }
  51. // Polygon
  52. if ($answers['hotspot_type'][$i] == 'poly') {
  53. $output .= "&hotspot_".$i."_type=poly";
  54. }
  55. /*// Delineation
  56. if ($answers['hotspot_type'][$i] == 'delineation')
  57. {
  58. $output .= "&hotspot_".$i."_type=delineation";
  59. }*/
  60. }
  61. // This is a good answer, count + 1 for nmbr of clicks
  62. if ($answers['weighting'][$i] > 0) {
  63. $nmbrTries++;
  64. }
  65. $output .= "&hotspot_".$i."_coord=".$answers['hotspot_coordinates'][$i]."";
  66. }
  67. // Generate empty
  68. $i++;
  69. for ($i; $i <= 12; $i++) {
  70. $output .= "&hotspot_".$i."=false";
  71. }
  72. // Output
  73. echo $output."&nmbrTries=".$nmbrTries."&done=done";