user_stats.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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'), get_lang('Course'), get_lang('Category'), get_lang('EvaluationAverage'),get_lang('Result'),get_lang('Display'));
  49. } else {
  50. $header_names= array (
  51. get_lang('Evaluation'), get_lang('Course'), get_lang('Category'), get_lang('EvaluationAverage'),get_lang('Result'));
  52. }
  53. $table = new HTML_Table(array('class' => 'data_table'));
  54. $row = 0;
  55. $column = 0;
  56. foreach ($header_names as $item) {
  57. $table->setHeaderContents($row, $column, $item);
  58. $column++;
  59. }
  60. $row = 1;
  61. if (!empty($newarray)) {
  62. foreach ($newarray as $data) {
  63. $column = 0;
  64. $table->setCellContents($row, $column, $data);
  65. $table->updateCellAttributes($row, $column, 'align="center"');
  66. $column++;
  67. $row++;
  68. }
  69. }
  70. $html .= $table->toHtml();
  71. $pdf = new PDF();
  72. $pdf->content_to_pdf($html);
  73. exit;
  74. }
  75. $actions = '<div class="actions">';
  76. if (isset($_GET['selectcat'])) {
  77. $interbreadcrumb[]= array ('url' => 'gradebook_flatview.php?selectcat=' . Security::remove_XSS($_GET['selectcat']), 'name' => get_lang('FlatView'));
  78. $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>';
  79. }
  80. if (isset ($_GET['selecteval'])) {
  81. $interbreadcrumb[]= array (
  82. 'url' => 'gradebook_view_result.php?selecteval=' . Security::remove_XSS($_GET['selecteval']),
  83. 'name' => get_lang('ViewResult'
  84. ));
  85. $actions.= '<a href=gradebook_view_result.php?selecteval=' . Security::remove_XSS($_GET['selecteval']) . '>
  86. '.Display::return_icon('back.png', get_lang('BackToEvaluation'),'',ICON_SIZE_MEDIUM).'</a>';
  87. }
  88. $actions.= '<a href="' . api_get_self() . '?exportpdf=&userid='.Security::remove_XSS($_GET['userid']).'&selectcat=' . $category[0]->get_id() . '" target="_blank">
  89. ' . Display::return_icon('pdf.png', get_lang('ExportPDF'),'',ICON_SIZE_MEDIUM).'</a>';
  90. $actions.='</div>';
  91. Display :: display_header(get_lang('ResultsPerUser'));
  92. echo $actions;
  93. DisplayGradebook :: display_header_user($_GET['userid']);
  94. $user_table->display();
  95. Display :: display_footer();