course_information.php 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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. $cidReset = true;
  9. require_once '../inc/global.inc.php';
  10. $this_section = SECTION_PLATFORM_ADMIN;
  11. api_protect_admin_script();
  12. /**
  13. *
  14. */
  15. function get_course_usage($course_code, $session_id = 0)
  16. {
  17. $table = Database::get_main_table(TABLE_MAIN_COURSE);
  18. $course_code = Database::escape_string($course_code);
  19. $sql = "SELECT * FROM $table WHERE code='".$course_code."'";
  20. $res = Database::query($sql);
  21. $course = Database::fetch_object($res);
  22. // Learnpaths
  23. $table = Database :: get_course_table(TABLE_LP_MAIN);
  24. $usage[] = array(
  25. get_lang(ucfirst(TOOL_LEARNPATH)),
  26. CourseManager::count_rows_course_table($table, $session_id, $course->id)
  27. );
  28. // Forums
  29. $table = Database :: get_course_table(TABLE_FORUM);
  30. $usage[] = array(get_lang('Forums'), CourseManager::count_rows_course_table($table, $session_id, $course->id));
  31. // Quizzes
  32. $table = Database :: get_course_table(TABLE_QUIZ_TEST);
  33. $usage[] = array(
  34. get_lang(ucfirst(TOOL_QUIZ)),
  35. CourseManager::count_rows_course_table($table, $session_id, $course->id)
  36. );
  37. // Documents
  38. $table = Database :: get_course_table(TABLE_DOCUMENT);
  39. $usage[] = array(
  40. get_lang(ucfirst(TOOL_DOCUMENT)),
  41. CourseManager::count_rows_course_table($table, $session_id, $course->id)
  42. );
  43. // Groups
  44. $table = Database :: get_course_table(TABLE_GROUP);
  45. $usage[] = array(
  46. get_lang(ucfirst(TOOL_GROUP)),
  47. CourseManager::count_rows_course_table($table, $session_id, $course->id)
  48. );
  49. // Calendar
  50. $table = Database :: get_course_table(TABLE_AGENDA);
  51. $usage[] = array(
  52. get_lang(ucfirst(TOOL_CALENDAR_EVENT)),
  53. CourseManager::count_rows_course_table($table, $session_id, $course->id)
  54. );
  55. // Link
  56. $table = Database::get_course_table(TABLE_LINK);
  57. $usage[] = array(
  58. get_lang(ucfirst(TOOL_LINK)),
  59. CourseManager::count_rows_course_table($table, $session_id, $course->id)
  60. );
  61. // Announcements
  62. $table = Database::get_course_table(TABLE_ANNOUNCEMENT);
  63. $usage[] = array(
  64. get_lang(ucfirst(TOOL_ANNOUNCEMENT)),
  65. CourseManager::count_rows_course_table($table, $session_id, $course->id)
  66. );
  67. return $usage;
  68. }
  69. if (!isset ($_GET['code'])) {
  70. api_not_allowed();
  71. }
  72. $interbreadcrumb[] = array("url" => 'index.php', "name" => get_lang('PlatformAdmin'));
  73. $interbreadcrumb[] = array("url" => 'course_list.php', "name" => get_lang('Courses'));
  74. $table_course = Database :: get_main_table(TABLE_MAIN_COURSE);
  75. $code = Database::escape_string($_GET['code']);
  76. $sql = "SELECT * FROM $table_course WHERE code = '".$code."'";
  77. $res = Database::query($sql);
  78. $course = Database::fetch_object($res);
  79. $courseId = $course->id;
  80. $tool_name = $course->title.' ('.$course->visual_code.')';
  81. Display::display_header($tool_name);
  82. ?>
  83. <div class="actions">
  84. <a href="<?php echo api_get_path(WEB_COURSE_PATH).$course->directory; ?>">
  85. <?php Display::display_icon('home.png', get_lang('CourseHomepage'), array(), ICON_SIZE_MEDIUM); ?>
  86. </a>
  87. </div>
  88. <?php
  89. echo Display::page_header(get_lang('CourseUsage'));
  90. $id_session = isset($_GET['id_session']) ? $_GET['id_session'] : 0;
  91. $table = new SortableTableFromArray(get_course_usage($course->code, $id_session), 0, 20, 'usage_table');
  92. $table->set_additional_parameters(array('code' => Security::remove_XSS($_GET['code'])));
  93. $table->set_other_tables(array('user_table', 'class_table'));
  94. $table->set_header(0, get_lang('Tool'), true);
  95. $table->set_header(1, get_lang('NumberOfItems'), true);
  96. $table->display();
  97. /**
  98. * Show all users subscribed in this course
  99. */
  100. echo Display::page_header(get_lang('Users'));
  101. $table_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
  102. $table_user = Database :: get_main_table(TABLE_MAIN_USER);
  103. $sql = "SELECT *, cu.status as course_status
  104. FROM $table_course_user cu, $table_user u";
  105. if (api_is_multiple_url_enabled()) {
  106. $sql .= " INNER JOIN ".Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER)." url_rel_user
  107. ON u.user_id = url_rel_user.user_id
  108. AND url_rel_user.access_url_id = ".intval(api_get_current_access_url_id());
  109. }
  110. $sql .= " WHERE
  111. cu.user_id = u.user_id AND
  112. cu.c_id = '".$courseId."' AND
  113. cu.relation_type <> ".COURSE_RELATION_TYPE_RRHH;
  114. $res = Database::query($sql);
  115. $is_western_name_order = api_is_western_name_order();
  116. if (Database::num_rows($res) > 0) {
  117. $users = array();
  118. while ($obj = Database::fetch_object($res)) {
  119. $user = array();
  120. $user[] = $obj->official_code;
  121. if ($is_western_name_order) {
  122. $user[] = $obj->firstname;
  123. $user[] = $obj->lastname;
  124. } else {
  125. $user[] = $obj->lastname;
  126. $user[] = $obj->firstname;
  127. }
  128. $user[] = Display :: encrypted_mailto_link($obj->email, $obj->email);
  129. $user[] = $obj->course_status == 5 ? get_lang('Student') : get_lang('Teacher');
  130. $user[] = '<a href="user_information.php?user_id='.$obj->user_id.'">'.Display::return_icon('synthese_view.gif', get_lang('UserInfo')).'</a>';
  131. $users[] = $user;
  132. }
  133. $table = new SortableTableFromArray($users, 0, 20, 'user_table');
  134. $table->set_additional_parameters(array('code' => $code));
  135. $table->set_other_tables(array('usage_table', 'class_table'));
  136. $table->set_header(0, get_lang('OfficialCode'), true);
  137. if ($is_western_name_order) {
  138. $table->set_header(1, get_lang('FirstName'), true);
  139. $table->set_header(2, get_lang('LastName'), true);
  140. } else {
  141. $table->set_header(1, get_lang('LastName'), true);
  142. $table->set_header(2, get_lang('FirstName'), true);
  143. }
  144. $table->set_header(3, get_lang('Email'), true);
  145. $table->set_header(4, get_lang('Status'), true);
  146. $table->set_header(5, '', false);
  147. $table->display();
  148. } else {
  149. echo get_lang('NoUsersInCourse');
  150. }
  151. $session_list = SessionManager::get_session_by_course($course->id);
  152. $url = api_get_path(WEB_CODE_PATH);
  153. if (!empty($session_list)) {
  154. foreach ($session_list as &$session) {
  155. $session[0] = Display::url($session[0], $url.'admin/resume_session.php?id_session='.$session['id']);
  156. unset($session[1]);
  157. }
  158. echo Display::page_header(get_lang('Sessions'));
  159. $table = new SortableTableFromArray($session_list, 0, 20, 'user_table');
  160. $table->display();
  161. }
  162. /*$group = new UserGroup();
  163. $usegroups = $group->get_usergroup_by_course($course->id);*/
  164. /*@todo This should be dissapear classes are a deprecated feature*/
  165. /*
  166. //Show all classes subscribed in this course
  167. $table_course_class = Database :: get_main_table(TABLE_MAIN_COURSE_CLASS);
  168. $table_class = Database :: get_main_table(TABLE_MAIN_CLASS);
  169. $sql = "SELECT * FROM $table_course_class cc, $table_class c WHERE cc.class_id = c.id AND cc.course_code = '".$code."'";
  170. $res = Database::query($sql);
  171. if (Database::num_rows($res) > 0) {
  172. $data = array ();
  173. while ($class = Database::fetch_object($res)) {
  174. $row = array ();
  175. $row[] = $class->name;
  176. $row[] = '<a href="class_information.php?id='.$class->id.'">'.Display::return_icon('synthese_view.gif', get_lang('Edit')).'</a>';
  177. $data[] = $row;
  178. }
  179. echo '<p><b>'.get_lang('AdminClasses').'</b></p>';
  180. echo '<blockquote>';
  181. $table = new SortableTableFromArray($data,0,20,'class_table');
  182. $table->set_additional_parameters(array ('code' => $_GET['code']));
  183. $table->set_other_tables(array('usage_table','user_table'));
  184. $table->set_header(0,get_lang('Title'));
  185. $table->set_header(1,'');
  186. $table->display();
  187. echo '</blockquote>';
  188. } else {
  189. echo '<p>'.get_lang('NoClassesForThisCourse').'</p>';
  190. }*/
  191. /* FOOTER */
  192. Display::display_footer();