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