lp_build.php 6.0 KB

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