mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
MDL-61380 Quiz: quiz_slots schema change
Adding questioncategoryid and includingsubcategories to the quiz_slots table
This commit is contained in:
parent
856e07e4e7
commit
b6c38f71e2
3 changed files with 41 additions and 3 deletions
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<XMLDB PATH="mod/quiz/db" VERSION="20150323" COMMENT="XMLDB file for Moodle mod/quiz"
|
<XMLDB PATH="mod/quiz/db" VERSION="20180207" COMMENT="XMLDB file for Moodle mod/quiz"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
|
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
|
||||||
>
|
>
|
||||||
|
@ -63,12 +63,16 @@
|
||||||
<FIELD NAME="page" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="The page number that this questions appears on. If the question in slot n appears on page p, then the question in slot n+1 must appear on page p or p+1. Well, except that when a quiz is being created, there may be empty pages, which would cause the page number to jump here."/>
|
<FIELD NAME="page" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="The page number that this questions appears on. If the question in slot n appears on page p, then the question in slot n+1 must appear on page p or p+1. Well, except that when a quiz is being created, there may be empty pages, which would cause the page number to jump here."/>
|
||||||
<FIELD NAME="requireprevious" TYPE="int" LENGTH="4" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Set to 1 when current question requires previous one to be answered first."/>
|
<FIELD NAME="requireprevious" TYPE="int" LENGTH="4" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Set to 1 when current question requires previous one to be answered first."/>
|
||||||
<FIELD NAME="questionid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Foreign key references question.id."/>
|
<FIELD NAME="questionid" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Foreign key references question.id."/>
|
||||||
|
<FIELD NAME="questioncategoryid" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false" COMMENT="The question category that the random question will be picked from. Will be null if and only if the question is not a random question."/>
|
||||||
|
<FIELD NAME="includingsubcategories" TYPE="int" LENGTH="4" NOTNULL="false" SEQUENCE="false" COMMENT="Whether the random question can be picked from sub categories or not. Will be null if questioncategoryid is null."/>
|
||||||
|
<FIELD NAME="tags" TYPE="text" NOTNULL="false" SEQUENCE="false" COMMENT="Contains data about the tags that a question must have so that it can be selected for this slot. This field is an array in the form of [tagid,tagname] which is stored as JSON. Will be null if questioncategoryid is null."/>
|
||||||
<FIELD NAME="maxmark" TYPE="number" LENGTH="12" NOTNULL="true" DEFAULT="0" SEQUENCE="false" DECIMALS="7" COMMENT="How many marks this question contributes to quiz.sumgrades."/>
|
<FIELD NAME="maxmark" TYPE="number" LENGTH="12" NOTNULL="true" DEFAULT="0" SEQUENCE="false" DECIMALS="7" COMMENT="How many marks this question contributes to quiz.sumgrades."/>
|
||||||
</FIELDS>
|
</FIELDS>
|
||||||
<KEYS>
|
<KEYS>
|
||||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||||
<KEY NAME="quizid" TYPE="foreign" FIELDS="quizid" REFTABLE="quiz" REFFIELDS="id"/>
|
<KEY NAME="quizid" TYPE="foreign" FIELDS="quizid" REFTABLE="quiz" REFFIELDS="id"/>
|
||||||
<KEY NAME="questionid" TYPE="foreign" FIELDS="questionid" REFTABLE="question" REFFIELDS="id"/>
|
<KEY NAME="questionid" TYPE="foreign" FIELDS="questionid" REFTABLE="question" REFFIELDS="id"/>
|
||||||
|
<KEY NAME="questioncategoryid" TYPE="foreign" FIELDS="questioncategoryid" REFTABLE="questioncategory" REFFIELDS="id"/>
|
||||||
</KEYS>
|
</KEYS>
|
||||||
<INDEXES>
|
<INDEXES>
|
||||||
<INDEX NAME="quizid-slot" UNIQUE="true" FIELDS="quizid, slot"/>
|
<INDEX NAME="quizid-slot" UNIQUE="true" FIELDS="quizid, slot"/>
|
||||||
|
|
|
@ -94,5 +94,39 @@ function xmldb_quiz_upgrade($oldversion) {
|
||||||
// Automatically generated Moodle v3.4.0 release upgrade line.
|
// Automatically generated Moodle v3.4.0 release upgrade line.
|
||||||
// Put any upgrade step following this.
|
// Put any upgrade step following this.
|
||||||
|
|
||||||
|
if ($oldversion < 2018020700) {
|
||||||
|
|
||||||
|
$table = new xmldb_table('quiz_slots');
|
||||||
|
|
||||||
|
// Define field questioncategoryid to be added to quiz_slots.
|
||||||
|
$field = new xmldb_field('questioncategoryid', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'questionid');
|
||||||
|
// Conditionally launch add field questioncategoryid.
|
||||||
|
if (!$dbman->field_exists($table, $field)) {
|
||||||
|
$dbman->add_field($table, $field);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Define key questioncategoryid (foreign) to be added to quiz_slots.
|
||||||
|
$key = new xmldb_key('questioncategoryid', XMLDB_KEY_FOREIGN, array('questioncategoryid'), 'questioncategory', array('id'));
|
||||||
|
// Launch add key questioncategoryid.
|
||||||
|
$dbman->add_key($table, $key);
|
||||||
|
|
||||||
|
// Define field includingsubcategories to be added to quiz_slots.
|
||||||
|
$field = new xmldb_field('includingsubcategories', XMLDB_TYPE_INTEGER, '4', null, null, null, null, 'questioncategoryid');
|
||||||
|
// Conditionally launch add field includingsubcategories.
|
||||||
|
if (!$dbman->field_exists($table, $field)) {
|
||||||
|
$dbman->add_field($table, $field);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Define field tags to be added to quiz_slots.
|
||||||
|
$field = new xmldb_field('tags', XMLDB_TYPE_TEXT, null, null, null, null, null, 'includingsubcategories');
|
||||||
|
// Conditionally launch add field tags.
|
||||||
|
if (!$dbman->field_exists($table, $field)) {
|
||||||
|
$dbman->add_field($table, $field);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Quiz savepoint reached.
|
||||||
|
upgrade_mod_savepoint(true, 2018020700, 'quiz');
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
defined('MOODLE_INTERNAL') || die();
|
defined('MOODLE_INTERNAL') || die();
|
||||||
|
|
||||||
$plugin->version = 2017111300;
|
$plugin->version = 2018020700;
|
||||||
$plugin->requires = 2017110800;
|
$plugin->requires = 2017110800;
|
||||||
$plugin->component = 'mod_quiz';
|
$plugin->component = 'mod_quiz';
|
||||||
$plugin->cron = 60;
|
$plugin->cron = 60;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue