hotspot.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. // in je FORM-tag voor de hotspots: onSubmit="return validateFlashVar('MINIMUM_AANTAL_CLICKS');
  2. var flashVar = 1;
  3. var lcId = new Date().getTime();
  4. //var flashProxy = new FlashProxy(lcId, "JavaScriptFlashGateway.swf");
  5. function validateFlashVar(counter, lang_1, lang_2)
  6. {
  7. return true;
  8. //alert(counter);
  9. //alert(flashVar);
  10. if(counter != flashVar)
  11. {
  12. alert(lang_1 + counter + lang_2);
  13. return false;
  14. }
  15. else
  16. {
  17. return true;
  18. }
  19. }
  20. function updateFlashVar()
  21. {
  22. //alert('updateFlashVar: ' + flashVar);
  23. flashVar++;
  24. }
  25. /*
  26. * Save the results of the positioning of a point by the user on top of
  27. * the answer area.
  28. * @param int Question ID
  29. * @param int ID of the area (square or ellipse)
  30. * @param int Whether the answer is correct or not
  31. * @param int X-coordinate (horizontal) of the answer point
  32. * @param int Y-coordinate (vertical) of the answer point
  33. */
  34. function saveHotspot(question_id, hotspot_id, answer, hotspot_x, hotspot_y)
  35. {
  36. newHotspot = document.createElement("input");
  37. newHotspot.type = "hidden";
  38. newHotspot.name = "hotspot["+question_id+"]["+hotspot_id+"]";
  39. newHotspot.value = hotspot_x + ";" + hotspot_y;
  40. document.frm_exercise.appendChild(newHotspot);
  41. newHotspot = document.createElement("input");
  42. newHotspot.type = "hidden";
  43. newHotspot.name = "choice["+question_id+"]["+hotspot_id+"]";
  44. newHotspot.value = answer;
  45. document.frm_exercise.appendChild(newHotspot);
  46. }
  47. /*
  48. * Save the results of the positioning of a point by the user on top of
  49. * the answer area ( for polygons and delineation )
  50. * @param int Question ID
  51. * @param int ID of the area (square or ellipse)
  52. * @param int Whether the answer is correct or not
  53. * @param array Coordinates (horizontal+vertical) of the answer points, in an array
  54. */
  55. function saveDelineationUserAnswer(question_id, hotspot_id, answer, coordinates)
  56. {
  57. newHotspot = document.createElement("input");
  58. newHotspot.type = "hidden";
  59. newHotspot.name = "hotspot["+question_id+"]["+hotspot_id+"]";
  60. newHotspot.value = coordinates;
  61. document.frm_exercise.appendChild(newHotspot);
  62. newHotspot = document.createElement("input");
  63. newHotspot.type = "hidden";
  64. newHotspot.name = "choice["+question_id+"]["+hotspot_id+"]";
  65. newHotspot.value = answer;
  66. document.frm_exercise.appendChild(newHotspot);
  67. }
  68. function saveShapeHotspot(question_id, hotspot_id, type, x, y, w, h)
  69. {
  70. document.frm_exercise["hotspot_coordinates["+hotspot_id+"]"].value = x + ";" + y + "|" + w + "|" + h;
  71. document.frm_exercise["hotspot_type["+hotspot_id+"]"].value = type;
  72. }
  73. function savePolyHotspot(question_id, hotspot_id, coordinates)
  74. {
  75. document.frm_exercise["hotspot_coordinates["+hotspot_id+"]"].value = coordinates;
  76. document.frm_exercise["hotspot_type["+hotspot_id+"]"].value = "poly";
  77. }
  78. function saveDelineationHotspot(question_id, hotspot_id, coordinates)
  79. {
  80. document.frm_exercise["hotspot_coordinates["+hotspot_id+"]"].value = coordinates;
  81. document.frm_exercise["hotspot_type["+hotspot_id+"]"].value = "delineation";
  82. }
  83. function saveOARHotspot(question_id, hotspot_id, coordinates)
  84. {
  85. document.frm_exercise["hotspot_coordinates["+hotspot_id+"]"].value = coordinates;
  86. document.frm_exercise["hotspot_type["+hotspot_id+"]"].value = "oar";
  87. }
  88. function jsdebug(debug_string)
  89. {
  90. alert(debug_string);
  91. }