lp_build.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. /* Constants and variables */
  17. $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
  18. /** @var learnpath $learnPath */
  19. $learnPath = Session::read('oLP');
  20. $isStudentView = (int) $_REQUEST['isStudentView'];
  21. $learnpath_id = (int) $_REQUEST['lp_id'];
  22. $submit = $_POST['submit_button'];
  23. /* MAIN CODE */
  24. if (!$is_allowed_to_edit || $isStudentView) {
  25. header('location:lp_controller.php?action=view&lp_id='.$learnpath_id.'&'.api_get_cidreq());
  26. exit;
  27. }
  28. /* The learnpath has been just created, go get the last id. */
  29. $is_new = false;
  30. if ($learnpath_id == 0) {
  31. $is_new = true;
  32. }
  33. if (api_is_in_gradebook()) {
  34. $interbreadcrumb[] = [
  35. 'url' => Category::getUrl(),
  36. 'name' => get_lang('ToolGradebook'),
  37. ];
  38. }
  39. $interbreadcrumb[] = ['url' => 'lp_controller.php?action=list&'.api_get_cidreq(), 'name' => get_lang('LearningPaths')];
  40. $interbreadcrumb[] = ['url' => '#', "name" => $learnPath->get_name()];
  41. // Theme calls.
  42. $lp_theme_css = $learnPath->get_theme();
  43. $show_learn_path = true;
  44. Display::display_header('', 'Path');
  45. $suredel = trim(get_lang('AreYouSureToDeleteJS'));
  46. ?>
  47. <script>
  48. /* <![CDATA[ */
  49. function stripslashes(str) {
  50. str=str.replace(/\\'/g,'\'');
  51. str=str.replace(/\\"/g,'"');
  52. str=str.replace(/\\\\/g,'\\');
  53. str=str.replace(/\\0/g,'\0');
  54. return str;
  55. }
  56. function confirmation(name) {
  57. name=stripslashes(name);
  58. if (confirm("<?php echo $suredel; ?> " + name + " ?")) {
  59. return true;
  60. } else {
  61. return false;
  62. }
  63. }
  64. </script>
  65. <?php
  66. /* DISPLAY SECTION */
  67. echo $learnPath->build_action_menu();
  68. echo '<div class="row">';
  69. echo '<div class="col-md-4">';
  70. // Build the tree with the menu items in it.
  71. echo $learnPath->return_new_tree();
  72. echo '</div>';
  73. echo '<div class="col-md-8">';
  74. if (isset($is_success) && $is_success === true) {
  75. echo Display::return_message(get_lang('ItemRemoved'), 'confirmation');
  76. } else {
  77. if ($is_new) {
  78. echo Display::return_message(get_lang('LearnpathAdded'), 'normal', false);
  79. }
  80. echo Display::page_subheader(get_lang('LearnPathAddedTitle'));
  81. echo '<ul id="lp_overview" class="thumbnails">';
  82. echo show_block(
  83. 'lp_controller.php?'.api_get_cidreq().'&action=add_item&type=step&lp_id='.$learnPath->get_id(),
  84. get_lang("NewStep"),
  85. get_lang('NewStepComment'),
  86. 'tools.png'
  87. );
  88. echo show_block(
  89. 'lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$learnPath->get_id(),
  90. get_lang("Display"),
  91. get_lang('DisplayComment'),
  92. 'view.png'
  93. );
  94. echo '</ul>';
  95. }
  96. echo '</div>';
  97. echo '</div>';
  98. function show_block($link, $title, $subtitle, $icon)
  99. {
  100. $html = '<li class="col-md-4">';
  101. $html .= '<div class="thumbnail">';
  102. $html .= '<a href="'.$link.'" title="'.$title.'">';
  103. $html .= Display::return_icon($icon, $title, [], ICON_SIZE_BIG);
  104. $html .= '</a>';
  105. $html .= '<div class="caption">';
  106. $html .= '<strong>'.$title.'</strong></a> '.$subtitle;
  107. $html .= '</div>';
  108. $html .= '</div>';
  109. $html .= '</li>';
  110. return $html;
  111. }
  112. Display::display_footer();