lp_move_item.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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. include 'learnpath_functions.inc.php';
  15. //include '../resourcelinker/resourcelinker.inc.php';
  16. include 'resourcelinker.inc.php';
  17. /* Header and action code */
  18. $htmlHeadXtra[] = '<script type="text/javascript">'.
  19. $_SESSION['oLP']->get_js_dropdown_array() .
  20. "
  21. function load_cbo(id) {
  22. if (!id) {
  23. return false;
  24. }
  25. var cbo = document.getElementById('previous');
  26. for(var i = cbo.length - 1; i > 0; i--) {
  27. cbo.options[i] = null;
  28. }
  29. var k=0;
  30. for(var i = 1; i <= child_name[id].length; i++) {
  31. cbo.options[i] = new Option(child_name[id][i - 1], child_value[id][i - 1]);
  32. k=i;
  33. }
  34. cbo.options[k].selected = true;
  35. $('#previous').selectpicker('refresh');
  36. }
  37. " .
  38. "\n" .
  39. '$().ready(function() {'."\n" .
  40. 'if ($(\'#previous\')) {'."\n" .
  41. 'if(\'parent is\'+$(\'#idParent\').val()) {'.
  42. 'load_cbo($(\'#idParent\').val());'."\n" .
  43. '}}'."\n" .
  44. '});</script>'."\n" ;
  45. /* Constants and variables */
  46. $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
  47. $tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
  48. $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
  49. $tbl_lp_view = Database::get_course_table(TABLE_LP_VIEW);
  50. $isStudentView = isset($_REQUEST['isStudentView']) ? (int) $_REQUEST['isStudentView'] : '';
  51. $learnpath_id = (int) $_REQUEST['lp_id'];
  52. $submit = isset($_POST['submit_button']) ? $_POST['submit_button'] : '';
  53. /* MAIN CODE */
  54. // Using the resource linker as a tool for adding resources to the learning path.
  55. if ($action == 'add' && $type == 'learnpathitem') {
  56. $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>";
  57. }
  58. if ((!$is_allowed_to_edit) || ($isStudentView)) {
  59. header('location:lp_controller.php?action=view&lp_id='.$learnpath_id);
  60. }
  61. // From here on, we are admin because of the previous condition, so don't check anymore.
  62. $course_id = api_get_course_int_id();
  63. $sql = "SELECT * FROM $tbl_lp
  64. WHERE c_id = $course_id AND id = $learnpath_id";
  65. $result = Database::query($sql);
  66. $therow = Database::fetch_array($result);
  67. /*
  68. Course admin section
  69. - all the functions not available for students - always available in this case (page only shown to admin)
  70. */
  71. /* SHOWING THE ADMIN TOOLS */
  72. if (isset($_SESSION['gradebook'])) {
  73. $gradebook= $_SESSION['gradebook'];
  74. }
  75. if (!empty($gradebook) && $gradebook == 'view') {
  76. $interbreadcrumb[] = array (
  77. 'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
  78. 'name' => get_lang('ToolGradebook')
  79. );
  80. }
  81. $interbreadcrumb[] = array(
  82. 'url' => 'lp_controller.php?action=list?'.api_get_cidreq(),
  83. 'name' => get_lang('LearningPaths'),
  84. );
  85. $interbreadcrumb[] = array(
  86. 'url' => api_get_self()."?action=build&lp_id=$learnpath_id&".api_get_cidreq(),
  87. 'name' => stripslashes("{$therow['name']}"),
  88. );
  89. $interbreadcrumb[] = array(
  90. 'url' => api_get_self()."?action=add_item&type=step&lp_id=$learnpath_id&".api_get_cidreq(),
  91. 'name' => get_lang('NewStep'),
  92. );
  93. // Theme calls
  94. $show_learn_path = true;
  95. $lp_theme_css = $_SESSION['oLP']->get_theme();
  96. Display::display_header(get_lang('Move'), 'Path');
  97. $suredel = trim(get_lang('AreYouSureToDeleteJS'));
  98. ?>
  99. <script type='text/javascript'>
  100. /* <![CDATA[ */
  101. function stripslashes(str) {
  102. str=str.replace(/\\'/g,'\'');
  103. str=str.replace(/\\"/g,'"');
  104. str=str.replace(/\\\\/g,'\\');
  105. str=str.replace(/\\0/g,'\0');
  106. return str;
  107. }
  108. function confirmation(name)
  109. {
  110. name=stripslashes(name);
  111. if (confirm("<?php echo $suredel; ?> " + name + " ?"))
  112. {
  113. return true;
  114. }
  115. else
  116. {
  117. return false;
  118. }
  119. }
  120. </script>
  121. <?php
  122. echo $_SESSION['oLP']->build_action_menu();
  123. echo '<div class="row">';
  124. echo '<div class="col-md-3">';
  125. echo $_SESSION['oLP']->return_new_tree();
  126. echo '</div>';
  127. echo '<div class="col-md-9">';
  128. if (isset($is_success) && $is_success === true) {
  129. $msg = '<div class="lp_message" style="margin-bottom:10px;">';
  130. $msg .= 'The item has been moved.';
  131. $msg .= '</div>';
  132. echo $_SESSION['oLP']->display_item($_GET['id'], $msg);
  133. } else {
  134. echo $_SESSION['oLP']->display_move_item($_GET['id']);
  135. }
  136. echo '</div>';
  137. echo '</div>';
  138. /* FOOTER */
  139. Display::display_footer();