activity.php 6.5 KB

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