lp_build.php 5.8 KB

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