user_stats.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Script
  5. * @package chamilo.gradebook
  6. */
  7. /**
  8. * Init
  9. */
  10. $language_file= 'gradebook';
  11. require_once '../inc/global.inc.php';
  12. require_once 'lib/be.inc.php';
  13. require_once 'lib/gradebook_functions.inc.php';
  14. require_once 'lib/fe/userform.class.php';
  15. require_once 'lib/user_data_generator.class.php';
  16. require_once 'lib/fe/usertable.class.php';
  17. require_once 'lib/fe/displaygradebook.php';
  18. require_once 'lib/scoredisplay.class.php';
  19. api_block_anonymous_users();
  20. block_students();
  21. $interbreadcrumb[]= array (
  22. 'url' => $_SESSION['gradebook_dest'],
  23. 'name' => get_lang('Gradebook'
  24. ));
  25. $category = Category :: load($_GET['selectcat']);
  26. $my_user_id=Security::remove_XSS($_GET['userid']);
  27. $allevals= $category[0]->get_evaluations($my_user_id, true);
  28. $alllinks= $category[0]->get_links($my_user_id, true);
  29. if ($_GET['selectcat'] != null) {
  30. $addparams= array (
  31. 'userid' => $my_user_id,
  32. 'selectcat' => Security::remove_XSS($_GET['selectcat'])
  33. );
  34. } else {
  35. $addparams= array (
  36. 'userid' => $my_user_id,
  37. 'selecteval' => Security::remove_XSS($_GET['selecteval'])
  38. );
  39. }
  40. $user_table= new UserTable($my_user_id, $allevals, $alllinks, $addparams);
  41. if (isset ($_GET['exportpdf'])) {
  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. foreach ($data_array as $data) {
  47. $newarray[] = array_slice($data, 1);
  48. }
  49. $userinfo = api_get_user_info($my_user_id);
  50. $html .= get_lang('Results').' : '.$userinfo['complete_name'].' ('. api_convert_and_format_date(null, DATE_FORMAT_SHORT). ' ' . api_convert_and_format_date(null, TIME_NO_SEC_FORMAT) .')';
  51. if ($displayscore->is_custom()) {
  52. $header_names= array (
  53. get_lang('Evaluation'), get_lang('Course'), get_lang('Category'), get_lang('EvaluationAverage'),get_lang('Result'),get_lang('Display'));
  54. } else {
  55. $header_names= array (
  56. get_lang('Evaluation'), get_lang('Course'), get_lang('Category'), get_lang('EvaluationAverage'),get_lang('Result'));
  57. }
  58. $table = new HTML_Table(array('class' => 'data_table'));
  59. $row = 0;
  60. $column = 0;
  61. foreach ($header_names as $item) {
  62. $table->setHeaderContents($row, $column, $item);
  63. $column++;
  64. }
  65. $row = 1;
  66. if (!empty($newarray)) {
  67. foreach ($newarray as $data) {
  68. $column = 0;
  69. $table->setCellContents($row, $column, $data);
  70. $table->updateCellAttributes($row, $column, 'align="center"');
  71. $column++;
  72. $row++;
  73. }
  74. }
  75. $html .= $table->toHtml();
  76. $pdf = new PDF();
  77. $pdf->content_to_pdf($html);
  78. exit;
  79. }
  80. $actions = '<div class="actions">';
  81. if (isset ($_GET['selectcat'])) {
  82. $interbreadcrumb[]= array ('url' => 'gradebook_flatview.php?selectcat=' . Security::remove_XSS($_GET['selectcat']), 'name' => get_lang('FlatView'));
  83. $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>';
  84. }
  85. if (isset ($_GET['selecteval'])) {
  86. $interbreadcrumb[]= array (
  87. 'url' => 'gradebook_view_result.php?selecteval=' . Security::remove_XSS($_GET['selecteval']),
  88. 'name' => get_lang('ViewResult'
  89. ));
  90. $actions.= '<a href=gradebook_view_result.php?selecteval=' . Security::remove_XSS($_GET['selecteval']) . '>
  91. '.Display::return_icon('back.png', get_lang('BackToEvaluation'),'',ICON_SIZE_MEDIUM).'</a>';
  92. }
  93. $actions.= '<a href="' . api_get_self() . '?exportpdf=&userid='.Security::remove_XSS($_GET['userid']).'&selectcat=' . $category[0]->get_id() . '" target="_blank">
  94. ' . Display::return_icon('pdf.png', get_lang('ExportPDF'),'',ICON_SIZE_MEDIUM).'</a>';
  95. $actions.='</div>';
  96. Display :: display_header(get_lang('ResultsPerUser'));
  97. echo $actions;
  98. DisplayGradebook :: display_header_user($_GET['userid']);
  99. $user_table->display();
  100. Display :: display_footer();