adminhp.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * HotPotatoes administration.
  5. *
  6. * @author Istvan Mandak
  7. */
  8. require_once __DIR__.'/../inc/global.inc.php';
  9. $this_section = SECTION_COURSES;
  10. api_protect_course_script(true);
  11. $_course = api_get_course_info();
  12. if (isset($_REQUEST["cancel"])) {
  13. if ($_REQUEST["cancel"] == get_lang('Cancel')) {
  14. header("Location: exercise.php");
  15. exit;
  16. }
  17. }
  18. $newName = !empty($_REQUEST['newName']) ? $_REQUEST['newName'] : '';
  19. $hotpotatoesName = !empty($_REQUEST['hotpotatoesName']) ? Security::remove_XSS($_REQUEST['hotpotatoesName']) : '';
  20. $is_allowedToEdit = api_is_allowed_to_edit(null, true);
  21. // document path
  22. $documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
  23. // picture path
  24. $picturePath = $documentPath.'/images';
  25. // audio path
  26. $audioPath = $documentPath.'/audio';
  27. // Database table definitions
  28. if (!$is_allowedToEdit) {
  29. api_not_allowed(true);
  30. }
  31. if (api_is_in_gradebook()) {
  32. $interbreadcrumb[] = [
  33. 'url' => Category::getUrl(),
  34. 'name' => get_lang('Assessments'),
  35. ];
  36. }
  37. $interbreadcrumb[] = [
  38. "url" => "exercise.php",
  39. "name" => get_lang('Tests'),
  40. ];
  41. $nameTools = get_lang('Hot Potatoes Admin');
  42. Display::display_header($nameTools, "Exercise");
  43. /** @todo probably wrong !!!! */
  44. require_once api_get_path(SYS_CODE_PATH).'/exercise/hotpotatoes.lib.php';
  45. ?>
  46. <h4>
  47. <?php echo $nameTools; ?>
  48. </h4>
  49. <?php
  50. if (isset($newName)) {
  51. if ($newName != "") {
  52. //alter database record for that test
  53. SetComment($hotpotatoesName, $newName);
  54. echo "<script> window.location='exercise.php'; </script>";
  55. }
  56. }
  57. echo "<form action=\"".api_get_self()."\" method='post' name='form1'>";
  58. echo "<input type=\"hidden\" name=\"hotpotatoesName\" value=\"$hotpotatoesName\">";
  59. echo "<input type=\"text\" name=\"newName\" value=\"";
  60. $lstrComment = GetComment($hotpotatoesName);
  61. if ($lstrComment == '') {
  62. $lstrComment = GetQuizName($hotpotatoesName, $documentPath);
  63. }
  64. if ($lstrComment == '') {
  65. $lstrComment = basename($hotpotatoesName, $documentPath);
  66. }
  67. echo $lstrComment;
  68. echo "\" size=40>&nbsp;";
  69. echo "<button type=\"submit\" class=\"save\" name=\"submit\" value=\"".get_lang('Validate')."\">".get_lang('Validate')."</button>";
  70. echo "<button type=\"button\" class=\"cancel\" name=\"cancel\" value=\"".get_lang('Cancel')."\" onclick=\"javascript:document.form1.newName.value='';\">".get_lang('Cancel')."</button>";
  71. echo "</form>";
  72. Display::display_footer();