lp_add_item.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  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
  24. * learnpath_handler.php
  25. *
  26. * @author Patrick Cool
  27. * @author Denes Nagy
  28. * @author Roan Embrechts, refactoring and code cleaning
  29. * @author Yannick Warnier <ywarnier@beeznest.org> - cleaning and update
  30. * @package dokeos.learnpath
  31. ==============================================================================
  32. */
  33. /*
  34. ==============================================================================
  35. INIT SECTION
  36. ==============================================================================
  37. */
  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. Header and action code
  56. -----------------------------------------------------------
  57. */
  58. $htmlHeadXtra[] = '
  59. <script type="text/javascript">
  60. function launch_templates(){
  61. window.frames[0].FCKToolbarItems.GetItem("Templates").Click();
  62. }
  63. </script>';
  64. $htmlHeadXtra[] = $_SESSION['oLP']->create_js();
  65. /*
  66. -----------------------------------------------------------
  67. Constants and variables
  68. -----------------------------------------------------------
  69. */
  70. $is_allowed_to_edit = api_is_allowed_to_edit();
  71. $tbl_lp = Database::get_course_table('lp');
  72. $tbl_lp_item = Database::get_course_table('lp_item');
  73. $tbl_lp_view = Database::get_course_table('lp_view');
  74. $isStudentView = (int) $_REQUEST['isStudentView'];
  75. $learnpath_id = (int) $_REQUEST['lp_id'];
  76. $submit = $_POST['submit_button'];
  77. /*
  78. $chapter_id = $_GET['chapter_id'];
  79. $title = $_POST['title'];
  80. $description = $_POST['description'];
  81. $Submititem = $_POST['Submititem'];
  82. $action = $_REQUEST['action'];
  83. $id = (int) $_REQUEST['id'];
  84. $type = $_REQUEST['type'];
  85. $direction = $_REQUEST['direction'];
  86. $moduleid = $_REQUEST['moduleid'];
  87. $prereq = $_REQUEST['prereq'];
  88. $type = $_REQUEST['type'];
  89. */
  90. /*
  91. ==============================================================================
  92. MAIN CODE
  93. ==============================================================================
  94. */
  95. // using the resource linker as a tool for adding resources to the learning path
  96. if ($action=="add" and $type=="learnpathitem")
  97. {
  98. $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>";
  99. }
  100. if ( (! $is_allowed_to_edit) or ($isStudentView) )
  101. {
  102. error_log('New LP - User not authorized in lp_add_item.php');
  103. header('location:lp_controller.php?action=view&lp_id='.$learnpath_id);
  104. }
  105. //from here on, we are admin because of the previous condition, so don't check anymore
  106. $sql_query = "SELECT * FROM $tbl_lp WHERE id = $learnpath_id";
  107. $result=api_sql_query($sql_query);
  108. $therow=Database::fetch_array($result);
  109. //$admin_output = '';
  110. /*
  111. -----------------------------------------------------------
  112. Course admin section
  113. - all the functions not available for students - always available in this case (page only shown to admin)
  114. -----------------------------------------------------------
  115. */
  116. /*==================================================
  117. SHOWING THE ADMIN TOOLS
  118. ==================================================*/
  119. $interbreadcrumb[]= array ("url"=>"lp_controller.php?action=list", "name"=> get_lang("_learning_path"));
  120. $interbreadcrumb[]= array ("url"=>api_get_self()."?action=build&lp_id=$learnpath_id", "name" => stripslashes("{$therow['name']}"));
  121. switch($_GET['type']){
  122. case 'chapter':
  123. $interbreadcrumb[]= array ("url"=>"#", "name" => get_lang("NewChapter"));
  124. break;
  125. default:
  126. $interbreadcrumb[]= array ("url"=>"#", "name" => get_lang("NewStep"));
  127. break;
  128. }
  129. //Theme calls
  130. $show_learn_path=true;
  131. $lp_theme_css=$_SESSION['oLP']->get_theme();
  132. Display::display_header(null,'Path');
  133. //api_display_tool_title($therow['name']);
  134. $suredel = get_lang('AreYouSureToDelete');
  135. $suredelstep = get_lang('AreYouSureToDeleteSteps');
  136. ?>
  137. <script type='text/javascript'>
  138. /* <![CDATA[ */
  139. function confirmation (name)
  140. {
  141. 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')
  142. {
  143. if (confirm("<?php echo $suredel; ?> "+ name + " <?php echo $suredelstep;?>?"))
  144. {return true;}
  145. else
  146. {return false;}
  147. }
  148. else
  149. {
  150. if (confirm("<?php echo $suredel; ?> "+ name + "?"))
  151. {return true;}
  152. else
  153. {return false;}
  154. }
  155. }
  156. </script>
  157. <?php
  158. //echo $admin_output;
  159. /*
  160. -----------------------------------------------------------
  161. DISPLAY SECTION
  162. -----------------------------------------------------------
  163. */
  164. echo '<table cellpadding="0" cellspacing="0" class="lp_build">';
  165. echo '<tr>';
  166. echo '<td class="tree">';
  167. echo '<p style="border-bottom:1px solid #999999; margin:0; padding:2px;">'.get_lang("Build").'&nbsp;<a href="' .api_get_self(). '?cidReq=' . $_GET['cidReq'] . '&amp;action=admin_view&amp;lp_id=' . $_SESSION['oLP']->lp_id . '">'.get_lang("BasicOverview").'</a>&nbsp;<a href="lp_controller.php?cidReq='.$_GET['cidReq'].'&action=view&lp_id='.$_SESSION['oLP']->lp_id.'">'.get_lang("Display").'</a></p>';
  168. //links for adding a module, chapter or step
  169. echo '<div class="lp_actions">';
  170. echo '<p class="lp_action">';
  171. 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>';
  172. echo '</p>';
  173. echo '<p class="lp_action">';
  174. 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>';
  175. echo '</p>';
  176. echo '</div>';
  177. echo '<div class="lp_tree">';
  178. //build the tree with the menu items in it
  179. echo $_SESSION['oLP']->build_tree();
  180. echo '</div>';
  181. echo '</td>';
  182. echo '<td class="workspace">';
  183. if(isset($new_item_id) && is_numeric($new_item_id))
  184. {
  185. switch($_GET['type'])
  186. {
  187. case 'chapter':
  188. echo $_SESSION['oLP']->display_manipulate($new_item_id, $_GET['type']);
  189. echo '<div class="lp_message" style="margin:3px 10px;">';
  190. echo get_lang("NewChapterCreated");
  191. echo '</div>';
  192. break;
  193. case TOOL_LINK:
  194. echo $_SESSION['oLP']->display_manipulate($new_item_id, $_GET['type']);
  195. echo '<div class="lp_message" style="margin:3px 10px;">';
  196. echo get_lang("NewLinksCreated");
  197. echo '</div>';
  198. break;
  199. case TOOL_STUDENTPUBLICATION:
  200. echo $_SESSION['oLP']->display_manipulate($new_item_id, $_GET['type']);
  201. echo '<div class="lp_message" style="margin:3px 10px;">';
  202. echo get_lang("NewStudentPublicationCreated");
  203. echo '</div>';
  204. break;
  205. case 'module':
  206. echo $_SESSION['oLP']->display_manipulate($new_item_id, $_GET['type']);
  207. echo '<div class="lp_message" style="margin:3px 10px;">';
  208. echo get_lang("NewModuleCreated");
  209. echo '</div>';
  210. break;
  211. case TOOL_QUIZ:
  212. echo $_SESSION['oLP']->display_manipulate($new_item_id, $_GET['type']);
  213. echo '<div class="lp_message" style="margin:3px 10px;">';
  214. echo get_lang("NewExerciseCreated");
  215. echo '</div>';
  216. break;
  217. case TOOL_DOCUMENT:
  218. $msg = '<div class="lp_message" style="margin-bottom:10px;">';
  219. $msg .= get_lang("NewDocumentCreated");
  220. $msg .= '</div>';
  221. echo $_SESSION['oLP']->display_item($new_item_id, true, $msg);
  222. break;
  223. case TOOL_FORUM:
  224. echo $_SESSION['oLP']->display_manipulate($new_item_id, $_GET['type']);
  225. echo '<div class="lp_message" style="margin:3px 10px;">';
  226. echo get_lang("NewForumCreated");
  227. echo '</div>';
  228. break;
  229. case 'thread':
  230. echo $_SESSION['oLP']->display_manipulate($new_item_id, $_GET['type']);
  231. echo '<div class="lp_message" style="margin:3px 10px;">';
  232. echo get_lang("NewThreadCreated");
  233. echo '</div>';
  234. break;
  235. }
  236. }
  237. else
  238. {
  239. switch($_GET['type'])
  240. {
  241. case 'chapter':
  242. echo $_SESSION['oLP']->display_item_form($_GET['type'], get_lang("EnterDataNewChapter"));
  243. break;
  244. case 'module':
  245. echo $_SESSION['oLP']->display_item_form($_GET['type'], get_lang("EnterDataNewModule"));
  246. break;
  247. case 'document':
  248. if(isset($_GET['file']) && is_numeric($_GET['file']))
  249. {
  250. echo $_SESSION['oLP']->display_document_form('add', 0, $_GET['file']);
  251. }
  252. else
  253. {
  254. echo $_SESSION['oLP']->display_document_form('add', 0);
  255. }
  256. break;
  257. case 'hotpotatoes':
  258. echo $_SESSION['oLP']->display_hotpotatoes_form('add', 0, $_GET['file']);
  259. break;
  260. case 'quiz':
  261. echo $_SESSION['oLP']->display_quiz_form('add', 0, $_GET['file']);
  262. break;
  263. case 'forum':
  264. echo $_SESSION['oLP']->display_forum_form('add', 0, $_GET['forum_id']);
  265. break;
  266. case 'thread':
  267. echo $_SESSION['oLP']->display_thread_form('add', 0, $_GET['thread_id']);
  268. break;
  269. case 'link':
  270. echo $_SESSION['oLP']->display_link_form('add', 0, $_GET['file']);
  271. break;
  272. case 'student_publication':
  273. echo $_SESSION['oLP']->display_student_publication_form('add', 0, $_GET['file']);
  274. break;
  275. case 'step':
  276. echo $_SESSION['oLP']->display_resources();
  277. break;
  278. }
  279. }
  280. echo '</td>';
  281. echo '</tr>';
  282. echo '</table>';
  283. /*
  284. ==============================================================================
  285. FOOTER
  286. ==============================================================================
  287. */
  288. Display::display_footer();
  289. ?>