lp_edit_item_prereq.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. /* Libraries */
  15. include 'learnpath_functions.inc.php';
  16. include 'resourcelinker.inc.php';
  17. /* Constants and variables */
  18. $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
  19. $tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
  20. $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
  21. $tbl_lp_view = Database::get_course_table(TABLE_LP_VIEW);
  22. $isStudentView = isset($_REQUEST['isStudentView']) ? (int) $_REQUEST['isStudentView'] : null;
  23. $learnpath_id = isset($_REQUEST['lp_id']) ? (int) $_REQUEST['lp_id'] : null;
  24. $submit = isset($_POST['submit_button']) ? $_POST['submit_button'] : null;
  25. /* MAIN CODE */
  26. // Using the resource linker as a tool for adding resources to the learning path.
  27. if ($action == 'add' and $type == 'learnpathitem') {
  28. $htmlHeadXtra[] = "<script> window.location=\"../resourcelinker/resourcelinker.php?source_id=5&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no\"; </script>";
  29. }
  30. if ((!$is_allowed_to_edit) || ($isStudentView)) {
  31. error_log('New LP - User not authorized in lp_edit_item_prereq.php');
  32. header('location:lp_controller.php?action=view&lp_id=' . $learnpath_id);
  33. }
  34. $course_id = api_get_course_int_id();
  35. $sql = "SELECT * FROM $tbl_lp WHERE c_id = $course_id AND id = $learnpath_id";
  36. $result = Database::query($sql);
  37. $therow = Database::fetch_array($result);
  38. /* SHOWING THE ADMIN TOOLS */
  39. if (isset($_SESSION['gradebook'])) {
  40. $gradebook = $_SESSION['gradebook'];
  41. }
  42. if (!empty($gradebook) && $gradebook == 'view') {
  43. $interbreadcrumb[] = array(
  44. 'url' => '../gradebook/' . $_SESSION['gradebook_dest'],
  45. 'name' => get_lang('ToolGradebook')
  46. );
  47. }
  48. $interbreadcrumb[] = array('url' => 'lp_controller.php?action=list', 'name' => get_lang('LearningPaths'));
  49. $interbreadcrumb[] = array(
  50. 'url' => api_get_self()."?action=build&lp_id=$learnpath_id",
  51. 'name' => stripslashes("{$therow['name']}"),
  52. );
  53. $interbreadcrumb[] = array(
  54. 'url' => api_get_self()."?action=add_item&type=step&lp_id=$learnpath_id&".api_get_cidreq(),
  55. 'name' => get_lang('NewStep'),
  56. );
  57. // Theme calls.
  58. $show_learn_path = true;
  59. /** @var learnpath $lp */
  60. $lp = $_SESSION['oLP'];
  61. $lp_theme_css = $lp->get_theme();
  62. Display::display_header(get_lang('LearnpathPrerequisites'), 'Path');
  63. $suredel = trim(get_lang('AreYouSureToDeleteJS'));
  64. ?>
  65. <script>
  66. function stripslashes(str) {
  67. str=str.replace(/\\'/g,'\'');
  68. str=str.replace(/\\"/g,'"');
  69. str=str.replace(/\\\\/g,'\\');
  70. str=str.replace(/\\0/g,'\0');
  71. return str;
  72. }
  73. function confirmation(name) {
  74. name=stripslashes(name);
  75. if (confirm("<?php echo $suredel; ?> " + name + " ?")) {
  76. return true;
  77. } else {
  78. return false;
  79. }
  80. }
  81. </script>
  82. <?php
  83. /* DISPLAY SECTION */
  84. echo $lp->build_action_menu();
  85. echo '<div class="row">';
  86. echo '<div class="col-md-3">';
  87. echo $lp->return_new_tree();
  88. echo '</div>';
  89. echo '<div class="col-md-9">';
  90. if (isset($is_success) && $is_success == true) {
  91. echo $lp->display_manipulate($_GET['id'], null);
  92. echo Display::return_message(get_lang("PrerequisitesAdded"));
  93. } else {
  94. echo $lp->display_manipulate($_GET['id'], null);
  95. echo $lp->display_item_prerequisites_form($_GET['id']);
  96. }
  97. echo '</div>';
  98. Display::display_footer();