Advertisement
stronk7

Untitled

Mar 29th, 2022
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. SELECT q.id, (SELECT COUNT(1)
  2. FROM m_quiz_attempts quiza
  3. JOIN m_question_attempts qa ON qa.questionusageid = quiza.uniqueid
  4. WHERE qa.questionid = q.id AND quiza.quiz = :o_quizaquiz AND quiza.userid = :o_userid AND preview = 0 AND state IN (:o_state1, :o_state2)
  5. ) AS previous_attempts
  6. FROM m_question q JOIN m_question_versions qv ON qv.questionid = q.id
  7. JOIN m_question_bank_entries qbe ON qbe.id = qv.questionbankentryid
  8. WHERE qbe.questioncategoryid IN (:o_qc12,:o_qc13)
  9. AND q.parent = 0
  10. AND qv.status = 'ready'
  11. AND qv.version = (SELECT MAX(v.version)
  12. FROM m_question_versions v
  13. JOIN m_question_bank_entries be
  14. ON be.id = v.questionbankentryid
  15. WHERE be.id = qbe.id) AND q.id IN (SELECT ti.itemid
  16. FROM m_tag_instance ti
  17. WHERE ti.itemtype = :o_questionitemtype
  18. AND ti.component = :o_questioncomponent
  19. AND ti.tagid = :o_ti14
  20. GROUP BY ti.itemid
  21. HAVING COUNT(itemid) = :o_tagcount) AND (q.qtype NOT IN (:o_excludedqtype8,:o_excludedqtype9,:o_excludedqtype10,:o_excludedqtype11))
  22. ORDER BY previous_attempts
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement