lp_add_item.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  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. $interbreadcrumb[]= array ("url"=>"lp_controller.php?action=list", "name"=> get_lang("_learning_path"));
  131. $interbreadcrumb[]= array ("url"=>api_get_self()."?action=build&lp_id=$learnpath_id", "name" => stripslashes("{$therow['name']}"));
  132. switch($_GET['type']){
  133. case 'chapter':
  134. $interbreadcrumb[]= array ("url"=>"#", "name" => get_lang("NewChapter"));
  135. break;
  136. default:
  137. $interbreadcrumb[]= array ("url"=>"#", "name" => get_lang("NewStep"));
  138. break;
  139. }
  140. //Theme calls
  141. $show_learn_path=true;
  142. $lp_theme_css=$_SESSION['oLP']->get_theme();
  143. Display::display_header(null,'Path');
  144. //api_display_tool_title($therow['name']);
  145. $suredel = trim(get_lang('AreYouSureToDelete'));
  146. //$suredelstep = trim(get_lang('AreYouSureToDeleteSteps'));
  147. ?>
  148. <script type='text/javascript'>
  149. /* <![CDATA[ */
  150. function stripslashes(str) {
  151. str=str.replace(/\\'/g,'\'');
  152. str=str.replace(/\\"/g,'"');
  153. str=str.replace(/\\\\/g,'\\');
  154. str=str.replace(/\\0/g,'\0');
  155. return str;
  156. }
  157. function confirmation(name)
  158. {
  159. name=stripslashes(name);
  160. if (confirm("<?php echo $suredel; ?> " + name + " ?"))
  161. {
  162. return true;
  163. }
  164. else
  165. {
  166. return false;
  167. }
  168. }
  169. </script>
  170. <?php
  171. //echo $admin_output;
  172. /*
  173. -----------------------------------------------------------
  174. DISPLAY SECTION
  175. -----------------------------------------------------------
  176. */
  177. echo $_SESSION['oLP']->build_action_menu();
  178. echo '<table cellpadding="0" cellspacing="0" class="lp_build">';
  179. echo '<tr>';
  180. echo '<td class="tree">';
  181. // show the template list
  182. if (isset($_GET['type']) && $_GET['type']=='document' && !isset($_GET['file']))
  183. {
  184. $count_items = count($_SESSION['oLP']->ordered_items);
  185. $style = ($count_items > 12)?' style="height:250px;width:230px;overflow-x : auto; overflow-y : scroll;" ':' class="lp_tree" ';
  186. echo '<div '.$style.'>';
  187. //build the tree with the menu items in it
  188. echo $_SESSION['oLP']->build_tree();
  189. echo '</div>';
  190. // show the template list
  191. echo '<p style="border-bottom:1px solid #999999; margin:0; padding:2px;"></p>'; //line
  192. echo '<br />';
  193. echo '<div id="frmModel" style="display:block; height:890px;width:100px; position:relative;"></div>';
  194. } else {
  195. echo '<div class="lp_tree">';
  196. //build the tree with the menu items in it
  197. echo $_SESSION['oLP']->build_tree();
  198. echo '</div>';
  199. }
  200. echo '</td>';
  201. echo '<td class="workspace">';
  202. if(isset($new_item_id) && is_numeric($new_item_id))
  203. {
  204. switch($_GET['type'])
  205. {
  206. case 'chapter':
  207. echo $_SESSION['oLP']->display_manipulate($new_item_id, $_GET['type']);
  208. echo '<div class="confirmation-message">';
  209. echo get_lang("NewChapterCreated");
  210. echo '</div>';
  211. break;
  212. case TOOL_LINK:
  213. echo $_SESSION['oLP']->display_manipulate($new_item_id, $_GET['type']);
  214. echo '<div class="confirmation-message">';
  215. echo get_lang("NewLinksCreated");
  216. echo '</div>';
  217. break;
  218. case TOOL_STUDENTPUBLICATION:
  219. echo $_SESSION['oLP']->display_manipulate($new_item_id, $_GET['type']);
  220. echo '<div class="confirmation-message">';
  221. echo get_lang("NewStudentPublicationCreated");
  222. echo '</div>';
  223. break;
  224. case 'module':
  225. echo $_SESSION['oLP']->display_manipulate($new_item_id, $_GET['type']);
  226. echo '<div class="confirmation-message">';
  227. echo get_lang("NewModuleCreated");
  228. echo '</div>';
  229. break;
  230. case TOOL_QUIZ:
  231. echo $_SESSION['oLP']->display_manipulate($new_item_id, $_GET['type']);
  232. echo '<div class="confirmation-message">';
  233. echo get_lang("NewExerciseCreated");
  234. echo '</div>';
  235. break;
  236. case TOOL_DOCUMENT:
  237. $msg = '<div class="confirmation-message">';
  238. $msg .= get_lang("NewDocumentCreated");
  239. $msg .= '</div>';
  240. echo $_SESSION['oLP']->display_item($new_item_id, true, $msg);
  241. break;
  242. case TOOL_FORUM:
  243. echo $_SESSION['oLP']->display_manipulate($new_item_id, $_GET['type']);
  244. echo '<div class="confirmation-message">';
  245. echo get_lang("NewForumCreated");
  246. echo '</div>';
  247. break;
  248. case 'thread':
  249. echo $_SESSION['oLP']->display_manipulate($new_item_id, $_GET['type']);
  250. echo '<div class="confirmation-message">';
  251. echo get_lang("NewThreadCreated");
  252. echo '</div>';
  253. break;
  254. }
  255. }
  256. else
  257. {
  258. switch($_GET['type'])
  259. {
  260. case 'chapter':
  261. echo $_SESSION['oLP']->display_item_form($_GET['type'], get_lang("EnterDataNewChapter"));
  262. break;
  263. case 'module':
  264. echo $_SESSION['oLP']->display_item_form($_GET['type'], get_lang("EnterDataNewModule"));
  265. break;
  266. case 'document':
  267. if(isset($_GET['file']) && is_numeric($_GET['file']))
  268. {
  269. echo $_SESSION['oLP']->display_document_form('add', 0, $_GET['file']);
  270. }
  271. else
  272. {
  273. echo $_SESSION['oLP']->display_document_form('add', 0);
  274. }
  275. break;
  276. case 'hotpotatoes':
  277. echo $_SESSION['oLP']->display_hotpotatoes_form('add', 0, $_GET['file']);
  278. break;
  279. case 'quiz':
  280. echo $_SESSION['oLP']->display_quiz_form('add', 0, $_GET['file']);
  281. break;
  282. case 'forum':
  283. echo $_SESSION['oLP']->display_forum_form('add', 0, $_GET['forum_id']);
  284. break;
  285. case 'thread':
  286. echo $_SESSION['oLP']->display_thread_form('add', 0, $_GET['thread_id']);
  287. break;
  288. case 'link':
  289. echo $_SESSION['oLP']->display_link_form('add', 0, $_GET['file']);
  290. break;
  291. case 'student_publication':
  292. echo $_SESSION['oLP']->display_student_publication_form('add', 0, $_GET['file']);
  293. break;
  294. case 'step':
  295. echo $_SESSION['oLP']->display_resources();
  296. break;
  297. }
  298. }
  299. echo '</td>';
  300. echo '</tr>';
  301. echo '</table>';
  302. /*
  303. ==============================================================================
  304. FOOTER
  305. ==============================================================================
  306. */
  307. Display::display_footer();
  308. ?>