PageRenderTime 45ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 1ms

/report/responses/renderer.php

https://github.com/KieranRBriggs/moodle-mod_hotpot
PHP | 118 lines | 59 code | 18 blank | 41 comment | 7 complexity | d4900543fcd8e6a99bb9a9b37791daa8 MD5 | raw file
  1. <?php
  2. // This file is part of Moodle - http://moodle.org/
  3. //
  4. // Moodle is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // Moodle is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License
  15. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
  16. /**
  17. * Render the responses report for a given HotPot activity
  18. *
  19. * @package mod-hotpot
  20. * @copyright 2010 Gordon Bateson <gordon.bateson@gmail.com>
  21. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  22. */
  23. defined('MOODLE_INTERNAL') || die();
  24. // get parent class
  25. require_once($CFG->dirroot.'/mod/hotpot/report/renderer.php');
  26. /**
  27. * mod_hotpot_report_responses_renderer
  28. *
  29. * @copyright 2010 Gordon Bateson
  30. * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  31. * @since Moodle 2.0
  32. */
  33. class mod_hotpot_report_responses_renderer extends mod_hotpot_report_renderer {
  34. public $mode = 'responses';
  35. public $tablecolumns = array(
  36. 'picture', 'fullname', 'grade', 'selected', 'attempt',
  37. 'timemodified','status', 'duration', 'penalties', 'score'
  38. );
  39. public $filterfields = array(
  40. 'group'=>0, 'realname'=>0, // 'lastname'=>1, 'firstname'=>1, 'username'=>1,
  41. 'grade'=>1, 'timemodified'=>1, 'status'=>1, 'duration'=>1, 'penalties'=>1, 'score'=>1
  42. );
  43. public $has_questioncolumns = true;
  44. /**
  45. * add_response_to_rawdata
  46. *
  47. * @param xxx $table (passed by reference)
  48. * @param xxx $attemptid
  49. * @param xxx $column
  50. * @param xxx $response
  51. */
  52. function add_response_to_rawdata(&$table, $attemptid, $column, $response) {
  53. $text = '';
  54. static $str = null;
  55. if (is_null($str)) {
  56. $str = (object)array(
  57. 'correct' => get_string('correct', 'hotpot'),
  58. 'wrong' => get_string('wrong', 'hotpot'),
  59. 'ignored' => get_string('ignored', 'hotpot'),
  60. 'score' => get_string('score', 'hotpot'),
  61. 'hintsclueschecks' => get_string('clues', 'hotpot').','.get_string('hints', 'hotpot').','.get_string('checks', 'hotpot')
  62. );
  63. }
  64. // correct
  65. if ($value = $response->correct) {
  66. $value = $table->set_legend($column, $value);
  67. $text .= html_writer::tag('li', $value, array('class'=>'correct'));
  68. }
  69. // wrong
  70. if ($value = $response->wrong) {
  71. $values = array();
  72. foreach (explode(',', $value) as $v) {
  73. $values[] = $table->set_legend($column, $v);
  74. }
  75. $text .= html_writer::tag('li', implode(',', $values), array('class'=>'wrong'));
  76. }
  77. // ignored
  78. if ($value = $response->ignored) {
  79. $values = array();
  80. foreach (explode(',', $value) as $v) {
  81. $values[] = $table->set_legend($column, $v);
  82. }
  83. $text .= html_writer::tag('li', implode(',', $values), array('class'=>'ignored'));
  84. }
  85. // numeric
  86. if (is_numeric($response->score)) {
  87. $value = $response->score.'%';
  88. $text .= html_writer::tag('li', $value, array('class'=>'score'));
  89. $hints = empty($response->hints) ? 0 : $response->hints;
  90. $clues = empty($response->clues) ? 0 : $response->clues;
  91. $checks = empty($response->checks) ? 0 : $response->checks;
  92. $value = '('.$hints.','.$clues.','.$checks.')';
  93. $text .= html_writer::tag('li', $value, array('class'=>'hintsclueschecks'));
  94. }
  95. if ($text) {
  96. $text = html_writer::tag('ul', $text, array('class'=>'response'));
  97. }
  98. $table->rawdata[$attemptid]->$column = $text;
  99. }
  100. }