lp_move_item.php 4.6 KB

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