Identifying the Parent Questionnaire

Re: Identifying the Parent Questionnaire

by Mike Churchward -
Number of replies: 0
Picture of Core developers Picture of Plugin developers Picture of Testers
There actually is no easy way ... definitely an oversight.

In the database, you can find the parent questionnaire using:

SELECT q.*
FROM mdl_questionnaire q
INNER JOIN mdl_questionnaire_survey s ON s.id = q.sid
WHERE s.realm = 'public' AND s.courseid = q.course

This will return all public surveys where the course id's are the same in the questionnaire table and the survey table. That is, the parent questionnaire.

The child questionnaires will similarly be:

SELECT q.*
FROM mdl_questionnaire q
INNER JOIN mdl_questionnaire_survey s ON s.id = q.sid
WHERE s.realm = 'public' AND s.courseid != q.course

If you are looking for a particular one, you will need to know the survey id, and add it to the "WHERE" statement.