dokeos-learnpath
[ class tree: dokeos-learnpath ] [ index: dokeos-learnpath ] [ all elements ]

Source for file lp_build.php

Documentation is available at lp_build.php

  1. <?php
  2. /*
  3. ============================================================================== 
  4.     Dokeos - elearning and course management software
  5.     
  6.     Copyright (c) 2004 Dokeos S.A.
  7.     Copyright (c) 2003 Ghent University (UGent)
  8.     Copyright (c) 2001 Universite catholique de Louvain (UCL)
  9.     Copyright (c) Patrick Cool
  10.     Copyright (c) Denes Nagy
  11.     Copyright (c) Yannick Warnier
  12.     
  13.     For a full list of contributors, see "credits.txt".
  14.     The full license can be read in "license.txt".
  15.     
  16.     This program is free software; you can redistribute it and/or
  17.     modify it under the terms of the GNU General Public License
  18.     as published by the Free Software Foundation; either version 2
  19.     of the License, or (at your option) any later version.
  20.     
  21.     See the GNU General Public License for more details.
  22.     
  23.     Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
  24. ============================================================================== 
  25. */
  26. /**
  27. ============================================================================== 
  28. * This is a learning path creation and player tool in Dokeos - previously learnpath_handler.php
  29. *
  30. @author Patrick Cool
  31. @author Denes Nagy
  32. @author Roan Embrechts, refactoring and code cleaning
  33. @author Yannick Warnier <ywarnier@beeznest.org> - cleaning and update for new SCORM tool
  34. @package dokeos.learnpath
  35. ============================================================================== 
  36. */
  37.  
  38. /*
  39. ==============================================================================
  40.         INIT SECTION
  41. ==============================================================================
  42. */ 
  43. $_SESSION['whereami''lp/build';
  44. $this_section=SECTION_COURSES;
  45.  
  46.  
  47.  
  48. /*
  49. -----------------------------------------------------------
  50.     Libraries
  51. -----------------------------------------------------------
  52. */ 
  53. //the main_api.lib.php, database.lib.php and display.lib.php
  54. //libraries are included by default
  55.  
  56. include('learnpath_functions.inc.php');
  57. //include('../resourcelinker/resourcelinker.inc.php');
  58. include('resourcelinker.inc.php');
  59. //rewrite the language file, sadly overwritten by resourcelinker.inc.php
  60. // name of the language file that needs to be included 
  61. $language_file "learnpath";
  62.  
  63. /*
  64. -----------------------------------------------------------
  65.     Constants and variables
  66. -----------------------------------------------------------
  67. */ 
  68. $is_allowed_to_edit api_is_allowed_to_edit();
  69.  
  70. $tbl_lp Database::get_course_table('lp');
  71. $tbl_lp_item Database::get_course_table('lp_item');
  72. $tbl_lp_view Database::get_course_table('lp_view');
  73.  
  74. $isStudentView  = (int) $_REQUEST['isStudentView'];
  75. $learnpath_id   = (int) $_REQUEST['lp_id'];
  76. $submit            $_POST['submit_button'];
  77. /*
  78. $chapter_id     = $_GET['chapter_id'];
  79. $title          = $_POST['title'];
  80. $description   = $_POST['description'];
  81. $Submititem     = $_POST['Submititem'];
  82. $action         = $_REQUEST['action'];
  83. $id             = (int) $_REQUEST['id'];
  84. $type           = $_REQUEST['type'];
  85. $direction      = $_REQUEST['direction'];
  86. $moduleid       = $_REQUEST['moduleid'];
  87. $prereq         = $_REQUEST['prereq'];
  88. $type           = $_REQUEST['type'];
  89. */
  90. /*
  91. ==============================================================================
  92.         MAIN CODE
  93. ==============================================================================
  94. */
  95. // using the resource linker as a tool for adding resources to the learning path
  96. if ($action=="add" and $type=="learnpathitem")
  97. {
  98.      $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>";
  99. }
  100. if ( ($is_allowed_to_editor ($isStudentView) )
  101. {
  102.     error_log('New LP - User not authorized in lp_build.php');
  103.     header('location:lp_controller.php?action=view&lp_id='.$learnpath_id);
  104. }
  105. //from here on, we are admin because of the previous condition, so don't check anymore
  106.  
  107. /* learnpath is just created, go get the last id */
  108. $is_new false;
  109.  
  110. if($learnpath_id == 0)
  111. {
  112.     $is_new true;
  113.     
  114.     $sql "
  115.         SELECT id
  116.         FROM " $tbl_lp "
  117.         ORDER BY id DESC
  118.         LIMIT 0, 1";
  119.     $result api_sql_query($sql);
  120.     $row Database::fetch_array($result);
  121.     
  122.     $learnpath_id $row['id'];
  123. }
  124.  
  125. $sql_query "SELECT * FROM $tbl_lp WHERE id = $learnpath_id";
  126.  
  127.  
  128. $result=api_sql_query($sql_query);
  129. $therow=Database::fetch_array($result)
  130.  
  131. //$admin_output = '';
  132. /*
  133. -----------------------------------------------------------
  134.     Course admin section
  135.     - all the functions not available for students - always available in this case (page only shown to admin)
  136. -----------------------------------------------------------
  137. */ 
  138. /*==================================================
  139.             SHOWING THE ADMIN TOOLS
  140.  ==================================================*/
  141.  
  142.  
  143.  
  144. /*==================================================
  145.     prerequisites setting end
  146.  ==================================================*/          
  147.  
  148. $interbreadcrumb[]array ("url"=>"lp_controller.php?action=list""name"=> get_lang("_learning_path"));
  149.  
  150. $interbreadcrumb[]array ("url"=>api_get_self()."?action=build&lp_id=$learnpath_id""name" => stripslashes("{$therow['name']}"));
  151.  
  152. //Theme calls
  153. $lp_theme_css=$_SESSION['oLP']->get_theme();
  154. $show_learn_path=true;
  155. Display::display_header(null,'Path');
  156.  
  157.  
  158. //api_display_tool_title($therow['name']);
  159.  
  160. $suredel trim(get_lang('AreYouSureToDelete'));
  161. //$suredelstep = trim(get_lang('AreYouSureToDeleteSteps'));
  162. ?>
  163. <script type='text/javascript'>
  164. /* <![CDATA[ */
  165. function stripslashes(str) {
  166.     str=str.replace(/\\'/g,'\'');
  167.     str=str.replace(/\\"/g,'"');
  168.     str=str.replace(/\\\\/g,'\\');
  169.     str=str.replace(/\\0/g,'\0');
  170.     return str;
  171. }
  172. function confirmation(name)
  173. {
  174.     name=stripslashes(name);    
  175.     if (confirm("<?php echo $suredel?> " + name + " ?"))
  176.     {
  177.         return true;
  178.     }
  179.     else
  180.     {
  181.         return false;
  182.     }    
  183. }
  184. </script>
  185. <?php
  186.  
  187. //echo $admin_output;
  188. /*
  189. -----------------------------------------------------------
  190.     DISPLAY SECTION
  191. -----------------------------------------------------------
  192. */
  193. echo '<table cellpadding="0" cellspacing="0" class="lp_build">';
  194.  
  195.     echo '<tr>';
  196.             
  197.         echo '<td class="tree">';
  198.         
  199.             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>';
  200.             
  201.             //links for adding a module, chapter or step
  202.             echo '<div class="lp_actions">';
  203.                 
  204.                 echo '<p class="lp_action">';
  205.                 
  206.                     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>';
  207.                         
  208.                 echo '</p>';
  209.                 echo '<p class="lp_action">';
  210.                 
  211.                     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>';
  212.                 
  213.                 echo '</p>';
  214.                 
  215.             echo '</div>';
  216.             
  217.             echo '<div class="lp_tree">';
  218.                     
  219.                 //build the tree with the menu items in it
  220.                 echo $_SESSION['oLP']->build_tree();
  221.             
  222.             echo '</div>';
  223.                     
  224.         echo '</td>';
  225.         echo '<td class="workspace">';
  226.         
  227.             if(isset($is_success&& $is_success === true)
  228.             {
  229.                 echo '<div class="lp_message" style="margin:3px 10px;">';
  230.             
  231.                     echo get_lang("ItemRemoved");
  232.             
  233.                 echo '</div>';
  234.             }
  235.             else
  236.             {
  237.                 if($is_new)
  238.                 {
  239.                     echo '<div class="lp_message" style="margin:3px 10px;">';
  240.                 
  241.                         echo get_lang("LearnPathAdded");
  242.                 
  243.                     echo '</div>';
  244.                 }
  245.                 
  246.                 if($is_new){
  247.                     echo '<p style="font-weight:bold; text-align:center;">'.get_lang("LPCreatedToContinue").'</p>';
  248.                 }
  249.                 else{
  250.                     echo '<p style="font-weight:bold; text-align:center;">'.get_lang("LPCreatedAddChapterStep").'</p>';
  251.                 }
  252.                                 
  253.             }
  254.         
  255.         echo '</td>';
  256.             
  257.     echo '</tr>';
  258.         
  259. echo '</table>';
  260.  
  261. /*
  262. ==============================================================================
  263.         FOOTER 
  264. ==============================================================================
  265. */ 
  266. ?>

Documentation generated on Thu, 12 Jun 2008 14:01:46 -0500 by phpDocumentor 1.4.1