lp_edit_item_prereq.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. // Theme calls.
  29. $show_learn_path = true;
  30. /** @var learnpath $lp */
  31. $lp = $_SESSION['oLP'];
  32. $lp_theme_css = $lp->get_theme();
  33. /* SHOWING THE ADMIN TOOLS */
  34. if (isset($_SESSION['gradebook'])) {
  35. $gradebook = $_SESSION['gradebook'];
  36. }
  37. if (!empty($gradebook) && $gradebook == 'view') {
  38. $interbreadcrumb[] = array(
  39. 'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
  40. 'name' => get_lang('ToolGradebook')
  41. );
  42. }
  43. $interbreadcrumb[] = array('url' => 'lp_controller.php?action=list', 'name' => get_lang('LearningPaths'));
  44. $interbreadcrumb[] = array(
  45. 'url' => api_get_self()."?action=build&lp_id=$learnpath_id",
  46. 'name' => stripslashes($lp->get_name()),
  47. );
  48. $interbreadcrumb[] = array(
  49. 'url' => api_get_self()."?action=add_item&type=step&lp_id=$learnpath_id&".api_get_cidreq(),
  50. 'name' => get_lang('NewStep'),
  51. );
  52. Display::display_header(get_lang('LearnpathPrerequisites'), 'Path');
  53. $suredel = trim(get_lang('AreYouSureToDeleteJS'));
  54. ?>
  55. <script>
  56. function stripslashes(str) {
  57. str=str.replace(/\\'/g,'\'');
  58. str=str.replace(/\\"/g,'"');
  59. str=str.replace(/\\\\/g,'\\');
  60. str=str.replace(/\\0/g,'\0');
  61. return str;
  62. }
  63. function confirmation(name) {
  64. name=stripslashes(name);
  65. if (confirm("<?php echo $suredel; ?> " + name + " ?")) {
  66. return true;
  67. } else {
  68. return false;
  69. }
  70. }
  71. </script>
  72. <?php
  73. /* DISPLAY SECTION */
  74. echo $lp->build_action_menu();
  75. echo '<div class="row">';
  76. echo '<div class="col-md-3">';
  77. echo $lp->return_new_tree();
  78. echo '</div>';
  79. echo '<div class="col-md-9">';
  80. $lpItem = new learnpathItem($_GET['id']);
  81. if (isset($is_success) && $is_success == true) {
  82. echo $lp->display_manipulate($_GET['id'], $lpItem->get_type());
  83. echo Display::return_message(get_lang("PrerequisitesAdded"));
  84. } else {
  85. echo $lp->display_manipulate($_GET['id'], $lpItem->get_type());
  86. echo $lp->display_item_prerequisites_form($_GET['id']);
  87. }
  88. echo '</div>';
  89. Display::display_footer();