Doh! wrong thread. I was actually talking about https://moodle.org/mod/forum/discuss.php?d=467747 / MDL-85311 which was fixed weeks ago, and is badly needed here.
Tim Hunt
Posts made by Tim Hunt
So, MDL-84978 has been fixed for some weeks. Is there a reason the fix has not been applied here yet?
Are you running the latest version of STACK: There were changes in Moodle which required this update to STACK: https://github.com/maths/moodle-qtype_stack/issues/1422
The place you need to look now is in the question_set_references table. (And, for non-random questions, it is the question_references table.) The data matches up like this:
- usingcontextid - this will be the contextid of the quiz.
- component - will be 'mod_quiz'.
- questionarea - will be 'slot'
- itemid - will be quiz_slot.id
(If you are familiar with the mdl_files table, then this sort of thing might look familiar.)
Then, the data about what can be randomly selected is:
- questionscontextid - this is the context id of where the questions are. E.g. will match question_catgories.contextid.
- filtercondition - this is JSON data, to represent the query being done to select a set of question.
Pretty complicated sample query here https://github.com/moodle/moodle/blob/024e36be173aa99c290d7e91ed088c645e523ee6/mod/quiz/classes/question/bank/qbank_helper.php#L109.
If you use Postgres, there are nice operators for accessing things inside JSON, here is a snippet from one of our queries:
FROM {quiz_slots} slot
LEFT JOIN {question_set_references} qsr ON qsr.itemid = slot.id AND qsr.component = 'mod_quiz'
AND qsr.questionarea = 'slot' AND qsr.usingcontextid = ctx.id
LEFT JOIN {question_categories} qc ON qc.id = (qsr.filtercondition::json->>'questioncategoryid')::INTEGER