lp_edit_item_prereq.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * This is a learning path creation and player tool in Chamilo - previously learnpath_handler.php
  5. *
  6. * @author Patrick Cool
  7. * @author Denes Nagy
  8. * @author Roan Embrechts, refactoring and code cleaning
  9. * @author Yannick Warnier <ywarnier@beeznest.org> - cleaning and update for new SCORM tool
  10. * @package chamilo.learnpath
  11. */
  12. $this_section = SECTION_COURSES;
  13. api_protect_course_script();
  14. /* Constants and variables */
  15. $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
  16. $tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
  17. $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
  18. $tbl_lp_view = Database::get_course_table(TABLE_LP_VIEW);
  19. $isStudentView = isset($_REQUEST['isStudentView']) ? (int) $_REQUEST['isStudentView'] : null;
  20. $learnpath_id = isset($_REQUEST['lp_id']) ? (int) $_REQUEST['lp_id'] : null;
  21. $submit = isset($_POST['submit_button']) ? $_POST['submit_button'] : null;
  22. /* MAIN CODE */
  23. if ((!$is_allowed_to_edit) || ($isStudentView)) {
  24. error_log('New LP - User not authorized in lp_edit_item_prereq.php');
  25. header('location:lp_controller.php?action=view&lp_id=' . $learnpath_id);
  26. exit;
  27. }
  28. $course_id = api_get_course_int_id();
  29. $sql = "SELECT * FROM $tbl_lp WHERE c_id = $course_id AND id = $learnpath_id";
  30. $result = Database::query($sql);
  31. $therow = Database::fetch_array($result);
  32. /* SHOWING THE ADMIN TOOLS */
  33. if (isset($_SESSION['gradebook'])) {
  34. $gradebook = $_SESSION['gradebook'];
  35. }
  36. if (!empty($gradebook) && $gradebook == 'view') {
  37. $interbreadcrumb[] = array(
  38. 'url' => '../gradebook/' . $_SESSION['gradebook_dest'],
  39. 'name' => get_lang('ToolGradebook')
  40. );
  41. }
  42. $interbreadcrumb[] = array('url' => 'lp_controller.php?action=list', 'name' => get_lang('LearningPaths'));
  43. $interbreadcrumb[] = array(
  44. 'url' => api_get_self()."?action=build&lp_id=$learnpath_id",
  45. 'name' => stripslashes("{$therow['name']}"),
  46. );
  47. $interbreadcrumb[] = array(
  48. 'url' => api_get_self()."?action=add_item&type=step&lp_id=$learnpath_id&".api_get_cidreq(),
  49. 'name' => get_lang('NewStep'),
  50. );
  51. // Theme calls.
  52. $show_learn_path = true;
  53. /** @var learnpath $lp */
  54. $lp = $_SESSION['oLP'];
  55. $lp_theme_css = $lp->get_theme();
  56. Display::display_header(get_lang('LearnpathPrerequisites'), 'Path');
  57. $suredel = trim(get_lang('AreYouSureToDeleteJS'));
  58. ?>
  59. <script>
  60. function stripslashes(str) {
  61. str=str.replace(/\\'/g,'\'');
  62. str=str.replace(/\\"/g,'"');
  63. str=str.replace(/\\\\/g,'\\');
  64. str=str.replace(/\\0/g,'\0');
  65. return str;
  66. }
  67. function confirmation(name) {
  68. name=stripslashes(name);
  69. if (confirm("<?php echo $suredel; ?> " + name + " ?")) {
  70. return true;
  71. } else {
  72. return false;
  73. }
  74. }
  75. </script>
  76. <?php
  77. /* DISPLAY SECTION */
  78. echo $lp->build_action_menu();
  79. echo '<div class="row">';
  80. echo '<div class="col-md-3">';
  81. echo $lp->return_new_tree();
  82. echo '</div>';
  83. echo '<div class="col-md-9">';
  84. if (isset($is_success) && $is_success == true) {
  85. echo $lp->display_manipulate($_GET['id'], null);
  86. echo Display::return_message(get_lang("PrerequisitesAdded"));
  87. } else {
  88. echo $lp->display_manipulate($_GET['id'], null);
  89. echo $lp->display_item_prerequisites_form($_GET['id']);
  90. }
  91. echo '</div>';
  92. Display::display_footer();