Deleted a quiz, resulting in deletion of questions

Deleted a quiz, resulting in deletion of questions

- Richard Michael Coo の投稿
返信数: 2

Hi all, I've run into a problem and I badly need help.  Thanks in advance.

 

I tried to import some questions from another quiz, so I created a quiz called "Final Exam",and using the question bank, I moved the categories of the questions to "Default for Final Exam".

However I did not get the results I want, so I deleted "Final Exam", and tried to duplicate "Midterm Exam".  This resulted in all questions being deleted.

 

I restored the questions and categories by re-inserting data from a backup, but I cannot review the attempts.

It says:  Can not find data record in database table context.

Moodle version is 2.5

Richard Michael Coo への返信

Re: Deleted a quiz, resulting in deletion of questions

- Tim Hunt の投稿
画像 Core developers 画像 Documentation writers 画像 Particularly helpful Moodlers 画像 Peer reviewers 画像 Plugin developers

Questions in the Moodle database are identified by a unique id. You can see that id in the URL when you edit or preview a question.

When you deleted the old questions, those ids were no longer used.

When you re-inserted the data from a backup, that will have created new questions with new ids.

You may be able to fix things by finding the data (in mdl_question_attempts) that points to the old question ids, and manually fix it to point to the corresponding new question ids.

However, it is not quite that easy. For example, if you are using multiple choice questions, then as well is referring to the question.id, there will also be other data (in question_attempt_step_data) which refers to other ids, like the question_answers.id, and that will have to be fixed too.

Tim Hunt への返信

Re: Deleted a quiz, resulting in deletion of questions

- Richard Michael Coo の投稿

Thanks Tim!

I modified the backup to do INSERT IGNOREs...

But I only touched question and question_categories...didn't think there are too many tables involved...

I'll just let it stay that way, the exam is already graded thankfully, and it was the only exam that got messed up.

I can't review an entire quiz, but I can review each question attempt individually as a.....uhmm....workaround ^_^