lp_edit_item_prereq.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. require_once 'learnpath_functions.inc.php';
  16. require_once 'resourcelinker.inc.php';
  17. // Name of the language file that needs to be included.
  18. $language_file = 'learnpath';
  19. /* Constants and variables */
  20. $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
  21. $tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
  22. $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
  23. $tbl_lp_view = Database::get_course_table(TABLE_LP_VIEW);
  24. $isStudentView = isset($_REQUEST['isStudentView']) ? $_REQUEST['isStudentView'] : null;
  25. $learnpath_id = isset($_REQUEST['lp_id']) ? $_REQUEST['lp_id'] : 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 type='text/javascript'> 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_query = "SELECT * FROM $tbl_lp WHERE c_id = $course_id AND id = $learnpath_id";
  37. $result = Database::query($sql_query);
  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(
  51. 'url' => api_get_self()."?action=build&lp_id=$learnpath_id",
  52. 'name' => stripslashes("{$therow['name']}")
  53. );
  54. $interbreadcrumb[] = array(
  55. 'url' => api_get_self()."?action=add_item&type=step&lp_id=$learnpath_id",
  56. 'name' => get_lang('NewStep')
  57. );
  58. // Theme calls.
  59. $show_learn_path = true;
  60. $lp_theme_css = $_SESSION['oLP']->get_theme();
  61. Display::display_header(get_lang('LearnpathPrerequisites'), 'Path');
  62. $suredel = trim(get_lang('AreYouSureToDelete'));
  63. ?>
  64. <script>
  65. /* <![CDATA[ */
  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 $_SESSION['oLP']->build_action_menu();
  85. echo '<div class="row-fluid">';
  86. echo '<div class="span3">';
  87. echo $_SESSION['oLP']->return_new_tree();
  88. echo '</div>';
  89. echo '<div class="span9">';
  90. //echo Display::return_message(get_lang("PrerequisitesAdded"));
  91. echo $_SESSION['oLP']->display_manipulate($_GET['id'], null);
  92. echo $_SESSION['oLP']->display_item_prerequisites_form($_GET['id']);
  93. echo '</div>';
  94. Display::display_footer();