lp_edit_item_prereq.php 3.7 KB

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