user_stats.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php // $Id: $
  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).'ezpdf/class.ezpdf.php');
  14. require_once (api_get_path(LIBRARY_PATH).'usermanager.lib.php');
  15. api_block_anonymous_users();
  16. block_students();
  17. $interbreadcrumb[]= array (
  18. 'url' => $_SESSION['gradebook_dest'],
  19. 'name' => get_lang('Gradebook'
  20. ));
  21. $category= Category :: load(0);
  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. $pdf= new Cezpdf();
  39. $pdf->selectFont(api_get_path(LIBRARY_PATH).'ezpdf/fonts/Courier.afm');
  40. $pdf->ezSetMargins(30, 30, 50, 30);
  41. $pdf->ezSetY(800);
  42. $datagen= new UserDataGenerator($my_user_id, $allevals,$alllinks);
  43. $data_array= $datagen->get_data(UserDataGenerator :: UDG_SORT_NAME, 0, null, true);
  44. $newarray= array ();
  45. $displayscore= Scoredisplay :: instance();
  46. $newitem= array ();
  47. foreach ($data_array as $data) {
  48. $newarray[] = array_slice($data, 1);
  49. }
  50. $pdf->ezSetY(810);
  51. $userinfo = get_user_info_from_id($my_user_id);
  52. $pdf->ezText(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) .')', 12, array('justification'=>'center'));
  53. $pdf->line(50,790,550,790);
  54. $pdf->line(50,40,550,40);
  55. $pdf->ezSetY(750);
  56. if ($displayscore->is_custom()) {
  57. $header_names= array (
  58. get_lang('Evaluation'
  59. ), get_lang('Course'), get_lang('Category'), get_lang('EvaluationAverage'),get_lang('Result'),get_lang('Display'));
  60. } else {
  61. $header_names= array (
  62. get_lang('Evaluation'
  63. ), get_lang('Course'), get_lang('Category'), get_lang('EvaluationAverage'),get_lang('Result'));
  64. }
  65. $pdf->ezTable($newarray, $header_names, '', array (
  66. 'showHeadings' => 1,
  67. 'shaded' => 1,
  68. 'showLines' => 1,
  69. 'rowGap' => 3,
  70. 'width' => 500
  71. ));
  72. $pdf->ezStream();
  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')).get_lang('BackTo').' '.get_lang('FlatView').'</a>&nbsp&nbsp';
  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']) . '><img src=../img/lp_leftarrow.gif alt=' . get_lang('BackToEvaluation') . ' align=absmiddle/> ' . get_lang('BackToEvaluation') . '</a>&nbsp&nbsp';
  86. }
  87. $actions.= '<a href="' . api_get_self() . '?exportpdf=&userid='.Security::remove_XSS($_GET['userid']).'&selectcat=' . $category[0]->get_id() . '" target="_blank"><img src=../img/file_pdf.gif alt=' . get_lang('ExportPDF') . '/> ' . get_lang('ExportPDF') . '</a>';
  88. $actions.='</div>';
  89. Display :: display_header(get_lang('ResultsPerUser'));
  90. DisplayGradebook :: display_header_user(Security::remove_XSS($_GET['userid']));
  91. echo $actions;
  92. $user_table->display();
  93. Display :: display_footer();