diff options
Diffstat (limited to 'sqlbox/report.php')
-rw-r--r-- | sqlbox/report.php | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/sqlbox/report.php b/sqlbox/report.php new file mode 100644 index 0000000..c39114d --- /dev/null +++ b/sqlbox/report.php @@ -0,0 +1,51 @@ +<?php + +require_once(dirname(dirname(dirname(__FILE__))).'/config.php'); +require_once(dirname(__FILE__).'/lib.php'); + +$id = required_param('id', PARAM_INT); //moduleid + +if ($id) { + $cm = get_coursemodule_from_id('sqlbox', $id, 0, false, MUST_EXIST); + $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); + $sqlbox = $DB->get_record('sqlbox', array('id' => $cm->instance), '*', MUST_EXIST); +} else { + error('You must specify a course_module ID or an instance ID'); +} + +require_login($course, true, $cm); + +$context = get_context_instance(CONTEXT_MODULE, $cm->id); +require_capability('mod/sqlbox:readqueries', $context); + +add_to_log($course->id, 'sqlbox', 'report', "report.php?id={$cm->id}", $sqlbox->name, $cm->id); + +$PAGE->set_url('/mod/sqlbox/report.php', array('id' => $cm->id)); +$PAGE->set_title(format_string($sqlbox->name)); +$PAGE->set_heading(format_string($course->fullname)); +$PAGE->set_context($context); + +echo $OUTPUT->header(); + +$sql = "SELECT u.*, s.* + 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)); +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); +} + +echo $OUTPUT->footer(); + +?> |