course_information.php 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. use Chamilo\CoreBundle\Framework\Container;
  4. /**
  5. * This script gives information about a course
  6. * @author Bart Mollet
  7. * @package chamilo.admin
  8. */
  9. $cidReset = true;
  10. $this_section = SECTION_PLATFORM_ADMIN;
  11. api_protect_admin_script();
  12. if (!isset($_GET['code'])) {
  13. api_not_allowed(true);
  14. }
  15. $courseInfo = api_get_course_info($_GET['code']);
  16. if (empty($courseInfo)) {
  17. api_not_allowed(true);
  18. }
  19. $sessionId = isset($_GET['id_session']) ? (int) $_GET['id_session'] : 0;
  20. function get_course_usage($course, $session_id = 0)
  21. {
  22. $courseId = $course['real_id'];
  23. // Learnpaths
  24. $table = Database :: get_course_table(TABLE_LP_MAIN);
  25. $usage[] = array(
  26. get_lang(ucfirst(TOOL_LEARNPATH)),
  27. CourseManager::count_rows_course_table($table, $session_id, $courseId)
  28. );
  29. // Forums
  30. $table = Database :: get_course_table(TABLE_FORUM);
  31. $usage[] = array(get_lang('Forums'), CourseManager::count_rows_course_table($table, $session_id, $courseId));
  32. // Quizzes
  33. $table = Database :: get_course_table(TABLE_QUIZ_TEST);
  34. $usage[] = array(
  35. get_lang(ucfirst(TOOL_QUIZ)),
  36. CourseManager::count_rows_course_table($table, $session_id, $courseId)
  37. );
  38. // Documents
  39. $table = Database :: get_course_table(TABLE_DOCUMENT);
  40. $usage[] = array(
  41. get_lang(ucfirst(TOOL_DOCUMENT)),
  42. CourseManager::count_rows_course_table($table, $session_id, $courseId)
  43. );
  44. // Groups
  45. $table = Database :: get_course_table(TABLE_GROUP);
  46. $usage[] = array(
  47. get_lang(ucfirst(TOOL_GROUP)),
  48. CourseManager::count_rows_course_table($table, $session_id, $courseId)
  49. );
  50. // Calendar
  51. $table = Database :: get_course_table(TABLE_AGENDA);
  52. $usage[] = array(
  53. get_lang(ucfirst(TOOL_CALENDAR_EVENT)),
  54. CourseManager::count_rows_course_table($table, $session_id, $courseId)
  55. );
  56. // Link
  57. $table = Database::get_course_table(TABLE_LINK);
  58. $usage[] = array(
  59. get_lang(ucfirst(TOOL_LINK)),
  60. CourseManager::count_rows_course_table($table, $session_id, $courseId)
  61. );
  62. // Announcements
  63. $table = Database::get_course_table(TABLE_ANNOUNCEMENT);
  64. $usage[] = array(
  65. get_lang(ucfirst(TOOL_ANNOUNCEMENT)),
  66. CourseManager::count_rows_course_table($table, $session_id, $courseId)
  67. );
  68. return $usage;
  69. }
  70. $interbreadcrumb[] = array('url' => Container::getRouter()->generate('administration') , "name" => get_lang('PlatformAdmin'));
  71. $interbreadcrumb[] = array("url" => 'course_list.php', "name" => get_lang('Courses'));
  72. $courseId = $courseInfo['real_id'];
  73. $tool_name = $courseInfo['title'].' ('.$courseInfo['visual_code'].')';
  74. Display::display_header($tool_name);
  75. ?>
  76. <div class="actions">
  77. <a href="<?php echo $courseInfo['course_public_url']; ?>">
  78. <?php Display::display_icon('home.png', get_lang('CourseHomepage'), array(), ICON_SIZE_MEDIUM); ?>
  79. </a>
  80. </div>
  81. <?php
  82. echo Display::page_header(get_lang('CourseUsage'));
  83. $table = new SortableTableFromArray(get_course_usage($courseInfo, $sessionId), 0, 20, 'usage_table');
  84. $table->set_additional_parameters(array('code' => $courseInfo['code']));
  85. $table->set_other_tables(array('user_table', 'class_table'));
  86. $table->set_header(0, get_lang('Tool'), true);
  87. $table->set_header(1, get_lang('NumberOfItems'), true);
  88. $table->display();
  89. /**
  90. * Show all users subscribed in this course
  91. */
  92. echo Display::page_header(get_lang('Users'));
  93. $table_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
  94. $table_user = Database :: get_main_table(TABLE_MAIN_USER);
  95. $sql = "SELECT *, cu.status as course_status
  96. FROM $table_course_user cu, $table_user u";
  97. if (api_is_multiple_url_enabled()) {
  98. $sql .= " INNER JOIN ".Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER)." url_rel_user
  99. ON
  100. u.user_id = url_rel_user.user_id AND
  101. url_rel_user.access_url_id = ".api_get_current_access_url_id();
  102. }
  103. $sql .= " WHERE
  104. cu.user_id = u.user_id AND
  105. cu.c_id = '".$courseId."' AND
  106. cu.relation_type <> ".COURSE_RELATION_TYPE_RRHH;
  107. $res = Database::query($sql);
  108. $is_western_name_order = api_is_western_name_order();
  109. if (Database::num_rows($res) > 0) {
  110. $users = array();
  111. while ($obj = Database::fetch_object($res)) {
  112. $user = array();
  113. $user[] = $obj->official_code;
  114. if ($is_western_name_order) {
  115. $user[] = $obj->firstname;
  116. $user[] = $obj->lastname;
  117. } else {
  118. $user[] = $obj->lastname;
  119. $user[] = $obj->firstname;
  120. }
  121. $user[] = Display :: encrypted_mailto_link($obj->email, $obj->email);
  122. $user[] = $obj->course_status == 5 ? get_lang('Student') : get_lang('Teacher');
  123. $user[] = '<a href="user_information.php?user_id='.$obj->user_id.'">'.
  124. Display::return_icon('synthese_view.gif', get_lang('UserInfo')).'</a>';
  125. $users[] = $user;
  126. }
  127. $table = new SortableTableFromArray($users, 0, 20, 'user_table');
  128. $table->set_additional_parameters(array('code' => $courseInfo['code']));
  129. $table->set_other_tables(array('usage_table', 'class_table'));
  130. $table->set_header(0, get_lang('OfficialCode'), true);
  131. if ($is_western_name_order) {
  132. $table->set_header(1, get_lang('FirstName'), true);
  133. $table->set_header(2, get_lang('LastName'), true);
  134. } else {
  135. $table->set_header(1, get_lang('LastName'), true);
  136. $table->set_header(2, get_lang('FirstName'), true);
  137. }
  138. $table->set_header(3, get_lang('Email'), true);
  139. $table->set_header(4, get_lang('Status'), true);
  140. $table->set_header(5, '', false);
  141. $table->display();
  142. } else {
  143. echo get_lang('NoUsersInCourse');
  144. }
  145. $sessionList = SessionManager::get_session_by_course($courseInfo['real_id']);
  146. $url = api_get_path(WEB_CODE_PATH);
  147. if (!empty($sessionList)) {
  148. foreach ($sessionList as &$session) {
  149. $session[0] = Display::url($session[0], $url.'session/resume_session.php?id_session='.$session['id']);
  150. unset($session[1]);
  151. }
  152. echo Display::page_header(get_lang('Sessions'));
  153. $table = new SortableTableFromArray($sessionList, 0, 20, 'user_table');
  154. $table->display();
  155. }
  156. Display::display_footer();