summaryrefslogtreecommitdiff
path: root/sqlbox/report.php
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@googlemail.com>2013-01-24 18:45:53 +0100
committerBenjamin Franzke <benjaminfranzke@googlemail.com>2013-01-24 22:11:28 +0100
commitde6f8313a068572c56ae1acfef3e68c7fdce2886 (patch)
tree9d219fe38da04ce6aa65916db0e9e1955e057df6 /sqlbox/report.php
parent1d4eebb6d417fa945b16fbfc644ca71f8d18b062 (diff)
downloadsqltutor-plugin-de6f8313a068572c56ae1acfef3e68c7fdce2886.tar.gz
sqltutor-plugin-de6f8313a068572c56ae1acfef3e68c7fdce2886.tar.bz2
sqltutor-plugin-de6f8313a068572c56ae1acfef3e68c7fdce2886.zip
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.
Diffstat (limited to 'sqlbox/report.php')
-rw-r--r--sqlbox/report.php22
1 files 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();