Moodle

upgrade from 1.9->2.0 fails on question/type/datasetdependent plugin because tables already there

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Blocker Blocker
  • Resolution: Fixed
  • Affects Version/s: 2.0
  • Fix Version/s: 2.0
  • Component/s: Questions
  • Labels:
    None
  • Affected Branches:
    MOODLE_20_STABLE
  • Fixed Branches:
    MOODLE_20_STABLE

Description

The problem is you can not move table definition from one install.xml to another - the target install.xml can not be executed because the tables will already exist.
I have no idea how to solve this

Issue Links

Activity

Hide
Pierre Pichet added a comment - - edited

Please search in the Tracker before creating a new bug.
just putting datasetdependent in the search tool will have show the MDL-16485 bug

Show
Pierre Pichet added a comment - - edited Please search in the Tracker before creating a new bug. just putting datasetdependent in the search tool will have show the MDL-16485 bug
Hide
Petr Škoda (skodak) added a comment - - edited

I do not search because I read all new bug reports and I thought it was not reported - this bug is new, but I know it's complete history
unfortunately my feed reader is not reliable much recently and I noticed the other issue after filing this one.

Show
Petr Škoda (skodak) added a comment - - edited I do not search because I read all new bug reports and I thought it was not reported - this bug is new, but I know it's complete history unfortunately my feed reader is not reliable much recently and I noticed the other issue after filing this one.
Hide
Pierre Pichet added a comment -

No problem with the duplicates and we should continue the discussion here I think.

The main problem is the datasetdependent which is an abstract question type only used by calculated questiontype.
As far as i understand the "old" code, this abstactype was created to be used by other questions types.
However the only one being calculated and the new plug-ins standard , I propose that the datasetdependent be in the future only used by calculated.
If other questiontypes need specific data, they just build a new table.
The code of datasetdependent/ directory should be put in the calculated directory and the datasetdependent table created there.
In a first step the code of abstractype be used as usual changing
require_once("$CFG->dirroot/question/type/datasetdependent/abstractqtype.php");
to
require_once("$CFG->dirroot/question/type/calculated/abstractqtype.php");
In a second step we could eliminate this abstract question type and integrate everything in calculated/questiontype.php.
We will then have a calculated questiontype that is a real plug-in.

Show
Pierre Pichet added a comment - No problem with the duplicates and we should continue the discussion here I think. The main problem is the datasetdependent which is an abstract question type only used by calculated questiontype. As far as i understand the "old" code, this abstactype was created to be used by other questions types. However the only one being calculated and the new plug-ins standard , I propose that the datasetdependent be in the future only used by calculated. If other questiontypes need specific data, they just build a new table. The code of datasetdependent/ directory should be put in the calculated directory and the datasetdependent table created there. In a first step the code of abstractype be used as usual changing require_once("$CFG->dirroot/question/type/datasetdependent/abstractqtype.php"); to require_once("$CFG->dirroot/question/type/calculated/abstractqtype.php"); In a second step we could eliminate this abstract question type and integrate everything in calculated/questiontype.php. We will then have a calculated questiontype that is a real plug-in.
Hide
Petr Škoda (skodak) added a comment -

I suppose we will need to:
1/ rename thecolliding tables in quiz upgrade
2/ add post installation hook for question plugins and migrate data into newly created tables and drop the renamed tables

Problem here is that the post installation hook does not work for this type of plugins - see lib/adminlib.php function upgrade_plugins($type, $dir, $return)

Show
Petr Škoda (skodak) added a comment - I suppose we will need to: 1/ rename thecolliding tables in quiz upgrade 2/ add post installation hook for question plugins and migrate data into newly created tables and drop the renamed tables Problem here is that the post installation hook does not work for this type of plugins - see lib/adminlib.php function upgrade_plugins($type, $dir, $return)
Hide
Pierre Pichet added a comment -

What I propose is to keep the same tables but to put their initializations in the db/ files of question/category/db
and to drop the question/datasetdependent directory, the other files being put in question/calculated/ directory.

Show
Pierre Pichet added a comment - What I propose is to keep the same tables but to put their initializations in the db/ files of question/category/db and to drop the question/datasetdependent directory, the other files being put in question/calculated/ directory.
Hide
Pierre Pichet added a comment -

I have already done the necessary changes and everything (3 steps calculted question creation and edition and preview ) is working correctly.
Just need to fix the calcualted/db/upgrade.php file...

Show
Pierre Pichet added a comment - I have already done the necessary changes and everything (3 steps calculted question creation and edition and preview ) is working correctly. Just need to fix the calcualted/db/upgrade.php file...
Hide
Pierre Pichet added a comment - - edited

You have a beter understanding of these database process.
If we eliminate datasetdependent dir there will be no qtype_datasedependent so the quiz does not have to work on this but let calculated do the work.
/// Now that the quiz is no longer responsible for creating all the question
/// bank tables, and some of the tables are now the responsibility of the
/// datasetdependent question type, which did not have a version.php file before,
/// we need to say that these tables are already installed, otherwise XMLDB
/// will try to create them again and give an error.
if ($result && $oldversion < 2008082600) { set_config('qtype_datasetdependent_version', 2008082600); upgrade_mod_savepoint($result, 2008082600, 'quiz'); }
In fact actually there is no qtype_datasetdependent question type because there is no datasetdependent/questiontype.php
There is just three tables defined in datasetdependent/install.xml
If we put these three tables in calculated/install.php,could this solve the problem

