activity.php 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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. $blocks = [];
  45. // Start of tools for CourseAdmins (teachers/tutors)
  46. if ($session_id === 0 && api_is_course_admin() && api_is_allowed_to_edit(null, true)) {
  47. $content .= '<div class="alert alert-success" style="border:0px; margin-top: 0px;padding:0px;">
  48. <div class="normal-message" id="id_normal_message" style="display:none">';
  49. $content .= Display::return_icon('indicator.gif').'&nbsp;&nbsp;';
  50. $content .= get_lang('PleaseStandBy');
  51. $content .= '</div>
  52. <div class="alert alert-success" id="id_confirmation_message" style="display:none"></div>
  53. </div>';
  54. $content .= $pluginExtra;
  55. if (api_get_setting('show_session_data') == 'true' && $session_id > 0) {
  56. $content .= '
  57. <div class="row">
  58. <div class="col-xs-12 col-md-12">
  59. <span class="viewcaption">'.get_lang('SessionData').'</span>
  60. <table class="course_activity_home">'.
  61. CourseHome::show_session_data($session_id).'
  62. </table>
  63. </div>
  64. </div>';
  65. }
  66. $my_list = CourseHome::get_tools_category(TOOL_AUTHORING);
  67. $blocks[] = [
  68. 'title' => get_lang('Authoring'),
  69. 'class' => 'course-tools-author',
  70. 'content' => CourseHome::show_tools_category($my_list)
  71. ];
  72. $list1 = CourseHome::get_tools_category(TOOL_INTERACTION);
  73. $list2 = CourseHome::get_tools_category(TOOL_COURSE_PLUGIN);
  74. $my_list = array_merge($list1, $list2);
  75. $blocks[] = [
  76. 'title' => get_lang('Interaction'),
  77. 'class' => 'course-tools-interaction',
  78. 'content' => CourseHome::show_tools_category($my_list)
  79. ];
  80. $my_list = CourseHome::get_tools_category(TOOL_ADMIN_PLATFORM);
  81. $blocks[] = [
  82. 'title' => get_lang('Administration'),
  83. 'class' => 'course-tools-administration',
  84. 'content' => CourseHome::show_tools_category($my_list)
  85. ];
  86. } elseif (api_is_coach()) {
  87. $content .= $pluginExtra;
  88. if (api_get_setting('show_session_data') === 'true' && $session_id > 0) {
  89. $content .= '<div class="row">
  90. <div class="col-xs-12 col-md-12">
  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></div>';
  95. }
  96. $my_list = CourseHome::get_tools_category(TOOL_STUDENT_VIEW);
  97. $blocks[] = [
  98. 'content' => CourseHome::show_tools_category($my_list)
  99. ];
  100. $sessionsCopy = api_get_setting('allow_session_course_copy_for_teachers');
  101. if ($sessionsCopy === 'true') {
  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. $blocks[] = [
  112. 'title' => get_lang('Administration'),
  113. 'content' => CourseHome::show_tools_category($onlyMaintenanceList)
  114. ];
  115. }
  116. } else {
  117. $tools = CourseHome::get_tools_category(TOOL_STUDENT_VIEW);
  118. $isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(
  119. api_get_user_id(),
  120. api_get_course_info()
  121. );
  122. // Force user icon for DRH
  123. if ($isDrhOfCourse) {
  124. $addUserTool = true;
  125. foreach ($tools as $tool) {
  126. if ($tool['name'] === 'user') {
  127. $addUserTool = false;
  128. break;
  129. }
  130. }
  131. if ($addUserTool) {
  132. $tools[] = array(
  133. 'c_id' => api_get_course_int_id(),
  134. 'name' => 'user',
  135. 'link' => 'user/user.php',
  136. 'image' => 'members.gif',
  137. 'visibility' => '1',
  138. 'admin' => '0',
  139. 'address' => 'squaregrey.gif',
  140. 'added_tool' => '0',
  141. 'target' => '_self',
  142. 'category' => 'interaction',
  143. 'session_id' => api_get_session_id()
  144. );
  145. }
  146. }
  147. if (count($tools) > 0) {
  148. $blocks[] = ['content' => CourseHome::show_tools_category($tools)];
  149. }
  150. if ($isDrhOfCourse) {
  151. $drhTool = CourseHome::get_tools_category(TOOL_DRH);
  152. $blocks[] = ['content' => CourseHome::show_tools_category($drhTool)];
  153. }
  154. }
  155. $activityView = new Template('', false, false, false, false, false, false);
  156. $activityView->assign('blocks', $blocks);
  157. $content .= $activityView->fetch(
  158. $activityView->get_template('course_home/activity.tpl')
  159. );