user_stats.php 4.2 KB

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