Error creating a default category!

Error creating a default category!

by Marcin Maly -
Number of replies: 12
Ever since I upgraded to Moodle 1.6.3 (from 1.5.2) I have been unable to run existing quizes or create new one.
I get 'Error creating a default category!' message whenever I try to view, modify or create this activity.
The database seems to be fine. The category table exists and is not empty.
Average of ratings: -
In reply to Marcin Maly

Re: Error creating a default category!

by Emilio Leiva Serrano -

Hi!

I have the same problem. You have found some solution?

Thanks

In reply to Emilio Leiva Serrano

Re: Error creating a default category!

by Marcin Maly -
No, I haven't.
And I'm beginning to lose any hope sad
In reply to Marcin Maly

Re: Error creating a default category!

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers
Hi Marcin, Hi Emilio,
the error you got seems to come from the "question/editlib.php" script, specifically from the "get_default_question_category" function.

If you are using a MySQL database, you can identify why your Moodle cannot create a new default quiz category by doing the following:
  1. open "question/editlib.php" with a text editor
  2. locate the following line (around line 89)
    notify("Error creating a default category!");
  3. change the above line to:
    notify("Error creating a default category!".mysql_error());
  4. try viewing a quiz again and report back on the new error message
cheers
Gordon
Average of ratings: Useful (1)
In reply to Gordon Bateson

Re: Error creating a default category!

by Marcin Maly -
It turned out there was no mdl_question_categories in the database.
I copied the table mdl_quiz_categories (structure and data) into a new mdl_question_categories and the quizes can now be displayed and edited.
I have lost all the questions and answers in all of my quizes however. Do I need to rename all mdl_quiz_*** tables into mdl_question_*** tables?
In reply to Marcin Maly

Re: Error creating a default category!

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers
> It turned out there was no mdl_question_categories in the database.

Oh dear. That seems like a serious problem to me. This "question" tables should have been created by a previous Moodle upgrade, so if you haven't got them, then the previous upgrade didn't work properly from some reason.

I am going to suggest something very drastic. Please, please, please take a back up of you entire Moodle database before you attempt the following. If you cannot take a backup, then STOP and DO NOT TRY what I am about to suggest.

Did you take a full backup? If this goes wrong, are you confident you can quickly and easily restore your database to its current state? If NO, please stop and seek advice. If YES, please continue ...
  1. login to Moodle as administrator, access Admin -> Variables, and in the "Miscellaneous" section set "Debug" to "Yes". Then logout from Moodle.
  2. start up and login to your favorite database administration tool, e.g. phpMyAdmin
  3. confirm that the MySQL username that Moodle uses has sufficient privileges to rename tables in the Moodle database. If it does not have these privileges, please add them
  4. if you copied the "mdl_quiz_categories" to "mdl_question_categories", please delete "mdl_question_categories"
    if you renamed "mdl_quiz_categories" to "mdl_question_categories", please rename it back to "mdl_quiz_categories"
  5. select the "mdl_modules" table then locate the "quiz" record. Make a note (= write down) the current "version" and then change the "version" field to "2006022399"
  6. login to Moodle as administrator. The upgrade of the quiz module should start. If it does not start, please access "admin/index.php" on your site. If the upgrade still does not start, please STOP and seek assistance.
By resetting the version number for the quiz module, you should force the automatic renaming of the "quiz" tables to "question" tables. Please make a note of an error messages that appear. In particular, the first error message is usually the most important, so please copy and paste it to this forum, along with the "version" numer that you wrote down in step 2 above - you did write it down, right wink

If there were any major problems, please restore to your backup.

I really hope this works for you, but even if it does not, please let us know what happened.

good luck!
Gordon
Average of ratings: Useful (1)
In reply to Gordon Bateson

Re: Error creating a default category!

by Timothy Takemoto -
Wow, super. This advice is as brave as it is wise and vice versa, and in any event super.
In reply to Timothy Takemoto

Re: Error creating a default category!

by Marcin Maly -
Has anyone tried to do this? Any results, comments?
I'm afraid I don't have the guts to risk my system and perform all this. Instead, I'm thinking of another upgrade. Perhaps if I try to upgrade to 1.7 now everything will get back to normal?
For the time being, I switched off the quiz module sad
In reply to Marcin Maly

Re: Error creating a default category!

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
If a previous upgrade failed it is very, very unlikely that another upgrade will fix it. In fact it will probably get worse - sorry sad
In reply to Howard Miller

Re: Error creating a default category!

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers
Howard,
in the general case you might be right, but in this particular case, I think there is a good chance that what I suggested will help. At least I am hopeful it will allow us to see an error about why the upgrade failed, which could well pinpoint something about the quiz module, or Marcin's setup, that does not allow the upgrade to succeed.

I do not think that what I suggested will make the situation worse. For I start, I was very clear about taking a backup, and restoring from the backup if the suggested action did not work. But more importantly, I looked inside "mod/quiz/db/mysql.php" and saw that the upgrade actions of the quiz module on or after 2006022400 are solely concerned with renaming the tables from "mdl_quiz..." to "mdl_question...". That seems to be exactly what we need to do in this situation. If you do not agree, I invite you to look inside "mod/quiz/db/mysql.php", after line 940, and explain what you see that leads you to say the situation will "probably get worse", if we try this upgrade.

Marcel,
I understand that you are worried about "experimenting" on your live Moodle site, so I advise you to download a copy of your live Moodle database and your Moodle directory from your server to your own PC, where you can install a "Complete install" from the Moodle downloads page, which includes Apache+PHP+MySQL. Then import your database to your MySQL on your PC and try to upgrade, using the suggestions I gave earlier. You will not make the situation worse and you will probably find out some information which will help you repair your live site.

Alternatively, if you would like me to try to upgrade your site on my machine, please send me details of where i can download a dump of your Moodle database. My contact address is: gordon at-sign kanazawa hyphen gu dot ac dot jp

good luck
Gordon
In reply to Gordon Bateson

Re: Error creating a default category!

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Gordon,

I don't think I was clear - I agree with you. I was answering the bit of his question which I took to be about doing another upgrade (to 1.7) of the complete Moodle site as opposed to (your suggestion) of trying to isolate the particular problem.

He needs to do what you suggest - or something like it.
In reply to Howard Miller

Re: Error creating a default category!

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers
Oh sorry Howard, I completely misunderstood! I see what you meant now though, and quite agree: it would be unwise to upgrade to 1.7, knowing that the Moodle 1.6 upgrade has not yet successfully completed.

Thanks for clearing that up smile
Gordon
In reply to Gordon Bateson

Re: Error creating a default category!

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
The only thing is that he doesn't say that he has *no* mdl_question... tables just that he's missing mdl_question_categories. You could well be right all the same, but I would want to make sure.

If that turns out to be the case then the rolling the version number back plan is worth a try - I doubt you can make the situation any worse than it is now smile

Just to reinforce though - if anybody tries this do make sure debugging is on and check the output very carefully for errors (and record them!)