exercise_admin.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. * Exercise administration
  18. * This script allows to manage an exercise. It is included from the script admin.php
  19. * @package dokeos.exercise
  20. * @author Olivier Brouckaert
  21. * @version $Id$
  22. */
  23. // name of the language file that needs to be included
  24. $language_file='exercice';
  25. include('exercise.class.php');
  26. include('question.class.php');
  27. include('answer.class.php');
  28. include('../inc/global.inc.php');
  29. include('exercise.lib.php');
  30. $this_section=SECTION_COURSES;
  31. if(!api_is_allowed_to_edit())
  32. {
  33. api_not_allowed(true);
  34. }
  35. /*********************
  36. * INIT EXERCISE
  37. *********************/
  38. include_once(api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
  39. $objExercise = new Exercise();
  40. /*********************
  41. * INIT FORM
  42. *********************/
  43. if(isset($_GET['exerciseId']))
  44. {
  45. $form = new FormValidator('exercise_admin', 'post', api_get_self().'?exerciseId='.$_GET['exerciseId']);
  46. $objExercise -> read (intval($_GET['exerciseId']));
  47. $form -> addElement ('hidden','edit','true');
  48. }else
  49. {
  50. $form = new FormValidator('exercise_admin');
  51. $form -> addElement ('hidden','edit','false');
  52. }
  53. $objExercise -> createForm ($form);
  54. /*********************
  55. * VALIDATE FORM
  56. *********************/
  57. if($form -> validate())
  58. {
  59. $objExercise -> processCreation($form);
  60. if($form -> getSubmitValue('edit') == 'true')
  61. {
  62. header('Location:exercice.php?message=ExerciseEdited');
  63. }
  64. else
  65. {
  66. header('Location:admin.php?message=ExerciseStored&exerciseId='.$objExercise->id);
  67. }
  68. }
  69. else
  70. {
  71. /*********************
  72. * DISPLAY FORM
  73. *********************/
  74. $nameTools=get_lang('ExerciseManagement');
  75. $interbreadcrumb[] = array ("url"=>"exercice.php", "name"=> get_lang('Exercices'));
  76. Display::display_header($nameTools,"Exercise");
  77. $form -> display ();
  78. }
  79. Display::display_footer();