lp_build.php 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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. $interbreadcrumb[]= array ("url"=>"lp_controller.php?action=list", "name"=> get_lang("_learning_path"));
  121. $interbreadcrumb[]= array ("url"=>api_get_self()."?action=build&lp_id=$learnpath_id", "name" => stripslashes("{$therow['name']}"));
  122. //Theme calls
  123. $lp_theme_css=$_SESSION['oLP']->get_theme();
  124. $show_learn_path=true;
  125. Display::display_header(null,'Path');
  126. //api_display_tool_title($therow['name']);
  127. $suredel = trim(get_lang('AreYouSureToDelete'));
  128. //$suredelstep = trim(get_lang('AreYouSureToDeleteSteps'));
  129. ?>
  130. <script type='text/javascript'>
  131. /* <![CDATA[ */
  132. function stripslashes(str) {
  133. str=str.replace(/\\'/g,'\'');
  134. str=str.replace(/\\"/g,'"');
  135. str=str.replace(/\\\\/g,'\\');
  136. str=str.replace(/\\0/g,'\0');
  137. return str;
  138. }
  139. function confirmation(name)
  140. {
  141. name=stripslashes(name);
  142. if (confirm("<?php echo $suredel; ?> " + name + " ?"))
  143. {
  144. return true;
  145. }
  146. else
  147. {
  148. return false;
  149. }
  150. }
  151. </script>
  152. <?php
  153. //echo $admin_output;
  154. /*
  155. -----------------------------------------------------------
  156. DISPLAY SECTION
  157. -----------------------------------------------------------
  158. */
  159. echo '<div class="actions">';
  160. echo '<span>'.Display::return_icon('learnpath_build.gif').' '.get_lang('Build').'</span>';
  161. echo '<a href="' .api_get_self(). '?cidReq=' . $_GET['cidReq'] . '&amp;action=admin_view&amp;lp_id=' . $_SESSION['oLP']->lp_id . '">'.Display::return_icon('learnpath_organize.gif').' '.get_lang("BasicOverview").'</a>';
  162. echo '<a href="lp_controller.php?cidReq='.$_GET['cidReq'].'&action=view&lp_id='.$_SESSION['oLP']->lp_id.'">'.Display::return_icon('learnpath_view.gif').' '.get_lang("Display").'</a>';
  163. echo '<a href="' .api_get_self(). '?cidReq=' . $_GET['cidReq'] . '&amp;action=add_item&amp;type=chapter&amp;lp_id=' . $_SESSION['oLP']->lp_id . '" title="'.get_lang("NewChapter").'"><img alt="'.get_lang("NewChapter").'" src="../img/lp_dokeos_chapter_add.png" title="'.get_lang("NewChapter").'" />'.get_lang("NewChapter").'</a>';
  164. echo '<a href="' .api_get_self(). '?cidReq=' . $_GET['cidReq'] . '&amp;action=add_item&amp;type=step&amp;lp_id=' . $_SESSION['oLP']->lp_id . '" title="'.get_lang("NewStep").'"><img alt="'.get_lang("NewStep").'" src="../img/lp_dokeos_step_add.png" title="'.get_lang("NewStep").'" />'.get_lang("NewStep").'</a>';
  165. echo '</div>';
  166. echo '<table cellpadding="0" cellspacing="0" class="lp_build">';
  167. echo '<tr>';
  168. echo '<td class="tree">';
  169. //links for adding a module, chapter or step
  170. echo '<div class="lp_actions">';
  171. echo '<p class="lp_action">';
  172. echo '</p>';
  173. echo '<p class="lp_action">';
  174. echo '</p>';
  175. echo '</div>';
  176. echo '<div class="lp_tree">';
  177. //build the tree with the menu items in it
  178. echo $_SESSION['oLP']->build_tree();
  179. echo '</div>';
  180. echo '</td>';
  181. echo '<td class="workspace">';
  182. if(isset($is_success) && $is_success === true)
  183. {
  184. echo '<div class="confirmation-message">';
  185. echo get_lang("ItemRemoved");
  186. echo '</div>';
  187. }
  188. else
  189. {
  190. if($is_new)
  191. {
  192. echo '<div class="confirmation-message">';
  193. echo get_lang("LearnPathAdded");
  194. echo '</div>';
  195. }
  196. if($is_new){
  197. Display::display_normal_message(get_lang("LPCreatedToContinue"));
  198. }
  199. else{
  200. Display::display_normal_message(get_lang('LPCreatedAddChapterStep'));
  201. }
  202. }
  203. echo '</td>';
  204. echo '</tr>';
  205. echo '</table>';
  206. /*
  207. ==============================================================================
  208. FOOTER
  209. ==============================================================================
  210. */
  211. Display::display_footer();
  212. ?>