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. /* Libraries */
  15. include 'learnpath_functions.inc.php';
  16. /* Constants and variables */
  17. $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
  18. $tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
  19. $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
  20. $tbl_lp_view = Database::get_course_table(TABLE_LP_VIEW);
  21. $isStudentView = isset($_REQUEST['isStudentView']) ? (int) $_REQUEST['isStudentView'] : null;
  22. $learnpath_id = isset($_REQUEST['lp_id']) ? (int) $_REQUEST['lp_id'] : null;
  23. $submit = isset($_POST['submit_button']) ? $_POST['submit_button'] : null;
  24. /* MAIN CODE */
  25. if ((!$is_allowed_to_edit) || ($isStudentView)) {
  26. error_log('New LP - User not authorized in lp_edit_item_prereq.php');
  27. header('location:lp_controller.php?action=view&lp_id=' . $learnpath_id);
  28. }
  29. $course_id = api_get_course_int_id();
  30. $sql = "SELECT * FROM $tbl_lp WHERE c_id = $course_id AND id = $learnpath_id";
  31. $result = Database::query($sql);
  32. $therow = Database::fetch_array($result);
  33. /* SHOWING THE ADMIN TOOLS */
  34. if (api_is_in_gradebook()) {
  35. $interbreadcrumb[]= array(
  36. 'url' => api_get_path(WEB_CODE_PATH).'gradebook/index.php?'.api_get_cidreq(),
  37. 'name' => get_lang('ToolGradebook')
  38. );
  39. }
  40. $interbreadcrumb[] = array(
  41. 'url' => 'lp_controller.php?action=list&'.api_get_cidreq(),
  42. 'name' => get_lang('LearningPaths'),
  43. );
  44. $interbreadcrumb[] = array(
  45. 'url' => api_get_self()."?action=build&lp_id=$learnpath_id&".api_get_cidreq(),
  46. 'name' => stripslashes("{$therow['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. // Theme calls.
  53. $show_learn_path = true;
  54. /** @var learnpath $lp */
  55. $lp = learnpath::getCurrentLpFromSession();
  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>';