What is parent column in question table

What is parent column in question table

by Rome Patel -
Number of replies: 4
I am unable to understand that,
Which Id is stored in the parent column of the question table

Please Help me out
Average of ratings: -
In reply to Rome Patel

Re: What is parent column in question table

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
It is only used in special cases. The main effect is that a question where parent != 0 is not a real question.

One case is random question, which use parent == question.id as a convention.

The other case is multianswer questions, where the subquestions have a parent pointing at the parent question.
Average of ratings: Useful (1)
In reply to Tim Hunt

Re: What is parent column in question table

by Pascal Maury -
Picture of Plugin developers

Hello,

I use Moodle 2.3.6

Could you give more information about "One case is random question, which use parent == question.id as a convention" ?

I explain my problem : I want to delete a category of questions but Moodle tells me "there are 10 questions in this category".
When I display the category, no question appears. If I check in the database, I find them with the field 'parent = question.id' and the name like "Random (Default for *coursename*).

Example :

id category parent name
9054 2426 9054

Random (Default for Test)

When I look the page /report/questioninstances, there are 10 visibles questions in the course.

What are these questions ? How can I delete them ?

(I found 70 questions like that, mainly (could be even 'only') in courses created by duplicating another course.)

Thanks !

Pascal

In reply to Pascal Maury

Re: What is parent column in question table

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Right, those are random questions. The most reliable way to detect that is to look in the qtype column.

If there are no references to that question in the quiz_question_instances table, then you can safely delete it.

Yes, we should make Moodle smarter about dealing with this automatically.

Average of ratings: Useful (1)
In reply to Tim Hunt

Re: What is parent column in question table

by Séverin Terrier -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Testers Picture of Translators

Yes, that would be useful!

Perhaps by adding some checks in /admin/tool/health/ and solutions (queries to apply in DB) if needed.