SQL Query for Quiz and its queestions

SQL Query for Quiz and its queestions

Zinedine Riza -
回帖数:3

I tried this query for generating quiz' questions and their answers. But this query depends in user's attempt on quiz.

select
  distinct q.course,
  q.name,
  quiza.quiz,
  qa.questionsummary,
  qa.rightanswer
FROM
  mdl_quiz_attempts quiza
  JOIN mdl_quiz q ON q.id = quiza.quiz
  JOIN mdl_question_usages qu ON qu.id = quiza.uniqueid
  JOIN mdl_question_attempts qa ON qa.questionusageid = qu.id
where
  q.id = 1


What I want is regular sql query to list questions and answer by quiz.id/course/id, irrelevant to user's attempt on quiz. Can someone help me?

回复Zinedine Riza

Re: SQL Query for Quiz and its queestions

Zinedine Riza -
what I'm struggling is I can't find how to link between mdl_quiz and mdl_question table, I hope anyone can help me with this
回复Zinedine Riza

Re: SQL Query for Quiz and its queestions

Tim Hunt -
Core developers的头像 Documentation writers的头像 Particularly helpful Moodlers的头像 Peer reviewers的头像 Plugin developers的头像
JOIN mdl_question question ON question.id = qa.questionid

See also https://docs.moodle.org/dev/Overview_of_the_Moodle_question_engine#Detailed_data_about_an_attempt