MDL-61605 quiz report: add missing index/key

Thanks to Patryk Szuta for the suggestion
This commit is contained in:
Tim Hunt 2018-03-18 20:40:43 +00:00
parent b63a3b04b1
commit d9b80a5e69
3 changed files with 19 additions and 3 deletions

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="mod/quiz/report/overview/db" VERSION="20120122" COMMENT="XMLDB file for Moodle mod/quiz/report/overview"
<XMLDB PATH="mod/quiz/report/overview/db" VERSION="20180319" COMMENT="XMLDB file for Moodle mod/quiz/report/overview"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../../lib/xmldb/xmldb.xsd"
>
@ -16,6 +16,7 @@
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
<KEY NAME="questionusageid-slot" TYPE="foreign-unique" FIELDS="questionusageid, slot" REFTABLE="question_attempts" REFFIELDS="questionusageid, slot"/>
</KEYS>
</TABLE>
</TABLES>

View File

@ -29,7 +29,9 @@ defined('MOODLE_INTERNAL') || die();
* @param number $oldversion
*/
function xmldb_quiz_overview_upgrade($oldversion) {
global $CFG;
global $DB;
$dbman = $DB->get_manager();
// Automatically generated Moodle v3.2.0 release upgrade line.
// Put any upgrade step following this.
@ -40,5 +42,18 @@ function xmldb_quiz_overview_upgrade($oldversion) {
// Automatically generated Moodle v3.4.0 release upgrade line.
// Put any upgrade step following this.
if ($oldversion < 2018021800) {
// Define key questionusageid-slot (foreign-unique) to be added to quiz_overview_regrades.
$table = new xmldb_table('quiz_overview_regrades');
$key = new xmldb_key('questionusageid-slot', XMLDB_KEY_FOREIGN_UNIQUE, array('questionusageid', 'slot'), 'question_attempts', array('questionusageid', 'slot'));
// Launch add key questionusageid-slot.
$dbman->add_key($table, $key);
// Overview savepoint reached.
upgrade_plugin_savepoint(true, 2018021800, 'quiz', 'overview');
}
return true;
}

View File

@ -24,6 +24,6 @@
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2017111300;
$plugin->version = 2018021800;
$plugin->requires = 2017110800;
$plugin->component = 'quiz_overview';