activity.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. }
  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. // Start of tools for CourseAdmins (teachers/tutors)
  51. if ($session_id == 0 && api_is_course_admin() && api_is_allowed_to_edit(null, true)) {
  52. $content .= '<div class="courseadminview" style="border:0px; margin-top: 0px;padding:0px;">
  53. <div class="normal-message" id="id_normal_message" style="display:none">';
  54. $content .= '<img src="'.api_get_path(WEB_PATH).'main/inc/lib/javascript/indicator.gif"/>&nbsp;&nbsp;';
  55. $content .= get_lang('PleaseStandBy');
  56. $content .= '</div>
  57. <div class="confirmation-message" id="id_confirmation_message" style="display:none"></div>
  58. </div>';
  59. if (api_get_setting('show_session_data') == 'true' && $session_id > 0) {
  60. $content .= '<div class="courseadminview">
  61. <span class="viewcaption">'.get_lang('SessionData').'</span>
  62. <table class="course_activity_home">'.CourseHome::show_session_data($session_id).'
  63. </table>
  64. </div>';
  65. }
  66. $my_list = CourseHome::get_tools_category(TOOL_AUTHORING);
  67. $items = CourseHome::show_tools_category($my_list);
  68. $content .= return_block(get_lang('Authoring'), $items);
  69. $my_list = CourseHome::get_tools_category(TOOL_INTERACTION);
  70. $list2 = CourseHome::get_tools_category(TOOL_COURSE_PLUGIN);
  71. $my_list = array_merge($my_list,$list2);
  72. $items = CourseHome::show_tools_category($my_list);
  73. $content .= return_block(get_lang('Interaction'), $items);
  74. $my_list = CourseHome::get_tools_category(TOOL_ADMIN_PLATFORM);
  75. $items = CourseHome::show_tools_category($my_list);
  76. $content .= return_block(get_lang('Administration'), $items);
  77. } elseif (api_is_coach()) {
  78. if (api_get_setting('show_session_data') == 'true' && $session_id > 0) {
  79. $content .= '<div class="row">
  80. <span class="viewcaption">'.get_lang('SessionData').'</span>
  81. <table class="course_activity_home">';
  82. $content .= CourseHome::show_session_data($session_id);
  83. $content .= '</table></div>';
  84. }
  85. $content .= '<div class="row">';
  86. $my_list = CourseHome::get_tools_category(TOOL_STUDENT_VIEW);
  87. $content .= CourseHome::show_tools_category($my_list);
  88. $content .= '</div>';
  89. } else {
  90. $my_list = CourseHome::get_tools_category(TOOL_STUDENT_VIEW);
  91. if (count($my_list) > 0) {
  92. $content .= '<div class="row">';
  93. $content .= CourseHome::show_tools_category($my_list);
  94. $content .= '</div>';
  95. }
  96. }
  97. function return_block($title, $content) {
  98. global $app;
  99. $rowDiv = '<div class="row">';
  100. if ($app['full_width']) {
  101. $rowDiv = '<div class="row-fluid">';
  102. }
  103. $html = $rowDiv.'<div class="span12">
  104. <div class="page-header"><h3>'.$title.'</h3></div></div></div>'.$rowDiv.$content.'</div>';
  105. return $html;
  106. }