lp_build.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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. /* Constants and variables */
  15. $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
  16. $tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
  17. $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
  18. $tbl_lp_view = Database::get_course_table(TABLE_LP_VIEW);
  19. $isStudentView = (int) $_REQUEST['isStudentView'];
  20. $learnpath_id = (int) $_REQUEST['lp_id'];
  21. $submit = $_POST['submit_button'];
  22. /* MAIN CODE */
  23. if ((!$is_allowed_to_edit) || ($isStudentView)) {
  24. error_log('New LP - User not authorized in lp_build.php');
  25. header('location:lp_controller.php?action=view&lp_id='.$learnpath_id);
  26. }
  27. // From here on, we are admin because of the previous condition, so don't check anymore.
  28. /* The learnpath has been just created, go get the last id. */
  29. $is_new = false;
  30. $course_id = api_get_course_int_id();
  31. if ($learnpath_id == 0) {
  32. $is_new = true;
  33. $sql = "SELECT id FROM $tbl_lp
  34. WHERE c_id = $course_id
  35. ORDER BY id DESC LIMIT 0, 1";
  36. $result = Database::query($sql);
  37. $row = Database::fetch_array($result);
  38. $learnpath_id = $row['id'];
  39. }
  40. $sql_query = "SELECT * FROM $tbl_lp WHERE c_id = $course_id AND id = $learnpath_id";
  41. $result = Database::query($sql_query);
  42. $therow = Database::fetch_array($result);
  43. if (api_is_in_gradebook()) {
  44. $interbreadcrumb[] = array(
  45. 'url' => Category::getUrl(),
  46. 'name' => get_lang('ToolGradebook')
  47. );
  48. }
  49. $interbreadcrumb[] = array('url' => 'lp_controller.php?action=list', 'name' => get_lang('LearningPaths'));
  50. $interbreadcrumb[] = array('url' => '#', "name" => $therow['name']);
  51. // Theme calls.
  52. $lp_theme_css = $_SESSION['oLP']->get_theme();
  53. $show_learn_path = true;
  54. Display::display_header('', 'Path');
  55. $suredel = trim(get_lang('AreYouSureToDeleteJS'));
  56. ?>
  57. <script>
  58. /* <![CDATA[ */
  59. function stripslashes(str) {
  60. str=str.replace(/\\'/g,'\'');
  61. str=str.replace(/\\"/g,'"');
  62. str=str.replace(/\\\\/g,'\\');
  63. str=str.replace(/\\0/g,'\0');
  64. return str;
  65. }
  66. function confirmation(name) {
  67. name=stripslashes(name);
  68. if (confirm("<?php echo $suredel; ?> " + name + " ?")) {
  69. return true;
  70. } else {
  71. return false;
  72. }
  73. }
  74. </script>
  75. <?php
  76. /* DISPLAY SECTION */
  77. echo $_SESSION['oLP']->build_action_menu();
  78. echo '<div class="row">';
  79. echo '<div class="col-md-4">';
  80. // Build the tree with the menu items in it.
  81. echo $_SESSION['oLP']->return_new_tree();
  82. echo '</div>';
  83. echo '<div class="col-md-8">';
  84. if (isset($is_success) && $is_success === true) {
  85. echo Display::return_message(get_lang('ItemRemoved'), 'confirmation');
  86. } else {
  87. if ($is_new) {
  88. echo Display::return_message(get_lang('LearnpathAdded'), 'normal', false);
  89. }
  90. echo Display::page_subheader(get_lang('LearnPathAddedTitle'));
  91. echo '<ul id="lp_overview" class="thumbnails">';
  92. echo show_block(
  93. 'lp_controller.php?'.api_get_cidreq().'&action=add_item&type=step&lp_id='.$_SESSION['oLP']->lp_id,
  94. get_lang("NewStep"),
  95. get_lang('NewStepComment'),
  96. 'tools.png'
  97. );
  98. echo show_block(
  99. 'lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$_SESSION['oLP']->lp_id,
  100. get_lang("Display"),
  101. get_lang('DisplayComment'),
  102. 'view.png'
  103. );
  104. echo '</ul>';
  105. }
  106. echo '</div>';
  107. echo '</div>';
  108. function show_block($link, $title, $subtitle, $icon)
  109. {
  110. $html = '<li class="col-md-4">';
  111. $html .= '<div class="thumbnail">';
  112. $html .= '<a href="'.$link.'" title="'.$title.'">';
  113. $html .= Display::return_icon($icon, $title, array(), ICON_SIZE_BIG);
  114. $html .= '</a>';
  115. $html .= '<div class="caption">';
  116. $html .= '<strong>'.$title.'</strong></a> '.$subtitle;
  117. $html .= '</div>';
  118. $html .= '</div>';
  119. $html .= '</li>';
  120. return $html;
  121. }
  122. /* FOOTER */
  123. Display::display_footer();