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

Source for file addlimits.php

Documentation is available at addlimits.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. *    Adding limits
  23. *    @package dokeos.exercise
  24. *     @author
  25. *     @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
  26. */
  27. /*
  28. -----------------------------------------------------------
  29.     including the global file
  30. -----------------------------------------------------------
  31. */
  32. include('../inc/global.inc.php');
  33.  
  34. /*
  35. -----------------------------------------------------------
  36.     Including necessary files
  37. -----------------------------------------------------------
  38. */
  39. include('exercise.class.php');
  40. include('question.class.php');
  41. include('answer.class.php');
  42. include_once(api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
  43.  
  44. /*
  45. -----------------------------------------------------------
  46.     Answer types
  47. -----------------------------------------------------------
  48. */
  49. define('UNIQUE_ANSWER',    1);
  50. define('MULTIPLE_ANSWER',    2);
  51. define('FILL_IN_BLANKS',    3);
  52. define('MATCHING',        4);
  53. define('FREE_ANSWER'5);
  54.  
  55. /*
  56. -----------------------------------------------------------
  57.     Language
  58. -----------------------------------------------------------
  59. */
  60. // name of the language file that needs to be included
  61. $language_file='exercice';
  62.  
  63. /*
  64. -----------------------------------------------------------
  65.     section (for the tabs)
  66. -----------------------------------------------------------
  67. */
  68. $this_section=SECTION_COURSES;
  69.  
  70.  
  71. /*
  72. -----------------------------------------------------------
  73.     Table definitions
  74.     @todo: use the Database :: get_course_table functions
  75. -----------------------------------------------------------
  76. */
  77. $TBL_EXERCICE_QUESTION Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
  78. $TBL_EXERCICES         Database::get_course_table(TABLE_QUIZ_TEST);
  79. $TBL_QUESTIONS         Database::get_course_table(TABLE_QUIZ_QUESTION);
  80. $TBL_REPONSES          Database::get_course_table('quiz_answer');
  81. $main_user_table Database :: get_main_table(TABLE_MAIN_USER);
  82. $main_course_user_table Database :: get_main_table(TABLE_MAIN_COURSE_USER);
  83. $TBL_TRACK_ATTEMPT        Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
  84.  
  85. $dsp_percent false;
  86. $debug=0;
  87. if($debug>0)
  88. {
  89.     echo str_repeat('&nbsp;',0).'Entered exercise_result.php'."<br />\n";var_dump($_POST);
  90. }
  91. // general parameters passed via POST/GET
  92. if empty $origin ) )
  93. {
  94.     $origin $_REQUEST['origin'];
  95. }
  96. if empty $learnpath_id ) )
  97. {
  98.     $learnpath_id       mysql_real_escape_string($_REQUEST['learnpath_id']);
  99. }
  100. if empty $learnpath_item_id ) )
  101. {
  102.     $learnpath_item_id  mysql_real_escape_string($_REQUEST['learnpath_item_id']);
  103. }
  104. if empty $formSent ) )
  105. {
  106.     $formSent$_REQUEST['formSent'];
  107. }
  108. if empty $exerciseResult ) )
  109. {
  110.     $exerciseResult $_SESSION['exerciseResult'];
  111. }
  112. if empty $questionId ) )
  113. {
  114.     $questionId $_REQUEST['questionId'];
  115. }
  116. if empty $choice ) ) {
  117.     $choice $_REQUEST['choice'];
  118. }
  119. if empty $questionNum ) )
  120. {
  121.     $questionNum    mysql_real_escape_string($_REQUEST['questionNum']);
  122. }
  123. if empty $nbrQuestions ) )
  124. {
  125.     $nbrQuestions   mysql_real_escape_string($_REQUEST['nbrQuestions']);
  126. }
  127. if empty $questionList ) )
  128. {
  129.     $questionList $_SESSION['questionList'];
  130. }
  131. if empty $objExercise ) )
  132. {
  133.     $objExercise $_SESSION['objExercise'];
  134. }
  135. $exercise_id $_GET['exercise_id'];
  136. $is_allowedToEdit=$is_courseAdmin;
  137.  
  138.  
  139. $nameTools=get_lang('Exercice');
  140.  
  141. $interbreadcrumb[]=array("url" => "exercice.php","name" => get_lang('Exercices'));
  142.  
  143. Display::display_header($nameTools,"Exercise");
  144.  
  145. /*
  146. -----------------------------------------------------------
  147.     Action handling
  148. -----------------------------------------------------------
  149. */
  150. include('../inc/global.inc.php');
  151. if (isset($_POST['ok']))
  152. {
  153.     $message get_lang('TestLimitsAdded');
  154.     Display::display_normal_message($message);
  155. }
  156. ?>
  157.  
  158.  
  159.  
  160.   <script type="text/javascript">
  161.   function selectlimited()
  162.   {
  163.       document.getElementById('limited').checked="checked";
  164.   }
  165.    function selectattempts()
  166.   {
  167.       document.getElementById('attemptlimited').checked="checked";
  168.   }
  169.   </script>
  170.   <h3><?php  echo get_lang('AddLimits')?></h3>
  171. <br>
  172. <form action="addlimits.php" name="frmlimit" method="post">
  173. <h4>
  174. Time :
  175. </h4>
  176. <input type="hidden" name="exe_id" value="<?php echo $exercise_id?>" />
  177. <input type="radio" name="limit" checked="checked" value="0" id="unlimit"><?php echo get_lang('Unlimited')?>
  178. <br>
  179. <input type="radio" name="limit" value="1" id="limited"><?php echo get_lang('LimitedTime')?>
  180. <select name="minutes" onfocus="selectlimited();" >
  181.   <option selected="selected">1</option>
  182.   <option>2</option>
  183.   <option>3</option>
  184.   <option>4</option>
  185.   <option>5</option>
  186.   <option>6</option>
  187.   <option>7</option>
  188.   <option>8</option>
  189.   <option>9</option>
  190.   <option>10</option>
  191.   <option>15</option>
  192.   <option>20</option>
  193.   <option>25</option>
  194.   <option>30</option>
  195.   <option>40</option>
  196.   <option>50</option>
  197.   <option>60</option>
  198. </select><?php echo get_lang('Minutes')?>.
  199. <h4>
  200. <?php echo get_lang('Attempts')?>:
  201. </h4>
  202. <input type="radio" name="attempt" checked="checked" value="0" id="attemptunlimited"><?php echo get_lang('Unlimited')?>
  203. <br>
  204. <input type="radio" name="attempt" value="1" id="attemptlimited"><?php echo get_lang('LimitedAttempts')?>
  205. <select name="attempts" onfocus="selectattempts();">
  206.   <option selected="selected">1</option>
  207.   <option>2</option>
  208.   <option>3</option>
  209.   <option>4</option>
  210.   <option>5</option>
  211.   <option>6</option>
  212.   <option>7</option>
  213.   <option>8</option>
  214.   <option>9</option>
  215.   <option>10</option>
  216.   </select><?php echo get_lang('Times')?>.
  217.  
  218. <br> <br>
  219. <input type="submit" name="ok" value="<?php echo get_lang('Ok')?>">
  220. </form>
  221. <?php
  222. /**
  223.  * @todo shouldn't this be moved to the part above (around line 111: action handling)
  224.  */
  225. if (isset($_POST['ok']))
  226. {
  227.     $exercise_id $_POST['exe_id'];
  228.     if ($_POST['limit']==1)
  229.     {
  230.         $minutes $_POST['minutes'];
  231.         $query "update `".$TBL_EXERCICES."` set ques_time_limit= $minutes where id= $exercise_id";
  232.         api_sql_query($query,__FILE__,__LINE__);
  233.     }
  234.     else
  235.     {
  236.         $query "update `".$TBL_EXERCICES."` set ques_time_limit= 0 where id= $exercise_id";
  237.         api_sql_query($query,__FILE__,__LINE__);
  238.     }
  239.  
  240.     if ($_POST['attempt']==1)
  241.     {
  242.         $attempts $_POST['attempts'];
  243.         $query "update `".$TBL_EXERCICES."` set num_attempts = $attempts where id= $exercise_id";
  244.         api_sql_query($query,__FILE__,__LINE__);
  245.     }
  246.     else
  247.     {
  248.         $query "update`".$TBL_EXERCICES."` set num_attempts = 0 where id= $exercise_id";
  249.         api_sql_query($query,__FILE__,__LINE__);
  250.     }
  251. }
  252. ?>

Documentation generated on Thu, 12 Jun 2008 12:53:29 -0500 by phpDocumentor 1.4.1