user_stats.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. $language_file= 'gradebook';
  4. //$cidReset= true;
  5. require_once '../inc/global.inc.php';
  6. require_once 'lib/be.inc.php';
  7. require_once 'lib/gradebook_functions.inc.php';
  8. require_once 'lib/fe/userform.class.php';
  9. require_once 'lib/user_data_generator.class.php';
  10. require_once 'lib/fe/usertable.class.php';
  11. require_once 'lib/fe/displaygradebook.php';
  12. require_once 'lib/scoredisplay.class.php';
  13. require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
  14. api_block_anonymous_users();
  15. block_students();
  16. $interbreadcrumb[]= array (
  17. 'url' => $_SESSION['gradebook_dest'],
  18. 'name' => get_lang('Gradebook'
  19. ));
  20. $category= Category :: load(0);
  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. $newitem = array ();
  42. foreach ($data_array as $data) {
  43. $newarray[] = array_slice($data, 1);
  44. }
  45. $userinfo = get_user_info_from_id($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. require_once api_get_path(LIBRARY_PATH).'pdf.lib.php';
  73. $pdf = new PDF();
  74. $pdf->content_to_pdf($html);
  75. exit;
  76. }
  77. $actions = '<div class="actions">';
  78. if (isset ($_GET['selectcat'])) {
  79. $interbreadcrumb[]= array ('url' => 'gradebook_flatview.php?selectcat=' . Security::remove_XSS($_GET['selectcat']), 'name' => get_lang('FlatView'));
  80. $actions.= '<a href=gradebook_flatview.php?selectcat=' .Security::remove_XSS($_GET['selectcat']) . '>' . Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('FlatView'),'','32').'</a>';
  81. }
  82. if (isset ($_GET['selecteval'])) {
  83. $interbreadcrumb[]= array (
  84. 'url' => 'gradebook_view_result.php?selecteval=' . Security::remove_XSS($_GET['selecteval']),
  85. 'name' => get_lang('ViewResult'
  86. ));
  87. $actions.= '<a href=gradebook_view_result.php?selecteval=' . Security::remove_XSS($_GET['selecteval']) . '>
  88. '.Display::return_icon('back.png', get_lang('BackToEvaluation'),'','32').'</a>';
  89. }
  90. $actions.= '<a href="' . api_get_self() . '?exportpdf=&userid='.Security::remove_XSS($_GET['userid']).'&selectcat=' . $category[0]->get_id() . '" target="_blank">
  91. ' . Display::return_icon('pdf.png', get_lang('ExportPDF'),'','32').'</a>';
  92. $actions.='</div>';
  93. Display :: display_header(get_lang('ResultsPerUser'));
  94. DisplayGradebook :: display_header_user(Security::remove_XSS($_GET['userid']));
  95. echo $actions;
  96. $user_table->display();
  97. Display :: display_footer();