user_stats.php 4.0 KB

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