hotspot_updatescore.inc.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * This file saves every click in the hotspot tool into track_e_hotspots
  5. * @package chamilo.exercise
  6. * @author Toon Keppens
  7. * @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
  8. */
  9. include 'exercise.class.php';
  10. include 'question.class.php';
  11. include 'answer.class.php';
  12. include '../inc/global.inc.php';
  13. $courseCode = $_GET['coursecode'];
  14. $questionId = $_GET['questionId'];
  15. $coordinates = $_GET['coord'];
  16. $objExcercise = $_SESSION['objExercise'];
  17. $hotspotId = $_GET['hotspotId'];
  18. $exerciseId = $objExcercise->selectId();
  19. if ($_GET['answerId'] == "0") { // click is NOT on a hotspot
  20. $hit = 0;
  21. $answerId = $hotspotId;
  22. // remove from session
  23. unset($_SESSION['exerciseResult'][$questionId][$answerId]);
  24. // Save clicking order
  25. //$answerOrderId = count($_SESSION['exerciseResult'][$questionId]['order'])+1;
  26. //$_SESSION['exerciseResult'][$questionId]['order'][$answerOrderId] = $answerId;
  27. } else { // user clicked ON a hotspot
  28. $hit = 1;
  29. $answerId = $hotspotId;
  30. // Save into session
  31. $_SESSION['exerciseResult'][$questionId][$answerId] = $hit;
  32. // Save clicking order
  33. //$answerOrderId = count($_SESSION['exerciseResult'][$questionId]['order'])+1;
  34. //$_SESSION['exerciseResult'][$questionId]['order'][$answerOrderId] = $answerId;
  35. }
  36. //round-up the coordinates
  37. $coords = explode('/',$coordinates);
  38. $coordinates = '';
  39. foreach ($coords as $coord) {
  40. list($x,$y) = explode(';',$coord);
  41. $coordinates .= round($x).';'.round($y).'/';
  42. }
  43. $coordinates = substr($coordinates,0,-1);
  44. $TBL_TRACK_E_HOTSPOT = Database::get_statistic_table(STATISTIC_TRACK_E_HOTSPOTS);
  45. // update db
  46. $update_id = $_SESSION['exerciseResult'][$questionId]['ids'][$answerId];
  47. $sql = "UPDATE $TBL_TRACK_E_HOTSPOT SET coordinate = '".Database::escape_string($coordinates)."' WHERE id = ".intval($update_id)." LIMIT 1 ;;";
  48. $result = Database::query($sql);