hotspot_updatescore.inc.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2004 Dokeos S.A.
  6. Copyright (c) 2003 Ghent University (UGent)
  7. Copyright (c) 2001 Universite catholique de Louvain (UCL)
  8. Copyright (c) Olivier Brouckaert
  9. For a full list of contributors, see "credits.txt".
  10. The full license can be read in "license.txt".
  11. This program is free software; you can redistribute it and/or
  12. modify it under the terms of the GNU General Public License
  13. as published by the Free Software Foundation; either version 2
  14. of the License, or (at your option) any later version.
  15. See the GNU General Public License for more details.
  16. Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
  17. ==============================================================================
  18. */
  19. /**
  20. ==============================================================================
  21. * This file saves every click in the hotspot tool into track_e_hotspots
  22. *
  23. * @author Toon Keppens
  24. * @package dokeos.exercise
  25. ==============================================================================
  26. */
  27. include('exercise.class.php');
  28. include('question.class.php');
  29. include('answer.class.php');
  30. include('../inc/global.inc.php');
  31. include('../inc/lib/database.lib.php');
  32. $courseCode = $_GET['coursecode'];
  33. $questionId = $_GET['questionId'];
  34. $coordinates = $_GET['coord'];
  35. $objExcercise = $_SESSION['objExercise'];
  36. $hotspotId = $_GET['hotspotId'];
  37. $exerciseId = $objExcercise->selectId();
  38. if ($_GET['answerId'] == "0") // click is NOT on a hotspot
  39. {
  40. $hit = 0;
  41. $answerId = $hotspotId;
  42. // remove from session
  43. unset($_SESSION['exerciseResult'][$questionId][$answerId]);
  44. // Save clicking order
  45. //$answerOrderId = count($_SESSION['exerciseResult'][$questionId]['order'])+1;
  46. //$_SESSION['exerciseResult'][$questionId]['order'][$answerOrderId] = $answerId;
  47. }
  48. else // user clicked ON a hotspot
  49. {
  50. $hit = 1;
  51. $answerId = $hotspotId;
  52. // Save into session
  53. $_SESSION['exerciseResult'][$questionId][$answerId] = $hit;
  54. // Save clicking order
  55. //$answerOrderId = count($_SESSION['exerciseResult'][$questionId]['order'])+1;
  56. //$_SESSION['exerciseResult'][$questionId]['order'][$answerOrderId] = $answerId;
  57. }
  58. $TBL_TRACK_E_HOTSPOT = Database::get_statistic_table(STATISTIC_TRACK_E_HOTSPOTS);
  59. // update db
  60. $update_id = $_SESSION['exerciseResult'][$questionId]['ids'][$answerId];
  61. $sql = "UPDATE $TBL_TRACK_E_HOTSPOT SET `coordinate` = '".$coordinates."' WHERE `id` =$update_id LIMIT 1 ;;";
  62. $result = api_sql_query($sql,__FILE__,__LINE__);
  63. ?>