Recreate quizzes from data stored in the mdl_quiz table

Recreate quizzes from data stored in the mdl_quiz table

by Mark Hamilton -
Number of replies: 1

Moodle version: 2.7.18


I've done several dot upgrades (e.g. 2.7.16 to 2.7.17), but at some point I lost references to quizzes in my courses. 


I have a backup of the database that contains all quiz data, but no moodledata/ backup.


It is possible to restore my quizzes from the database data? I assume that in creating new quizzes, I would not have the ability to modify 'id' numbers.


Thanks for the help!

Average of ratings: -
In reply to Mark Hamilton

Re: Recreate quizzes from data stored in the mdl_quiz table

by Guillermo Madero -

Hi Mark,

Well, all the information is definitely there, however, reconstructing the quizzes from it I'd say is almost next to impossible, as all the quiz elements (questions, options, feedbacks) are distributed among many tables (e.g. mdl_qtype_match_subquestions, mdl_question, mdl_question_answers), where some of them just contain numeric references (links from one table to another).

Instead, what I would try would be:

1. Do a full site backup (https://docs.moodle.org/27/en/Backup) and make sure it is valid and works.

2. Restore the old database.

3. Go to the courses that contain quizzes.

4. Confirm the state of the quizzes.

5. Backup only the quiz activities of each course (https://docs.moodle.org/27/en/Reusing_activities).

6. Maybe a bit of extra work, but given the situation and to improve my possibilities of restoring the quizzes (or at least ease the process) I guess I would also go the Question bank page and export each quiz (https://docs.moodle.org/27/en/Export_questions) in Moodle XML format.

Once all that, well, time to restore and pray smile

1. Restore your site from your full site backup.

2. Go the courses which are supposed to contain quizzes and restore the respective Quiz Activity backups.

3. If for some particular reason the question bank has problems, well, you have the XML question backups, so you can try and work with them.

Once you have all your quizzes back and working... do a new full site backup smile

Cheers!