summaryrefslogtreecommitdiff
path: root/sqlbox/view.php
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@googlemail.com>2013-01-25 09:25:23 +0100
committerBenjamin Franzke <benjaminfranzke@googlemail.com>2013-01-25 09:25:23 +0100
commita278371368e6ece009bd62504788898ae256d868 (patch)
tree99363223bdb719833e3d5bd99d0578bf1d8c6410 /sqlbox/view.php
parenta3d5dfe86e51c71a7b29776f48e107ccd6fabb31 (diff)
downloadsqltutor-plugin-a278371368e6ece009bd62504788898ae256d868.tar.gz
sqltutor-plugin-a278371368e6ece009bd62504788898ae256d868.tar.bz2
sqltutor-plugin-a278371368e6ece009bd62504788898ae256d868.zip
Fix coding style
Diffstat (limited to 'sqlbox/view.php')
-rw-r--r--sqlbox/view.php60
1 files changed, 30 insertions, 30 deletions
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;
}