hotspot.js 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 jsdebug(debug_string)
  84. {
  85. alert(debug_string);
  86. }