SQL Query for Quiz and its queestions

SQL Query for Quiz and its queestions

Zinedine Riza
Number of replies: 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?

평균 등급 : -
In reply to 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
In reply to 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
평균 등급 :Useful (1)