MDL-62871 quiz: incorrect foreign key declaration
authorVadim Tabunshchik <tvn.pstu@gmail.com>
Thu, 19 Jul 2018 08:29:34 +0000 (18:29 +1000)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Thu, 26 Jul 2018 09:36:43 +0000 (11:36 +0200)
mod/quiz/db/install.xml
mod/quiz/db/upgrade.php

index 8ff8747..b3d09f6 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="mod/quiz/db" VERSION="20180407" COMMENT="XMLDB file for Moodle mod/quiz"
+<XMLDB PATH="mod/quiz/db" VERSION="20180719" COMMENT="XMLDB file for Moodle mod/quiz"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
 >
@@ -71,7 +71,7 @@
         <KEY NAME="primary" TYPE="primary" FIELDS="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="questioncategoryid" TYPE="foreign" FIELDS="questioncategoryid" REFTABLE="questioncategory" REFFIELDS="id"/>
+        <KEY NAME="questioncategoryid" TYPE="foreign" FIELDS="questioncategoryid" REFTABLE="question_categories" REFFIELDS="id"/>
       </KEYS>
       <INDEXES>
         <INDEX NAME="quizid-slot" UNIQUE="true" FIELDS="quizid, slot"/>
index f3b19ee..f1b726b 100644 (file)
@@ -106,7 +106,7 @@ function xmldb_quiz_upgrade($oldversion) {
         }
 
         // Define key questioncategoryid (foreign) to be added to quiz_slots.
-        $key = new xmldb_key('questioncategoryid', XMLDB_KEY_FOREIGN, array('questioncategoryid'), 'questioncategory', array('id'));
+        $key = new xmldb_key('questioncategoryid', XMLDB_KEY_FOREIGN, array('questioncategoryid'), 'question_categories', ['id']);
         // Launch add key questioncategoryid.
         $dbman->add_key($table, $key);