course_information.php 6.6 KB

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