addlimits.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <?php
  2. include('exercise.class.php');
  3. include('question.class.php');
  4. include('answer.class.php');
  5. // answer types
  6. define('UNIQUE_ANSWER', 1);
  7. define('MULTIPLE_ANSWER', 2);
  8. define('FILL_IN_BLANKS', 3);
  9. define('MATCHING', 4);
  10. define('FREE_ANSWER', 5);
  11. $langFile='exercice';
  12. include('../inc/global.inc.php');
  13. $this_section=SECTION_COURSES;
  14. api_protect_course_script();
  15. include(api_get_path(LIBRARY_PATH).'text.lib.php');
  16. include_once(api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
  17. $TBL_EXERCICE_QUESTION = $_course['dbNameGlu'].'quiz_rel_question';
  18. $TBL_EXERCICES = $_course['dbNameGlu'].'quiz';
  19. $TBL_QUESTIONS = $_course['dbNameGlu'].'quiz_question';
  20. $TBL_REPONSES = $_course['dbNameGlu'].'quiz_answer';
  21. $main_user_table = Database :: get_main_table(MAIN_USER_TABLE);
  22. $main_course_user_table = Database :: get_main_table(MAIN_COURSE_USER_TABLE);
  23. $statsdb = $statsDbName;
  24. $TABLETRACK_ATTEMPT = $statsDbName."`.`track_e_attempt";
  25. $TABLETRACK_EXERCICES = $statsDbName."`.`track_e_exercices";
  26. $dsp_percent = false;
  27. $debug=0;
  28. if($debug>0){echo str_repeat('&nbsp;',0).'Entered exercise_result.php'."<br />\n";var_dump($_POST);}
  29. // general parameters passed via POST/GET
  30. if ( empty ( $origin ) ) {
  31. $origin = $_REQUEST['origin'];
  32. }
  33. if ( empty ( $learnpath_id ) ) {
  34. $learnpath_id = mysql_real_escape_string($_REQUEST['learnpath_id']);
  35. }
  36. if ( empty ( $learnpath_item_id ) ) {
  37. $learnpath_item_id = mysql_real_escape_string($_REQUEST['learnpath_item_id']);
  38. }
  39. if ( empty ( $formSent ) ) {
  40. $formSent= $_REQUEST['formSent'];
  41. }
  42. if ( empty ( $exerciseResult ) ) {
  43. $exerciseResult = $_SESSION['exerciseResult'];
  44. }
  45. if ( empty ( $questionId ) ) {
  46. $questionId = $_REQUEST['questionId'];
  47. }
  48. if ( empty ( $choice ) ) {
  49. $choice = $_REQUEST['choice'];
  50. }
  51. if ( empty ( $questionNum ) ) {
  52. $questionNum = mysql_real_escape_string($_REQUEST['questionNum']);
  53. }
  54. if ( empty ( $nbrQuestions ) ) {
  55. $nbrQuestions = mysql_real_escape_string($_REQUEST['nbrQuestions']);
  56. }
  57. if ( empty ( $questionList ) ) {
  58. $questionList = $_SESSION['questionList'];
  59. }
  60. if ( empty ( $objExercise ) ) {
  61. $objExercise = $_SESSION['objExercise'];
  62. }
  63. $exercise_id = $_GET['exercise_id'];
  64. $is_allowedToEdit=$is_courseAdmin;
  65. $nameTools=get_lang('Exercice');
  66. $interbreadcrumb[]=array("url" => "exercice.php","name" => get_lang('Exercices'));
  67. Display::display_header($nameTools,"Exercise");
  68. if (isset($_POST['ok']))
  69. {
  70. $message = "Test limits added";
  71. Display::display_normal_message($message);
  72. }
  73. ?>
  74. <script type="text/javascript">
  75. function selectlimited()
  76. {
  77. document.getElementById('limited').checked="checked";
  78. }
  79. function selectattempts()
  80. {
  81. document.getElementById('attemptlimited').checked="checked";
  82. }
  83. </script>
  84. <h3>
  85. <?php
  86. echo "AddLimits"; ?>
  87. </h3>
  88. <br>
  89. <form action="addlimits.php" name="frmlimit" method="post">
  90. <h4>
  91. Time :
  92. </h4>
  93. <input type="hidden" name="exe_id" value="<?php echo $exercise_id; ?>" />
  94. <input type="radio" name="limit" checked="checked" value="0" id="unlimit"> Unlimited
  95. <br>
  96. <input type="radio" name="limit" value="1" id="limited"> Limited: Each question of the test should be answered in
  97. <select name="minutes" onfocus="selectlimited();" >
  98. <option selected="selected">1</option>
  99. <option>2</option>
  100. <option>3</option>
  101. <option>4</option>
  102. <option>5</option>
  103. <option>6</option>
  104. <option>7</option>
  105. <option>8</option>
  106. <option>9</option>
  107. <option>10</option>
  108. <option>15</option>
  109. <option>20</option>
  110. <option>25</option>
  111. <option>30</option>
  112. <option>40</option>
  113. <option>50</option>
  114. <option>60</option>
  115. </select> minute(s).
  116. <h4>
  117. Attempts :
  118. </h4>
  119. <input type="radio" name="attempt" checked="checked" value="0" id="attemptunlimited"> Unlimited
  120. <br>
  121. <input type="radio" name="attempt" value="1" id="attemptlimited"> Limited: The test can be taken only
  122. <select name="attempts" onfocus="selectattempts();">
  123. <option selected="selected">1</option>
  124. <option>2</option>
  125. <option>3</option>
  126. <option>4</option>
  127. <option>5</option>
  128. <option>6</option>
  129. <option>7</option>
  130. <option>8</option>
  131. <option>9</option>
  132. <option>10</option>
  133. </select> time(s).
  134. <br> <br>
  135. <input type="submit" name="ok" value="Ok">
  136. </form>
  137. <?php
  138. if (isset($_POST['ok']))
  139. {
  140. $exercise_id = $_POST['exe_id'];
  141. if ($_POST['limit']==1)
  142. {
  143. $minutes = $_POST['minutes'];
  144. $query = "update `".$TBL_EXERCICES."` set ques_time_limit= $minutes where id= $exercise_id";
  145. api_sql_query($query,_FILE_,_LINE_);
  146. }
  147. else
  148. {
  149. $query = "update `".$TBL_EXERCICES."` set ques_time_limit= 0 where id= $exercise_id";
  150. api_sql_query($query,_FILE_,_LINE_);
  151. }
  152. if ($_POST['attempt']==1)
  153. {
  154. $attempts = $_POST['attempts'];
  155. $query = "update `".$TBL_EXERCICES."` set num_attempts = $attempts where id= $exercise_id";
  156. api_sql_query($query,_FILE_,_LINE_);
  157. }
  158. else
  159. {
  160. $query = "update`".$TBL_EXERCICES."` set num_attempts = 0 where id= $exercise_id";
  161. api_sql_query($query,_FILE_,_LINE_);
  162. }
  163. }
  164. ?>