The question plug-in takes for granted that if there is a directory in question/type/ directory it is a plug-in questiontype.
This convention is not true for datasetdependent...

Show
Pierre Pichet added a comment - - edited You have a beter understanding of these database process. If we eliminate datasetdependent dir there will be no qtype_datasedependent so the quiz does not have to work on this but let calculated do the work. /// Now that the quiz is no longer responsible for creating all the question /// bank tables, and some of the tables are now the responsibility of the /// datasetdependent question type, which did not have a version.php file before, /// we need to say that these tables are already installed, otherwise XMLDB /// will try to create them again and give an error. if ($result && $oldversion < 2008082600) { set_config('qtype_datasetdependent_version', 2008082600); upgrade_mod_savepoint($result, 2008082600, 'quiz'); } In fact actually there is no qtype_datasetdependent question type because there is no datasetdependent/questiontype.php There is just three tables defined in datasetdependent/install.xml If we put these three tables in calculated/install.php,could this solve the problem The question plug-in takes for granted that if there is a directory in question/type/ directory it is a plug-in questiontype. This convention is not true for datasetdependent...
Hide
Tim Hunt added a comment -

I do not understand why people are having a problem here. The original issue was MDL-6095, some core question bank tables, and some question-type-specific tables were being created by mod/quiz/install.php for historical reasons. That was bad, so I fixed it.

On an upgrade from 1.9 to 2.0, the following sequence of actions should occur.

admin/index.php calls
upgrade_activity_modules, which calls
mod/quiz/db/upgrade.php which does
set_config('qtype_datasetdependent_version', 2008082600);
upgrade_plugins('qtype', 'question/type', ...
// Does not try to upgrade the datasetdependent question type, because the version is up to date.

At least, that is how it worked when I checked in the fix for MDL-6095 and MDL-16200.

However, since then I have done MDL-16411, so the set_config line needs to change to set_config('version', 2008082600, 'qtype_datasetdependent'); Now I understand why people have been reporting this problem in moodle HQ chat. Will fix.

Show
Tim Hunt added a comment - I do not understand why people are having a problem here. The original issue was MDL-6095, some core question bank tables, and some question-type-specific tables were being created by mod/quiz/install.php for historical reasons. That was bad, so I fixed it. On an upgrade from 1.9 to 2.0, the following sequence of actions should occur. admin/index.php calls upgrade_activity_modules, which calls mod/quiz/db/upgrade.php which does set_config('qtype_datasetdependent_version', 2008082600); upgrade_plugins('qtype', 'question/type', ... // Does not try to upgrade the datasetdependent question type, because the version is up to date. At least, that is how it worked when I checked in the fix for MDL-6095 and MDL-16200. However, since then I have done MDL-16411, so the set_config line needs to change to set_config('version', 2008082600, 'qtype_datasetdependent'); Now I understand why people have been reporting this problem in moodle HQ chat. Will fix.
Hide
Tim Hunt added a comment -

Fixed, and I tested an upgrade from 1.9 to 2.0 and it worked.

Show
Tim Hunt added a comment - Fixed, and I tested an upgrade from 1.9 to 2.0 and it worked.
Hide
Tim Hunt added a comment -

And a clean install works too.

Show
Tim Hunt added a comment - And a clean install works too.
Hide
Pierre Pichet added a comment -

Tim,
How about my proposal to eliminate the datasetdependent question type which is only used by calculated questiontype, and put everything in question/type/calculated/ directory?
This can be done easily and will give to calculated a more standard plug-in structure unless you have some plan to use these datasetdependent table to other questiontypes.

Show
Pierre Pichet added a comment - Tim, How about my proposal to eliminate the datasetdependent question type which is only used by calculated questiontype, and put everything in question/type/calculated/ directory? This can be done easily and will give to calculated a more standard plug-in structure unless you have some plan to use these datasetdependent table to other questiontypes.
Hide
Petr Škoda (skodak) added a comment -

stupid me, of course the correct fix is to set version in quiz which makes moodle think the question plugin was already installed, sorry!

Show
Petr Škoda (skodak) added a comment - stupid me, of course the correct fix is to set version in quiz which makes moodle think the question plugin was already installed, sorry!
Hide
Tim Hunt added a comment -

Pierre - if we are sure datasets will only ever be used by the calculated question type, then yes, it would be better to eliminate datasetdependent as a separate 'question type'. If you want to go ahead with that, I think we should set up a separate issue in the tracker.

Sorry I did not read all the comments carefully before, I was in too much of a hurry to fix the bug!

Show
Tim Hunt added a comment - Pierre - if we are sure datasets will only ever be used by the calculated question type, then yes, it would be better to eliminate datasetdependent as a separate 'question type'. If you want to go ahead with that, I think we should set up a separate issue in the tracker. Sorry I did not read all the comments carefully before, I was in too much of a hurry to fix the bug!
Hide
Pierre Pichet added a comment -

Tim
I think that if somebody want to use this kind of table, he should build his own dataset table taking care that the table name are different from these already in core.
Doing so future question using their specific dataset tables will have all the liberty to code them.
So I will set a new tracker issue for 2.0.

Show
Pierre Pichet added a comment - Tim I think that if somebody want to use this kind of table, he should build his own dataset table taking care that the table name are different from these already in core. Doing so future question using their specific dataset tables will have all the liberty to code them. So I will set a new tracker issue for 2.0.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: