question_admin.inc.php 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. <?php
  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. * QUESTION ADMINISTRATION
  22. *
  23. * This script allows to manage a question and its answers
  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. $pictureName=$objQuestion->selectPicture();
  36. if ( empty ($answerType) ) {
  37. $answerType = $objQuestion->selectType();
  38. }
  39. //added
  40. if($_REQUEST['exerciseId'])
  41. $myid=1;
  42. else
  43. $myid=0;
  44. // if the question we are modifying is used in several exercises
  45. if($usedInSeveralExercises)
  46. {
  47. ?>
  48. <h3>
  49. <?php echo $questionName; ?>
  50. </h3>
  51. <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>?modifyQuestion=<?php echo $modifyQuestion; ?>&modifyAnswers=<?php echo $modifycAnswers; ?>">
  52. <?php
  53. // submit question
  54. if($submitQuestion)
  55. {
  56. ?>
  57. <input type="hidden" name="questionName" value="<?php echo htmlentities($questionName); ?>">
  58. <input type="hidden" name="questionDescription" value="<?php echo htmlentities($questionDescription); ?>">
  59. <input type="hidden" name="imageUpload_size" value="<?php echo $imageUpload_size; ?>">
  60. <input type="hidden" name="deletePicture" value="<?php echo $deletePicture; ?>">
  61. <input type="hidden" name="pictureName" value="<?php echo htmlentities($pictureName); ?>">
  62. <?php
  63. }
  64. // submit answers
  65. else
  66. {
  67. if($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER)
  68. {
  69. ?>
  70. <input type="hidden" name="correct" value="<?php echo htmlentities(serialize($correct)); ?>">
  71. <input type="hidden" name="reponse" value="<?php echo htmlentities(serialize($reponse)); ?>">
  72. <input type="hidden" name="comment" value="<?php echo htmlentities(serialize($comment)); ?>">
  73. <input type="hidden" name="weighting" value="<?php echo htmlentities(serialize($weighting)); ?>">
  74. <input type="hidden" name="nbrAnswers" value="<?php echo $nbrAnswers; ?>">
  75. <?php
  76. }
  77. elseif($answerType == MATCHING)
  78. {
  79. ?>
  80. <input type="hidden" name="option" value="<?php echo htmlentities(serialize($option)); ?>">
  81. <input type="hidden" name="match" value="<?php echo htmlentities(serialize($match)); ?>">
  82. <input type="hidden" name="sel" value="<?php echo htmlentities(serialize($sel)); ?>">
  83. <input type="hidden" name="weighting" value="<?php echo htmlentities(serialize($weighting)); ?>">
  84. <input type="hidden" name="nbrOptions" value="<?php echo $nbrOptions; ?>">
  85. <input type="hidden" name="nbrMatches" value="<?php echo $nbrMatches; ?>">
  86. <?php
  87. }
  88. elseif ( $answerType == FREE_ANSWER)
  89. {
  90. ?>
  91. <input type="hidden" name="reponse" value="<?php echo htmlentities(serialize($reponse)); ?>">
  92. <input type="hidden" name="comment" value="<?php echo htmlentities(serialize($comment)); ?>">
  93. <input type="hidden" name="weighting" value="<?php echo htmlentities(serialize($weighting)); ?>">
  94. <input type="hidden" name="setWeighting" value="1">
  95. <?php
  96. }
  97. else
  98. {
  99. ?>
  100. <input type="hidden" name="reponse" value="<?php echo htmlentities(serialize($reponse)); ?>">
  101. <input type="hidden" name="comment" value="<?php echo htmlentities(serialize($comment)); ?>">
  102. <input type="hidden" name="blanks" value="<?php echo htmlentities(serialize($blanks)); ?>">
  103. <input type="hidden" name="weighting" value="<?php echo htmlentities(serialize($weighting)); ?>">
  104. <input type="hidden" name="setWeighting" value="1">
  105. <?php
  106. }
  107. } // end submit answers
  108. ?>
  109. <input type="hidden" name="answerType" value="<?php echo $answerType; ?>">
  110. <?php
  111. $msgBox= " ".get_lang('langUsedInSeveralExercises')." :<br />
  112. <input class=\"checkbox\" type=\"radio\" name=\"modifyIn\" value=\"allExercises\" checked=\"checked\"> ".get_lang('langModifyInAllExercises')."<br />
  113. <input class=\"checkbox\" type=\"radio\" name=\"modifyIn\" value=\"thisExercise\"> ".get_lang('langModifyInThisExercise')."<br />
  114. <input type=\"submit\" name=\"".($submitQuestion?'submitQuestion':'submitAnswers')."\" value=\"".get_lang('langOk')."\">
  115. ";
  116. Display::display_normal_message($msgBox); //main API
  117. ?>
  118. </form>
  119. <?php
  120. }
  121. else
  122. {
  123. // selects question informations
  124. $questionName=$objQuestion->selectTitle();
  125. $questionDescription=$objQuestion->selectDescription();
  126. // is picture set ?
  127. $okPicture=empty($pictureName)?false:true;
  128. ?>
  129. <h3>
  130. <?php echo $questionName; ?>
  131. <?php
  132. // doesn't show the edit link if we come from the question pool to pick a question for an exercise
  133. if(!$fromExercise)
  134. {
  135. //edited
  136. ?>
  137. <a href="<?php echo $_SERVER['PHP_SELF']; ?>?myid=<?php echo $myid; ?>&modifyQuestion=<?php echo $questionId; ?>"><img src="../img/edit.gif" border="0" align="absmiddle" alt="<?php echo get_lang('langModify'); ?>"></a>
  138. <?php
  139. }
  140. ?></h3>
  141. <?php
  142. // show the picture of the question
  143. if($okPicture)
  144. {
  145. ?>
  146. <center><img src="../document/download.php?doc_url=%2Fimages%2F<?php echo $pictureName; ?>" border="0"></center>
  147. <?php
  148. }
  149. ?>
  150. <blockquote>
  151. <?php echo $questionDescription; ?>
  152. </blockquote>
  153. <?php
  154. // doesn't show the edit link if we come from the question pool to pick a question for an exercise
  155. /*if(!$fromExercise)
  156. {
  157. ?>
  158. <a href="<?php echo $_SERVER['PHP_SELF']; ?>?modifyQuestion=<?php echo $questionId; ?>"><img src="../img/edit.gif" border="0" align="absmiddle" alt="<?php echo get_lang('langModify'); ?>"></a>
  159. <?php
  160. }*/
  161. ?>
  162. <hr size="1" noshade="noshade">
  163. <?php
  164. // we are in an exercise
  165. if($exerciseId)
  166. {
  167. ?>
  168. <!--<a href="<?php echo $_SERVER['PHP_SELF']; ?>">&lt;&lt; <?php echo get_lang('langGoBackToQuestionList'); ?></a>-->
  169. <?php
  170. }
  171. // we are not in an exercise, so we come from the question pool
  172. else
  173. {
  174. ?>
  175. <a href="question_pool.php?fromExercise=<?php echo $fromExercise; ?>">&lt;&lt; <?php echo get_lang('langGoBackToQuestionPool'); ?></a>
  176. <?php
  177. }
  178. if($answerType != FREE_ANSWER){
  179. ?>
  180. <b><?php echo get_lang('langQuestionAnswers'); ?></b>
  181. <a href="<?php echo $_SERVER['PHP_SELF']; ?>?myid=<?php echo $myid; ?>&modifyAnswers=<?php echo $questionId; ?>"><img src="../img/edit.gif" border="0" align="absmiddle" alt="<?php echo get_lang('langModify'); ?>"></a>
  182. <table border="0" align="center" cellpadding="2" cellspacing="2" width="100%">
  183. <form>
  184. <?php
  185. // shows answers of the question. 'true' means that we don't show the question, only answers
  186. $hide_question = true;
  187. #if ( $answerType == FREE_ANSWER) { $hide_question = false; echo "voila"; } //show the question if free answer, because there is no set answer
  188. if(!showQuestion($questionId,$hide_question))
  189. {
  190. ?>
  191. <tr>
  192. <td><?php echo get_lang('langNoAnswer'); ?></td>
  193. </tr>
  194. <?php
  195. }
  196. ?>
  197. </form>
  198. </table>
  199. <br>
  200. <?php
  201. }
  202. // doesn't show the edit link if we come from the question pool to pick a question for an exercise
  203. if(!$fromExercise)
  204. {
  205. ?>
  206. <!--<a href="<?php //echo $_SERVER['PHP_SELF']; ?>?modifyAnswers=<?php //echo $questionId; ?>"><img src="../img/edit.gif" border="0" align="absmiddle" alt="<?php //echo get_lang('langModify'); ?>"></a>-->
  207. <?php
  208. }
  209. if ($exerciseId)
  210. {
  211. ?><a href="<?php echo $_SERVER['PHP_SELF']; ?>">&lt;&lt; <?php echo get_lang('langGoBackToQuestionList'); ?></a>
  212. <?php
  213. }
  214. }
  215. ?>