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