addlimits.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Adding limits
  5. * @package chamilo.exercise
  6. * @author
  7. * @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
  8. */
  9. /**
  10. * including the global file
  11. */
  12. require_once '../inc/global.inc.php';
  13. /* section (for the tabs) */
  14. $this_section=SECTION_COURSES;
  15. api_protect_course_script();
  16. $dsp_percent = false;
  17. $debug=0;
  18. if($debug>0) {
  19. echo str_repeat('&nbsp;',0).'Entered exercise_result.php'."<br />\n";var_dump($_POST);
  20. }
  21. // general parameters passed via POST/GET
  22. if ( empty ( $origin ) )
  23. {
  24. $origin = $_REQUEST['origin'];
  25. }
  26. if ( empty ( $learnpath_id ) )
  27. {
  28. $learnpath_id = $_REQUEST['learnpath_id'];
  29. }
  30. if ( empty ( $learnpath_item_id ) )
  31. {
  32. $learnpath_item_id = $_REQUEST['learnpath_item_id'];
  33. }
  34. if ( empty ( $formSent ) )
  35. {
  36. $formSent= $_REQUEST['formSent'];
  37. }
  38. if ( empty ( $exerciseResult ) )
  39. {
  40. $exerciseResult = $_SESSION['exerciseResult'];
  41. }
  42. if ( empty ( $questionId ) )
  43. {
  44. $questionId = $_REQUEST['questionId'];
  45. }
  46. if ( empty ( $choice ) ) {
  47. $choice = $_REQUEST['choice'];
  48. }
  49. if ( empty ( $questionNum ) )
  50. {
  51. $questionNum = $_REQUEST['questionNum'];
  52. }
  53. if ( empty ( $nbrQuestions ) )
  54. {
  55. $nbrQuestions = $_REQUEST['nbrQuestions'];
  56. }
  57. if ( empty ( $questionList ) )
  58. {
  59. $questionList = $_SESSION['questionList'];
  60. }
  61. if ( empty ( $objExercise ) )
  62. {
  63. $objExercise = $_SESSION['objExercise'];
  64. }
  65. $exercise_id = intval($_GET['exercise_id']);
  66. $is_allowedToEdit=$is_courseAdmin;
  67. if (isset($_SESSION['gradebook'])){
  68. $gradebook= $_SESSION['gradebook'];
  69. }
  70. if (!empty($gradebook) && $gradebook=='view') {
  71. $interbreadcrumb[]= array (
  72. 'url' => '../gradebook/'.Security::remove_XSS($_SESSION['gradebook_dest']),
  73. 'name' => get_lang('ToolGradebook')
  74. );
  75. }
  76. $nameTools=get_lang('Exercises');
  77. $interbreadcrumb[]=array("url" => "exercise.php","name" => get_lang('Exercises'));
  78. Display::display_header($nameTools,"Exercises");
  79. if (isset($_POST['ok'])) {
  80. $message = get_lang('TestLimitsAdded');
  81. Display::display_normal_message($message);
  82. }
  83. ?>
  84. <script type="text/javascript">
  85. function selectlimited()
  86. {
  87. document.getElementById('limited').checked="checked";
  88. }
  89. function selectattempts()
  90. {
  91. document.getElementById('attemptlimited').checked="checked";
  92. }
  93. </script>
  94. <h3><?php echo get_lang('AddLimits'); ?></h3>
  95. <br>
  96. <form action="addlimits.php" name="frmlimit" method="post">
  97. <h4>
  98. Time :
  99. </h4>
  100. <input type="hidden" name="exe_id" value="<?php echo $exercise_id; ?>" />
  101. <input type="radio" name="limit" checked="checked" value="0" id="unlimit"><?php echo get_lang('Unlimited'); ?>
  102. <br>
  103. <input type="radio" name="limit" value="1" id="limited"><?php echo get_lang('LimitedTime'); ?>
  104. <select name="minutes" onfocus="selectlimited();" >
  105. <option selected="selected">1</option>
  106. <option>2</option>
  107. <option>3</option>
  108. <option>4</option>
  109. <option>5</option>
  110. <option>6</option>
  111. <option>7</option>
  112. <option>8</option>
  113. <option>9</option>
  114. <option>10</option>
  115. <option>15</option>
  116. <option>20</option>
  117. <option>25</option>
  118. <option>30</option>
  119. <option>40</option>
  120. <option>50</option>
  121. <option>60</option>
  122. </select><?php echo get_lang('Minutes'); ?>.
  123. <h4>
  124. <?php echo get_lang('Attempts'); ?>:
  125. </h4>
  126. <input type="radio" name="attempt" checked="checked" value="0" id="attemptunlimited"><?php echo get_lang('Unlimited'); ?>
  127. <br>
  128. <input type="radio" name="attempt" value="1" id="attemptlimited"><?php echo get_lang('LimitedAttempts'); ?>
  129. <select name="attempts" onfocus="selectattempts();">
  130. <option selected="selected">1</option>
  131. <option>2</option>
  132. <option>3</option>
  133. <option>4</option>
  134. <option>5</option>
  135. <option>6</option>
  136. <option>7</option>
  137. <option>8</option>
  138. <option>9</option>
  139. <option>10</option>
  140. </select><?php echo get_lang('Times'); ?>.
  141. <br> <br>
  142. <input type="submit" name="ok" value="<?php echo get_lang('Ok'); ?>">
  143. </form>
  144. <?php
  145. /**
  146. * @todo shouldn't this be moved to the part above (around line 111: action handling)
  147. */
  148. if (isset($_POST['ok'])) {
  149. $exercise_id = intval($_POST['exe_id']);
  150. if ($_POST['limit']==1) {
  151. $minutes = intval($_POST['minutes']);
  152. $query = "UPDATE ".$TBL_EXERCISES." SET ques_time_limit= $minutes WHERE id= $exercise_id";
  153. Database::query($query);
  154. } else {
  155. $query = "UPDATE ".$TBL_EXERCISES." SET ques_time_limit= 0 WHERE id= $exercise_id";
  156. Database::query($query);
  157. }
  158. if ($_POST['attempt']==1) {
  159. $attempts = intval($_POST['attempts']);
  160. $query = "UPDATE ".$TBL_EXERCISES." SET num_attempts = $attempts WHERE id= $exercise_id";
  161. Database::query($query);
  162. } else {
  163. $query = "UPDATE ".$TBL_EXERCISES." SET num_attempts = 0 WHERE id= $exercise_id";
  164. Database::query($query);
  165. }
  166. }
  167. ?>