question_admin.inc.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <?php
  2. /*
  3. DOKEOS - elearning and course management software
  4. For a full list of contributors, see documentation/credits.html
  5. This program is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU General Public License
  7. as published by the Free Software Foundation; either version 2
  8. of the License, or (at your option) any later version.
  9. See "documentation/licence.html" more details.
  10. Contact:
  11. Dokeos
  12. Rue des Palais 44 Paleizenstraat
  13. B-1030 Brussels - Belgium
  14. Tel. +32 (2) 211 34 56
  15. */
  16. /**
  17. * Statement (?) administration
  18. * This script allows to manage the statements of questions.
  19. * It is included from the script admin.php
  20. * @package dokeos.exercise
  21. * @author Olivier Brouckaert
  22. * @version $Id: question_admin.inc.php 13311 2007-09-27 08:03:12Z elixir_inter $
  23. */
  24. /*
  25. ==============================================================================
  26. INIT SECTION
  27. ==============================================================================
  28. */
  29. include_once(api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
  30. include_once(api_get_path(LIBRARY_PATH).'image.lib.php');
  31. // ALLOWED_TO_INCLUDE is defined in admin.php
  32. if(!defined('ALLOWED_TO_INCLUDE'))
  33. {
  34. exit();
  35. }
  36. /*********************
  37. * INIT QUESTION
  38. *********************/
  39. if(isset($_GET['editQuestion']))
  40. {
  41. $objQuestion = Question::read ($_GET['editQuestion']);
  42. $action = api_get_self()."?modifyQuestion=".$modifyQuestion."&editQuestion=".$objQuestion->id;
  43. }
  44. else
  45. {
  46. $objQuestion = Question :: getInstance($_REQUEST['answerType']);
  47. $action = api_get_self()."?modifyQuestion=".$modifyQuestion."&newQuestion=".$newQuestion;
  48. }
  49. if(is_object($objQuestion))
  50. {
  51. /*********************
  52. * FORM STYLES
  53. *********************/
  54. // if you have a better way to improve the display, please inform me e.marguin@elixir-interactive.com
  55. $styles = '
  56. <style>
  57. div.row div.label{
  58. width: 10%;
  59. }
  60. div.row div.formw{
  61. width: 85%;
  62. }
  63. </style>
  64. ';
  65. echo $styles;
  66. /*********************
  67. * INIT FORM
  68. *********************/
  69. $form = new FormValidator('question_admin_form','post',$action);
  70. /*********************
  71. * FORM CREATION
  72. *********************/
  73. $objQuestion -> createForm ($form);
  74. $objQuestion -> createAnswersForm ($form);
  75. $form->addElement('submit','submitQuestion',get_lang('Ok'));
  76. $renderer = $form->defaultRenderer();
  77. $renderer->setElementTemplate('<div class="row"><div class="label">{label}</div><div class="formw">{element}</div></div>','submitQuestion');
  78. /**********************
  79. * FORM VALIDATION
  80. **********************/
  81. if(isset($_POST['submitQuestion']) && $form->validate())
  82. {
  83. // question
  84. $objQuestion -> processCreation($form,$objExercise);
  85. // answers
  86. $objQuestion -> processAnswersCreation($form,$nb_answers);
  87. // redirect
  88. if($objQuestion -> type != HOT_SPOT)
  89. echo '<script type="text/javascript">window.location.href="admin.php"</script>';
  90. else
  91. echo '<script type="text/javascript">window.location.href="admin.php?hotspotadmin='.$objQuestion->id.'"</script>';
  92. }
  93. else
  94. {
  95. /******************
  96. * FORM DISPLAY
  97. ******************/
  98. echo '<h3>'.$questionName.'</h3>';
  99. if(!empty($pictureName)){
  100. echo '<img src="../document/download.php?doc_url=%2Fimages%2F'.$pictureName.'" border="0">';
  101. }
  102. if(!empty($msgErr))
  103. {
  104. Display::display_normal_message($msgErr); //main API
  105. }
  106. // display the form
  107. $form->display();
  108. }
  109. }
  110. ?>