lp_move_item.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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('url' => 'lp_controller.php?action=list', 'name' => get_lang('LearningPaths'));
  82. $interbreadcrumb[] = array('url' => api_get_self()."?action=build&lp_id=$learnpath_id", 'name' => stripslashes("{$therow['name']}"));
  83. $interbreadcrumb[] = array('url' => api_get_self()."?action=add_item&type=step&lp_id=$learnpath_id", 'name' => get_lang('NewStep'));
  84. // Theme calls
  85. $show_learn_path = true;
  86. $lp_theme_css = $_SESSION['oLP']->get_theme();
  87. Display::display_header(get_lang('Move'), 'Path');
  88. $suredel = trim(get_lang('AreYouSureToDeleteJS'));
  89. ?>
  90. <script type='text/javascript'>
  91. /* <![CDATA[ */
  92. function stripslashes(str) {
  93. str=str.replace(/\\'/g,'\'');
  94. str=str.replace(/\\"/g,'"');
  95. str=str.replace(/\\\\/g,'\\');
  96. str=str.replace(/\\0/g,'\0');
  97. return str;
  98. }
  99. function confirmation(name)
  100. {
  101. name=stripslashes(name);
  102. if (confirm("<?php echo $suredel; ?> " + name + " ?"))
  103. {
  104. return true;
  105. }
  106. else
  107. {
  108. return false;
  109. }
  110. }
  111. </script>
  112. <?php
  113. echo $_SESSION['oLP']->build_action_menu();
  114. echo '<div class="row">';
  115. echo '<div class="col-md-3">';
  116. echo $_SESSION['oLP']->return_new_tree();
  117. echo '</div>';
  118. echo '<div class="col-md-9">';
  119. if (isset($is_success) && $is_success === true) {
  120. $msg = '<div class="lp_message" style="margin-bottom:10px;">';
  121. $msg .= 'The item has been moved.';
  122. $msg .= '</div>';
  123. echo $_SESSION['oLP']->display_item($_GET['id'], $msg);
  124. } else {
  125. echo $_SESSION['oLP']->display_move_item($_GET['id']);
  126. }
  127. echo '</div>';
  128. echo '</div>';
  129. /* FOOTER */
  130. Display::display_footer();