activity.php 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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. $id = isset($_GET['id']) ? intval($_GET['id']) : null;
  15. $course_id = api_get_course_int_id();
  16. $session_id = api_get_session_id();
  17. // MAIN CODE
  18. if (api_is_allowed_to_edit(null, true)) {
  19. // HIDE
  20. if (!empty($_GET['hide'])) {
  21. $sql = "UPDATE $tool_table SET visibility=0 WHERE c_id = $course_id AND id=".$id;
  22. Database::query($sql);
  23. $show_message = Display::return_message(get_lang('ToolIsNowHidden'), 'confirmation');
  24. } elseif (!empty($_GET['restore'])) {
  25. // visibility 0,2 -> 1
  26. // REACTIVATE
  27. $sql = "UPDATE $tool_table SET visibility=1 WHERE c_id = $course_id AND id=".$id;
  28. Database::query($sql);
  29. //$show_message = Display::return_message(get_lang('ToolIsNowVisible'),'confirmation');
  30. }
  31. }
  32. // Work with data post askable by admin of course
  33. if (api_is_platform_admin()) {
  34. // Show message to confirm that a tool it to be hidden from available tools
  35. // visibility 0,1->2
  36. if (!empty($_GET['askDelete'])) {
  37. $content .='<div id="toolhide">'.get_lang('DelLk').'<br />&nbsp;&nbsp;&nbsp;
  38. <a href="'.api_get_self().'">'.get_lang('No').'</a>&nbsp;|&nbsp;
  39. <a href="'.api_get_self().'?delete=yes&id='.$id.'">'.get_lang('Yes').'</a>
  40. </div>';
  41. } elseif (isset($_GET['delete']) && $_GET['delete']) {
  42. /*
  43. * Process hiding a tools from available tools.
  44. */
  45. //where $id is set?
  46. $id = intval($id);
  47. Database::query("DELETE FROM $tool_table WHERE c_id = $course_id AND id='$id' AND added_tool=1");
  48. }
  49. }
  50. // Course legal
  51. $enabled = api_get_plugin_setting('courselegal', 'tool_enable');
  52. $pluginExtra = null;
  53. if ($enabled == 'true') {
  54. require_once api_get_path(SYS_PLUGIN_PATH).'courselegal/config.php';
  55. $plugin = CourseLegalPlugin::create();
  56. $pluginExtra = $plugin->getTeacherLink();
  57. }
  58. // COURSE ADMIN ONLY VIEW
  59. // Start of tools for CourseAdmins (teachers/tutors)
  60. if ($session_id == 0 && api_is_course_admin() && api_is_allowed_to_edit(null, true)) {
  61. $content .= '<div class="courseadminview" style="border:0px; margin-top: 0px;padding:0px;">
  62. <div class="normal-message" id="id_normal_message" style="display:none">';
  63. $content .= '<img src="'.api_get_path(WEB_PATH).'main/inc/lib/javascript/indicator.gif"/>&nbsp;&nbsp;';
  64. $content .= get_lang('PleaseStandBy');
  65. $content .= '</div>
  66. <div class="confirmation-message" id="id_confirmation_message" style="display:none"></div>
  67. </div>';
  68. $content .= $pluginExtra;
  69. if (api_get_setting('show_session_data') == 'true' && $session_id > 0) {
  70. $content .= '<div class="courseadminview">
  71. <span class="viewcaption">'.get_lang('SessionData').'</span>
  72. <table class="course_activity_home">'.CourseHome::show_session_data($session_id).'
  73. </table>
  74. </div>';
  75. }
  76. $my_list = CourseHome::get_tools_category(TOOL_AUTHORING);
  77. $items = CourseHome::show_tools_category($my_list);
  78. $content .= return_block(get_lang('Authoring'), $items, 'course-tools-author');
  79. $my_list = CourseHome::get_tools_category(TOOL_INTERACTION);
  80. $list2 = CourseHome::get_tools_category(TOOL_COURSE_PLUGIN);
  81. $my_list = array_merge($my_list,$list2);
  82. $items = CourseHome::show_tools_category($my_list);
  83. $content .= return_block(get_lang('Interaction'), $items, 'course-tools-interaction');
  84. $my_list = CourseHome::get_tools_category(TOOL_ADMIN_PLATFORM);
  85. $items = CourseHome::show_tools_category($my_list);
  86. $content .= return_block(get_lang('Administration'), $items , 'course-tools-administration');
  87. } elseif (api_is_coach()) {
  88. $content .= $pluginExtra;
  89. if (api_get_setting('show_session_data') == 'true' && $session_id > 0) {
  90. $content .= '<div class="row">
  91. <span class="viewcaption">'.get_lang('SessionData').'</span>
  92. <table class="course_activity_home">';
  93. $content .= CourseHome::show_session_data($session_id);
  94. $content .= '</table></div>';
  95. }
  96. $content .= '<div class="row">';
  97. $my_list = CourseHome::get_tools_category(TOOL_STUDENT_VIEW);
  98. $content .= CourseHome::show_tools_category($my_list);
  99. $content .= '</div>';
  100. if (isset($_configuration['allow_session_course_copy_for_teachers'])) {
  101. if ($_configuration['allow_session_course_copy_for_teachers']) {
  102. // Adding only maintenance for coaches.
  103. $myList = CourseHome::get_tools_category(TOOL_ADMIN_PLATFORM);
  104. $onlyMaintenanceList = array();
  105. foreach ($myList as $item) {
  106. if ($item['name'] == 'course_maintenance') {
  107. $item['link'] = 'course_info/maintenance_coach.php';
  108. $onlyMaintenanceList[] = $item;
  109. }
  110. }
  111. $items = CourseHome::show_tools_category($onlyMaintenanceList);
  112. $content .= return_block(get_lang('Administration'), $items);
  113. }
  114. }
  115. } else {
  116. $tools = CourseHome::get_tools_category(TOOL_STUDENT_VIEW);
  117. $isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(
  118. api_get_user_id(),
  119. api_get_course_info()
  120. );
  121. // Force user icon for DRH
  122. if ($isDrhOfCourse) {
  123. $addUserTool = true;
  124. foreach ($tools as $tool) {
  125. if ($tool['name'] == 'user') {
  126. $addUserTool = false;
  127. break;
  128. }
  129. }
  130. if ($addUserTool) {
  131. $tools[] = array(
  132. 'c_id' => api_get_course_int_id(),
  133. 'name' => 'user',
  134. 'link' => 'user/user.php',
  135. 'image' => 'members.gif',
  136. 'visibility' => '1',
  137. 'admin' => '0',
  138. 'address' => 'squaregrey.gif',
  139. 'added_tool' => '0',
  140. 'target' => '_self',
  141. 'category' => 'interaction',
  142. 'session_id' => api_get_session_id()
  143. );
  144. }
  145. }
  146. if (count($tools) > 0) {
  147. $content .= '<div class="row">';
  148. $content .= CourseHome::show_tools_category($tools);
  149. $content .= '</div>';
  150. }
  151. if ($isDrhOfCourse) {
  152. $drhTool = CourseHome::get_tools_category(TOOL_DRH);
  153. $content .= '<div class="row">';
  154. $content .= CourseHome::show_tools_category($drhTool);
  155. $content .= '</div>';
  156. }
  157. }
  158. /**
  159. * @param string $title
  160. * @param string $content
  161. * @param string $class
  162. *
  163. * @return string
  164. */
  165. function return_block($title, $content, $class = null)
  166. {
  167. $html = '<div class="row course-title-tools">
  168. <div class="span12">
  169. <div class="page-header">
  170. <h3>'.$title.'</h3>
  171. </div>
  172. </div>
  173. </div>
  174. <div class="row '.$class.'">'.$content.'</div>';
  175. return $html;
  176. }