hotspot_actionscript_admin.as.php 2.4 KB

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