course_home.php 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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 initialization file.
  57. require '../../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. $htmlHeadXtra[] ='<script type="text/javascript">
  60. $(document).ready(function() {
  61. $(".make_visible_and_invisible").attr("href", "javascript:void(0);");
  62. $("td .make_visible_and_invisible > img").click(function () {
  63. make_visible = "visible.gif";
  64. make_invisible = "invisible.gif";
  65. path_name = $(this).attr("src");
  66. list_path_name = path_name.split("/");
  67. image_link = list_path_name[list_path_name.length - 1];
  68. tool_id = $(this).attr("id");
  69. tool_info = tool_id.split("_");
  70. my_tool_id = tool_info[1];
  71. $.ajax({
  72. contentType: "application/x-www-form-urlencoded",
  73. beforeSend: function(objeto) {
  74. $(".normal-message").show();
  75. $("#id_confirmation_message").hide();
  76. },
  77. type: "GET",
  78. url: "'.api_get_path(WEB_CODE_PATH).'course_home/activity.php",
  79. data: "id=" + my_tool_id + "&sent_http_request=1",
  80. success: function(data) {
  81. eval("var info=" + data);
  82. new_current_tool_image = "'.api_get_path(WEB_IMG_PATH).'" + info.image;
  83. new_current_view = "'.api_get_path(WEB_IMG_PATH).'" + info.view;
  84. //eyes
  85. $("#" + tool_id).attr("src", new_current_view);
  86. //tool
  87. $("#toolimage_" + my_tool_id).attr("src", new_current_tool_image);
  88. //clase
  89. $("#tooldesc_" + my_tool_id).attr("class", info.tclass);
  90. $("#istooldesc_" + my_tool_id).attr("class", info.tclass);
  91. if (image_link == "visible.gif") {
  92. $("#" + tool_id).attr("alt", "'.get_lang('Activate', '').'");
  93. $("#" + tool_id).attr("title", "'.get_lang('Activate', '').'");
  94. } else {
  95. $("#" + tool_id).attr("alt", "'.get_lang('Deactivate', '').'");
  96. $("#" + tool_id).attr("title", "'.get_lang('Deactivate', '').'");
  97. }
  98. if (info.message == "is_active") {
  99. message = "'.get_lang('ToolIsNowVisible', '').'";
  100. } else {
  101. message = "'.get_lang('ToolIsNowHidden', '').'";
  102. }
  103. $(".normal-message").hide();
  104. $("#id_confirmation_message").html(message);
  105. $("#id_confirmation_message").show();
  106. }
  107. });
  108. });
  109. });
  110. </script>';
  111. if (!isset($cidReq)) {
  112. $cidReq = api_get_course_id(); // To provide compatibility with previous systems.
  113. global $error_msg,$error_no;
  114. $classError = "init";
  115. $error_no[$classError][] = "2";
  116. $error_level[$classError][] = "info";
  117. $error_msg[$classError][] = "[".__FILE__."][".__LINE__."] cidReq was Missing $cidReq take $dbname;";
  118. }
  119. if (isset($_SESSION['_gid'])) {
  120. unset($_SESSION['_gid']);
  121. }
  122. // The section for the tabs
  123. $this_section = SECTION_COURSES;
  124. /*
  125. -----------------------------------------------------------
  126. Libraries
  127. -----------------------------------------------------------
  128. */
  129. include_once api_get_path(LIBRARY_PATH).'course.lib.php';
  130. include_once api_get_path(LIBRARY_PATH).'debug.lib.inc.php';
  131. /*
  132. -----------------------------------------------------------
  133. Constants
  134. -----------------------------------------------------------
  135. */
  136. define ('TOOL_PUBLIC', 'Public');
  137. define ('TOOL_PUBLIC_BUT_HIDDEN', 'PublicButHide');
  138. define ('TOOL_COURSE_ADMIN', 'courseAdmin');
  139. define ('TOOL_PLATFORM_ADMIN', 'platformAdmin');
  140. define ('TOOL_AUTHORING', 'toolauthoring');
  141. define ('TOOL_INTERACTION', 'toolinteraction');
  142. define ('TOOL_ADMIN', 'tooladmin');
  143. define ('TOOL_ADMIN_PLATEFORM', 'tooladminplatform');
  144. // ('TOOL_ADMIN_PLATFORM_VISIBLE', 'tooladminplatformvisible');
  145. //define ('TOOL_ADMIN_PLATFORM_INVISIBLE', 'tooladminplatforminvisible');
  146. //define ('TOOL_ADMIN_COURS_INVISIBLE', 'tooladmincoursinvisible');
  147. define ('TOOL_STUDENT_VIEW', 'toolstudentview');
  148. define ('TOOL_ADMIN_VISIBLE', 'tooladminvisible');
  149. /*
  150. -----------------------------------------------------------
  151. Virtual course support code
  152. -----------------------------------------------------------
  153. */
  154. $user_id = api_get_user_id();
  155. $course_code = $_course['sysCode'];
  156. $course_info = Database::get_course_info($course_code);
  157. $return_result = CourseManager::determine_course_title_from_course_info($_user['user_id'], $course_info);
  158. $course_title = $return_result['title'];
  159. $course_code = $return_result['code'];
  160. $_course['name'] = $course_title;
  161. $_course['official_code'] = $course_code;
  162. api_session_unregister('toolgroup');
  163. /*
  164. -----------------------------------------------------------
  165. Is the user allowed here?
  166. -----------------------------------------------------------
  167. */
  168. if (!$is_allowed_in_course) {
  169. api_not_allowed(true);
  170. }
  171. /*
  172. -----------------------------------------------------------
  173. Header
  174. -----------------------------------------------------------
  175. */
  176. //Display::display_header($course_title, 'Home');
  177. Display::display_header('', 'Home');
  178. /*
  179. -----------------------------------------------------------
  180. STATISTICS
  181. -----------------------------------------------------------
  182. */
  183. if (!isset($coursesAlreadyVisited[$_cid])) {
  184. event_access_course();
  185. $coursesAlreadyVisited[$_cid] = 1;
  186. api_session_register('coursesAlreadyVisited');
  187. }
  188. $tool_table = Database::get_course_table(TABLE_TOOL_LIST);
  189. $temps = time();
  190. $reqdate = "&reqdate=$temps";
  191. /*
  192. ==============================================================================
  193. MAIN CODE
  194. ==============================================================================
  195. */
  196. //display course title for course home page (similar to toolname for tool pages)
  197. //echo '<h3>'.api_display_tool_title($nameTools) . '</h3>';
  198. /*
  199. -----------------------------------------------------------
  200. Introduction section
  201. (editable by course admins)
  202. -----------------------------------------------------------
  203. */
  204. Display::display_introduction_section(TOOL_COURSE_HOMEPAGE, array(
  205. 'CreateDocumentWebDir' => api_get_path('WEB_COURSE_PATH').api_get_course_path().'/document/',
  206. 'CreateDocumentDir' => 'document/',
  207. 'BaseHref' => api_get_path('WEB_COURSE_PATH').api_get_course_path().'/'
  208. )
  209. );
  210. /*
  211. -----------------------------------------------------------
  212. SWITCH TO A DIFFERENT HOMEPAGE VIEW
  213. the setting homepage_view is adjustable through
  214. the platform administration section
  215. -----------------------------------------------------------
  216. */
  217. if (api_get_setting('homepage_view') == 'activity') {
  218. require 'activity.php';
  219. }
  220. elseif(api_get_setting('homepage_view') == '2column') {
  221. require '2column.php';
  222. }
  223. elseif(api_get_setting('homepage_view') == '3column') {
  224. require '3column.php';
  225. }
  226. /*
  227. ==============================================================================
  228. FOOTER
  229. ==============================================================================
  230. */
  231. Display::display_footer();