gradebook_display_summary.php 4.7 KB

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