user_stats.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Script
  5. * @package chamilo.gradebook
  6. */
  7. require_once '../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' => $_SESSION['gradebook_dest'],
  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(UserDataGenerator :: UDG_SORT_NAME, 0, null, true);
  39. $newarray = array();
  40. $displayscore = ScoreDisplay :: instance();
  41. foreach ($data_array as $data) {
  42. $newarray[] = array_slice($data, 1);
  43. }
  44. $userinfo = api_get_user_info($my_user_id);
  45. $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) .')';
  46. if ($displayscore->is_custom()) {
  47. $header_names = array(
  48. get_lang('Evaluation'),
  49. get_lang('Course'),
  50. get_lang('Category'),
  51. get_lang('EvaluationAverage'),
  52. get_lang('Result'),
  53. get_lang('Display'),
  54. );
  55. } else {
  56. $header_names = array(
  57. get_lang('Evaluation'),
  58. get_lang('Course'),
  59. get_lang('Category'),
  60. get_lang('EvaluationAverage'),
  61. get_lang('Result'),
  62. );
  63. }
  64. $table = new HTML_Table(array('class' => 'data_table'));
  65. $row = 0;
  66. $column = 0;
  67. foreach ($header_names as $item) {
  68. $table->setHeaderContents($row, $column, $item);
  69. $column++;
  70. }
  71. $row = 1;
  72. if (!empty($newarray)) {
  73. foreach ($newarray as $data) {
  74. $column = 0;
  75. $table->setCellContents($row, $column, $data);
  76. $table->updateCellAttributes($row, $column, 'align="center"');
  77. $column++;
  78. $row++;
  79. }
  80. }
  81. $html .= $table->toHtml();
  82. $pdf = new PDF();
  83. $pdf->content_to_pdf($html);
  84. exit;
  85. }
  86. $actions = '<div class="actions">';
  87. if (isset($_GET['selectcat'])) {
  88. $interbreadcrumb[]= array ('url' => 'gradebook_flatview.php?selectcat=' . Security::remove_XSS($_GET['selectcat']), 'name' => get_lang('FlatView'));
  89. $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>';
  90. }
  91. if (isset ($_GET['selecteval'])) {
  92. $interbreadcrumb[]= array (
  93. 'url' => 'gradebook_view_result.php?selecteval=' . Security::remove_XSS($_GET['selecteval']),
  94. 'name' => get_lang('ViewResult'
  95. ));
  96. $actions.= '<a href=gradebook_view_result.php?selecteval=' . Security::remove_XSS($_GET['selecteval']) . '>
  97. '.Display::return_icon('back.png', get_lang('BackToEvaluation'),'',ICON_SIZE_MEDIUM).'</a>';
  98. }
  99. $actions.= '<a href="' . api_get_self() . '?exportpdf=&userid='.Security::remove_XSS($_GET['userid']).'&selectcat=' . $category[0]->get_id() . '" target="_blank">
  100. ' . Display::return_icon('pdf.png', get_lang('ExportPDF'),'',ICON_SIZE_MEDIUM).'</a>';
  101. $actions.='</div>';
  102. Display :: display_header(get_lang('ResultsPerUser'));
  103. echo $actions;
  104. DisplayGradebook :: display_header_user($_GET['userid']);
  105. $user_table->display();
  106. Display :: display_footer();