MDL-14202 "Replace Item Analysis Report with new improved 'Statistics' report." finis...
[moodle.git] / mod / quiz / report / statistics / statistics_question_table.php
CommitLineData
869309b8 1<?php // $Id$
2require_once($CFG->libdir.'/tablelib.php');
3
4class quiz_report_statistics_question_table extends flexible_table {
5 /**
6 * @var object this question with _stats object.
7 */
8 var $question;
9
10 function quiz_report_statistics_question_table($qid){
11 parent::flexible_table('mod-quiz-report-statistics-question-table'.$qid);
12 }
13
14 /**
15 * Setup the columns and headers and other properties of the table and then
16 * call flexible_table::setup() method.
17 */
18 function setup($reporturl, $question, $hassubqs){
19 $this->question = $question;
20 // Define table columns
21 $columns = array();
22 $headers = array();
23
24 if ($hassubqs){
25 $columns[]= 'subq';
26 $headers[]= '';
27 }
28
29 $columns[]= 'response';
30 $headers[]= get_string('response', 'quiz_statistics');
31
32
33 $columns[]= 'credit';
34 $headers[]= get_string('optiongrade', 'quiz_statistics');
35
36 $columns[]= 'rcount';
37 $headers[]= get_string('count', 'quiz_statistics');
38
39 $columns[]= 'frequency';
40 $headers[]= get_string('frequency', 'quiz_statistics');
41
42 $this->define_columns($columns);
43 $this->define_headers($headers);
44 $this->sortable(false);
45
46 $this->column_class('credit', 'numcol');
47 $this->column_class('rcount', 'numcol');
48 $this->column_class('frequency', 'numcol');
49
50 // Set up the table
51 $this->define_baseurl($reporturl->out());
52
53 $this->collapsible(false);
54
55 $this->set_attribute('class', 'generaltable generalbox boxaligncenter');
56
57 parent::setup();
58 }
59
60 function col_subq($response){
61 return $response->subq;
62 }
63
64 function col_credit($response){
65 if (!is_null($response->credit)){
66 return ($response->credit*100).'%';
67 } else {
68 return '';
69 }
70 }
71
72 function col_frequency($response){
73 if ($this->question->_stats->s){
74 return format_float((($response->rcount / $this->question->_stats->s)*100),2).'%';
75 } else {
76 return '';
77 }
78 }
79
80
81
82}
83?>