user_stats.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Script.
  5. *
  6. * @package chamilo.gradebook
  7. */
  8. require_once __DIR__.'/../inc/global.inc.php';
  9. api_block_anonymous_users();
  10. $isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(
  11. api_get_user_id(),
  12. api_get_course_info()
  13. );
  14. if (!$isDrhOfCourse) {
  15. GradebookUtils::block_students();
  16. }
  17. $interbreadcrumb[] = [
  18. 'url' => Category::getUrl(),
  19. 'name' => get_lang('Gradebook'),
  20. ];
  21. $category = Category::load($_GET['selectcat']);
  22. $my_user_id = Security::remove_XSS($_GET['userid']);
  23. $allevals = $category[0]->get_evaluations($my_user_id, true);
  24. $alllinks = $category[0]->get_links($my_user_id, true);
  25. if ($_GET['selectcat'] != null) {
  26. $addparams = [
  27. 'userid' => $my_user_id,
  28. 'selectcat' => Security::remove_XSS($_GET['selectcat']),
  29. ];
  30. } else {
  31. $addparams = [
  32. 'userid' => $my_user_id,
  33. 'selecteval' => Security::remove_XSS($_GET['selecteval']),
  34. ];
  35. }
  36. $user_table = new UserTable($my_user_id, $allevals, $alllinks, $addparams);
  37. if (isset($_GET['exportpdf'])) {
  38. $datagen = new UserDataGenerator($my_user_id, $allevals, $alllinks);
  39. $data_array = $datagen->get_data(
  40. UserDataGenerator::UDG_SORT_NAME,
  41. 0,
  42. null,
  43. true
  44. );
  45. $newarray = [];
  46. $displayscore = ScoreDisplay :: instance();
  47. foreach ($data_array as $data) {
  48. $newarray[] = array_slice($data, 1);
  49. }
  50. $userInfo = api_get_user_info($my_user_id);
  51. $html .= get_lang('Results').' : '.$userInfo['complete_name'].' ('.api_convert_and_format_date(null, DATE_FORMAT_SHORT).' '.api_convert_and_format_date(null, TIME_NO_SEC_FORMAT).')';
  52. if ($displayscore->is_custom()) {
  53. $header_names = [
  54. get_lang('Evaluation'),
  55. get_lang('Course'),
  56. get_lang('Category'),
  57. get_lang('EvaluationAverage'),
  58. get_lang('Result'),
  59. get_lang('Display'),
  60. ];
  61. } else {
  62. $header_names = [
  63. get_lang('Evaluation'),
  64. get_lang('Course'),
  65. get_lang('Category'),
  66. get_lang('EvaluationAverage'),
  67. get_lang('Result'),
  68. ];
  69. }
  70. $table = new HTML_Table(['class' => 'data_table']);
  71. $row = 0;
  72. $column = 0;
  73. foreach ($header_names as $item) {
  74. $table->setHeaderContents($row, $column, $item);
  75. $column++;
  76. }
  77. $row = 1;
  78. if (!empty($newarray)) {
  79. foreach ($newarray as $data) {
  80. $column = 0;
  81. $table->setCellContents($row, $column, $data);
  82. $table->updateCellAttributes($row, $column, 'align="center"');
  83. $column++;
  84. $row++;
  85. }
  86. }
  87. $html .= $table->toHtml();
  88. $pdf = new PDF();
  89. $pdf->content_to_pdf($html);
  90. exit;
  91. }
  92. $actions = '<div class="actions">';
  93. if (isset($_GET['selectcat'])) {
  94. $interbreadcrumb[] = [
  95. 'url' => 'gradebook_flatview.php?selectcat='.Security::remove_XSS($_GET['selectcat']),
  96. 'name' => get_lang('FlatView'),
  97. ];
  98. $actions .= '<a href=gradebook_flatview.php?selectcat='.Security::remove_XSS($_GET['selectcat']).'>'.
  99. Display::return_icon(
  100. 'back.png',
  101. get_lang('BackTo').' '.get_lang('FlatView'),
  102. '',
  103. ICON_SIZE_MEDIUM
  104. ).
  105. '</a>';
  106. }
  107. if (isset($_GET['selecteval'])) {
  108. $interbreadcrumb[] = [
  109. 'url' => 'gradebook_view_result.php?selecteval='.Security::remove_XSS($_GET['selecteval']),
  110. 'name' => get_lang('ViewResult'),
  111. ];
  112. $actions .= '<a href=gradebook_view_result.php?selecteval='.Security::remove_XSS($_GET['selecteval']).'>
  113. '.Display::return_icon('back.png', get_lang('BackToEvaluation'), '', ICON_SIZE_MEDIUM).'</a>';
  114. }
  115. $actions .= '<a href="'.api_get_self().'?exportpdf=&userid='.Security::remove_XSS($_GET['userid']).'&selectcat='.$category[0]->get_id().'" target="_blank">
  116. '.Display::return_icon('pdf.png', get_lang('ExportPDF'), '', ICON_SIZE_MEDIUM).'</a>';
  117. $actions .= '</div>';
  118. Display::display_header(get_lang('ResultsPerUser'));
  119. echo $actions;
  120. DisplayGradebook::display_header_user($_GET['userid'], $category[0]->get_id());
  121. $user_table->display();
  122. Display::display_footer();