exercise_admin.inc.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <?php // $Id: exercise_admin.inc.php 9665 2006-10-24 10:43:48Z elixir_inter $
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2004 Dokeos S.A.
  6. Copyright (c) 2003 Ghent University (UGent)
  7. Copyright (c) 2001 Universite catholique de Louvain (UCL)
  8. Copyright (c) Olivier Brouckaert
  9. For a full list of contributors, see "credits.txt".
  10. The full license can be read in "license.txt".
  11. This program is free software; you can redistribute it and/or
  12. modify it under the terms of the GNU General Public License
  13. as published by the Free Software Foundation; either version 2
  14. of the License, or (at your option) any later version.
  15. See the GNU General Public License for more details.
  16. Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
  17. ==============================================================================
  18. */
  19. /**
  20. ==============================================================================
  21. * EXERCISE ADMINISTRATION
  22. *
  23. * This script allows to manage an exercise.
  24. * It is included from the script admin.php
  25. *
  26. * @author Olivier Brouckaert
  27. * @package dokeos.exercise
  28. ==============================================================================
  29. */
  30. // ALLOWED_TO_INCLUDE is defined in admin.php
  31. if(!defined('ALLOWED_TO_INCLUDE'))
  32. {
  33. exit();
  34. }
  35. // the exercise form has been submitted
  36. if($submitExercise)
  37. {
  38. $exerciseTitle=trim($exerciseTitle);
  39. $exerciseDescription=trim($exerciseDescription);
  40. $randomQuestions=$randomQuestions?$questionDrawn:0;
  41. $deleteSound=$deleteSound?true:false;
  42. // no title given
  43. if(empty($exerciseTitle))
  44. {
  45. $msgErr=get_lang('GiveExerciseName');
  46. }
  47. else
  48. {
  49. $objExercise->updateTitle($exerciseTitle);
  50. $objExercise->updateDescription($exerciseDescription);
  51. $objExercise->updateSound($_FILES['exerciseSound'],$deleteSound);
  52. $objExercise->updateType($exerciseType);
  53. $objExercise->setRandom($randomQuestions);
  54. $objExercise->save();
  55. if($deleteSound)
  56. {
  57. $exerciseSound='';
  58. }
  59. else
  60. {
  61. $exerciseSound=$objExercise->selectSound();
  62. }
  63. // reads the exercise ID (only usefull for a new exercise)
  64. $exerciseId=$objExercise->selectId();
  65. unset($modifyExercise);
  66. }
  67. }
  68. else
  69. {
  70. $exerciseTitle=$objExercise->selectTitle();
  71. $exerciseDescription=$objExercise->selectDescription();
  72. $exerciseSound=$objExercise->selectSound();
  73. $exerciseType=$objExercise->selectType();
  74. $randomQuestions=$objExercise->isRandom();
  75. }
  76. // shows the form to modify the exercise
  77. if($modifyExercise)
  78. {
  79. ?>
  80. <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>?modifyExercise=<?php echo $modifyExercise; ?>" style="margin:0px;" enctype="multipart/form-data">
  81. <table border="0" cellpadding="5">
  82. <?php
  83. if(!empty($msgErr))
  84. {
  85. ?>
  86. <tr>
  87. <td colspan="2">
  88. <?php
  89. Display::display_normal_message($msgErr); //main API
  90. ?>
  91. </td>
  92. </tr>
  93. <?php
  94. }
  95. ?>
  96. <tr>
  97. <td><?php echo get_lang('langExerciseName'); ?> :</td>
  98. <td><input type="text" name="exerciseTitle" size="50" maxlength="200" value="<?php echo htmlentities($exerciseTitle); ?>" style="width:400px;"></td>
  99. </tr>
  100. <tr>
  101. <td valign="top"><?php echo get_lang('langExerciseDescription'); ?> :</td>
  102. <td>
  103. <textarea name="exerciseDescription" rows="4" cols="48"><?php echo $exerciseDescription; ?></textarea>
  104. <?php
  105. //api_disp_html_area('exerciseDescription',$exerciseDescription,'250px');
  106. ?>
  107. </td>
  108. </tr>
  109. <!--
  110. <tr>
  111. <td valign="top"><?php echo get_lang('langSound'); ?> :
  112. <?php if(!empty($exerciseSound)): ?>
  113. <a href="../document/download.php?doc_url=%2Faudio%2F<?php echo $exerciseSound; ?>" target="_blank"><img src="../img/wav.gif" border="0" align="absmiddle" alt="<?php echo get_lang('langSound'); ?>"></a>
  114. <?php endif; ?>
  115. </td>
  116. <td><input type="file" name="exerciseSound" size="50" style="width:400px;">
  117. <?php if(!empty($exerciseSound)): ?>
  118. <br>
  119. <input class="checkbox" type="checkbox" name="deleteSound" value="1"> <?php echo get_lang('langDeleteSound'); ?>
  120. <?php endif; ?>
  121. </td>
  122. </tr>
  123. //-->
  124. <tr>
  125. <td valign="top"><?php echo get_lang('langExerciseType'); ?> :</td>
  126. <td><input class="checkbox" type="radio" name="exerciseType" value="1" <?php if($exerciseType <= 1) echo 'checked="checked"'; ?>> <?php echo get_lang('langSimpleExercise'); ?><br>
  127. <input class="checkbox" type="radio" name="exerciseType" value="2" <?php if($exerciseType >= 2) echo 'checked="checked"'; ?>> <?php echo get_lang('langSequentialExercise'); ?></td>
  128. </tr>
  129. <?php
  130. if($exerciseId && $nbrQuestions)
  131. {
  132. ?>
  133. <tr>
  134. <td valign="top"><?php echo get_lang('langRandomQuestions'); ?> :</td>
  135. <td><input class="checkbox" type="checkbox" name="randomQuestions" value="1" <?php if($randomQuestions) echo 'checked="checked"'; ?>> <?php echo get_lang('langYes'); ?>, <?php echo get_lang('langTake'); ?>
  136. <select name="questionDrawn">
  137. <?php
  138. for($i=1;$i <= $nbrQuestions;$i++)
  139. {
  140. ?>
  141. <option value="<?php echo $i; ?>" <?php if(($formSent && $questionDrawn == $i) || (!$formSent && ($randomQuestions == $i || ($randomQuestions <= 0 && $i == $nbrQuestions)))) echo 'selected="selected"'; ?>><?php echo $i; ?></option>
  142. <?php
  143. }
  144. ?>
  145. </select> <?php echo strtolower(get_lang('langQuestions')).' '.get_lang('langAmong').' '.$nbrQuestions; ?>
  146. </td>
  147. </tr>
  148. <?php
  149. }
  150. ?>
  151. <tr>
  152. <td>&nbsp;</td>
  153. <td>
  154. <input type="hidden" name="myid" value="1"><?php //added?>
  155. <input type="submit" name="submitExercise" value="<?php echo get_lang('langOk'); ?>">
  156. <!-- &nbsp;&nbsp;<input type="submit" name="cancelExercise" value="<?php echo get_lang('langCancel'); ?>" onclick="javascript:if(!confirm('<?php echo addslashes(htmlentities(get_lang('langConfirmYourChoice'))); ?>')) return false;"> //-->
  157. </td>
  158. </tr>
  159. </table>
  160. </form>
  161. <?php
  162. }
  163. else
  164. {
  165. ?>
  166. <h3>
  167. <?php
  168. $exerciseTitle = api_parse_tex($exerciseTitle);
  169. echo $exerciseTitle; ?>
  170. <?php if(!empty($exerciseSound)): ?>
  171. <a href="../document/download.php?doc_url=%2Faudio%2F<?php echo $exerciseSound; ?>" target="_blank"><img src="../img/wav.gif" border="0" align="absmiddle" alt="<?php echo get_lang('langSound'); ?>"></a>
  172. <?php endif; ?>
  173. </h3>
  174. <blockquote>
  175. <?php
  176. $exerciseDescription = api_parse_tex($exerciseDescription);
  177. echo $exerciseDescription; ?>
  178. </blockquote>
  179. <a href="<?php echo $_SERVER['PHP_SELF']; ?>?modifyExercise=yes"><img src="../img/edit.gif" border="0" align="absmiddle" alt="<?php echo get_lang('langModify'); ?>"></a>
  180. <?php
  181. }
  182. ?>