diff options
author | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2013-01-24 15:25:53 +0100 |
---|---|---|
committer | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2013-01-24 15:25:53 +0100 |
commit | d6fdaffa76976f486dc228f89359254fa20f1676 (patch) | |
tree | de5f2842bb797ae24b97156776dd4069ef08cbf6 /sqlbox | |
parent | ff544ab8d8d2afeb2ecd0a6c54daf72a96f33049 (diff) | |
download | sqltutor-plugin-d6fdaffa76976f486dc228f89359254fa20f1676.tar.gz sqltutor-plugin-d6fdaffa76976f486dc228f89359254fa20f1676.tar.bz2 sqltutor-plugin-d6fdaffa76976f486dc228f89359254fa20f1676.zip |
Show already filed queries.
And if it was correct.
Diffstat (limited to 'sqlbox')
-rw-r--r-- | sqlbox/sqlbox_form.php | 5 | ||||
-rw-r--r-- | sqlbox/view.php | 18 |
2 files changed, 18 insertions, 5 deletions
diff --git a/sqlbox/sqlbox_form.php b/sqlbox/sqlbox_form.php index 946fad4..5360b59 100644 --- a/sqlbox/sqlbox_form.php +++ b/sqlbox/sqlbox_form.php @@ -12,6 +12,11 @@ class mod_sqlbox_form extends moodleform { $mform->addElement('text', 'sqlbox_query', 'SQL Query', 'size="50"'); $mform->addElement('submit', 'sqlbox_button', 'Submit'); } + + public function set_query($query) { + $mform = &$this->_form; + $mform->setDefault("sqlbox_query", $query); + } } ?> diff --git a/sqlbox/view.php b/sqlbox/view.php index 7a151ce..f9b4ba1 100644 --- a/sqlbox/view.php +++ b/sqlbox/view.php @@ -76,6 +76,10 @@ if ($sqlbox->intro) { // Conditions to show the intro can change to look for own // Replace the following lines with you own code $form = new mod_sqlbox_form($PAGE->url->out(false)); +$data = $form->get_data(); +$current = $DB->get_record('sqlbox_solutions', array('sqlboxid' => $sqlbox->id, 'userid' => $USER->id)); +if ($current) + $form->set_query($current->query); $form->display(); $data = $form->get_data(); @@ -98,12 +102,16 @@ if (isset($data->sqlbox_query)) { echo html_writer::table($table); - if ($correct) - echo $OUTPUT->heading("Correct!"); - else - echo $OUTPUT->heading("Incorrect!"); - sqlbox_submit_response($data->sqlbox_query, $sqlbox, $correct, $USER->id); +} else if ($current) { + $correct = $current->correct; +} + +if (isset($data->sqlbox_query) || $current) { + if ($correct) + echo $OUTPUT->heading("Correct!"); + else + echo $OUTPUT->heading("Incorrect!"); } // Finish the page |