MDL-20601 fixed fatal SQL upgrade error, missing {} around table names
[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
2280e147 60 function col_response($response){
61 global $QTYPES;
62 if (!$this->is_downloading() || $this->is_downloading() == 'xhtml'){
63 return $QTYPES[$this->question->qtype]->format_response($response->response, $this->question->questiontextformat);
64 } else {
65 return $response->response;
66 }
67 }
68
869309b8 69 function col_subq($response){
70 return $response->subq;
71 }
72
73 function col_credit($response){
74 if (!is_null($response->credit)){
75 return ($response->credit*100).'%';
76 } else {
77 return '';
78 }
79 }
80
81 function col_frequency($response){
82 if ($this->question->_stats->s){
83 return format_float((($response->rcount / $this->question->_stats->s)*100),2).'%';
84 } else {
85 return '';
86 }
87 }
88
89
90
91}
92?>