gradebook_display_summary.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Script
  5. * @package chamilo.gradebook
  6. */
  7. $language_file = 'gradebook';
  8. require_once '../inc/global.inc.php';
  9. $current_course_tool = TOOL_GRADEBOOK;
  10. api_protect_course_script();
  11. set_time_limit(0);
  12. ini_set('max_execution_time', 0);
  13. api_block_anonymous_users();
  14. if (!api_is_allowed_to_edit()) {
  15. api_not_allowed(true);
  16. }
  17. $cat_id = isset($_GET['selectcat']) ? (int)$_GET['selectcat'] : null;
  18. $action = isset($_GET['action']) && $_GET['action'] ? $_GET['action'] : null;
  19. $userList = CourseManager::get_user_list_from_course_code(
  20. api_get_course_id(),
  21. api_get_session_id()
  22. );
  23. switch ($action) {
  24. case 'export_all':
  25. $params = array();
  26. $pdf = new PDF('A4', 'P', $params);
  27. $pdfList = array();
  28. foreach ($userList as $index => $value) {
  29. $pdfList[] = GradebookUtils::generateTable(
  30. $value['user_id'],
  31. $cat_id,
  32. false,
  33. true
  34. );
  35. }
  36. if (!empty($pdfList)) {
  37. // Print certificates (without the common header/footer/watermark
  38. // stuff) and return as one multiple-pages PDF
  39. $pdf->html_to_pdf(
  40. $pdfList,
  41. null,
  42. null,
  43. false,
  44. false,
  45. true
  46. );
  47. }
  48. break;
  49. case 'download':
  50. $userId = isset($_GET['user_id']) && $_GET['user_id'] ? $_GET['user_id'] : null;
  51. GradebookUtils::generateTable($userId, $cat_id);
  52. break;
  53. /*case 'generate_all_certificates':
  54. $user_list = CourseManager::get_user_list_from_course_code(api_get_course_id(), api_get_session_id());
  55. if (!empty($user_list)) {
  56. foreach ($user_list as $user_info) {
  57. if ($user_info['status'] == INVITEE) {
  58. continue;
  59. }
  60. Category::register_user_certificate($cat_id, $user_info['user_id']);
  61. }
  62. }
  63. break;
  64. case 'delete_all_certificates':
  65. Category::deleteAllCertificates($cat_id);
  66. break;*/
  67. }
  68. $course_code = api_get_course_id();
  69. $interbreadcrumb[] = array('url' => Security::remove_XSS($_SESSION['gradebook_dest']).'?', 'name' => get_lang('Gradebook'));
  70. $interbreadcrumb[] = array('url' => '#','name' => get_lang('GradebookListOfStudentsReports'));
  71. $this_section = SECTION_COURSES;
  72. Display::display_header('');
  73. $token = Security::get_token();
  74. echo Display::page_header(get_lang('GradebookListOfStudentsReports'));
  75. echo '<div class="btn-group">';
  76. /*$url = api_get_self().'?action=generate_all_certificates'.'&'.api_get_cidReq().'&selectcat='.$cat_id;
  77. echo Display::url(get_lang('GenerateCertificates'), $url, array('class' => 'btn'));
  78. */
  79. /*$url = api_get_self().'?action=delete_all_certificates'.'&'.api_get_cidReq().'&selectcat='.$cat_id;
  80. echo Display::url(get_lang('DeleteAllCertificates'), $url, array('class' => 'btn'));*/
  81. if (count($userList) > 0) {
  82. $url = api_get_self().'?action=export_all&'.api_get_cidReq().'&selectcat='.$cat_id;
  83. echo Display::url(get_lang('ExportAllToPDF'), $url, array('class' => 'btn btn-default'));
  84. }
  85. echo '</div>';
  86. if (count($userList) == 0 ) {
  87. echo Display::display_warning_message(get_lang('NoResultsAvailable'));
  88. } else {
  89. echo '<br /><br /><table class="data_table">';
  90. foreach ($userList as $index => $value) {
  91. echo '<tr>
  92. <td width="100%" >'.
  93. get_lang('Student').' : '.api_get_person_name($value['firstname'], $value['lastname']).' ('.$value['username'].') </td>';
  94. echo '<td>';
  95. $url = api_get_self().'?'.api_get_cidreq().'&action=download&user_id='.$value['user_id'].'&selectcat='.$cat_id;
  96. $link = Display::url(
  97. get_lang('ExportToPDF'),
  98. $url,
  99. array('target' => '_blank', 'class' => 'btn btn-default')
  100. );
  101. echo $link;
  102. echo '</td></tr>';
  103. }
  104. echo '</table>';
  105. }
  106. Display::display_footer();