user_stats.php 4.0 KB

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