I found this really helpful query by Tim Hunt
SELECT upper(u.username), q.name as question, qa.rightanswer, qa.responsesummary FROM mdl_quiz_attempts quiza JOIN mdl_question_usages qu ON qu.id = quiza.uniqueid JOIN mdl_question_attempts qa ON qa.questionusageid = qu.id JOIN mdl_question q ON qa.questionid = q.id JOIN mdl_question_attempt_steps qas ON qas.questionattemptid = qa.id AND qas.sequencenumber = ( SELECT MAX(sequencenumber) FROM mdl_question_attempt_steps WHERE questionattemptid = qa.id ) JOIN mdl_user u ON qas.userid = u.id LEFT JOIN mdl_question_attempt_step_data qasd ON qasd.attemptstepid = qas.id
Now I am storing the results in a table tabl1. I am using a second query in the form
select count(*),question,responsesummary from tabl1 group by question,responsesummary
Now as per the query I should get count to all the responses to a question. But options are coming twice. I wonder if they are internally different because they appear the same. I have added a screenshot for reference below. Ideally only 4 options should be present (Questions are MCQ) . It's happening for many questions. Any idea why is this happening? Maybe the HTML formatting or something.