course_information.php 6.9 KB

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