hotspot_updatescore.inc.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php //$id:$
  2. /* For licensing terms, see /dokeos_license.txt */
  3. //error_log(__FILE__);
  4. /**
  5. * This file saves every click in the hotspot tool into track_e_hotspots
  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. $courseCode = $_GET['coursecode'];
  15. $questionId = $_GET['questionId'];
  16. $coordinates = $_GET['coord'];
  17. $objExcercise = $_SESSION['objExercise'];
  18. $hotspotId = $_GET['hotspotId'];
  19. $exerciseId = $objExcercise->selectId();
  20. if ($_GET['answerId'] == "0") // click is NOT on a hotspot
  21. {
  22. $hit = 0;
  23. $answerId = $hotspotId;
  24. // remove from session
  25. unset($_SESSION['exerciseResult'][$questionId][$answerId]);
  26. // Save clicking order
  27. //$answerOrderId = count($_SESSION['exerciseResult'][$questionId]['order'])+1;
  28. //$_SESSION['exerciseResult'][$questionId]['order'][$answerOrderId] = $answerId;
  29. }
  30. else // user clicked ON a hotspot
  31. {
  32. $hit = 1;
  33. $answerId = $hotspotId;
  34. // Save into session
  35. $_SESSION['exerciseResult'][$questionId][$answerId] = $hit;
  36. // Save clicking order
  37. //$answerOrderId = count($_SESSION['exerciseResult'][$questionId]['order'])+1;
  38. //$_SESSION['exerciseResult'][$questionId]['order'][$answerOrderId] = $answerId;
  39. }
  40. //round-up the coordinates
  41. $coords = explode('/',$coordinates);
  42. $coordinates = '';
  43. foreach ($coords as $coord) {
  44. list($x,$y) = explode(';',$coord);
  45. $coordinates .= round($x).';'.round($y).'/';
  46. }
  47. $coordinates = substr($coordinates,0,-1);
  48. $TBL_TRACK_E_HOTSPOT = Database::get_statistic_table(STATISTIC_TRACK_E_HOTSPOTS);
  49. // update db
  50. $update_id = $_SESSION['exerciseResult'][$questionId]['ids'][$answerId];
  51. $sql = "UPDATE $TBL_TRACK_E_HOTSPOT SET coordinate = '".Database::escape_string($coordinates)."' WHERE id ='".Database::escape_string($update_id)."' LIMIT 1 ;;";
  52. $result = Database::query($sql,__FILE__,__LINE__);
  53. ?>