@@ -52,6 +52,9 @@ public function add_data($row) {
52
52
}
53
53
}
54
54
55
+ // A version of Moodle's table_sql that handles the screw up with formatting
56
+ // of code (converting it all to HTML, stripping newlines etc - stupid, stupid, stupid -
57
+ // and which formats the datetime field (a Unix timestamp) in a DB independent manner.
55
58
class UnscrewedSqlTable extends table_sql {
56
59
/**
57
60
* Get, and optionally set, the export class.
@@ -75,6 +78,22 @@ function export_class_instance($exportclass = null) {
75
78
}
76
79
return $ this ->exportclass ;
77
80
}
81
+
82
+ /**
83
+ * Format Unix timestamp into readable date/time
84
+ * This method will be automatically called for the 'datetime' column
85
+ *
86
+ * @param object $row The row of data
87
+ * @return string Formatted date
88
+ */
89
+ public function col_datetime ($ row ) {
90
+ if (empty ($ row ->datetime )) {
91
+ return '- ' ;
92
+ }
93
+
94
+ // Use Moodle's built-in time formatting function
95
+ return userdate ($ row ->datetime );
96
+ }
78
97
//phpcs:enable
79
98
}
80
99
@@ -125,7 +144,7 @@ function export_class_instance($exportclass = null) {
125
144
quest.name as qname,
126
145
slot.maxmark as mark,
127
146
qattsteps.timecreated as timestamp,
128
- FROM_UNIXTIME( qattsteps.timecreated,'%Y/%m/%d %H:%i:%s') as datetime,
147
+ qattsteps.timecreated as datetime,
129
148
qattsteps.fraction,
130
149
qattsteps.state,
131
150
qasd.attemptstepid,
0 commit comments