vertical_activity.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. if (api_is_allowed_to_edit(null, true)) {
  18. // HIDE
  19. if (!empty($_GET['hide'])) { // visibility 1 -> 0
  20. $sql = "UPDATE $tool_table SET visibility=0 WHERE c_id = $course_id AND id='".$id."'";
  21. Database::query($sql);
  22. $show_message = Display::return_message(get_lang('ToolIsNowHidden'), 'confirmation');
  23. } elseif (!empty($_GET['restore'])) {
  24. // visibility 0,2 -> 1
  25. // REACTIVATE
  26. $sql = "UPDATE $tool_table SET visibility=1 WHERE c_id = $course_id AND id='".$id."'";
  27. Database::query($sql);
  28. $show_message = Display::return_message(get_lang('ToolIsNowVisible'), 'confirmation');
  29. }
  30. }
  31. // Work with data post askable by admin of course
  32. if (api_is_platform_admin()) {
  33. // Show message to confirm that a tool it to be hidden from available tools
  34. // visibility 0,1->2
  35. if (!empty($_GET['askDelete'])) {
  36. $content .= '<div id="toolhide">'.get_lang('DelLk').'<br />&nbsp;&nbsp;&nbsp;
  37. <a href="'.api_get_self().'">'.get_lang('No').'</a>&nbsp;|&nbsp;
  38. <a href="'.api_get_self().'?delete=yes&id='.$id.'">'.get_lang('Yes').'</a>
  39. </div>';
  40. } elseif (isset($_GET['delete']) && $_GET['delete']) {
  41. /*
  42. * Process hiding a tools from available tools.
  43. */
  44. //where $id is set?
  45. $id = intval($id);
  46. Database::query("DELETE FROM $tool_table WHERE c_id = $course_id AND id='$id' AND added_tool=1");
  47. }
  48. }
  49. // COURSE ADMIN ONLY VIEW
  50. $blocks = [];
  51. // Start of tools for CourseAdmins (teachers/tutors)
  52. if (api_is_allowed_to_edit(null, true) && !api_is_coach()) {
  53. $content .= '<div class="courseadminview" style="border:0px; margin-top: 0px;padding:5px;">
  54. <div class="normal-message" id="id_normal_message" style="display:none">';
  55. $content .= '<img src="'.api_get_path(WEB_PATH).'main/inc/lib/javascript/indicator.gif"/>&nbsp;&nbsp;';
  56. $content .= get_lang('PleaseStandBy');
  57. $content .= '</div>
  58. <div class="confirmation-message" id="id_confirmation_message" style="display:none"></div></div>';
  59. $content .= '<div id="activity-3col">';
  60. if (api_get_setting('show_session_data') == 'true' && $session_id > 0) {
  61. $content .= '<div class="courseadminview-activity-3col"><span class="viewcaption">'.get_lang('SessionData').'</span>
  62. <table width="100%">'.CourseHome::show_session_data($session_id).'</table>
  63. </div>';
  64. }
  65. $my_list = CourseHome::get_tools_category(TOOL_AUTHORING);
  66. $blocks[] = [
  67. 'title' => get_lang('Authoring'),
  68. 'content' => CourseHome::show_tools_category($my_list),
  69. ];
  70. $my_list = CourseHome::get_tools_category(TOOL_INTERACTION);
  71. $blocks[] = [
  72. 'title' => get_lang('Interaction'),
  73. 'content' => CourseHome::show_tools_category($my_list),
  74. ];
  75. $my_list = CourseHome::get_tools_category(TOOL_ADMIN_PLATFORM);
  76. $blocks[] = [
  77. 'title' => get_lang('Administration'),
  78. 'content' => CourseHome::show_tools_category($my_list),
  79. ];
  80. } elseif (api_is_coach()) {
  81. if (api_get_setting('show_session_data') == 'true' && $session_id > 0) {
  82. $content .= '<div class="courseadminview-activity-3col"><span class="viewcaption">'.get_lang('SessionData').'</span>
  83. <table width="100%">';
  84. $content .= CourseHome::show_session_data($session_id);
  85. $content .= '</table></div>';
  86. }
  87. $my_list = CourseHome::get_tools_category(TOOL_STUDENT_VIEW);
  88. $blocks[] = [
  89. 'class' => 'Authoringview',
  90. 'content' => CourseHome::show_tools_category($my_list),
  91. ];
  92. // TOOLS AUTHORING
  93. } else {
  94. $my_list = CourseHome::get_tools_category(TOOL_STUDENT_VIEW);
  95. if (count($my_list) > 0) {
  96. //ordering by get_lang name
  97. $order_tool_list = [];
  98. foreach ($my_list as $key => $new_tool) {
  99. $tool_name = CourseHome::translate_tool_name($new_tool);
  100. $order_tool_list[$key] = $tool_name;
  101. }
  102. natsort($order_tool_list);
  103. $my_temp_tool_array = [];
  104. foreach ($order_tool_list as $key => $new_tool) {
  105. $my_temp_tool_array[] = $my_list[$key];
  106. }
  107. $blocks[] = [
  108. 'class' => 'course-student-view-activity-3col',
  109. 'content' => CourseHome::show_tools_category($my_temp_tool_array),
  110. ];
  111. }
  112. }
  113. $activityView = new Template('', false, false, false, false, false, false);
  114. $activityView->assign('blocks', $blocks);
  115. $content .= $activityView->fetch(
  116. $activityView->get_template('course_home/vertical_activity.tpl')
  117. );