vertical_activity.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * HOME PAGE FOR EACH COURSE
  5. *
  6. * This page, included in every course's index.php is the home
  7. * page. To make administration simple, the teacher edits his
  8. * course from the home page. Only the login detects that the
  9. * visitor is allowed to activate, deactivate home page links,
  10. * access to the teachers tools (statistics, edit forums...).
  11. *
  12. * @package chamilo.course_home
  13. */
  14. // MAIN CODE
  15. $course_id = api_get_course_int_id();
  16. if (api_is_allowed_to_edit(null, true)) {
  17. // HIDE
  18. if (!empty($_GET['hide'])) { // visibility 1 -> 0
  19. $sql = "UPDATE $tool_table SET visibility=0 WHERE c_id = $course_id AND id='".intval($_GET["id"])."'";
  20. Database::query($sql);
  21. $show_message = Display::return_message(get_lang('ToolIsNowHidden'), 'confirmation');
  22. } elseif (!empty($_GET['restore'])) {
  23. // visibility 0,2 -> 1
  24. // REACTIVATE
  25. $sql = "UPDATE $tool_table SET visibility=1 WHERE c_id = $course_id AND id='".intval($_GET["id"])."'";
  26. Database::query($sql);
  27. $show_message = Display::return_message(get_lang('ToolIsNowVisible'), 'confirmation');
  28. }
  29. }
  30. // Work with data post askable by admin of course
  31. if (api_is_platform_admin()) {
  32. // Show message to confirm that a tool it to be hidden from available tools
  33. // visibility 0,1->2
  34. if (!empty($_GET['askDelete'])) {
  35. $content .='<div id="toolhide">'.get_lang('DelLk').'<br />&nbsp;&nbsp;&nbsp;
  36. <a href="'.api_get_self().'">'.get_lang('No').'</a>&nbsp;|&nbsp;
  37. <a href="'.api_get_self().'?delete=yes&id='.intval($_GET['id']).'">'.get_lang('Yes').'</a>
  38. </div>';
  39. } elseif (isset($_GET['delete']) && $_GET['delete']) {
  40. /*
  41. * Process hiding a tools from available tools.
  42. */
  43. //where $id is set?
  44. $id = intval($id);
  45. Database::query("DELETE FROM $tool_table WHERE c_id = $course_id AND id='$id' AND added_tool=1");
  46. }
  47. }
  48. // COURSE ADMIN ONLY VIEW
  49. // Start of tools for CourseAdmins (teachers/tutors)
  50. if (api_is_allowed_to_edit(null, true) && !api_is_coach()) {
  51. $current_protocol = $_SERVER['SERVER_PROTOCOL'];
  52. $current_host = $_SERVER['HTTP_HOST'];
  53. $server_protocol = substr($current_protocol, 0, strrpos($current_protocol, '/'));
  54. $server_protocol = $server_protocol.'://';
  55. if ($current_host == 'localhost') {
  56. // Get information of path
  57. $info = explode('courses', api_get_self());
  58. $path_work = substr($info[0], 1);
  59. } else {
  60. $path_work = '';
  61. }
  62. $content .= '<div class="courseadminview" style="border:0px; margin-top: 0px;padding:5px;">
  63. <div class="normal-message" id="id_normal_message" style="display:none">';
  64. $content .= '<img src="'.api_get_path(WEB_PATH).'main/inc/lib/javascript/indicator.gif"/>&nbsp;&nbsp;';
  65. $content .= get_lang('PleaseStandBy');
  66. $content .= '</div>
  67. <div class="confirmation-message" id="id_confirmation_message" style="display:none"></div>
  68. </div>';
  69. $content .= '<div id="activity-3col">';
  70. if (api_get_setting('show_session_data') == 'true' && $id_session > 0) {
  71. $content .= '<div class="courseadminview-activity-3col"><span class="viewcaption">'.get_lang('SessionData').'</span>
  72. <table width="100%">'.CourseHome::show_session_data($id_session).'</table>
  73. </div>';
  74. }
  75. $content .= '<div class="courseadminview-activity-3col"><span class="viewcaption">'.get_lang('Authoring').'</span>';
  76. $my_list = CourseHome::get_tools_category(TOOL_AUTHORING);
  77. $content .= CourseHome::show_tools_category($my_list);
  78. $content .= '</div>';
  79. $content .= '<div class="courseadminview-activity-3col"><span class="viewcaption">'.get_lang('Interaction').'</span>';
  80. $my_list = CourseHome::get_tools_category(TOOL_INTERACTION);
  81. $content .= CourseHome::show_tools_category($my_list);
  82. $content .= '</div>';
  83. $content .= '<div class="courseadminview-activity-3col"><span class="viewcaption">'.get_lang('Administration').'</span>';
  84. $my_list = CourseHome::get_tools_category(TOOL_ADMIN_PLATFORM);
  85. $content .= CourseHome::show_tools_category($my_list);
  86. $content .= '</div>';
  87. } elseif (api_is_coach()) {
  88. if (api_get_setting('show_session_data') == 'true' && $id_session > 0) {
  89. $content .= '<div class="courseadminview-activity-3col"><span class="viewcaption">'.get_lang('SessionData').'</span>
  90. <table width="100%">';
  91. $content .= CourseHome::show_session_data($id_session);
  92. $content .= '</table></div>';
  93. }
  94. $content .= '<div class="Authoringview">';
  95. $my_list = CourseHome::get_tools_category(TOOL_STUDENT_VIEW);
  96. $content .= CourseHome::show_tools_category($my_list);
  97. $content .= '</div>';
  98. // TOOLS AUTHORING
  99. } else {
  100. $my_list = CourseHome::get_tools_category(TOOL_STUDENT_VIEW);
  101. if (count($my_list) > 0) {
  102. $content .= '<div class="course-student-view-activity-3col">';
  103. //ordering by get_lang name
  104. $order_tool_list = array();
  105. foreach($my_list as $key=>$new_tool) {
  106. $tool_name = CourseHome::translate_tool_name($new_tool);
  107. $order_tool_list [$key]= $tool_name;
  108. }
  109. natsort($order_tool_list);
  110. $my_temp_tool_array = array();
  111. foreach($order_tool_list as $key=>$new_tool) {
  112. $my_temp_tool_array[] = $my_list[$key];
  113. }
  114. $my_list = $my_temp_tool_array;
  115. $i = 0;
  116. foreach($my_list as $new_tool) {
  117. if ($i >= 10) {
  118. $my_list2[] = $new_tool;
  119. } else {
  120. $my_list1[] = $new_tool;
  121. }
  122. $i++;
  123. }
  124. $content .=CourseHome::show_tools_category($my_list1);
  125. $content .=CourseHome::show_tools_category($my_list2);
  126. $content .= '</div>';
  127. }
  128. }
  129. $content .= '</div>';