Moodle PHP Documentation 4.1
Moodle 4.1.11 (Build: 20240610) (c8c84b4af18)
mod_quiz\question\bank\qbank_helper Class Reference

Static Public Member Functions

static choose_question_for_redo (int $quizid, context_module $quizcontext, int $slotid, qubaid_condition $qubaids)
 Choose question for redo in a particular slot.
 
static describe_random_question (\stdClass $slotdata)
 Given a slot from the array returned by get_question_structure, describe the random question it represents.
 
static get_question_structure (int $quizid, context_module $quizcontext, int $slotid=null)
 Get the information about which questions should be used to create a quiz attempt.
 
static get_tag_ids_for_slot (\stdClass $slotdata)
 Get this list of random selection tag ids from one of the slots returned by get_question_structure.
 
static get_version_options (int $questionid)
 Get the available versions of a question where one of the version has the given question id.
 

Detailed Description

Author
Safat Shahin safat.nosp@m.shah.nosp@m.in@ca.nosp@m.taly.nosp@m.st-au.nosp@m..net
License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Member Function Documentation

◆ choose_question_for_redo()

static mod_quiz\question\bank\qbank_helper::choose_question_for_redo ( int $quizid,
context_module $quizcontext,
int $slotid,
qubaid_condition $qubaids )
static

Choose question for redo in a particular slot.

Parameters
int$quizidthe id of the quiz to load the data for.
context_module$quizcontextthe context of this quiz.
int$slotidoptional, if passed only load the data for this one slot (if it is in this quiz).
qubaid_condition$qubaidsattempts to consider when avoiding picking repeats of random questions.
Return values
intthe id of the question to use.

◆ describe_random_question()

static mod_quiz\question\bank\qbank_helper::describe_random_question ( \stdClass $slotdata)
static

Given a slot from the array returned by get_question_structure, describe the random question it represents.

Parameters
stdClass$slotdataone of the array elements returned by get_question_structure.
Return values
stringthat can be used to display the random slot.

◆ get_question_structure()

static mod_quiz\question\bank\qbank_helper::get_question_structure ( int $quizid,
context_module $quizcontext,
int $slotid = null )
static

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'.
Parameters
int$quizidthe id of the quiz to load the data for.
context_module$quizcontextthe context of this quiz.
int | null$slotidoptional, if passed only load the data for this one slot (if it is in this quiz).
Return values
arrayindexed by slot, with information about the content of each slot.

◆ get_tag_ids_for_slot()

static mod_quiz\question\bank\qbank_helper::get_tag_ids_for_slot ( \stdClass $slotdata)
static

Get this list of random selection tag ids from one of the slots returned by get_question_structure.

Parameters
stdClass$slotdataone of the array elements returned by get_question_structure.
Return values
arraylist of tag ids.

◆ get_version_options()

static mod_quiz\question\bank\qbank_helper::get_version_options ( int $questionid)
static

Get the available versions of a question where one of the version has the given question id.

Parameters
int$questionidid of a question.
Return values
stdClass[]other versions of this question. Each object has fields versionid, version and questionid. Array is returned most recent version first.

The documentation for this class was generated from the following file: