hotspot_savescore.inc.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /*
  3. DOKEOS - elearning and course management software
  4. For a full list of contributors, see documentation/credits.html
  5. This program is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU General Public License
  7. as published by the Free Software Foundation; either version 2
  8. of the License, or (at your option) any later version.
  9. See "documentation/licence.html" more details.
  10. Contact:
  11. Dokeos
  12. Rue des Palais 44 Paleizenstraat
  13. B-1030 Brussels - Belgium
  14. Tel. +32 (2) 211 34 56
  15. */
  16. /**
  17. * This file saves every click in the hotspot tool into track_e_hotspots
  18. * @package dokeos.exercise
  19. * @author Toon Keppens
  20. * @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
  21. */
  22. include('exercise.class.php');
  23. include('question.class.php');
  24. include('answer.class.php');
  25. include('../inc/global.inc.php');
  26. include('../inc/lib/database.lib.php');
  27. $courseCode = $_GET['coursecode'];
  28. $questionId = $_GET['questionId'];
  29. $coordinates = $_GET['coord'];
  30. $objExcercise = $_SESSION['objExercise'];
  31. $exerciseId = $objExcercise->selectId();
  32. // Save clicking order
  33. $answerOrderId = count($_SESSION['exerciseResult'][$questionId]['ids'])+1;
  34. if ($_GET['answerId'] == "0") // click is NOT on a hotspot
  35. {
  36. $hit = 0;
  37. $answerId = NULL;
  38. }
  39. else // user clicked ON a hotspot
  40. {
  41. $hit = 1;
  42. $answerId = substr($_GET['answerId'],22,2);
  43. // Save into session
  44. $_SESSION['exerciseResult'][$questionId][$answerId] = $hit;
  45. }
  46. $TBL_TRACK_E_HOTSPOT = Database::get_statistic_table(STATISTIC_TRACK_E_HOTSPOTS);
  47. // Save into db
  48. $sql = "INSERT INTO $TBL_TRACK_E_HOTSPOT (`user_id` , `course_id` , `quiz_id` , `question_id` , `answer_id` , `correct` , `coordinate` ) VALUES ('".$_user['user_id']."', '$courseCode', '$exerciseId', '$questionId', '$answerId', '$hit', '$coordinates')";
  49. $result = api_sql_query($sql,__FILE__,__LINE__);
  50. // Save insert id into session if users changes answer.
  51. $insert_id = mysql_insert_id();
  52. $_SESSION['exerciseResult'][$questionId]['ids'][$answerOrderId] = $insert_id;
  53. ?>