gradebook_statistics.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <?php
  2. // $Id: gradebook_view_result.php 725 2007-04-24 07:27:11Z stijn $
  3. /*
  4. ==============================================================================
  5. Dokeos - elearning and course management software
  6. Copyright (c) 2006 Dokeos S.A.
  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, 44 rue des palais, B-1030 Brussels, Belgium
  17. Mail: info@dokeos.com
  18. ==============================================================================
  19. */
  20. $language_file= 'gradebook';
  21. $cidReset= true;
  22. include_once ('../inc/global.inc.php');
  23. include_once ('lib/be.inc.php');
  24. include_once ('lib/gradebook_functions.inc.php');
  25. include_once ('lib/fe/dataform.class.php');
  26. include_once ('lib/scoredisplay.class.php');
  27. include_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. {
  32. // if category id is negative, then the evaluation's origin is a link
  33. $link= LinkFactory :: get_evaluation_link($eval[0]->get_id());
  34. $currentcat= Category :: load($link->get_category_id());
  35. } else
  36. $currentcat= Category :: load($eval[0]->get_category_id());
  37. $interbreadcrumb[]= array (
  38. 'url' => 'gradebook.php?selectcat=' . $currentcat[0]->get_id(), 'name' => get_lang('Gradebook'));
  39. if (api_is_allowed_to_create_course())
  40. {
  41. $interbreadcrumb[]= array (
  42. 'url' => 'gradebook_view_result.php?selecteval=' . $_GET['selecteval'],
  43. 'name' => get_lang('ViewResult'
  44. ));
  45. }
  46. $displayscore= ScoreDisplay :: instance();
  47. Display :: display_header(get_lang('EvaluationStatistics'));
  48. DisplayGradebook :: display_header_result($eval[0], $currentcat[0]->get_id(), 0, 0);
  49. if (!$displayscore->is_custom())
  50. Display :: display_error_message(get_lang('PleaseEnableScoringSystem'),false);
  51. else
  52. {
  53. // generate data
  54. $displays= $displayscore->get_custom_score_display_settings();
  55. $allresults = Result :: load(null,null,$eval[0]->get_id());
  56. $nr_items = array();
  57. foreach ($displays as $itemsdisplay)
  58. $nr_items[$itemsdisplay['display']] = 0;
  59. $resultcount = 0;
  60. foreach ($allresults as $result)
  61. {
  62. $score = $result->get_score();
  63. if (isset($score))
  64. {
  65. $display = $displayscore->display_score(array($score, $eval[0]->get_max()),SCORE_DIV | SCORE_IGNORE_SPLIT, SCORE_ONLY_CUSTOM);
  66. $nr_items[$display] ++;
  67. $resultcount ++;
  68. }
  69. }
  70. $keys = array_keys($nr_items);
  71. // find the region with the most scores, this is 100% of the bar
  72. $highest_ratio = 0;
  73. foreach ($keys as $key)
  74. {
  75. if ($nr_items[$key] > $highest_ratio)
  76. $highest_ratio = $nr_items[$key];
  77. }
  78. // generate table
  79. $stattable= '<br><table class="data_table" cellspacing="0" cellpadding="3">';
  80. $stattable .= '<tr><th colspan="4">' . get_lang('Statistics') . '</th></tr>';
  81. $counter=0;
  82. foreach ($keys as $key)
  83. {
  84. //var_dump ($key);
  85. $bar = ($nr_items[$key] / $highest_ratio) * 100;
  86. $stattable .= '<tr class="row_' . ($counter % 2 == 0 ? 'odd' : 'even') . '">';
  87. $stattable .= '<td width="150">' . $key . '</td>';
  88. $stattable .= '<td width="550"><img src="../img/bar_1u.gif" width="' . $bar . '%" height="10"/></td>';
  89. $stattable .= '<td align="right">' . $nr_items[$key] . '</td>';
  90. $stattable .= '<td align="right"> ' . round( ($nr_items[$key] / $resultcount) * 100 ) . '%</td>';
  91. $counter++;
  92. }
  93. $stattable .= '</tr></table>';
  94. echo $stattable;
  95. }
  96. Display :: display_footer();
  97. ?>