hotspot_savescore.inc.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. $exerciseId = $objExcercise->selectId();
  37. // Save clicking order
  38. $answerOrderId = count($_SESSION['exerciseResult'][$questionId]['ids'])+1;
  39. if ($_GET['answerId'] == "0") // click is NOT on a hotspot
  40. {
  41. $hit = 0;
  42. $answerId = NULL;
  43. }
  44. else // user clicked ON a hotspot
  45. {
  46. $hit = 1;
  47. $answerId = substr($_GET['answerId'],22,2);
  48. // Save into session
  49. $_SESSION['exerciseResult'][$questionId][$answerId] = $hit;
  50. }
  51. $TBL_TRACK_E_HOTSPOT = Database::get_statistic_table(STATISTIC_TRACK_E_HOTSPOTS);
  52. // Save into db
  53. $sql = "INSERT INTO $TBL_TRACK_E_HOTSPOT (`user_id` , `course_id` , `quiz_id` , `question_id` , `answer_id` , `correct` , `coordinate` ) VALUES ('$_uid', '$courseCode', '$exerciseId', '$questionId', '$answerId', '$hit', '$coordinates')";
  54. $result = api_sql_query($sql,__FILE__,__LINE__);
  55. // Save insert id into session if users changes answer.
  56. $insert_id = mysql_insert_id();
  57. $_SESSION['exerciseResult'][$questionId]['ids'][$answerOrderId] = $insert_id;
  58. ?>