lp_add.php 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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 learnpath_handler.php
  20. *
  21. * @author Patrick Cool
  22. * @author Denes Nagy
  23. * @author Roan Embrechts, refactoring and code cleaning
  24. * @author Yannick Warnier <ywarnier@beeznest.org> - cleaning and update for new SCORM tool
  25. * @package dokeos.learnpath
  26. ==============================================================================
  27. */
  28. /*
  29. ==============================================================================
  30. INIT SECTION
  31. ==============================================================================
  32. */
  33. $this_section=SECTION_COURSES;
  34. api_protect_course_script();
  35. /*
  36. -----------------------------------------------------------
  37. Libraries
  38. -----------------------------------------------------------
  39. */
  40. //the main_api.lib.php, database.lib.php and display.lib.php
  41. //libraries are included by default
  42. include('learnpath_functions.inc.php');
  43. //include('../resourcelinker/resourcelinker.inc.php');
  44. include('resourcelinker.inc.php');
  45. //rewrite the language file, sadly overwritten by resourcelinker.inc.php
  46. // name of the language file that needs to be included
  47. $language_file = 'learnpath';
  48. /*
  49. -----------------------------------------------------------
  50. Header and action code
  51. -----------------------------------------------------------
  52. */
  53. $currentstyle = api_get_setting('stylesheets');
  54. //$htmlHeadXtra[] = '<link rel="stylesheet" type="text/css" href="'.api_get_path(WEB_CODE_PATH).'css/'.$currentstyle.'/learnpath.css"/>';
  55. //$htmlHeadXtra[] = '<link rel="stylesheet" type="text/css" href="learnpath.css" />'; //will be a merged with original learnpath.css
  56. $htmlHeadXtra[] = '<link rel="stylesheet" type="text/css" href="dtree.css" />'; //will be moved
  57. /*
  58. -----------------------------------------------------------
  59. Constants and variables
  60. -----------------------------------------------------------
  61. */
  62. $is_allowed_to_edit = api_is_allowed_to_edit(null,true);
  63. $tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
  64. $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
  65. $tbl_lp_view = Database::get_course_table(TABLE_LP_VIEW);
  66. $isStudentView = (int) $_REQUEST['isStudentView'];
  67. $learnpath_id = (int) $_REQUEST['lp_id'];
  68. $submit = $_POST['submit_button'];
  69. /*
  70. ==============================================================================
  71. MAIN CODE
  72. ==============================================================================
  73. */
  74. // using the resource linker as a tool for adding resources to the learning path
  75. if ($action=="add" and $type=="learnpathitem")
  76. {
  77. $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>";
  78. }
  79. if ( (! $is_allowed_to_edit) or ($isStudentView) )
  80. {
  81. error_log('New LP - User not authorized in lp_add.php');
  82. header('location:lp_controller.php?action=view&lp_id='.$learnpath_id);
  83. }
  84. //from here on, we are admin because of the previous condition, so don't check anymore
  85. $sql_query = "SELECT * FROM $tbl_lp WHERE id = $learnpath_id";
  86. $result=Database::query($sql_query);
  87. $therow=Database::fetch_array($result);
  88. /*
  89. -----------------------------------------------------------
  90. Course admin section
  91. - all the functions not available for students - always available in this case (page only shown to admin)
  92. -----------------------------------------------------------
  93. */
  94. if (isset($_SESSION['gradebook'])){
  95. $gradebook= $_SESSION['gradebook'];
  96. }
  97. if (!empty($gradebook) && $gradebook=='view') {
  98. $interbreadcrumb[]= array (
  99. 'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
  100. 'name' => get_lang('Gradebook')
  101. );
  102. }
  103. $interbreadcrumb[]= array ("url"=>"lp_controller.php?action=list", "name"=> get_lang("_learning_path"));
  104. $interbreadcrumb[]= array ("url"=>"#", "name"=> get_lang("_add_learnpath"));
  105. Display::display_header(null,'Path');
  106. echo '<div class="actions">';
  107. echo '<a href="lp_controller.php?cidReq='.$_course['sysCode'].'">'.Display::return_icon('scorm.gif',get_lang('ReturnToLearningPaths')).' '.get_lang('ReturnToLearningPaths').'</a>';
  108. echo '</div>';
  109. Display::display_normal_message(get_lang('AddLpIntro'),false);
  110. if ($_POST AND empty($_REQUEST['learnpath_name']))
  111. {
  112. Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'), false);
  113. }
  114. echo '<form method="post">';
  115. // form title
  116. echo '<div class="row"><div class="form_header">'.get_lang('AddLpToStart').'</div></div>';
  117. // title field
  118. echo '<div class="row">';
  119. echo '<div class="label">';
  120. echo '<label for="idTitle"><span class="form_required">*</span> '.get_lang('LPName').'</label>';
  121. echo '</div>';
  122. echo '<div class="formw">';
  123. echo '<input id="idTitle" name="learnpath_name" type="text" size="50" />';
  124. echo '</div>';
  125. echo '</div>';
  126. // submit button
  127. echo '<div class="row">';
  128. echo '<div class="label">';
  129. echo '</div>';
  130. echo '<div class="formw">';
  131. echo '<button class="save" style="width:150px;" type="submit"/>'.get_lang('CreateLearningPath').'</button>';
  132. echo '</div>';
  133. echo '</div>';
  134. echo '<input name="post_time" type="hidden" value="' . time() . '" />';
  135. echo '</form>';
  136. echo '<div class="row">';
  137. echo '<div class="label"></div>';
  138. echo '<div class="formw"><span class="form_required">*</span> <small>'.get_lang('ThisFieldIsRequired').'</small></div>';
  139. echo '</div>';
  140. // footer
  141. Display::display_footer();
  142. ?>