From de6f8313a068572c56ae1acfef3e68c7fdce2886 Mon Sep 17 00:00:00 2001 From: Benjamin Franzke Date: Thu, 24 Jan 2013 18:45:53 +0100 Subject: report: Query only needed fields and generate values in SQL So concat firstname and lastname and substitude correctness with a utf-8 character representing false or true. Also always display table header. --- sqlbox/report.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/sqlbox/report.php b/sqlbox/report.php index c39114d..ad907a2 100644 --- a/sqlbox/report.php +++ b/sqlbox/report.php @@ -27,24 +27,24 @@ $PAGE->set_context($context); echo $OUTPUT->header(); -$sql = "SELECT u.*, s.* +$sql = "SELECT + u.id, + translate(to_char(s.correct, 'FM9'), '01', '☒☑'), + (u.firstname || ' ' || u.lastname), + s.query FROM {user} u, {sqlbox_solutions} s WHERE u.id = s.userid and s.sqlboxid = :id"; $records = $DB->get_records_sql($sql, array('id' => $sqlbox->id)); +$table = new html_table; +$table->head = array("Lösung", "Nutzer", "Anfrage"); +$table->align = array("center", "left", "left"); if ($records) { - $table = new html_table; - $table->head = array("Lösung", "Nutzer", "Anfrage"); - foreach ($records as $record) { - $table->data[] = array( - ($record->correct == 1) ? '☑' : '☒', - $record->firstname . ' ' . $record->lastname, - $record->query - ); - } - echo html_writer::table($table); + foreach ($records as $record) + $table->data[] = array_slice((array)$record, 1); } +echo html_writer::table($table); echo $OUTPUT->footer(); -- cgit