adminhp.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * HotPotatoes administration.
  5. * @package chamilo.exercise
  6. * @author Istvan Mandak
  7. * @version $Id: adminhp.php 20089 2009-04-24 21:12:54Z cvargas1 $
  8. */
  9. /**
  10. * Code
  11. */
  12. include 'exercise.class.php';
  13. include 'question.class.php';
  14. include 'answer.class.php';
  15. include 'exercise.lib.php';
  16. // name of the language file that needs to be included
  17. $language_file='exercice';
  18. include('../inc/global.inc.php');
  19. $this_section=SECTION_COURSES;
  20. if (isset($_REQUEST["cancel"])) {
  21. if ($_REQUEST["cancel"]==get_lang('Cancel')) {
  22. header("Location: exercice.php");
  23. }
  24. }
  25. //$is_courseAdmin = $_SESSION['is_courseAdmin'];
  26. $newName = (!empty($_REQUEST['newName'])?$_REQUEST['newName']:'');
  27. $hotpotatoesName = (!empty($_REQUEST['hotpotatoesName'])?$_REQUEST['hotpotatoesName']:'');
  28. // answer types
  29. define(UNIQUE_ANSWER, 1);
  30. define(MULTIPLE_ANSWER, 2);
  31. define(FILL_IN_BLANKS, 3);
  32. define(MATCHING, 4);
  33. define(FREE_ANSWER, 5);
  34. define(MULTIPLE_ANSWER_COMBINATION, 6);
  35. // allows script inclusions
  36. define(ALLOWED_TO_INCLUDE,1);
  37. $is_allowedToEdit=api_is_allowed_to_edit(null,true);
  38. // document path
  39. $documentPath=api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
  40. // picture path
  41. $picturePath=$documentPath.'/images';
  42. // audio path
  43. $audioPath=$documentPath.'/audio';
  44. // Database table definitions
  45. $TBL_EXERCICE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
  46. $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
  47. $TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
  48. $TBL_REPONSES = Database::get_course_table(TABLE_QUIZ_ANSWER);
  49. $TBL_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT);
  50. $dbTable = $TBL_DOCUMENT;
  51. if (!$is_allowedToEdit) {
  52. api_not_allowed(true);
  53. }
  54. if (isset($_SESSION['gradebook'])) {
  55. $gradebook= $_SESSION['gradebook'];
  56. }
  57. if (!empty($gradebook) && $gradebook=='view') {
  58. $interbreadcrumb[]= array (
  59. 'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
  60. 'name' => get_lang('ToolGradebook')
  61. );
  62. }
  63. $interbreadcrumb[]=array("url" => "exercice.php","name" => get_lang('Exercices'));
  64. $nameTools = get_lang('adminHP');
  65. Display::display_header($nameTools,"Exercise");
  66. /** @todo probably wrong !!!! */
  67. require_once(api_get_path(SYS_CODE_PATH).'/exercice/hotpotatoes.lib.php');
  68. ?>
  69. <h4>
  70. <?php echo $nameTools; ?>
  71. </h4>
  72. <?php
  73. if (isset($newName)) {
  74. if ($newName!="") {
  75. //alter database record for that test
  76. SetComment($hotpotatoesName,$newName);
  77. echo "<script language='Javascript' type='text/javascript'> window.location='exercice.php'; </script>";
  78. }
  79. }
  80. echo "<form action=\"".api_get_self()."\" method='post' name='form1'>";
  81. echo "<input type=\"hidden\" name=\"hotpotatoesName\" value=\"$hotpotatoesName\">";
  82. echo "<input type=\"text\" name=\"newName\" value=\"";
  83. $lstrComment = "";
  84. $lstrComment = GetComment($hotpotatoesName);
  85. if ($lstrComment=="") {
  86. $lstrComment = GetQuizName($hotpotatoesName,$documentPath);
  87. }
  88. if ($lstrComment=="") {
  89. $lstrComment = basename($hotpotatoesName,$documentPath);
  90. }
  91. echo $lstrComment;
  92. echo "\" size=40>&nbsp;";
  93. echo "<button type=\"submit\" class=\"save\" name=\"submit\" value=\"".get_lang('Ok')."\">".get_lang('Ok')."</button>";
  94. echo "<button type=\"button\" class=\"cancel\" name=\"cancel\" value=\"".get_lang('Cancel')."\" onclick=\"javascript:document.form1.newName.value='';\">".get_lang('Cancel')."</button>";
  95. echo "</form>";
  96. Display::display_footer();