Identifying the Parent Questionnaire

Identifying the Parent Questionnaire

by RK B -
Number of replies: 1

Is there a way to find out the parent questionnaire being used by a particular course ?

While configuring the course /activity we choose the parent questionnaire.

Once saved we don't see the parent questionnaire name.

The only way to know is through our documentation and naming conventions.

Is there a technical way of ascertaining this ? either from the target course/activity or the course/ activity in which the parent questionnaire resides

Average of ratings: -
In reply to RK B

Re: Identifying the Parent Questionnaire

by Mike Churchward -
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.