lp_add_item.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  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. $this_section=SECTION_COURSES;
  38. api_protect_course_script();
  39. /*
  40. -----------------------------------------------------------
  41. Libraries
  42. -----------------------------------------------------------
  43. */
  44. //the main_api.lib.php, database.lib.php and display.lib.php
  45. //libraries are included by default
  46. include('learnpath_functions.inc.php');
  47. //include('../resourcelinker/resourcelinker.inc.php');
  48. include('resourcelinker.inc.php');
  49. //rewrite the language file, sadly overwritten by resourcelinker.inc.php
  50. // name of the language file that needs to be included
  51. $language_file = "learnpath";
  52. /*
  53. -----------------------------------------------------------
  54. Header and action code
  55. -----------------------------------------------------------
  56. */
  57. $currentstyle = api_get_setting('stylesheets');
  58. $htmlHeadXtra[] = '<link rel="stylesheet" type="text/css" href="'.api_get_path(WEB_CODE_PATH).'css/'.$currentstyle.'/learnpath.css"/>';
  59. $htmlHeadXtra[] = "<link rel='stylesheet' type='text/css' href='learnpath.css' />"; //will be a merged with original learnpath.css
  60. $htmlHeadXtra[] = "<link rel='stylesheet' type='text/css' href='dtree.css' />"; //will be moved
  61. $htmlHeadXtra[] = "<script src='dtree.js' type='text/javascript'></script>"; //will be moved
  62. $htmlHeadXtra[] = $_SESSION['oLP']->create_js();
  63. /*
  64. -----------------------------------------------------------
  65. Constants and variables
  66. -----------------------------------------------------------
  67. */
  68. $is_allowed_to_edit = api_is_allowed_to_edit();
  69. $tbl_lp = Database::get_course_table('lp');
  70. $tbl_lp_item = Database::get_course_table('lp_item');
  71. $tbl_lp_view = Database::get_course_table('lp_view');
  72. $isStudentView = (int) $_REQUEST['isStudentView'];
  73. $learnpath_id = (int) $_REQUEST['lp_id'];
  74. $submit = $_POST['submit_button'];
  75. /*
  76. $chapter_id = $_GET['chapter_id'];
  77. $title = $_POST['title'];
  78. $description = $_POST['description'];
  79. $Submititem = $_POST['Submititem'];
  80. $action = $_REQUEST['action'];
  81. $id = (int) $_REQUEST['id'];
  82. $type = $_REQUEST['type'];
  83. $direction = $_REQUEST['direction'];
  84. $moduleid = $_REQUEST['moduleid'];
  85. $prereq = $_REQUEST['prereq'];
  86. $type = $_REQUEST['type'];
  87. */
  88. /*
  89. ==============================================================================
  90. MAIN CODE
  91. ==============================================================================
  92. */
  93. // using the resource linker as a tool for adding resources to the learning path
  94. if ($action=="add" and $type=="learnpathitem")
  95. {
  96. $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>";
  97. }
  98. if ( (! $is_allowed_to_edit) or ($isStudentView) )
  99. {
  100. error_log('New LP - User not authorized in lp_add_item.php');
  101. header('location:lp_controller.php?action=view&lp_id='.$learnpath_id);
  102. }
  103. //from here on, we are admin because of the previous condition, so don't check anymore
  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"=>$_SERVER['PHP_SELF']."?action=build&lp_id=$learnpath_id", "name" => stripslashes("{$therow['name']}"));
  122. switch($_GET['type']){
  123. case 'chapter':
  124. $interbreadcrumb[]= array ("url"=>"#", "name" => get_lang("NewChapter"));
  125. break;
  126. default:
  127. $interbreadcrumb[]= array ("url"=>"#", "name" => get_lang("NewStep"));
  128. break;
  129. }
  130. Display::display_header(null,'Path');
  131. //api_display_tool_title($therow['name']);
  132. $suredel = get_lang('AreYouSureToDelete');
  133. $suredelstep = get_lang('AreYouSureToDeleteSteps');
  134. ?>
  135. <script type='text/javascript'>
  136. /* <![CDATA[ */
  137. function confirmation (name)
  138. {
  139. 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')
  140. {
  141. if (confirm("<?php echo $suredel; ?> "+ name + " <?php echo $suredelstep;?>?"))
  142. {return true;}
  143. else
  144. {return false;}
  145. }
  146. else
  147. {
  148. if (confirm("<?php echo $suredel; ?> "+ name + "?"))
  149. {return true;}
  150. else
  151. {return false;}
  152. }
  153. }
  154. </script>
  155. <?php
  156. //echo $admin_output;
  157. /*
  158. -----------------------------------------------------------
  159. DISPLAY SECTION
  160. -----------------------------------------------------------
  161. */
  162. echo '<table cellpadding="0" cellspacing="0" class="lp_build">';
  163. echo '<tr>';
  164. echo '<td class="tree">';
  165. echo '<p style="border-bottom:1px solid #999999; margin:0; padding:2px;">'.get_lang("Build").'&nbsp;<a href="' . $_SERVER['PHP_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>';
  166. //links for adding a module, chapter or step
  167. echo '<div class="lp_actions">';
  168. echo '<p class="lp_action">';
  169. echo '<a href="' . $_SERVER['PHP_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>';
  170. echo '</p>';
  171. echo '<p class="lp_action">';
  172. echo '<a href="' . $_SERVER['PHP_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>';
  173. echo '</p>';
  174. echo '</div>';
  175. echo '<div class="lp_tree">';
  176. //build the tree with the menu items in it
  177. echo $_SESSION['oLP']->build_tree();
  178. echo '</div>';
  179. echo '</td>';
  180. echo '<td class="workspace">';
  181. if(isset($new_item_id) && is_numeric($new_item_id))
  182. {
  183. switch($_GET['type'])
  184. {
  185. case 'chapter':
  186. echo $_SESSION['oLP']->display_manipulate($new_item_id, $_GET['type']);
  187. echo '<div class="lp_message" style="margin:3px 10px;">';
  188. echo get_lang("NewChapterCreated");
  189. echo '</div>';
  190. break;
  191. case TOOL_LINK:
  192. echo $_SESSION['oLP']->display_manipulate($new_item_id, $_GET['type']);
  193. echo '<div class="lp_message" style="margin:3px 10px;">';
  194. echo get_lang("NewLinksCreated");
  195. echo '</div>';
  196. break;
  197. case TOOL_STUDENTPUBLICATION:
  198. echo $_SESSION['oLP']->display_manipulate($new_item_id, $_GET['type']);
  199. echo '<div class="lp_message" style="margin:3px 10px;">';
  200. echo get_lang("NewStudentPublicationCreated");
  201. echo '</div>';
  202. break;
  203. case 'module':
  204. echo $_SESSION['oLP']->display_manipulate($new_item_id, $_GET['type']);
  205. echo '<div class="lp_message" style="margin:3px 10px;">';
  206. echo get_lang("NewModuleCreated");
  207. echo '</div>';
  208. break;
  209. case TOOL_QUIZ:
  210. echo $_SESSION['oLP']->display_manipulate($new_item_id, $_GET['type']);
  211. echo '<div class="lp_message" style="margin:3px 10px;">';
  212. echo get_lang("NewExerciseCreated");
  213. echo '</div>';
  214. break;
  215. case TOOL_DOCUMENT:
  216. $msg = '<div class="lp_message" style="margin-bottom:10px;">';
  217. $msg .= get_lang("NewDocumentCreated");
  218. $msg .= '</div>';
  219. echo $_SESSION['oLP']->display_item($new_item_id, true, $msg);
  220. break;
  221. case TOOL_FORUM:
  222. echo $_SESSION['oLP']->display_manipulate($new_item_id, $_GET['type']);
  223. echo '<div class="lp_message" style="margin:3px 10px;">';
  224. echo get_lang("NewForumCreated");
  225. echo '</div>';
  226. break;
  227. case 'thread':
  228. echo $_SESSION['oLP']->display_manipulate($new_item_id, $_GET['type']);
  229. echo '<div class="lp_message" style="margin:3px 10px;">';
  230. echo get_lang("NewThreadCreated");
  231. echo '</div>';
  232. break;
  233. }
  234. }
  235. else
  236. {
  237. switch($_GET['type'])
  238. {
  239. case 'chapter':
  240. echo $_SESSION['oLP']->display_item_form($_GET['type'], get_lang("EnterDataNewChapter"));
  241. break;
  242. case 'module':
  243. echo $_SESSION['oLP']->display_item_form($_GET['type'], get_lang("EnterDataNewModule"));
  244. break;
  245. case 'document':
  246. if(isset($_GET['file']) && is_numeric($_GET['file']))
  247. {
  248. echo $_SESSION['oLP']->display_document_form('add', 0, $_GET['file']);
  249. }
  250. else
  251. {
  252. echo $_SESSION['oLP']->display_document_form('add', 0);
  253. }
  254. break;
  255. case 'quiz':
  256. echo $_SESSION['oLP']->display_quiz_form('add', 0, $_GET['file']);
  257. break;
  258. case 'forum':
  259. echo $_SESSION['oLP']->display_forum_form('add', 0, $_GET['forum_id']);
  260. break;
  261. case 'thread':
  262. echo $_SESSION['oLP']->display_thread_form('add', 0, $_GET['thread_id']);
  263. break;
  264. case 'link':
  265. echo $_SESSION['oLP']->display_link_form('add', 0, $_GET['file']);
  266. break;
  267. case 'student_publication':
  268. echo $_SESSION['oLP']->display_student_publication_form('add', 0, $_GET['file']);
  269. break;
  270. case 'step':
  271. echo $_SESSION['oLP']->display_resources();
  272. break;
  273. }
  274. }
  275. echo '</td>';
  276. echo '</tr>';
  277. echo '</table>';
  278. /*
  279. ==============================================================================
  280. FOOTER
  281. ==============================================================================
  282. */
  283. Display::display_footer();
  284. ?>