course_home.php 9.6 KB

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