gradebook_statistics.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php // $Id: $
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2008 Dokeos Latinoamerica SAC
  6. Copyright (c) 2006 Dokeos SPRL
  7. Copyright (c) 2006 Ghent University (UGent)
  8. Copyright (c) various contributors
  9. For a full list of contributors, see "credits.txt".
  10. The full license can be read in "license.txt".
  11. This program is free software; you can redistribute it and/or
  12. modify it under the terms of the GNU General Public License
  13. as published by the Free Software Foundation; either version 2
  14. of the License, or (at your option) any later version.
  15. See the GNU General Public License for more details.
  16. Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
  17. Mail: info@dokeos.com
  18. ==============================================================================
  19. */
  20. $language_file= 'gradebook';
  21. //$cidReset= true;
  22. require_once ('../inc/global.inc.php');
  23. require_once ('lib/be.inc.php');
  24. require_once ('lib/gradebook_functions.inc.php');
  25. require_once ('lib/fe/dataform.class.php');
  26. require_once ('lib/scoredisplay.class.php');
  27. require_once ('lib/fe/displaygradebook.php');
  28. api_block_anonymous_users();
  29. $eval= Evaluation :: load($_GET['selecteval']);
  30. if ($eval[0]->get_category_id() < 0) {
  31. // if category id is negative, then the evaluation's origin is a link
  32. $link= LinkFactory :: get_evaluation_link($eval[0]->get_id());
  33. $currentcat= Category :: load($link->get_category_id());
  34. } else {
  35. $currentcat= Category :: load($eval[0]->get_category_id());
  36. }
  37. $interbreadcrumb[]= array (
  38. 'url' => $_SESSION['gradebook_dest'].'?selectcat=' . $currentcat[0]->get_id(), 'name' => get_lang('Gradebook'));
  39. if (api_is_allowed_to_create_course()){
  40. $interbreadcrumb[]= array (
  41. 'url' => 'gradebook_view_result.php?selecteval=' . Security::remove_XSS($_GET['selecteval']),
  42. 'name' => get_lang('ViewResult'
  43. ));
  44. }
  45. $displayscore= ScoreDisplay :: instance();
  46. Display :: display_header(get_lang('EvaluationStatistics'));
  47. DisplayGradebook :: display_header_result($eval[0], $currentcat[0]->get_id(), 0, 0);
  48. if (!$displayscore->is_custom()) {
  49. //Display :: display_error_message(get_lang('PleaseEnableScoringSystem'),false);
  50. } else {
  51. $displays= $displayscore->get_custom_score_display_settings();
  52. $allresults = Result :: load(null,null,$eval[0]->get_id());
  53. $nr_items = array();
  54. foreach ($displays as $itemsdisplay) {
  55. $nr_items[$itemsdisplay['display']] = 0;
  56. }
  57. $resultcount = 0;
  58. foreach ($allresults as $result) {
  59. $score = $result->get_score();
  60. if (isset($score)) {
  61. $display = $displayscore->display_score(array($score, $eval[0]->get_max()),SCORE_DIV | SCORE_IGNORE_SPLIT, SCORE_ONLY_CUSTOM);
  62. $nr_items[$display] ++;
  63. $resultcount ++;
  64. }
  65. }
  66. $keys = array_keys($nr_items);
  67. // find the region with the most scores, this is 100% of the bar
  68. $highest_ratio = 0;
  69. foreach ($keys as $key) {
  70. if ($nr_items[$key] > $highest_ratio){
  71. $highest_ratio = $nr_items[$key];
  72. }
  73. }
  74. // generate table
  75. $stattable= '<br><table class="data_table" cellspacing="0" cellpadding="3">';
  76. $stattable .= '<tr><th colspan="4">' . get_lang('Statistics') . '</th></tr>';
  77. $counter=0;
  78. foreach ($keys as $key) {
  79. $bar = ($nr_items[$key] / $highest_ratio) * 100;
  80. $stattable .= '<tr class="row_' . ($counter % 2 == 0 ? 'odd' : 'even') . '">';
  81. $stattable .= '<td width="150">' . $key . '</td>';
  82. $stattable .= '<td width="550"><img src="../img/bar_1u.gif" width="' . $bar . '%" height="10"/></td>';
  83. $stattable .= '<td align="right">' . $nr_items[$key] . '</td>';
  84. $stattable .= '<td align="right"> ' . round(($nr_items[$key] / $resultcount) * 100,2) . '%</td>';
  85. $counter++;
  86. }
  87. $stattable .= '</tr></table>';
  88. echo $stattable;
  89. }
  90. Display :: display_footer();