Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 400 and 402] [Versions 400 and 403]

(no description)

File Size: 260 lines (12 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: qbank_helper  - X-Ref

Helper class for question bank and its associated data.

get_version_options(int $questionid)   X-Ref
Get the available versions of a question where one of the version has the given question id.

return: \stdClass[] other versions of this question. Each object has fields versionid,
param: int $questionid id of a question.

get_question_structure(int $quizid, \context_module $quizcontext,int $slotid = null)   X-Ref
Get the information about which questions should be used to create a quiz attempt.

Each element in the returned array is indexed by slot.slot (slot number) an each object hass:
- All the field of the slot table.
- contextid for where the question(s) come from.
- category id for where the questions come from.
- For non-random questions, All the fields of the question table (but id is in questionid).
Also question version and question bankentryid.
- For random questions, filtercondition, which is also unpacked into category, randomrecurse,
randomtags, and note that these also have a ->name set and ->qtype set to 'random'.

return: array indexed by slot, with information about the content of each slot.
param: int $quizid the id of the quiz to load the data for.
param: \context_module $quizcontext the context of this quiz.
param: int|null $slotid optional, if passed only load the data for this one slot (if it is in this quiz).

get_tag_ids_for_slot(\stdClass $slotdata)   X-Ref
Get this list of random selection tag ids from one of the slots returned by get_question_structure.

return: array list of tag ids.
param: \stdClass $slotdata one of the array elements returned by get_question_structure.

describe_random_question(\stdClass $slotdata)   X-Ref
Given a slot from the array returned by get_question_structure, describe the random question it represents.

return: string that can be used to display the random slot.
param: \stdClass $slotdata one of the array elements returned by get_question_structure.

choose_question_for_redo(int $quizid, \context_module $quizcontext,int $slotid, qubaid_condition $qubaids)   X-Ref
Choose question for redo in a particular slot.

return: int the id of the question to use.
param: int $quizid the id of the quiz to load the data for.
param: \context_module $quizcontext the context of this quiz.
param: int $slotid optional, if passed only load the data for this one slot (if it is in this quiz).
param: qubaid_condition $qubaids attempts to consider when avoiding picking repeats of random questions.