From: pichetp Date: Sat, 22 Aug 2009 14:54:36 +0000 (+0000) Subject: MDL-19519 , MDL-1728 Adding database question_calculated_options X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=e593233a22d7f321ec38a864ca9a6f48cf4b1e89;p=moodle.git MDL-19519 , MDL-1728 Adding database question_calculated_options --- diff --git a/question/type/calculated/db/install.xml b/question/type/calculated/db/install.xml index 8e1135b336..84bca655d1 100644 --- a/question/type/calculated/db/install.xml +++ b/question/type/calculated/db/install.xml @@ -1,7 +1,7 @@ - + - +
@@ -19,7 +19,18 @@
- +
+ + + + + + + + + +
+ diff --git a/question/type/calculated/db/upgrade.php b/question/type/calculated/db/upgrade.php index 78f3b2e206..6dbe8b9caf 100644 --- a/question/type/calculated/db/upgrade.php +++ b/question/type/calculated/db/upgrade.php @@ -27,13 +27,34 @@ function xmldb_qtype_calculated_upgrade($oldversion) { $result = true; // MDL-16505. - if ($result && $oldversion < 2008091700) { //New version in version.php + if ($result && $oldversion < 2008091700 ) { //New version in version.php if (get_config('qtype_datasetdependent', 'version')) { $result = $result && unset_config('version', 'qtype_datasetdependent'); } upgrade_plugin_savepoint($result, 2008091700, 'qtype', 'calculated'); } +// let if ($dbman->table_exists()) replace the normal $oldversion test +// as in any case the question question_calculated_options should be created + + /// Define table question_calculated_options to be created + $table = new xmldb_table('question_calculated_options'); + + /// Adding fields to table question_calculated_options + $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null); + $table->add_field('question', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0'); + $table->add_field('synchronize', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0'); + + /// Adding keys to table question_calculated_options + $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id')); + $table->add_key('question', XMLDB_KEY_FOREIGN, array('question'), 'question', array('id')); + + /// Conditionally launch create table for question_calculated_options + if (!$dbman->table_exists($table)) { + $result = $dbman->create_table($table); + } + +/// calculated savepoint reached /// if ($result && $oldversion < YYYYMMDD00) { //New version in version.php /// $result = result of database_manager methods /// upgrade_plugin_savepoint($result, YYYYMMDD00, 'qtype', 'calculated'); diff --git a/question/type/calculated/edit_calculated_form.php b/question/type/calculated/edit_calculated_form.php index 13c0e9a67a..b7fc93d133 100644 --- a/question/type/calculated/edit_calculated_form.php +++ b/question/type/calculated/edit_calculated_form.php @@ -91,6 +91,12 @@ class question_edit_calculated_form extends question_edit_form { $firstunit->setPersistantFreeze(true); } //hidden elements + $mform->addElement('hidden', 'synchronize', ''); + if (isset($this->question->options)&& isset($this->question->options->synchronize) ){ + $mform->setDefault("synchronize", $this->question->options->synchronize); + } else { + $mform->setDefault("synchronize", 0 ); + } $mform->addElement('hidden', 'wizard', 'datasetdefinitions'); $mform->setType('wizard', PARAM_ALPHA); diff --git a/question/type/calculated/version.php b/question/type/calculated/version.php index d576aac75a..add73d0b3f 100644 --- a/question/type/calculated/version.php +++ b/question/type/calculated/version.php @@ -1,5 +1,5 @@ version = 2008091700; +$plugin->version = 2009082000; $plugin->requires = 2007101000; ?>