Relatório detalhado das respostas da enquete das questões do tipo outro com comando SQL

Relatório detalhado das respostas da enquete das questões do tipo outro com comando SQL

por Lino Vaz Moniz -
Número de respostas: 0

Segue o comando SQL que lista todas as respostas da enquete das questões do tipo outro

Filtro apenas na tabela de banco de questão mdl_questionnaire_response_other

SELECT id,response_id,question_id,response FROM mdl_questionnaire_response_other WHERE id > 0

 

Filtro com junção na tabela de enquete, tipo de questões e questão 

Testado em Março/2022 no Moodle 3.11.2 Versão do questionnaire: 3.10.1 (Build - 2021080400)

SELECT ro.id,r.id AS mdlresponseid, qs.id AS mdlsurveyid,qs.name AS surveyname,qs.title AS surveytitle,q.id AS mdlquestionnaireid,q.name AS questionnairename, q.intro AS questionnaireintro,q.qtype AS questionnaireqtype,q.opendate AS questionnaireopendate,q.closedate AS questionnaireclosedate,q.resume AS questionnaireresume,q.grade AS questionnairegrade,q.completionsubmit AS questionnairecompletionsubmit, q.course AS mdlcourseid,c.fullname AS coursename,ct.id AS mdlcoursecategoryid,ct.name AS coursecategoryname,ct.path AS coursecategorypath,r.submitted AS responsesubmitted,r.complete AS responsecomplete,r.grade AS responsegrade,r.submitted,r.userid AS mdluserid,u.firstname AS userfirstname,u.lastname AS userlastname,u.email AS useremail,qq.id AS mdlquestionid,qq.name AS questionname,qq.content AS questioncontent, ro.response FROM mdl_questionnaire_response r INNER JOIN mdl_questionnaire q ON r.questionnaireid =q.id INNER JOIN mdl_questionnaire_survey qs ON qs.id=q.sid INNER JOIN mdl_course c ON c.id=q.course LEFT JOIN mdl_course_categories ct ON ct.id=c.category LEFT JOIN mdl_user u ON r.userid=u.id LEFT JOIN mdl_questionnaire_response_other ro ON ro.response_id=r.id LEFT JOIN mdl_questionnaire_question qq ON qq.id=ro.question_id  WHERE ro.id > 0

Versão anterior (Testado em: Maio/2017 -  2017050101 e Dezembro/2013  - 2013122200)

SELECT ro.id,r.id AS mdlresponseid, r.survey_id AS mdlsurveyid,qs.name AS surveyname,qs.title AS surveytitle,t.qid AS mdlquestionnaireid,q.name AS questionnairename, q.intro AS questionnaireintro,q.qtype AS questionnaireqtype,q.opendate AS questionnaireopendate,q.closedate AS questionnaireclosedate,q.resume AS questionnaireresume,q.grade AS questionnairegrade,q.completionsubmit AS questionnairecompletionsubmit, q.course AS mdlcourseid,c.fullname AS coursename,ct.id AS mdlcoursecategoryid,ct.name AS coursecategoryname,ct.path AS coursecategorypath,r.submitted AS responsesubmitted,r.complete AS responsecomplete,r.grade AS responsegrade,t.timemodified,t.userid AS mdluserid,u.firstname AS userfirstname,u.lastname AS userlastname,u.email AS useremail,qq.id AS mdlquestionid,qq.name AS questionname,qq.content AS questioncontent, ro.response FROM mdl_questionnaire_response r LEFT JOIN mdl_questionnaire_attempts t ON r.id=t.rid LEFT JOIN mdl_questionnaire_survey qs ON qs.id=r.survey_id LEFT JOIN mdl_questionnaire q ON t.qid=q.id LEFT JOIN mdl_course c ON c.id=q.course LEFT JOIN mdl_course_categories ct ON ct.id=c.category LEFT JOIN mdl_user u ON t.userid=u.id LEFT JOIN mdl_questionnaire_response_other ro ON ro.response_id=r.id LEFT JOIN mdl_questionnaire_question qq ON qq.id=ro.question_id  WHERE ro.id > 0