exercise_admin.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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/div_hide.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/div_show.gif" alt="" />&nbsp;'.get_lang('AdvancedParameters').'\';
  43. }
  44. }
  45. function show_media() {
  46. if(document.getElementById(\'media\').style.display == \'none\') {
  47. document.getElementById(\'media\').style.display = \'block\';
  48. document.getElementById(\'media_icon\').innerHTML=\'&nbsp;<img src="../img/looknfeelna.png" alt="" />&nbsp;'.get_lang('ExerciseDescription').'\';
  49. } else {
  50. document.getElementById(\'media\').style.display = \'none\';
  51. document.getElementById(\'media_icon\').innerHTML=\'&nbsp;<img src="../img/looknfeel.png" alt="" />&nbsp;'.get_lang('ExerciseDescription').'\';
  52. }
  53. }
  54. function timelimit() {
  55. if(document.getElementById(\'options2\').style.display == \'none\') {
  56. document.getElementById(\'options2\').style.display = \'block\';
  57. } else {
  58. document.getElementById(\'options2\').style.display = \'none\';
  59. }
  60. }
  61. function feedbackselection()
  62. {
  63. var index = document.exercise_admin.exerciseFeedbackType.selectedIndex;
  64. if (index == \'1\') {
  65. document.exercise_admin.exerciseType[1].checked=true;
  66. document.exercise_admin.exerciseType[0].disabled=true;
  67. } else {
  68. document.exercise_admin.exerciseType[0].disabled=false;
  69. }
  70. }
  71. </script>';
  72. /*********************
  73. * INIT EXERCISE
  74. *********************/
  75. include_once(api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
  76. $objExercise = new Exercise();
  77. /*********************
  78. * INIT FORM
  79. *********************/
  80. if(isset($_GET['exerciseId'])) {
  81. $form = new FormValidator('exercise_admin', 'post', api_get_self().'?exerciseId='.$_GET['exerciseId']);
  82. $objExercise -> read (intval($_GET['exerciseId']));
  83. $form -> addElement ('hidden','edit','true');
  84. } else {
  85. $form = new FormValidator('exercise_admin');
  86. $form -> addElement ('hidden','edit','false');
  87. }
  88. $objExercise -> createForm ($form);
  89. /*********************
  90. * VALIDATE FORM
  91. *********************/
  92. if($form -> validate()) {
  93. $objExercise -> processCreation($form);
  94. if ($form -> getSubmitValue('edit') == 'true') {
  95. header('Location:admin.php?message=ExerciseEdited&exerciseId='.$objExercise->id);
  96. } else {
  97. header('Location:admin.php?message=ExerciseStored&exerciseId='.$objExercise->id);
  98. }
  99. } else {
  100. /*********************
  101. * DISPLAY FORM
  102. *********************/
  103. if (isset($_SESSION['gradebook'])) {
  104. $gradebook= $_SESSION['gradebook'];
  105. }
  106. if (!empty($gradebook) && $gradebook=='view') {
  107. $interbreadcrumb[]= array (
  108. 'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
  109. 'name' => get_lang('Gradebook')
  110. );
  111. }
  112. $nameTools=get_lang('ExerciseManagement');
  113. $interbreadcrumb[] = array ("url"=>"exercice.php", "name"=> get_lang('Exercices'));
  114. Display::display_header($nameTools,"Exercise");
  115. if ($objExercise->feedbacktype==1)
  116. Display::display_normal_message(get_lang("DirectFeedbackCantModifyTypeQuestion"));
  117. $form -> display ();
  118. }
  119. Display::display_footer();