Mezuen egilea: Tim Hunt

Core developers-ren irudia Documentation writers-ren irudia Particularly helpful Moodlers-ren irudia Peer reviewers-ren irudia Plugin developers-ren irudia

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
        
Puntuazioen batez bestekoa:Useful (1)