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