lp_add_item.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  1. <?php
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2004-2008 Dokeos SPRL
  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 address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
  19. Mail: info@dokeos.com
  20. ==============================================================================
  21. */
  22. /**
  23. ==============================================================================
  24. * This is a learning path creation and player tool in Dokeos - previously
  25. * learnpath_handler.php
  26. *
  27. * @author Patrick Cool
  28. * @author Denes Nagy
  29. * @author Roan Embrechts, refactoring and code cleaning
  30. * @author Yannick Warnier <ywarnier@beeznest.org> - cleaning and update
  31. * @author Julio Montoya - Improving the list of templates
  32. * @package dokeos.learnpath
  33. ==============================================================================
  34. */
  35. /*
  36. ==============================================================================
  37. INIT SECTION
  38. ==============================================================================
  39. */
  40. $this_section=SECTION_COURSES;
  41. api_protect_course_script();
  42. /*
  43. -----------------------------------------------------------
  44. Libraries
  45. -----------------------------------------------------------
  46. */
  47. //the main_api.lib.php, database.lib.php and display.lib.php
  48. //libraries are included by default
  49. include('learnpath_functions.inc.php');
  50. //include('../resourcelinker/resourcelinker.inc.php');
  51. include('resourcelinker.inc.php');
  52. //rewrite the language file, sadly overwritten by resourcelinker.inc.php
  53. // name of the language file that needs to be included
  54. $language_file = "learnpath";
  55. /*
  56. -----------------------------------------------------------
  57. Header and action code
  58. -----------------------------------------------------------
  59. */
  60. $htmlHeadXtra[] = '
  61. <script type="text/javascript">
  62. function FCKeditor_OnComplete( editorInstance )
  63. {
  64. document.getElementById(\'frmModel\').innerHTML = "<iframe height=890px width=230px; frameborder=0 src=\''.api_get_path(WEB_LIBRARY_PATH).'fckeditor/editor/fckdialogframe.html \'>";
  65. }
  66. function InnerDialogLoaded()
  67. {
  68. if (document.all)
  69. {
  70. // if is iexplorer
  71. var B=new window.frames.content_lp___Frame.FCKToolbarButton(\'Templates\',window.content_lp___Frame.FCKLang.Templates);
  72. }
  73. else
  74. {
  75. var B=new window.frames[0].FCKToolbarButton(\'Templates\',window.frames[0].FCKLang.Templates);
  76. }
  77. return B.ClickFrame();
  78. };
  79. </script>';
  80. $htmlHeadXtra[] = $_SESSION['oLP']->create_js();
  81. /*
  82. -----------------------------------------------------------
  83. Constants and variables
  84. -----------------------------------------------------------
  85. */
  86. $is_allowed_to_edit = api_is_allowed_to_edit();
  87. $tbl_lp = Database::get_course_table('lp');
  88. $tbl_lp_item = Database::get_course_table('lp_item');
  89. $tbl_lp_view = Database::get_course_table('lp_view');
  90. $isStudentView = (int) $_REQUEST['isStudentView'];
  91. $learnpath_id = (int) $_REQUEST['lp_id'];
  92. $submit = $_POST['submit_button'];
  93. /*
  94. $chapter_id = $_GET['chapter_id'];
  95. $title = $_POST['title'];
  96. $description = $_POST['description'];
  97. $Submititem = $_POST['Submititem'];
  98. $action = $_REQUEST['action'];
  99. $id = (int) $_REQUEST['id'];
  100. $type = $_REQUEST['type'];
  101. $direction = $_REQUEST['direction'];
  102. $moduleid = $_REQUEST['moduleid'];
  103. $prereq = $_REQUEST['prereq'];
  104. $type = $_REQUEST['type'];
  105. */
  106. /*
  107. ==============================================================================
  108. MAIN CODE
  109. ==============================================================================
  110. */
  111. // using the resource linker as a tool for adding resources to the learning path
  112. if ($action=="add" and $type=="learnpathitem")
  113. {
  114. $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>";
  115. }
  116. if ( (! $is_allowed_to_edit) or ($isStudentView) )
  117. {
  118. error_log('New LP - User not authorized in lp_add_item.php');
  119. header('location:lp_controller.php?action=view&lp_id='.$learnpath_id);
  120. }
  121. //from here on, we are admin because of the previous condition, so don't check anymore
  122. $sql_query = "SELECT * FROM $tbl_lp WHERE id = $learnpath_id";
  123. $result=api_sql_query($sql_query);
  124. $therow=Database::fetch_array($result);
  125. //$admin_output = '';
  126. /*
  127. -----------------------------------------------------------
  128. Course admin section
  129. - all the functions not available for students - always available in this case (page only shown to admin)
  130. -----------------------------------------------------------
  131. */
  132. /*==================================================
  133. SHOWING THE ADMIN TOOLS
  134. ==================================================*/
  135. $interbreadcrumb[]= array ("url"=>"lp_controller.php?action=list", "name"=> get_lang("_learning_path"));
  136. $interbreadcrumb[]= array ("url"=>api_get_self()."?action=build&lp_id=$learnpath_id", "name" => stripslashes("{$therow['name']}"));
  137. switch($_GET['type']){
  138. case 'chapter':
  139. $interbreadcrumb[]= array ("url"=>"#", "name" => get_lang("NewChapter"));
  140. break;
  141. default:
  142. $interbreadcrumb[]= array ("url"=>"#", "name" => get_lang("NewStep"));
  143. break;
  144. }
  145. //Theme calls
  146. $show_learn_path=true;
  147. $lp_theme_css=$_SESSION['oLP']->get_theme();
  148. Display::display_header(null,'Path');
  149. //api_display_tool_title($therow['name']);
  150. $suredel = trim(get_lang('AreYouSureToDelete'));
  151. //$suredelstep = trim(get_lang('AreYouSureToDeleteSteps'));
  152. ?>
  153. <script type='text/javascript'>
  154. /* <![CDATA[ */
  155. function stripslashes(str) {
  156. str=str.replace(/\\'/g,'\'');
  157. str=str.replace(/\\"/g,'"');
  158. str=str.replace(/\\\\/g,'\\');
  159. str=str.replace(/\\0/g,'\0');
  160. return str;
  161. }
  162. function confirmation(name)
  163. {
  164. name=stripslashes(name);
  165. if (confirm("<?php echo $suredel; ?> " + name + " ?"))
  166. {
  167. return true;
  168. }
  169. else
  170. {
  171. return false;
  172. }
  173. }
  174. </script>
  175. <?php
  176. //echo $admin_output;
  177. /*
  178. -----------------------------------------------------------
  179. DISPLAY SECTION
  180. -----------------------------------------------------------
  181. */
  182. echo '<table cellpadding="0" cellspacing="0" class="lp_build">';
  183. echo '<tr>';
  184. echo '<td class="tree">';
  185. echo '<p style="border-bottom:1px solid #999999; margin:0; padding:2px;">'.get_lang("Build").'&nbsp;&#124;&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;&#124;&nbsp;<a href="lp_controller.php?cidReq='.$_GET['cidReq'].'&action=view&lp_id='.$_SESSION['oLP']->lp_id.'">'.get_lang("Display").'</a></p>';
  186. //links for adding a module, chapter or step
  187. echo '<div class="lp_actions">';
  188. echo '<p class="lp_action">';
  189. 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>';
  190. echo '</p>';
  191. echo '<p class="lp_action">';
  192. 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>';
  193. echo '</p>';
  194. echo '</div>';
  195. echo '<div class="lp_tree" style="height:250px">';
  196. //build the tree with the menu items in it
  197. echo $_SESSION['oLP']->build_tree();
  198. echo '</div>';
  199. // show the template list
  200. if ($_GET['type']=='document')
  201. {
  202. echo '<p style="border-bottom:1px solid #999999; margin:0; padding:2px;"></p>'; //line
  203. echo '<br>';
  204. echo '<div id="frmModel" style="display:block; height:890px;width:100px; position:relative;"></div>';
  205. }
  206. echo '</td>';
  207. echo '<td class="workspace">';
  208. if(isset($new_item_id) && is_numeric($new_item_id))
  209. {
  210. switch($_GET['type'])
  211. {
  212. case 'chapter':
  213. echo $_SESSION['oLP']->display_manipulate($new_item_id, $_GET['type']);
  214. echo '<div class="lp_message" style="margin:3px 10px;">';
  215. echo get_lang("NewChapterCreated");
  216. echo '</div>';
  217. break;
  218. case TOOL_LINK:
  219. echo $_SESSION['oLP']->display_manipulate($new_item_id, $_GET['type']);
  220. echo '<div class="lp_message" style="margin:3px 10px;">';
  221. echo get_lang("NewLinksCreated");
  222. echo '</div>';
  223. break;
  224. case TOOL_STUDENTPUBLICATION:
  225. echo $_SESSION['oLP']->display_manipulate($new_item_id, $_GET['type']);
  226. echo '<div class="lp_message" style="margin:3px 10px;">';
  227. echo get_lang("NewStudentPublicationCreated");
  228. echo '</div>';
  229. break;
  230. case 'module':
  231. echo $_SESSION['oLP']->display_manipulate($new_item_id, $_GET['type']);
  232. echo '<div class="lp_message" style="margin:3px 10px;">';
  233. echo get_lang("NewModuleCreated");
  234. echo '</div>';
  235. break;
  236. case TOOL_QUIZ:
  237. echo $_SESSION['oLP']->display_manipulate($new_item_id, $_GET['type']);
  238. echo '<div class="lp_message" style="margin:3px 10px;">';
  239. echo get_lang("NewExerciseCreated");
  240. echo '</div>';
  241. break;
  242. case TOOL_DOCUMENT:
  243. $msg = '<div class="lp_message" style="margin-bottom:10px;">';
  244. $msg .= get_lang("NewDocumentCreated");
  245. $msg .= '</div>';
  246. echo $_SESSION['oLP']->display_item($new_item_id, true, $msg);
  247. break;
  248. case TOOL_FORUM:
  249. echo $_SESSION['oLP']->display_manipulate($new_item_id, $_GET['type']);
  250. echo '<div class="lp_message" style="margin:3px 10px;">';
  251. echo get_lang("NewForumCreated");
  252. echo '</div>';
  253. break;
  254. case 'thread':
  255. echo $_SESSION['oLP']->display_manipulate($new_item_id, $_GET['type']);
  256. echo '<div class="lp_message" style="margin:3px 10px;">';
  257. echo get_lang("NewThreadCreated");
  258. echo '</div>';
  259. break;
  260. }
  261. }
  262. else
  263. {
  264. switch($_GET['type'])
  265. {
  266. case 'chapter':
  267. echo $_SESSION['oLP']->display_item_form($_GET['type'], get_lang("EnterDataNewChapter"));
  268. break;
  269. case 'module':
  270. echo $_SESSION['oLP']->display_item_form($_GET['type'], get_lang("EnterDataNewModule"));
  271. break;
  272. case 'document':
  273. if(isset($_GET['file']) && is_numeric($_GET['file']))
  274. {
  275. echo $_SESSION['oLP']->display_document_form('add', 0, $_GET['file']);
  276. }
  277. else
  278. {
  279. echo $_SESSION['oLP']->display_document_form('add', 0);
  280. }
  281. break;
  282. case 'hotpotatoes':
  283. echo $_SESSION['oLP']->display_hotpotatoes_form('add', 0, $_GET['file']);
  284. break;
  285. case 'quiz':
  286. echo $_SESSION['oLP']->display_quiz_form('add', 0, $_GET['file']);
  287. break;
  288. case 'forum':
  289. echo $_SESSION['oLP']->display_forum_form('add', 0, $_GET['forum_id']);
  290. break;
  291. case 'thread':
  292. echo $_SESSION['oLP']->display_thread_form('add', 0, $_GET['thread_id']);
  293. break;
  294. case 'link':
  295. echo $_SESSION['oLP']->display_link_form('add', 0, $_GET['file']);
  296. break;
  297. case 'student_publication':
  298. echo $_SESSION['oLP']->display_student_publication_form('add', 0, $_GET['file']);
  299. break;
  300. case 'step':
  301. echo $_SESSION['oLP']->display_resources();
  302. break;
  303. }
  304. }
  305. echo '</td>';
  306. echo '</tr>';
  307. echo '</table>';
  308. /*
  309. ==============================================================================
  310. FOOTER
  311. ==============================================================================
  312. */
  313. Display::display_footer();
  314. ?>