lp_move_item.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. use ChamiloSession as Session;
  4. /**
  5. * This is a learning path creation and player tool in Chamilo - previously learnpath_handler.php.
  6. *
  7. * @author Patrick Cool
  8. * @author Denes Nagy
  9. * @author Roan Embrechts, refactoring and code cleaning
  10. * @author Yannick Warnier <ywarnier@beeznest.org> - cleaning and update for new SCORM tool
  11. *
  12. * @package chamilo.learnpath
  13. */
  14. $this_section = SECTION_COURSES;
  15. api_protect_course_script();
  16. /** @var learnpath $learnPath */
  17. $learnPath = Session::read('oLP');
  18. /* Header and action code */
  19. $htmlHeadXtra[] = '<script>'.
  20. $learnPath->get_js_dropdown_array().
  21. "
  22. function load_cbo(id) {
  23. if (!id) {
  24. return false;
  25. }
  26. var cbo = document.getElementById('previous');
  27. for(var i = cbo.length - 1; i > 0; i--) {
  28. cbo.options[i] = null;
  29. }
  30. var k=0;
  31. for(var i = 1; i <= child_name[id].length; i++) {
  32. cbo.options[i] = new Option(child_name[id][i - 1], child_value[id][i - 1]);
  33. k=i;
  34. }
  35. cbo.options[k].selected = true;
  36. $('#previous').selectpicker('refresh');
  37. }
  38. ".
  39. "\n".
  40. '$().ready(function() {'."\n".
  41. 'if ($(\'#previous\')) {'."\n".
  42. 'if(\'parent is\'+$(\'#idParent\').val()) {'.
  43. 'load_cbo($(\'#idParent\').val());'."\n".
  44. '}}'."\n".
  45. '});</script>'."\n";
  46. /* Constants and variables */
  47. $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
  48. $isStudentView = isset($_REQUEST['isStudentView']) ? (int) $_REQUEST['isStudentView'] : '';
  49. $learnpath_id = (int) $_REQUEST['lp_id'];
  50. $submit = isset($_POST['submit_button']) ? $_POST['submit_button'] : '';
  51. /* MAIN CODE */
  52. if ((!$is_allowed_to_edit) || ($isStudentView)) {
  53. header('location:lp_controller.php?action=view&lp_id='.$learnpath_id);
  54. }
  55. // From here on, we are admin because of the previous condition, so don't check anymore.
  56. $course_id = api_get_course_int_id();
  57. $sql = "SELECT * FROM $tbl_lp WHERE iid = $learnpath_id";
  58. $result = Database::query($sql);
  59. $therow = Database::fetch_array($result);
  60. /*
  61. Course admin section
  62. - all the functions not available for students - always available in this case (page only shown to admin)
  63. */
  64. if (api_is_in_gradebook()) {
  65. $interbreadcrumb[] = [
  66. 'url' => Category::getUrl(),
  67. 'name' => get_lang('ToolGradebook'),
  68. ];
  69. }
  70. $interbreadcrumb[] = [
  71. 'url' => 'lp_controller.php?action=list&'.api_get_cidreq(),
  72. 'name' => get_lang('LearningPaths'),
  73. ];
  74. $interbreadcrumb[] = [
  75. 'url' => api_get_self()."?action=build&lp_id=$learnpath_id&".api_get_cidreq(),
  76. 'name' => stripslashes("{$therow['name']}"),
  77. ];
  78. $interbreadcrumb[] = [
  79. 'url' => api_get_self()."?action=add_item&type=step&lp_id=$learnpath_id&".api_get_cidreq(),
  80. 'name' => get_lang('NewStep'),
  81. ];
  82. // Theme calls
  83. $show_learn_path = true;
  84. $lp_theme_css = $learnPath->get_theme();
  85. Display::display_header(get_lang('Move'), 'Path');
  86. $suredel = trim(get_lang('AreYouSureToDeleteJS'));
  87. ?>
  88. <script>
  89. /* <![CDATA[ */
  90. function stripslashes(str) {
  91. str=str.replace(/\\'/g,'\'');
  92. str=str.replace(/\\"/g,'"');
  93. str=str.replace(/\\\\/g,'\\');
  94. str=str.replace(/\\0/g,'\0');
  95. return str;
  96. }
  97. function confirmation(name) {
  98. name=stripslashes(name);
  99. if (confirm("<?php echo $suredel; ?> " + name + " ?"))
  100. {
  101. return true;
  102. }
  103. else
  104. {
  105. return false;
  106. }
  107. }
  108. </script>
  109. <?php
  110. echo $learnPath->build_action_menu();
  111. echo '<div class="row">';
  112. echo '<div class="col-md-3">';
  113. echo $learnPath->return_new_tree();
  114. echo '</div>';
  115. echo '<div class="col-md-9">';
  116. if (isset($is_success) && $is_success === true) {
  117. $msg = '<div class="lp_message" style="margin-bottom:10px;">';
  118. $msg .= 'The item has been moved.';
  119. $msg .= '</div>';
  120. echo $learnPath->display_item($_GET['id'], $msg);
  121. } else {
  122. echo $learnPath->display_move_item($_GET['id']);
  123. }
  124. echo '</div>';
  125. echo '</div>';
  126. Display::display_footer();