From a278371368e6ece009bd62504788898ae256d868 Mon Sep 17 00:00:00 2001 From: Benjamin Franzke Date: Fri, 25 Jan 2013 09:25:23 +0100 Subject: Fix coding style --- sqlbox/view.php | 60 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 30 insertions(+), 30 deletions(-) (limited to 'sqlbox/view.php') diff --git a/sqlbox/view.php b/sqlbox/view.php index fababb7..47a9de4 100644 --- a/sqlbox/view.php +++ b/sqlbox/view.php @@ -36,13 +36,13 @@ $id = optional_param('id', 0, PARAM_INT); // course_module ID, or $n = optional_param('n', 0, PARAM_INT); // sqlbox instance ID - it should be named as the first character of the module 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); + $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); } elseif ($n) { - $sqlbox = $DB->get_record('sqlbox', array('id' => $n), '*', MUST_EXIST); - $course = $DB->get_record('course', array('id' => $sqlbox->course), '*', MUST_EXIST); - $cm = get_coursemodule_from_instance('sqlbox', $sqlbox->id, $course->id, false, MUST_EXIST); + $sqlbox = $DB->get_record('sqlbox', array('id' => $n), '*', MUST_EXIST); + $course = $DB->get_record('course', array('id' => $sqlbox->course), '*', MUST_EXIST); + $cm = get_coursemodule_from_instance('sqlbox', $sqlbox->id, $course->id, false, MUST_EXIST); } else { print_error('invalidcourse'); } @@ -86,30 +86,30 @@ $data = $form->get_data(); $correct = true; if (isset($data->sqlbox_query)) { - echo $OUTPUT->heading('SQL Query: '.$data->sqlbox_query); - - $con = sprintf("host=%s dbname=%s user=%s password=%s", - $CFG->sqlbox_hostname ? $CFG->sqlbox_hostname : "localhost", - $CFG->sqlbox_database ? $CFG->sqlbox_database : "sqlbox", - $CFG->sqlbox_user ? $CFG->sqlbox_user : "sqlbox", - $CFG->sqlbox_password ? $CFG->sqlbox_password : "sqlbox_pw" ); - - $db = pg_connect($con); - if (!$db) - print_error('dbconnectionfailed', 'sqlbox'); - - $table = db_table_from_query($db, $data->sqlbox_query); - if (strlen($sqlbox->query) > 0) { - $table_orig = db_table_from_query($db, $sqlbox->query); - if ($table->data != $table_orig->data || - $table->head != $table_orig->head) - $correct = false; - } - pg_close($db); - - echo html_writer::table($table); - - sqlbox_submit_response($data->sqlbox_query, $sqlbox, $correct, $USER->id); + echo $OUTPUT->heading('SQL Query: '.$data->sqlbox_query); + + $con = sprintf("host=%s dbname=%s user=%s password=%s", + $CFG->sqlbox_hostname ? $CFG->sqlbox_hostname : "localhost", + $CFG->sqlbox_database ? $CFG->sqlbox_database : "sqlbox", + $CFG->sqlbox_user ? $CFG->sqlbox_user : "sqlbox", + $CFG->sqlbox_password ? $CFG->sqlbox_password : "sqlbox_pw" ); + + $db = pg_connect($con); + if (!$db) + print_error('dbconnectionfailed', 'sqlbox'); + + $table = db_table_from_query($db, $data->sqlbox_query); + if (strlen($sqlbox->query) > 0) { + $table_orig = db_table_from_query($db, $sqlbox->query); + if ($table->data != $table_orig->data || + $table->head != $table_orig->head) + $correct = false; + } + pg_close($db); + + echo html_writer::table($table); + + sqlbox_submit_response($data->sqlbox_query, $sqlbox, $correct, $USER->id); } else if ($current) { $correct = $current->correct; } -- cgit