lp_build.php 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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. /* INIT SECTION */
  13. $_SESSION['whereami'] = 'lp/build';
  14. $this_section = SECTION_COURSES;
  15. api_protect_course_script();
  16. /* Libraries */
  17. // The main_api.lib.php, database.lib.php and display.lib.php
  18. // libraries are included by default.
  19. include 'learnpath_functions.inc.php';
  20. //include '../resourcelinker/resourcelinker.inc.php';
  21. include 'resourcelinker.inc.php';
  22. // Rewrite the language file, sadly overwritten by resourcelinker.inc.php.
  23. // Name of the language file that needs to be included.
  24. $language_file = 'learnpath';
  25. /* Constants and variables */
  26. $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
  27. $tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
  28. $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
  29. $tbl_lp_view = Database::get_course_table(TABLE_LP_VIEW);
  30. $isStudentView = (int) $_REQUEST['isStudentView'];
  31. $learnpath_id = (int) $_REQUEST['lp_id'];
  32. $submit = $_POST['submit_button'];
  33. /*
  34. $chapter_id = $_GET['chapter_id'];
  35. $title = $_POST['title'];
  36. $description = $_POST['description'];
  37. $Submititem = $_POST['Submititem'];
  38. $action = $_REQUEST['action'];
  39. $id = (int) $_REQUEST['id'];
  40. $type = $_REQUEST['type'];
  41. $direction = $_REQUEST['direction'];
  42. $moduleid = $_REQUEST['moduleid'];
  43. $prereq = $_REQUEST['prereq'];
  44. $type = $_REQUEST['type'];
  45. */
  46. /* MAIN CODE */
  47. // Using the resource linker as a tool for adding resources to the learning path.
  48. if ($action=="add" and $type=="learnpathitem") {
  49. $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>";
  50. }
  51. if ((!$is_allowed_to_edit) || ($isStudentView)) {
  52. error_log('New LP - User not authorized in lp_build.php');
  53. header('location:lp_controller.php?action=view&lp_id='.$learnpath_id);
  54. }
  55. // From here on, we are admin because of the previous condition, so don't check anymore.
  56. /* The learnpath has been just created, go get the last id. */
  57. $is_new = false;
  58. if ($learnpath_id == 0) {
  59. $is_new = true;
  60. $sql = "
  61. SELECT id
  62. FROM " . $tbl_lp . "
  63. ORDER BY id DESC
  64. LIMIT 0, 1";
  65. $result = Database::query($sql);
  66. $row = Database::fetch_array($result);
  67. $learnpath_id = $row['id'];
  68. }
  69. $sql_query = "SELECT * FROM $tbl_lp WHERE id = $learnpath_id";
  70. $result = Database::query($sql_query);
  71. $therow = Database::fetch_array($result);
  72. //$admin_output = '';
  73. /*
  74. Course admin section
  75. - all the functions not available for students - always available in this case (page only shown to admin)
  76. */
  77. /* SHOWING THE ADMIN TOOLS */
  78. if (!empty($_GET['gradebook']) && $_GET['gradebook'] == 'view') {
  79. $_SESSION['gradebook'] = Security::remove_XSS($_GET['gradebook']);
  80. $gradebook = $_SESSION['gradebook'];
  81. } elseif (empty($_GET['gradebook'])) {
  82. unset($_SESSION['gradebook']);
  83. $gradebook = '';
  84. }
  85. if (!empty($gradebook) && $gradebook == 'view') {
  86. $interbreadcrumb[] = array (
  87. 'url' => '../gradebook/' . $_SESSION['gradebook_dest'],
  88. 'name' => get_lang('ToolGradebook')
  89. );
  90. }
  91. $interbreadcrumb[] = array('url' => 'lp_controller.php?action=list', 'name' => get_lang('_learning_path'));
  92. $interbreadcrumb[] = array('url' => api_get_self()."?action=build&lp_id=$learnpath_id", "name" => stripslashes("{$therow['name']}"));
  93. // Theme calls.
  94. $lp_theme_css=$_SESSION['oLP']->get_theme();
  95. $show_learn_path = true;
  96. Display::display_header(null, 'Path');
  97. //api_display_tool_title($therow['name']);
  98. $suredel = trim(get_lang('AreYouSureToDelete'));
  99. //$suredelstep = trim(get_lang('AreYouSureToDeleteSteps'));
  100. ?>
  101. <script type='text/javascript'>
  102. /* <![CDATA[ */
  103. function stripslashes(str) {
  104. str=str.replace(/\\'/g,'\'');
  105. str=str.replace(/\\"/g,'"');
  106. str=str.replace(/\\\\/g,'\\');
  107. str=str.replace(/\\0/g,'\0');
  108. return str;
  109. }
  110. function confirmation(name)
  111. {
  112. name=stripslashes(name);
  113. if (confirm("<?php echo $suredel; ?> " + name + " ?"))
  114. {
  115. return true;
  116. }
  117. else
  118. {
  119. return false;
  120. }
  121. }
  122. </script>
  123. <?php
  124. //echo $admin_output;
  125. /* DISPLAY SECTION */
  126. echo $_SESSION['oLP']->build_action_menu();
  127. echo '<table cellpadding="0" cellspacing="0" class="lp_build">';
  128. echo '<tr>';
  129. echo '<td class="tree">';
  130. echo '<div class="lp_tree">';
  131. // Build the tree with the menu items in it.
  132. echo $_SESSION['oLP']->build_tree();
  133. echo '</div>';
  134. echo '</td>';
  135. echo '<td class="workspace">';
  136. if (isset($is_success) && $is_success === true) {
  137. Display::display_confirmation_message(get_lang('ItemRemoved'));
  138. } else {
  139. if ($is_new) {
  140. Display::display_normal_message(get_lang('LearnpathAdded'), false);
  141. }
  142. // Display::display_normal_message(get_lang('LPCreatedAddChapterStep'), false);
  143. $gradebook = Security::remove_XSS($_GET['gradebook']);
  144. //$learnpathadded = Display::return_icon('gallery/creative.gif', '', array('align' => 'right'));
  145. $learnpathadded .= '<p><strong>'.get_lang('LearnPathAddedTitle').'</strong><br /><br />';
  146. $learnpathadded .= '<a href="lp_controller.php?'.api_get_cidreq().'&amp;action=build&amp;lp_id='.Security::remove_XSS($_GET['lp_id']).'" target="_parent">'.Display::return_icon('learnpath_build.gif', get_lang('Build'), array('style' => 'vertical-align: middle;')).' '.get_lang('Build')."</a>: ".get_lang('BuildComment').'<br />';
  147. $learnpathadded .= '<a href="lp_controller.php?cidReq=' . Security::remove_XSS($_GET['cidReq']) . '&amp;gradebook='.$gradebook.'&amp;action=admin_view&amp;lp_id=' . $_SESSION['oLP']->lp_id . '" title="'.get_lang("BasicOverview").'">'.Display::return_icon('learnpath_organize.gif', get_lang('BasicOverview'), array('style' => 'vertical-align: middle;')).' '.get_lang('BasicOverview').'</a>: '.get_lang('BasicOverviewComment').'<br />';
  148. $learnpathadded .= '<a href="lp_controller.php?cidReq=' . Security::remove_XSS($_GET['cidReq']) . '&amp;gradebook='.$gradebook.'&action=view&lp_id='.$_SESSION['oLP']->lp_id.'">'.Display::return_icon('learnpath_view.gif', get_lang('Display'),array('style' => 'vertical-align: middle;')).' '.get_lang('Display').'</a>: '.get_lang('DisplayComment').'<br />';
  149. $learnpathadded .= '<a href="lp_controller.php?cidReq=' . Security::remove_XSS($_GET['cidReq']) . '&amp;gradebook='.$gradebook.'&amp;action=add_item&amp;type=chapter&amp;lp_id=' . $_SESSION['oLP']->lp_id . '" title="'.get_lang('NewChapter').'">'.Display::return_icon('lp_dokeos_chapter_add.gif', get_lang('NewChapter'), array('style' => 'vertical-align: middle;')).' '.get_lang('NewChapter').'</a>: '.get_lang('NewChapterComment').'<br />';
  150. $learnpathadded .= '<a href="lp_controller.php?cidReq=' . Security::remove_XSS($_GET['cidReq']) . '&amp;gradebook='.$gradebook.'&amp;action=add_item&amp;type=step&amp;lp_id=' . $_SESSION['oLP']->lp_id . '" title="'.get_lang('NewStep').'">'.Display::return_icon('new_test.gif', get_lang('NewStep'), array('style' => 'vertical-align: middle;')).' '.get_lang('NewStep').'</a>: '.get_lang('NewStepComment').'<br />';
  151. $learnpathadded .= '<br /><br /><br /><br /></p>';
  152. Display::display_normal_message($learnpathadded, false);
  153. }
  154. echo '</td>';
  155. echo '</tr>';
  156. echo '</table>';
  157. /* FOOTER */
  158. Display::display_footer();