lp_add_item.php 12 KB

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