lp_build.php 4.8 KB

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