lp_edit_item_prereq.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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. /* INIT SECTION */
  13. $this_section = SECTION_COURSES;
  14. api_protect_course_script();
  15. /* Libraries */
  16. // The main_api.lib.php, database.lib.php and display.lib.php
  17. // libraries are included by default.
  18. include 'learnpath_functions.inc.php';
  19. //include '../resourcelinker/resourcelinker.inc.php';
  20. include 'resourcelinker.inc.php';
  21. // Rewrite the language file, sadly overwritten by resourcelinker.inc.php.
  22. // Name of the language file that needs to be included.
  23. $language_file = 'learnpath';
  24. /* Constants and variables */
  25. $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
  26. $tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
  27. $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
  28. $tbl_lp_view = Database::get_course_table(TABLE_LP_VIEW);
  29. $isStudentView = (int) $_REQUEST['isStudentView'];
  30. $learnpath_id = (int) $_REQUEST['lp_id'];
  31. $submit = $_POST['submit_button'];
  32. /*
  33. $chapter_id = $_GET['chapter_id'];
  34. $title = $_POST['title'];
  35. $description = $_POST['description'];
  36. $Submititem = $_POST['Submititem'];
  37. $action = $_REQUEST['action'];
  38. $id = (int) $_REQUEST['id'];
  39. $type = $_REQUEST['type'];
  40. $direction = $_REQUEST['direction'];
  41. $moduleid = $_REQUEST['moduleid'];
  42. $prereq = $_REQUEST['prereq'];
  43. $type = $_REQUEST['type'];
  44. */
  45. /* MAIN CODE */
  46. // Using the resource linker as a tool for adding resources to the learning path.
  47. if ($action == 'add' and $type == 'learnpathitem') {
  48. $htmlHeadXtra[] = "<script language='JavaScript' type='text/javascript'> window.location=\"../resourcelinker/resourcelinker.php?source_id=5&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no\"; </script>";
  49. }
  50. if ((! $is_allowed_to_edit) || ($isStudentView)) {
  51. error_log('New LP - User not authorized in lp_edit_item_prereq.php');
  52. header('location:lp_controller.php?action=view&lp_id='.$learnpath_id);
  53. }
  54. // From here on, we are admin because of the previous condition, so don't check anymore.
  55. $sql_query = "SELECT * FROM $tbl_lp WHERE id = $learnpath_id";
  56. $result = Database::query($sql_query);
  57. $therow = Database::fetch_array($result);
  58. //$admin_output = '';
  59. /*
  60. Course admin section
  61. - all the functions not available for students - always available in this case (page only shown to admin)
  62. */
  63. /* SHOWING THE ADMIN TOOLS */
  64. if (isset($_SESSION['gradebook'])){
  65. $gradebook = $_SESSION['gradebook'];
  66. }
  67. if (!empty($gradebook) && $gradebook == 'view') {
  68. $interbreadcrumb[] = array (
  69. 'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
  70. 'name' => get_lang('ToolGradebook')
  71. );
  72. }
  73. $interbreadcrumb[] = array('url' => 'lp_controller.php?action=list', 'name' => get_lang('LearningPaths'));
  74. $interbreadcrumb[] = array('url' => api_get_self()."?action=build&lp_id=$learnpath_id", 'name' => stripslashes("{$therow['name']}"));
  75. // Theme calls.
  76. $show_learn_path = true;
  77. $lp_theme_css = $_SESSION['oLP']->get_theme();
  78. Display::display_header(null,'Path');
  79. //api_display_tool_title($therow['name']);
  80. $suredel = trim(get_lang('AreYouSureToDelete'));
  81. //$suredelstep = trim(get_lang('AreYouSureToDeleteSteps'));
  82. ?>
  83. <script type='text/javascript'>
  84. /* <![CDATA[ */
  85. function stripslashes(str) {
  86. str=str.replace(/\\'/g,'\'');
  87. str=str.replace(/\\"/g,'"');
  88. str=str.replace(/\\\\/g,'\\');
  89. str=str.replace(/\\0/g,'\0');
  90. return str;
  91. }
  92. function confirmation(name)
  93. {
  94. name=stripslashes(name);
  95. if (confirm("<?php echo $suredel; ?> " + name + " ?"))
  96. {
  97. return true;
  98. }
  99. else
  100. {
  101. return false;
  102. }
  103. }
  104. </script>
  105. <?php
  106. //echo $admin_output;
  107. /* DISPLAY SECTION */
  108. echo $_SESSION['oLP']->build_action_menu();
  109. echo '<table cellpadding="0" cellspacing="0" class="lp_build">';
  110. echo '<tr>';
  111. echo '<td class="tree">';
  112. echo '<div class="lp_tree">';
  113. // Build the tree with the menu items in it.
  114. echo $_SESSION['oLP']->build_tree();
  115. echo '</div>';
  116. echo '</td>';
  117. echo '<td class="workspace">';
  118. if (isset($is_success) && $is_success === true) {
  119. echo '<div class="lp_message" style="margin:3px 10px;">';
  120. echo get_lang("PrerequisitesAdded");
  121. echo '</div>';
  122. } else {
  123. echo $_SESSION['oLP']->display_manipulate($_GET['id'], null);
  124. echo $_SESSION['oLP']->display_item_prerequisites_form($_GET['id']);
  125. }
  126. echo '</td>';
  127. echo '</tr>';
  128. echo '</table>';
  129. /* FOOTER */
  130. Display::display_footer();