MDL-19519 , MDL-1728 Adding database question_calculated_options
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<XMLDB PATH="question/type/calculated/db" VERSION="20060812" COMMENT="XMLDB file for Moodle question/type/calculated. This question type also relies on the question_numerical_units table created by the numerical question type, and the tables created by the datasetdependent question type base class.">
|
||||
<XMLDB PATH="question/type/calculated/db" VERSION="20090819" COMMENT="XMLDB file for Moodle question/type/calculated. This question type also relies on the question_numerical_units table created by the numerical question type, and the tables created by the datasetdependent question type base class.">
|
||||
<TABLES>
|
||||
<TABLE NAME="question_calculated" COMMENT="Options for questions of type calculated" NEXT="question_dataset_definitions">
|
||||
<TABLE NAME="question_calculated" COMMENT="Options for questions of type calculated" NEXT="question_calculated_options">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="question"/>
|
||||
<FIELD NAME="question" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="id" NEXT="answer"/>
|
||||
@@ -19,7 +19,18 @@
|
||||
<INDEX NAME="answer" UNIQUE="false" FIELDS="answer"/>
|
||||
</INDEXES>
|
||||
</TABLE>
|
||||
<TABLE NAME="question_dataset_definitions" COMMENT="Organises and stores properties for dataset items" PREVIOUS="question_calculated" NEXT="question_dataset_items">
|
||||
<TABLE NAME="question_calculated_options" COMMENT="Options for questions of type calculated" PREVIOUS="question_calculated" NEXT="question_dataset_definitions">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="question"/>
|
||||
<FIELD NAME="question" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="id" NEXT="synchronize"/>
|
||||
<FIELD NAME="synchronize" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="question"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id" NEXT="question"/>
|
||||
<KEY NAME="question" TYPE="foreign" FIELDS="question" REFTABLE="question" REFFIELDS="id" PREVIOUS="primary"/>
|
||||
</KEYS>
|
||||
</TABLE>
|
||||
<TABLE NAME="question_dataset_definitions" COMMENT="Organises and stores properties for dataset items" PREVIOUS="question_calculated_options" NEXT="question_dataset_items">
|
||||
<FIELDS>
|
||||
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="category"/>
|
||||
<FIELD NAME="category" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="id" NEXT="name"/>
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?PHP // $Id$
|
||||
|
||||
$plugin->version = 2008091700;
|
||||
$plugin->version = 2009082000;
|
||||
$plugin->requires = 2007101000;
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user