course_home.php 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. <?php // $Id: course_home.php 22294 2009-07-22 19:27:47Z iflorespaz $
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2004-2005 Dokeos S.A.
  6. Copyright (c) 2003 Ghent University
  7. Copyright (c) 2001 Universite Catholique de Louvain
  8. Copyright (c) various contributors
  9. For a full list of contributors, see "credits.txt".
  10. The full license can be read in "license.txt".
  11. This program is free software; you can redistribute it and/or
  12. modify it under the terms of the GNU General Public License
  13. as published by the Free Software Foundation; either version 2
  14. of the License, or (at your option) any later version.
  15. See the GNU General Public License for more details.
  16. Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium
  17. Mail: info@dokeos.com
  18. ==============================================================================
  19. */
  20. /**
  21. ==============================================================================
  22. * HOME PAGE FOR EACH COURSE
  23. *
  24. * This page, included in every course's index.php is the home
  25. * page. To make administration simple, the teacher edits his
  26. * course from the home page. Only the login detects that the
  27. * visitor is allowed to activate, deactivate home page links,
  28. * access to the teachers tools (statistics, edit forums...).
  29. *
  30. * Edit visibility of tools
  31. *
  32. * visibility = 1 - everybody
  33. * visibility = 0 - course admin (teacher) and platform admin
  34. *
  35. * Who can change visibility ?
  36. *
  37. * admin = 0 - course admin (teacher) and platform admin
  38. * admin = 1 - platform admin
  39. *
  40. * Show message to confirm that a tools must be hide from available tools
  41. *
  42. * visibility 0,1
  43. *
  44. *
  45. * @package dokeos.course_home
  46. ==============================================================================
  47. */
  48. /*
  49. ==============================================================================
  50. INIT SECTION
  51. ==============================================================================
  52. */
  53. // name of the language file that needs to be included
  54. $language_file[] = "course_home";
  55. $use_anonymous = true;
  56. // inlcuding the global file
  57. include '../../main/inc/global.inc.php';
  58. $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
  59. if ($_SERVER['HTTP_HOST'] == 'localhost') {
  60. //Get information of path
  61. $info = explode('courses',api_get_self());
  62. $path_work = substr($info[0],0,strlen($info[0])-1);
  63. } else {
  64. $path_work = "";
  65. }
  66. $htmlHeadXtra[] ='<script type="text/javascript">
  67. $(document).ready(function() {
  68. $(".make_visible_and_invisible").attr("href","javascript:void(0);");
  69. $("td .make_visible_and_invisible > img").click(function () {
  70. make_visible="visible.gif";
  71. make_invisible="invisible.gif";
  72. path_name=$(this).attr("src");
  73. list_path_name=path_name.split("/");
  74. image_link=list_path_name[list_path_name.length-1];
  75. tool_id=$(this).attr("id");
  76. tool_info=tool_id.split("_");
  77. my_tool_id=tool_info[1];
  78. //Delete last item
  79. list_path_name[list_path_name.length-1]=null;
  80. real_path = list_path_name.join("/");
  81. my_protocol = location.protocol;
  82. my_host = location.host;
  83. my_real_path = my_protocol+"//"+my_host;
  84. $.ajax({
  85. contentType: "application/x-www-form-urlencoded",
  86. beforeSend: function(objeto) {
  87. $(".normal-message").show();
  88. $("#id_confirmation_message").hide();
  89. },
  90. type: "GET",
  91. url: my_real_path+"'.$path_work.'/main/course_home/activity.php",
  92. data: "id="+my_tool_id+"&sent_http_request=1",
  93. success: function(datos) {
  94. eval("var info="+datos);
  95. new_current_tool_image = real_path+info.image;
  96. new_current_view = real_path+info.view;
  97. //eyes
  98. $("#"+tool_id).attr("src",new_current_view);
  99. //tool
  100. $("#toolimage_"+my_tool_id).attr("src",new_current_tool_image);
  101. //clase
  102. $("#tooldesc_"+my_tool_id).attr("class",info.tclass);
  103. $("#istooldesc_"+my_tool_id).attr("class",info.tclass);
  104. if (image_link=="visible.gif") {
  105. $("#"+tool_id).attr("alt","'.get_lang('Activate').'");
  106. $("#"+tool_id).attr("title","'.get_lang('Activate').'");
  107. } else {
  108. $("#"+tool_id).attr("alt","'.get_lang('Deactivate').'");
  109. $("#"+tool_id).attr("title","'.get_lang('Deactivate').'");
  110. }
  111. if (info.message=="is_active") {
  112. message = "'.get_lang('ToolIsNowVisible').'";
  113. } else {
  114. message = "'.get_lang('ToolIsNowHidden').'";
  115. }
  116. $(".normal-message").hide();
  117. $("#id_confirmation_message").html(message);
  118. $("#id_confirmation_message").show();
  119. } });
  120. });
  121. });
  122. </script>';
  123. if(!isset($cidReq))
  124. {
  125. $cidReq = api_get_course_id(); // to provide compatibility. with previous system
  126. global $error_msg,$error_no;
  127. $classError = "init";
  128. $error_no[$classError][] = "2";
  129. $error_level[$classError][] = "info";
  130. $error_msg[$classError][] = "[".__FILE__."][".__LINE__."] cidReq was Missing $cidReq take $dbname;";
  131. }
  132. if(isset($_SESSION['_gid'])){
  133. unset($_SESSION['_gid']);
  134. }
  135. // The section for the tabs
  136. $this_section=SECTION_COURSES;
  137. /*
  138. -----------------------------------------------------------
  139. Libraries
  140. -----------------------------------------------------------
  141. */
  142. include_once(api_get_path(LIBRARY_PATH) . 'course.lib.php');
  143. include_once(api_get_path(LIBRARY_PATH) . 'debug.lib.inc.php');
  144. /*
  145. -----------------------------------------------------------
  146. Constants
  147. -----------------------------------------------------------
  148. */
  149. define ("TOOL_PUBLIC", "Public");
  150. define ("TOOL_PUBLIC_BUT_HIDDEN", "PublicButHide");
  151. define ("TOOL_COURSE_ADMIN", "courseAdmin");
  152. define ("TOOL_PLATFORM_ADMIN", "platformAdmin");
  153. define ("TOOL_AUTHORING", "toolauthoring");
  154. define ("TOOL_INTERACTION", "toolinteraction");
  155. define ("TOOL_ADMIN", "tooladmin");
  156. define ("TOOL_ADMIN_PLATEFORM", "tooladminplatform");
  157. // ("TOOL_ADMIN_PLATFORM_VISIBLE", "tooladminplatformvisible");
  158. //define ("TOOL_ADMIN_PLATFORM_INVISIBLE", "tooladminplatforminvisible");
  159. //define ("TOOL_ADMIN_COURS_INVISIBLE", "tooladmincoursinvisible");
  160. define ("TOOL_STUDENT_VIEW", "toolstudentview");
  161. define ("TOOL_ADMIN_VISIBLE", "tooladminvisible");
  162. /*
  163. -----------------------------------------------------------
  164. Virtual course support code
  165. -----------------------------------------------------------
  166. */
  167. $user_id = api_get_user_id();
  168. $course_code = $_course["sysCode"];
  169. $course_info = Database::get_course_info($course_code);
  170. $return_result = CourseManager::determine_course_title_from_course_info($_user['user_id'], $course_info);
  171. $course_title = $return_result["title"];
  172. $course_code = $return_result["code"];
  173. $_course["name"] = $course_title;
  174. $_course['official_code'] = $course_code;
  175. api_session_unregister('toolgroup');
  176. /*
  177. -----------------------------------------------------------
  178. Is the user allowed here?
  179. -----------------------------------------------------------
  180. */
  181. if($is_allowed_in_course == false)
  182. {
  183. api_not_allowed(true);
  184. }
  185. /*
  186. -----------------------------------------------------------
  187. Header
  188. -----------------------------------------------------------
  189. */
  190. Display::display_header($course_title, "Home");
  191. /*
  192. -----------------------------------------------------------
  193. STATISTICS
  194. -----------------------------------------------------------
  195. */
  196. if(!isset($coursesAlreadyVisited[$_cid]) )
  197. {
  198. event_access_course();
  199. $coursesAlreadyVisited[$_cid] = 1;
  200. api_session_register('coursesAlreadyVisited');
  201. }
  202. $tool_table = Database::get_course_table(TABLE_TOOL_LIST);
  203. $temps=time();
  204. $reqdate="&reqdate=$temps";
  205. /*
  206. ==============================================================================
  207. MAIN CODE
  208. ==============================================================================
  209. */
  210. //display course title for course home page (similar to toolname for tool pages)
  211. //echo '<h3>'.api_display_tool_title($nameTools) . '</h3>';
  212. /*
  213. -----------------------------------------------------------
  214. Introduction section
  215. (editable by course admins)
  216. -----------------------------------------------------------
  217. */
  218. Display::display_introduction_section(TOOL_COURSE_HOMEPAGE, array(
  219. 'CreateDocumentWebDir' => api_get_path('WEB_COURSE_PATH').api_get_course_path().'/document/',
  220. 'CreateDocumentDir' => 'document/',
  221. 'BaseHref' => api_get_path('WEB_COURSE_PATH').api_get_course_path().'/'
  222. )
  223. );
  224. /*
  225. -----------------------------------------------------------
  226. SWITCH TO A DIFFERENT HOMEPAGE VIEW
  227. the setting homepage_view is adjustable through
  228. the platform administration section
  229. -----------------------------------------------------------
  230. */
  231. if(api_get_setting('homepage_view') == "activity")
  232. {
  233. include('activity.php');
  234. }
  235. elseif(api_get_setting('homepage_view') == "2column")
  236. {
  237. include('2column.php');
  238. }
  239. elseif(api_get_setting('homepage_view') == "3column")
  240. {
  241. include('3column.php');
  242. }
  243. /*
  244. ==============================================================================
  245. FOOTER
  246. ==============================================================================
  247. */
  248. Display::display_footer();
  249. ?>