course_home.php 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. <?php // $Id: course_home.php 22086 2009-07-14 20:11:38Z 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. $htmlHeadXtra[] ='<script type="text/javascript">
  60. $(document).ready(function() {
  61. $(window).load(function () {
  62. $(".make_visible_and_invisible").attr("href","javascript:void(0)");
  63. });
  64. $("td .make_visible_and_invisible > img").click(function () {
  65. make_visible="visible.gif";
  66. make_invisible="invisible.gif";
  67. path_name=$(this).attr("src");
  68. list_path_name=path_name.split("/");
  69. image_link=list_path_name[list_path_name.length-1];
  70. tool_id=$(this).attr("id");
  71. tool_info=tool_id.split("_");
  72. my_tool_id=tool_info[1];
  73. current_tool_image=$("#toolimage_"+my_tool_id).attr("src");
  74. list_current_tool_image=current_tool_image.split("/");
  75. image_for_replace=list_current_tool_image[list_current_tool_image.length-1];
  76. list_new_image=image_for_replace.split(".");
  77. if (image_for_replace.split("_na").length==2){
  78. list_image_na=image_for_replace.split("_na");
  79. list_image_na=list_image_na[0]+".gif";
  80. new_current_tool_image=current_tool_image.replace(image_for_replace,list_image_na);
  81. $("#tooldesc_"+my_tool_id).attr("class","");
  82. } else {
  83. new_image_to_replace=list_new_image[0]+"_na.gif";
  84. new_current_tool_image=current_tool_image.replace(image_for_replace,new_image_to_replace);
  85. $("#tooldesc_"+my_tool_id).attr("class","invisible");
  86. }
  87. $("#toolimage_"+my_tool_id).attr("src",new_current_tool_image);
  88. if (image_link=="visible.gif") {
  89. mew_path_name=path_name.replace(make_visible,make_invisible);
  90. my_visibility=0;
  91. } else {
  92. mew_path_name=path_name.replace(make_invisible,make_visible);
  93. my_visibility=1;
  94. }
  95. $.ajax({
  96. contentType: "application/x-www-form-urlencoded",
  97. beforeSend: function(objeto) {
  98. $("#id_content_message").html("<div class=\"normal-message\"><img src=\'/main/inc/lib/javascript/indicator.gif\' /></div>");
  99. },
  100. type: "GET",
  101. url: "/main/course_home/activity.php",
  102. data: "id="+my_tool_id+"&visibility="+my_visibility+"&sent_http_request=1",
  103. success: function(datos) {
  104. $("#"+tool_id).attr("src",mew_path_name);
  105. if (image_link=="visible.gif") {
  106. $("#"+tool_id).attr("alt","'.get_lang('Activate').'");
  107. $("#"+tool_id).attr("title","'.get_lang('Activate').'");
  108. } else {
  109. $("#"+tool_id).attr("alt","'.get_lang('Deactivate').'");
  110. $("#"+tool_id).attr("title","'.get_lang('Deactivate').'");
  111. }
  112. //$("#id_content_message").html(datos);
  113. if (datos=="ToolIsNowVisible") {
  114. $("#id_content_message").html("<div class=\"confirmation-message\">'.get_lang('ToolIsNowVisible').'</div>");
  115. } else {
  116. $("#id_content_message").html("<div class=\"confirmation-message\">'.get_lang('ToolIsNowHidden').'</div>");
  117. }
  118. } });
  119. });
  120. });
  121. </script>';
  122. if(!isset($cidReq))
  123. {
  124. $cidReq = api_get_course_id(); // to provide compatibility. with previous system
  125. global $error_msg,$error_no;
  126. $classError = "init";
  127. $error_no[$classError][] = "2";
  128. $error_level[$classError][] = "info";
  129. $error_msg[$classError][] = "[".__FILE__."][".__LINE__."] cidReq was Missing $cidReq take $dbname;";
  130. }
  131. if(isset($_SESSION['_gid'])){
  132. unset($_SESSION['_gid']);
  133. }
  134. // The section for the tabs
  135. $this_section=SECTION_COURSES;
  136. /*
  137. -----------------------------------------------------------
  138. Libraries
  139. -----------------------------------------------------------
  140. */
  141. include_once(api_get_path(LIBRARY_PATH) . 'course.lib.php');
  142. include_once(api_get_path(LIBRARY_PATH) . 'debug.lib.inc.php');
  143. /*
  144. -----------------------------------------------------------
  145. Constants
  146. -----------------------------------------------------------
  147. */
  148. define ("TOOL_PUBLIC", "Public");
  149. define ("TOOL_PUBLIC_BUT_HIDDEN", "PublicButHide");
  150. define ("TOOL_COURSE_ADMIN", "courseAdmin");
  151. define ("TOOL_PLATFORM_ADMIN", "platformAdmin");
  152. define ("TOOL_AUTHORING", "toolauthoring");
  153. define ("TOOL_INTERACTION", "toolinteraction");
  154. define ("TOOL_ADMIN", "tooladmin");
  155. define ("TOOL_ADMIN_PLATEFORM", "tooladminplatform");
  156. // ("TOOL_ADMIN_PLATFORM_VISIBLE", "tooladminplatformvisible");
  157. //define ("TOOL_ADMIN_PLATFORM_INVISIBLE", "tooladminplatforminvisible");
  158. //define ("TOOL_ADMIN_COURS_INVISIBLE", "tooladmincoursinvisible");
  159. define ("TOOL_STUDENT_VIEW", "toolstudentview");
  160. define ("TOOL_ADMIN_VISIBLE", "tooladminvisible");
  161. /*
  162. -----------------------------------------------------------
  163. Virtual course support code
  164. -----------------------------------------------------------
  165. */
  166. $user_id = api_get_user_id();
  167. $course_code = $_course["sysCode"];
  168. $course_info = Database::get_course_info($course_code);
  169. $return_result = CourseManager::determine_course_title_from_course_info($_user['user_id'], $course_info);
  170. $course_title = $return_result["title"];
  171. $course_code = $return_result["code"];
  172. $_course["name"] = $course_title;
  173. $_course['official_code'] = $course_code;
  174. api_session_unregister('toolgroup');
  175. /*
  176. -----------------------------------------------------------
  177. Is the user allowed here?
  178. -----------------------------------------------------------
  179. */
  180. if($is_allowed_in_course == false)
  181. {
  182. api_not_allowed(true);
  183. }
  184. /*
  185. -----------------------------------------------------------
  186. Header
  187. -----------------------------------------------------------
  188. */
  189. Display::display_header($course_title, "Home");
  190. /*
  191. -----------------------------------------------------------
  192. STATISTICS
  193. -----------------------------------------------------------
  194. */
  195. if(!isset($coursesAlreadyVisited[$_cid]) )
  196. {
  197. include(api_get_path(LIBRARY_PATH) . 'events.lib.inc.php');
  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(get_setting('homepage_view') == "activity")
  232. {
  233. include('activity.php');
  234. }
  235. elseif(get_setting('homepage_view') == "2column")
  236. {
  237. include('2column.php');
  238. }
  239. elseif(get_setting('homepage_view') == "3column")
  240. {
  241. include('3column.php');
  242. }
  243. /*
  244. ==============================================================================
  245. FOOTER
  246. ==============================================================================
  247. */
  248. Display::display_footer();
  249. ?>