lp_build.php 8.8 KB

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