exercise_admin.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?php
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2004-2009 Dokeos SPRL
  6. For a full list of contributors, see "credits.txt".
  7. The full license can be read in "license.txt".
  8. This program is free software; you can redistribute it and/or
  9. modify it under the terms of the GNU General Public License
  10. as published by the Free Software Foundation; either version 2
  11. of the License, or (at your option) any later version.
  12. See the GNU General Public License for more details.
  13. Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
  14. Mail: info@dokeos.com
  15. ==============================================================================
  16. */
  17. /**
  18. * Exercise administration
  19. * This script allows to manage an exercise. It is included from the script admin.php
  20. * @package dokeos.exercise
  21. * @author Olivier Brouckaert
  22. * @version $Id$
  23. */
  24. // name of the language file that needs to be included
  25. $language_file='exercice';
  26. include('exercise.class.php');
  27. include('question.class.php');
  28. include('answer.class.php');
  29. include('../inc/global.inc.php');
  30. include('exercise.lib.php');
  31. $this_section=SECTION_COURSES;
  32. if(!api_is_allowed_to_edit()) {
  33. api_not_allowed(true);
  34. }
  35. $htmlHeadXtra[] = '<script>
  36. function advanced_parameters() {
  37. if(document.getElementById(\'options\').style.display == \'none\') {
  38. document.getElementById(\'options\').style.display = \'block\';
  39. document.getElementById(\'img_plus_and_minus\').innerHTML=\'&nbsp;<img src="../img/nolines_minus.gif" alt="" />&nbsp;'.get_lang('AdvancedParameters').'\';
  40. } else {
  41. document.getElementById(\'options\').style.display = \'none\';
  42. document.getElementById(\'img_plus_and_minus\').innerHTML=\'&nbsp;<img src="../img/nolines_plus.gif" alt="" />&nbsp;'.get_lang('AdvancedParameters').'\';
  43. }
  44. }
  45. function timelimit() {
  46. if(document.getElementById(\'options2\').style.display == \'none\') {
  47. document.getElementById(\'options2\').style.display = \'block\';
  48. document.getElementById(\'img_plus_and_minus2\').innerHTML=\'&nbsp;<img src="../img/nolines_minus.gif" alt="" />&nbsp;'.get_lang('AdvancedParameters').'\';
  49. } else {
  50. document.getElementById(\'options2\').style.display = \'none\';
  51. document.getElementById(\'img_plus_and_minus2\').innerHTML=\'&nbsp;<img src="../img/nolines_plus.gif" alt="" />&nbsp;'.get_lang('AdvancedParameters').'\';
  52. }
  53. }
  54. function feedbackselection()
  55. {
  56. var index = document.exercise_admin.exerciseFeedbackType.selectedIndex;
  57. if (index == \'1\') {
  58. document.exercise_admin.exerciseType[1].checked=true;
  59. document.exercise_admin.exerciseType[0].disabled=true;
  60. } else {
  61. document.exercise_admin.exerciseType[0].disabled=false;
  62. }
  63. }
  64. </script>';
  65. /*********************
  66. * INIT EXERCISE
  67. *********************/
  68. include_once(api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
  69. $objExercise = new Exercise();
  70. /*********************
  71. * INIT FORM
  72. *********************/
  73. if(isset($_GET['exerciseId'])) {
  74. $form = new FormValidator('exercise_admin', 'post', api_get_self().'?exerciseId='.$_GET['exerciseId']);
  75. $objExercise -> read (intval($_GET['exerciseId']));
  76. $form -> addElement ('hidden','edit','true');
  77. } else {
  78. $form = new FormValidator('exercise_admin');
  79. $form -> addElement ('hidden','edit','false');
  80. }
  81. $objExercise -> createForm ($form);
  82. /*********************
  83. * VALIDATE FORM
  84. *********************/
  85. if($form -> validate()) {
  86. $objExercise -> processCreation($form);
  87. if($form -> getSubmitValue('edit') == 'true') {
  88. header('Location:exercice.php?message=ExerciseEdited');
  89. } else {
  90. header('Location:admin.php?message=ExerciseStored&exerciseId='.$objExercise->id);
  91. }
  92. } else {
  93. /*********************
  94. * DISPLAY FORM
  95. *********************/
  96. $nameTools=get_lang('ExerciseManagement');
  97. $interbreadcrumb[] = array ("url"=>"exercice.php", "name"=> get_lang('Exercices'));
  98. Display::display_header($nameTools,"Exercise");
  99. $form -> display ();
  100. }
  101. Display::display_footer();