lp_edit_item_prereq.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * This is a learning path creation and player tool in Dokeos - previously learnpath_handler.php
  5. *
  6. * @author Patrick Cool
  7. * @author Denes Nagy
  8. * @author Roan Embrechts, refactoring and code cleaning
  9. * @author Yannick Warnier <ywarnier@beeznest.org> - cleaning and update for new SCORM tool
  10. * @package chamilo.learnpath
  11. */
  12. /*
  13. * INIT SECTION
  14. */
  15. $this_section=SECTION_COURSES;
  16. api_protect_course_script();
  17. /*
  18. -----------------------------------------------------------
  19. Libraries
  20. -----------------------------------------------------------
  21. */
  22. //the main_api.lib.php, database.lib.php and display.lib.php
  23. //libraries are included by default
  24. include 'learnpath_functions.inc.php';
  25. //include '../resourcelinker/resourcelinker.inc.php';
  26. include 'resourcelinker.inc.php';
  27. //rewrite the language file, sadly overwritten by resourcelinker.inc.php
  28. // name of the language file that needs to be included
  29. $language_file = "learnpath";
  30. /*
  31. -----------------------------------------------------------
  32. Constants and variables
  33. -----------------------------------------------------------
  34. */
  35. $is_allowed_to_edit = api_is_allowed_to_edit(null,true);
  36. $tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
  37. $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
  38. $tbl_lp_view = Database::get_course_table(TABLE_LP_VIEW);
  39. $isStudentView = (int) $_REQUEST['isStudentView'];
  40. $learnpath_id = (int) $_REQUEST['lp_id'];
  41. $submit = $_POST['submit_button'];
  42. /*
  43. $chapter_id = $_GET['chapter_id'];
  44. $title = $_POST['title'];
  45. $description = $_POST['description'];
  46. $Submititem = $_POST['Submititem'];
  47. $action = $_REQUEST['action'];
  48. $id = (int) $_REQUEST['id'];
  49. $type = $_REQUEST['type'];
  50. $direction = $_REQUEST['direction'];
  51. $moduleid = $_REQUEST['moduleid'];
  52. $prereq = $_REQUEST['prereq'];
  53. $type = $_REQUEST['type'];
  54. */
  55. /*
  56. ==============================================================================
  57. MAIN CODE
  58. ==============================================================================
  59. */
  60. // using the resource linker as a tool for adding resources to the learning path
  61. if ($action=="add" and $type=="learnpathitem")
  62. {
  63. $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>";
  64. }
  65. if ( (! $is_allowed_to_edit) or ($isStudentView) )
  66. {
  67. error_log('New LP - User not authorized in lp_edit_item_prereq.php');
  68. header('location:lp_controller.php?action=view&lp_id='.$learnpath_id);
  69. }
  70. //from here on, we are admin because of the previous condition, so don't check anymore
  71. $sql_query = "SELECT * FROM $tbl_lp WHERE id = $learnpath_id";
  72. $result=Database::query($sql_query);
  73. $therow=Database::fetch_array($result);
  74. //$admin_output = '';
  75. /*
  76. -----------------------------------------------------------
  77. Course admin section
  78. - all the functions not available for students - always available in this case (page only shown to admin)
  79. -----------------------------------------------------------
  80. */
  81. /*==================================================
  82. SHOWING THE ADMIN TOOLS
  83. ==================================================*/
  84. /*==================================================
  85. prerequisites setting end
  86. ==================================================*/
  87. if (isset($_SESSION['gradebook'])){
  88. $gradebook= $_SESSION['gradebook'];
  89. }
  90. if (!empty($gradebook) && $gradebook=='view') {
  91. $interbreadcrumb[]= array (
  92. 'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
  93. 'name' => get_lang('ToolGradebook')
  94. );
  95. }
  96. $interbreadcrumb[]= array ("url"=>"lp_controller.php?action=list", "name"=> get_lang("_learning_path"));
  97. $interbreadcrumb[]= array ("url"=>api_get_self()."?action=build&lp_id=$learnpath_id", "name" => stripslashes("{$therow['name']}"));
  98. //Theme calls
  99. $show_learn_path=true;
  100. $lp_theme_css=$_SESSION['oLP']->get_theme();
  101. Display::display_header(null,'Path');
  102. //api_display_tool_title($therow['name']);
  103. $suredel = trim(get_lang('AreYouSureToDelete'));
  104. //$suredelstep = trim(get_lang('AreYouSureToDeleteSteps'));
  105. ?>
  106. <script type='text/javascript'>
  107. /* <![CDATA[ */
  108. function stripslashes(str) {
  109. str=str.replace(/\\'/g,'\'');
  110. str=str.replace(/\\"/g,'"');
  111. str=str.replace(/\\\\/g,'\\');
  112. str=str.replace(/\\0/g,'\0');
  113. return str;
  114. }
  115. function confirmation(name)
  116. {
  117. name=stripslashes(name);
  118. if (confirm("<?php echo $suredel; ?> " + name + " ?"))
  119. {
  120. return true;
  121. }
  122. else
  123. {
  124. return false;
  125. }
  126. }
  127. </script>
  128. <?php
  129. //echo $admin_output;
  130. /*
  131. -----------------------------------------------------------
  132. DISPLAY SECTION
  133. -----------------------------------------------------------
  134. */
  135. echo $_SESSION['oLP']->build_action_menu();
  136. echo '<table cellpadding="0" cellspacing="0" class="lp_build">';
  137. echo '<tr>';
  138. echo '<td class="tree">';
  139. echo '<div class="lp_tree">';
  140. //build the tree with the menu items in it
  141. echo $_SESSION['oLP']->build_tree();
  142. echo '</div>';
  143. echo '</td>';
  144. echo '<td class="workspace">';
  145. if(isset($is_success) && $is_success === true) {
  146. echo '<div class="lp_message" style="margin:3px 10px;">';
  147. echo get_lang("PrerequisitesAdded");
  148. echo '</div>';
  149. } else {
  150. echo $_SESSION['oLP']->display_item_prerequisites_form($_GET['id']);
  151. }
  152. echo '</td>';
  153. echo '</tr>';
  154. echo '</table>';
  155. /*
  156. ==============================================================================
  157. FOOTER
  158. ==============================================================================
  159. */
  160. Display::display_footer();
  161. ?>