dokeos-exercise
[ class tree: dokeos-exercise ] [ index: dokeos-exercise ] [ all elements ]

Source for file hotspot_answers.as.php

Documentation is available at hotspot_answers.as.php

  1. <?php
  2. /*
  3.     DOKEOS - elearning and course management software
  4.  
  5.     For a full list of contributors, see documentation/credits.html
  6.  
  7.     This program is free software; you can redistribute it and/or
  8.     modify it under the terms of the GNU General Public License
  9.     as published by the Free Software Foundation; either version 2
  10.     of the License, or (at your option) any later version.
  11.     See "documentation/licence.html" more details.
  12.  
  13.     Contact:
  14.         Dokeos
  15.         Rue des Palais 44 Paleizenstraat
  16.         B-1030 Brussels - Belgium
  17.         Tel. +32 (2) 211 34 56
  18. */
  19.  
  20.  
  21. /**
  22. *    This file generates the ActionScript variables code used by the HotSpot .swf
  23. *    @package dokeos.exercise
  24. *     @author Toon Keppens
  25. *     @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
  26. */
  27.  
  28.  
  29. include('exercise.class.php');
  30. include('question.class.php');
  31. include('answer.class.php');
  32. include('../inc/global.inc.php');
  33.  
  34. // set vars
  35. $userId        $_user['user_id'];
  36. $questionId    $_GET['modifyAnswers'];
  37. $exe_id    $_GET['exe_id'];
  38. $from_db = isset($_GET['from_db']$_GET['from_db'0;
  39. $objQuestion Question :: read($questionId);
  40. $documentPath  api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
  41.  
  42. $picturePath   $documentPath.'/images';
  43. $pictureName   $objQuestion->selectPicture();
  44. $pictureSize   getimagesize($picturePath.'/'.$objQuestion->selectPicture());
  45. $pictureWidth  $pictureSize[0];
  46. $pictureHeight $pictureSize[1];
  47.  
  48. $courseLang $_course['language'];
  49. $courseCode $_course['sysCode'];
  50. $coursePath $_course['path'];
  51.  
  52. // Query db for answers
  53. $sql "SELECT id, answer, hotspot_coordinates, hotspot_type FROM $TBL_ANSWERS WHERE question_id = '$questionId' ORDER BY id";
  54. $result api_sql_query($sql,__FILE__,__LINE__);
  55.  
  56. // Init
  57. $output "hotspot_lang=$courseLang&hotspot_image=$pictureName&hotspot_image_width=$pictureWidth&hotspot_image_height=$pictureHeight&courseCode=$coursePath";
  58. $i 0;
  59.  
  60. while ($hotspot mysql_fetch_array($result))
  61. {
  62.     $output .= "&hotspot_".$hotspot['id']."=true";
  63.     // Square or rectancle
  64.     if ($hotspot['hotspot_type'== 'square' )
  65.     {
  66.         $output .= "&hotspot_".$hotspot['id']."_type=square";
  67.     }
  68.  
  69.     // Circle or ovale
  70.     if ($hotspot['hotspot_type'== 'circle')
  71.     {
  72.         $output .= "&hotspot_".$hotspot['id']."_type=circle";
  73.     }
  74.  
  75.     // Polygon
  76.     if ($hotspot['hotspot_type'== 'poly')
  77.     {
  78.         $output .= "&hotspot_".$hotspot['id']."_type=poly";
  79.     }
  80.  
  81.     $output .= "&hotspot_".$hotspot['id']."_coord=".$hotspot['hotspot_coordinates']."";
  82.  
  83.     $i++;
  84. }
  85.  
  86. // Generate empty
  87. $i++;
  88. for ($i$i <= 12$i++)
  89. {
  90.     $output .= "&hotspot_".$i."=false";
  91. }
  92.  
  93. // set vars
  94. $questionId    $_GET['modifyAnswers'];
  95. $course_code $_course['id'];
  96.  
  97. // Get clicks
  98. if(isset($_SESSION['exerciseResultCoordinates']&& $from_db==0)
  99. {
  100.     foreach ($_SESSION['exerciseResultCoordinates'][$questionIdas $coordinate)
  101.     {
  102.         $output2 .= $coordinate."|";
  103.     }
  104. }
  105. else
  106. {
  107.     // get it from db
  108.     $sql 'SELECT hotspot_coordinate 
  109.             FROM '.$tbl_track_e_hotspot.'
  110.             WHERE hotspot_question_id = '.intval($questionId).'
  111.             AND hotspot_course_code = "'.Database::escape_string($course_code).'"
  112.             AND hotspot_exe_id='.intval($exe_id);
  113.     
  114.     $rs @api_sql_query($sql)// don't output error because we are in Flash execution.
  115.     while($row Database :: fetch_array($rs))
  116.     {
  117.         $output2 .= $row['hotspot_coordinate']."|";
  118.     }
  119. }
  120.  
  121. $output .= "&p_hotspot_answers=".substr($output2,0,-1)."&done=done";
  122.  
  123. $explode explode('&'$output);
  124.  
  125. echo $output;
  126. ?>

Documentation generated on Thu, 12 Jun 2008 13:39:36 -0500 by phpDocumentor 1.4.1