hotspot_save.inc.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * @package chamilo.exercise
  5. *
  6. * @author Toon Keppens
  7. *
  8. * @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
  9. */
  10. require_once __DIR__.'/../inc/global.inc.php';
  11. api_protect_course_script(true);
  12. $TBL_ANSWER = Database::get_course_table(TABLE_QUIZ_ANSWER);
  13. $questionId = intval($_GET['questionId']);
  14. $answerId = intval($_GET['answerId']);
  15. if ($_GET['type'] == "square" || $_GET['type'] == "circle") {
  16. $hotspot_type = $_GET['type'];
  17. $hotspot_coordinates = $_GET['x'].";".$_GET['y']."|".$_GET['width']."|".$_GET['height'];
  18. }
  19. if ($_GET['type'] == "poly" || $_GET['type'] == "delineation" || $_GET['type'] == "oar") {
  20. $hotspot_type = $_GET['type'];
  21. $tmp_coord = explode(",", $_GET['co']);
  22. $i = 0;
  23. $hotspot_coordinates = "";
  24. foreach ($tmp_coord as $coord) {
  25. if ($i % 2 == 0) {
  26. $delimiter = ";";
  27. } else {
  28. $delimiter = "|";
  29. }
  30. $hotspot_coordinates .= $coord.$delimiter;
  31. $i++;
  32. }
  33. $hotspot_coordinates = api_substr($hotspot_coordinates, 0, -2);
  34. }
  35. $course_id = api_get_course_int_id();
  36. $sql = "UPDATE $TBL_ANSWER SET
  37. hotspot_coordinates = '".Database::escape_string($hotspot_coordinates)."',
  38. hotspot_type = '".Database::escape_string($hotspot_type)."'
  39. WHERE
  40. c_id = $course_id AND
  41. id = ".intval($answerId)." AND
  42. question_id = ".intval($questionId)."
  43. LIMIT 1 ";
  44. $result = Database::query($sql);
  45. echo "done=done";