lp_build.php 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <?php // $Id: index.php 16620 2008-10-25 20:03:54Z yannoo $
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2004-2008 Dokeos SPRL
  6. Copyright (c) 2003 Ghent University (UGent)
  7. For a full list of contributors, see "credits.txt".
  8. The full license can be read in "license.txt".
  9. This program is free software; you can redistribute it and/or
  10. modify it under the terms of the GNU General Public License
  11. as published by the Free Software Foundation; either version 2
  12. of the License, or (at your option) any later version.
  13. See the GNU General Public License for more details.
  14. Contact: Dokeos, rue Notre Dame, 152, B-1140 Evere, Belgium, info@dokeos.com
  15. ==============================================================================
  16. */
  17. /**
  18. ==============================================================================
  19. * This is a learning path creation and player tool in Dokeos - previously learnpath_handler.php
  20. *
  21. * @author Patrick Cool
  22. * @author Denes Nagy
  23. * @author Roan Embrechts, refactoring and code cleaning
  24. * @author Yannick Warnier <ywarnier@beeznest.org> - cleaning and update for new SCORM tool
  25. * @package dokeos.learnpath
  26. ==============================================================================
  27. */
  28. /*
  29. ==============================================================================
  30. INIT SECTION
  31. ==============================================================================
  32. */
  33. $_SESSION['whereami'] = 'lp/build';
  34. $this_section=SECTION_COURSES;
  35. api_protect_course_script();
  36. /*
  37. -----------------------------------------------------------
  38. Libraries
  39. -----------------------------------------------------------
  40. */
  41. //the main_api.lib.php, database.lib.php and display.lib.php
  42. //libraries are included by default
  43. include('learnpath_functions.inc.php');
  44. //include('../resourcelinker/resourcelinker.inc.php');
  45. include('resourcelinker.inc.php');
  46. //rewrite the language file, sadly overwritten by resourcelinker.inc.php
  47. // name of the language file that needs to be included
  48. $language_file = "learnpath";
  49. /*
  50. -----------------------------------------------------------
  51. Constants and variables
  52. -----------------------------------------------------------
  53. */
  54. $is_allowed_to_edit = api_is_allowed_to_edit();
  55. $tbl_lp = Database::get_course_table('lp');
  56. $tbl_lp_item = Database::get_course_table('lp_item');
  57. $tbl_lp_view = Database::get_course_table('lp_view');
  58. $isStudentView = (int) $_REQUEST['isStudentView'];
  59. $learnpath_id = (int) $_REQUEST['lp_id'];
  60. $submit = $_POST['submit_button'];
  61. /*
  62. $chapter_id = $_GET['chapter_id'];
  63. $title = $_POST['title'];
  64. $description = $_POST['description'];
  65. $Submititem = $_POST['Submititem'];
  66. $action = $_REQUEST['action'];
  67. $id = (int) $_REQUEST['id'];
  68. $type = $_REQUEST['type'];
  69. $direction = $_REQUEST['direction'];
  70. $moduleid = $_REQUEST['moduleid'];
  71. $prereq = $_REQUEST['prereq'];
  72. $type = $_REQUEST['type'];
  73. */
  74. /*
  75. ==============================================================================
  76. MAIN CODE
  77. ==============================================================================
  78. */
  79. // using the resource linker as a tool for adding resources to the learning path
  80. if ($action=="add" and $type=="learnpathitem")
  81. {
  82. $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>";
  83. }
  84. if ( (! $is_allowed_to_edit) or ($isStudentView) )
  85. {
  86. error_log('New LP - User not authorized in lp_build.php');
  87. header('location:lp_controller.php?action=view&lp_id='.$learnpath_id);
  88. }
  89. //from here on, we are admin because of the previous condition, so don't check anymore
  90. /* learnpath is just created, go get the last id */
  91. $is_new = false;
  92. if($learnpath_id == 0)
  93. {
  94. $is_new = true;
  95. $sql = "
  96. SELECT id
  97. FROM " . $tbl_lp . "
  98. ORDER BY id DESC
  99. LIMIT 0, 1";
  100. $result = api_sql_query($sql);
  101. $row = Database::fetch_array($result);
  102. $learnpath_id = $row['id'];
  103. }
  104. $sql_query = "SELECT * FROM $tbl_lp WHERE id = $learnpath_id";
  105. $result=api_sql_query($sql_query);
  106. $therow=Database::fetch_array($result);
  107. //$admin_output = '';
  108. /*
  109. -----------------------------------------------------------
  110. Course admin section
  111. - all the functions not available for students - always available in this case (page only shown to admin)
  112. -----------------------------------------------------------
  113. */
  114. /*==================================================
  115. SHOWING THE ADMIN TOOLS
  116. ==================================================*/
  117. /*==================================================
  118. prerequisites setting end
  119. ==================================================*/
  120. if (!empty($_GET['gradebook']) && $_GET['gradebook']=='view' ) {
  121. $_SESSION['gradebook']=Security::remove_XSS($_GET['gradebook']);
  122. $gradebook= $_SESSION['gradebook'];
  123. } elseif (empty($_GET['gradebook'])) {
  124. unset($_SESSION['gradebook']);
  125. $gradebook= '';
  126. }
  127. if (!empty($gradebook) && $gradebook=='view') {
  128. $interbreadcrumb[] = array (
  129. 'url' => '../gradebook/' . $_SESSION['gradebook_dest'],
  130. 'name' => get_lang('Gradebook')
  131. );
  132. }
  133. $interbreadcrumb[]= array ("url"=>"lp_controller.php?action=list", "name"=> get_lang("_learning_path"));
  134. $interbreadcrumb[]= array ("url"=>api_get_self()."?action=build&lp_id=$learnpath_id", "name" => stripslashes("{$therow['name']}"));
  135. //Theme calls
  136. $lp_theme_css=$_SESSION['oLP']->get_theme();
  137. $show_learn_path=true;
  138. Display::display_header(null,'Path');
  139. //api_display_tool_title($therow['name']);
  140. $suredel = trim(get_lang('AreYouSureToDelete'));
  141. //$suredelstep = trim(get_lang('AreYouSureToDeleteSteps'));
  142. ?>
  143. <script type='text/javascript'>
  144. /* <![CDATA[ */
  145. function stripslashes(str) {
  146. str=str.replace(/\\'/g,'\'');
  147. str=str.replace(/\\"/g,'"');
  148. str=str.replace(/\\\\/g,'\\');
  149. str=str.replace(/\\0/g,'\0');
  150. return str;
  151. }
  152. function confirmation(name)
  153. {
  154. name=stripslashes(name);
  155. if (confirm("<?php echo $suredel; ?> " + name + " ?"))
  156. {
  157. return true;
  158. }
  159. else
  160. {
  161. return false;
  162. }
  163. }
  164. </script>
  165. <?php
  166. //echo $admin_output;
  167. /*
  168. -----------------------------------------------------------
  169. DISPLAY SECTION
  170. -----------------------------------------------------------
  171. */
  172. echo $_SESSION['oLP']->build_action_menu();
  173. echo '<table cellpadding="0" cellspacing="0" class="lp_build">';
  174. echo '<tr>';
  175. echo '<td class="tree">';
  176. //links for adding a module, chapter or step
  177. echo '<div class="lp_actions">';
  178. echo '<p class="lp_action">';
  179. echo '</p>';
  180. echo '<p class="lp_action">';
  181. echo '</p>';
  182. echo '</div>';
  183. echo '<div class="lp_tree">';
  184. //build the tree with the menu items in it
  185. echo $_SESSION['oLP']->build_tree();
  186. echo '</div>';
  187. echo '</td>';
  188. echo '<td class="workspace">';
  189. if(isset($is_success) && $is_success === true) {
  190. echo '<div class="confirmation-message">';
  191. echo get_lang("ItemRemoved");
  192. echo '</div>';
  193. } else {
  194. if($is_new) {
  195. echo '<div class="confirmation-message">';
  196. echo get_lang("LearnPathAdded");
  197. echo '</div>';
  198. }
  199. if($is_new) {
  200. Display::display_normal_message(get_lang('LPCreatedToContinue'));
  201. } else {
  202. // Display::display_normal_message(get_lang('LPCreatedAddChapterStep'), false);
  203. echo '<div class="normal-message">';
  204. echo get_lang("LearnPathAdded");
  205. echo '</div>';
  206. }
  207. }
  208. echo '</td>';
  209. echo '</tr>';
  210. echo '</table>';
  211. /*
  212. ==============================================================================
  213. FOOTER
  214. ==============================================================================
  215. */
  216. Display::display_footer();
  217. ?>