course_information.php 7.0 KB

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