user_stats.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
  20. api_block_anonymous_users();
  21. block_students();
  22. $interbreadcrumb[]= array (
  23. 'url' => $_SESSION['gradebook_dest'],
  24. 'name' => get_lang('Gradebook'
  25. ));
  26. $category= Category :: load(0);
  27. $my_user_id=Security::remove_XSS($_GET['userid']);
  28. $allevals= $category[0]->get_evaluations($my_user_id, true);
  29. $alllinks= $category[0]->get_links($my_user_id, true);
  30. if ($_GET['selectcat'] != null) {
  31. $addparams= array (
  32. 'userid' => $my_user_id,
  33. 'selectcat' => Security::remove_XSS($_GET['selectcat'])
  34. );
  35. } else {
  36. $addparams= array (
  37. 'userid' => $my_user_id,
  38. 'selecteval' => Security::remove_XSS($_GET['selecteval'])
  39. );
  40. }
  41. $user_table= new UserTable($my_user_id, $allevals, $alllinks, $addparams);
  42. if (isset ($_GET['exportpdf'])) {
  43. $datagen = new UserDataGenerator($my_user_id, $allevals,$alllinks);
  44. $data_array = $datagen->get_data(UserDataGenerator :: UDG_SORT_NAME, 0, null, true);
  45. $newarray = array ();
  46. $displayscore = Scoredisplay :: instance();
  47. $newitem = array ();
  48. foreach ($data_array as $data) {
  49. $newarray[] = array_slice($data, 1);
  50. }
  51. $userinfo = get_user_info_from_id($my_user_id);
  52. $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) .')';
  53. if ($displayscore->is_custom()) {
  54. $header_names= array (
  55. get_lang('Evaluation'), get_lang('Course'), get_lang('Category'), get_lang('EvaluationAverage'),get_lang('Result'),get_lang('Display'));
  56. } else {
  57. $header_names= array (
  58. get_lang('Evaluation'), get_lang('Course'), get_lang('Category'), get_lang('EvaluationAverage'),get_lang('Result'));
  59. }
  60. $table = new HTML_Table(array('class' => 'data_table'));
  61. $row = 0;
  62. $column = 0;
  63. foreach ($header_names as $item) {
  64. $table->setHeaderContents($row, $column, $item);
  65. $column++;
  66. }
  67. $row = 1;
  68. if (!empty($newarray)) {
  69. foreach ($newarray as $data) {
  70. $column = 0;
  71. $table->setCellContents($row, $column, $data);
  72. $table->updateCellAttributes($row, $column, 'align="center"');
  73. $column++;
  74. $row++;
  75. }
  76. }
  77. $html .= $table->toHtml();
  78. require_once api_get_path(LIBRARY_PATH).'pdf.lib.php';
  79. $pdf = new PDF();
  80. $pdf->content_to_pdf($html);
  81. exit;
  82. }
  83. $actions = '<div class="actions">';
  84. if (isset ($_GET['selectcat'])) {
  85. $interbreadcrumb[]= array ('url' => 'gradebook_flatview.php?selectcat=' . Security::remove_XSS($_GET['selectcat']), 'name' => get_lang('FlatView'));
  86. $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>';
  87. }
  88. if (isset ($_GET['selecteval'])) {
  89. $interbreadcrumb[]= array (
  90. 'url' => 'gradebook_view_result.php?selecteval=' . Security::remove_XSS($_GET['selecteval']),
  91. 'name' => get_lang('ViewResult'
  92. ));
  93. $actions.= '<a href=gradebook_view_result.php?selecteval=' . Security::remove_XSS($_GET['selecteval']) . '>
  94. '.Display::return_icon('back.png', get_lang('BackToEvaluation'),'','32').'</a>';
  95. }
  96. $actions.= '<a href="' . api_get_self() . '?exportpdf=&userid='.Security::remove_XSS($_GET['userid']).'&selectcat=' . $category[0]->get_id() . '" target="_blank">
  97. ' . Display::return_icon('pdf.png', get_lang('ExportPDF'),'','32').'</a>';
  98. $actions.='</div>';
  99. Display :: display_header(get_lang('ResultsPerUser'));
  100. DisplayGradebook :: display_header_user($_GET['userid']);
  101. echo $actions;
  102. $user_table->display();
  103. Display :: display_footer();