gradebook_display_summary.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. use ChamiloSession as Session;
  4. /**
  5. * Script
  6. * @package chamilo.gradebook
  7. */
  8. $current_course_tool = TOOL_GRADEBOOK;
  9. api_protect_course_script();
  10. set_time_limit(0);
  11. ini_set('max_execution_time', 0);
  12. api_block_anonymous_users();
  13. if (!api_is_allowed_to_edit()) {
  14. api_not_allowed(true);
  15. }
  16. $cat_id = isset($_GET['selectcat']) ? (int)$_GET['selectcat'] : null;
  17. $action = isset($_GET['action']) && $_GET['action'] ? $_GET['action'] : null;
  18. $userList = CourseManager::get_user_list_from_course_code(
  19. api_get_course_id(),
  20. api_get_session_id()
  21. );
  22. switch ($action) {
  23. case 'export_all':
  24. $params = array();
  25. $pdf = new PDF('A4', 'P', $params);
  26. $pdfList = array();
  27. $cats = Category::load($cat_id, null, null, null, null, null, false);
  28. $session_id = api_get_session_id();
  29. if (empty($session_id)) {
  30. $statusToFilter = STUDENT;
  31. } else {
  32. $statusToFilter = 0;
  33. }
  34. $studentList = CourseManager::get_user_list_from_course_code(
  35. api_get_course_id(),
  36. $session_id,
  37. null,
  38. null,
  39. $statusToFilter
  40. );
  41. $tpl = new Template('', false, false, false);
  42. $courseInfo = api_get_course_info();
  43. $params = array(
  44. 'pdf_title' => sprintf(get_lang('GradeFromX'), $courseInfo['name']),
  45. 'session_info' => '',
  46. 'course_info' => '',
  47. 'pdf_date' => '',
  48. 'course_code' => api_get_course_id(),
  49. 'add_signatures' => false,
  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('platform.institution_address');
  70. $phone = api_get_setting('admin.administrator_phone');
  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::display_warning_message(get_lang('NoResultsAvailable'));
  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();