gradebook_display_summary.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. use ChamiloSession as Session;
  4. /**
  5. * Script
  6. * @package chamilo.gradebook
  7. */
  8. require_once __DIR__.'/../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. $cats = Category::load($cat_id, null, null, null, null, null, false);
  29. $session_id = api_get_session_id();
  30. if (empty($session_id)) {
  31. $statusToFilter = STUDENT;
  32. } else {
  33. $statusToFilter = 0;
  34. }
  35. $studentList = CourseManager::get_user_list_from_course_code(
  36. api_get_course_id(),
  37. $session_id,
  38. null,
  39. null,
  40. $statusToFilter
  41. );
  42. $tpl = new Template('', false, false, false);
  43. $courseInfo = api_get_course_info();
  44. $params = array(
  45. 'pdf_title' => sprintf(get_lang('GradeFromX'), $courseInfo['name']),
  46. 'session_info' => '',
  47. 'course_info' => '',
  48. 'pdf_date' => '',
  49. 'course_code' => api_get_course_id(),
  50. 'student_info' => null,
  51. 'show_grade_generated_date' => true,
  52. 'show_real_course_teachers' => false,
  53. 'show_teacher_as_myself' => false
  54. );
  55. $pdf = new PDF('A4', $params['orientation'], $params, $tpl);
  56. foreach ($userList as $index => $value) {
  57. $pdfList[] = GradebookUtils::generateTable(
  58. $value['user_id'],
  59. $cats,
  60. false,
  61. true,
  62. $studentList,
  63. $pdf
  64. );
  65. }
  66. if (!empty($pdfList)) {
  67. // Print certificates (without the common header/footer/watermark
  68. // stuff) and return as one multiple-pages PDF
  69. $address = api_get_setting('institution_address');
  70. $phone = api_get_setting('administratorTelephone');
  71. $address = str_replace('\n', '<br />', $address);
  72. $pdf->custom_header = array('html' => "<h5 align='right'>$address <br />$phone</h5>");
  73. // stuff) and return as one multiple-pages PDF
  74. $pdf->html_to_pdf(
  75. $pdfList,
  76. null,
  77. null,
  78. false,
  79. true,
  80. true
  81. );
  82. }
  83. // Delete calc_score session data
  84. Session::erase('calc_score');
  85. break;
  86. case 'download':
  87. $userId = isset($_GET['user_id']) && $_GET['user_id'] ? $_GET['user_id'] : null;
  88. $cats = Category::load($cat_id, null, null, null, null, null, false);
  89. GradebookUtils::generateTable($userId, $cats);
  90. break;
  91. }
  92. $course_code = api_get_course_id();
  93. $interbreadcrumb[] = array('url' => Security::remove_XSS($_SESSION['gradebook_dest']).'?', 'name' => get_lang('Gradebook'));
  94. $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('GradebookListOfStudentsReports'));
  95. $this_section = SECTION_COURSES;
  96. Display::display_header('');
  97. $token = Security::get_token();
  98. echo Display::page_header(get_lang('GradebookListOfStudentsReports'));
  99. echo '<div class="btn-group">';
  100. if (count($userList) > 0) {
  101. $url = api_get_self().'?action=export_all&'.api_get_cidreq().'&selectcat='.$cat_id;
  102. echo Display::url(get_lang('ExportAllToPDF'), $url, array('class' => 'btn btn-default'));
  103. }
  104. echo '</div>';
  105. if (count($userList) == 0) {
  106. echo Display::return_message(get_lang('NoResultsAvailable'), 'warning');
  107. } else {
  108. echo '<br /><br /><table class="data_table">';
  109. foreach ($userList as $index => $value) {
  110. echo '<tr>
  111. <td width="100%" >'.
  112. get_lang('Student').' : '.api_get_person_name($value['firstname'], $value['lastname']).' ('.$value['username'].') </td>';
  113. echo '<td>';
  114. $url = api_get_self().'?'.api_get_cidreq().'&action=download&user_id='.$value['user_id'].'&selectcat='.$cat_id;
  115. $link = Display::url(
  116. get_lang('ExportToPDF'),
  117. $url,
  118. array('target' => '_blank', 'class' => 'btn btn-default')
  119. );
  120. echo $link;
  121. echo '</td></tr>';
  122. }
  123. echo '</table>';
  124. }
  125. Display::display_footer();