Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
|
A question_variant_selection_strategy that randomly selects variants that were not used yet. More...
Public Member Functions | |
__construct (\question_usage_by_activity $quba, qubaid_condition $qubaids) | |
Constructor. | |
choose_variant ($maxvariants, $seed) | |
Protected Attributes | |
array | $selectedvariant = array() |
seed => variant number. | |
array | $variantsusecounts = array() |
seed => variant number => number of uses. | |
A question_variant_selection_strategy that randomly selects variants that were not used yet.
If all variants have been used at least once in the set of usages under consideration, then then it picks one of the least often used.
Within one particular use of this class, each seed will always select the same variant. This is so that shared datasets work in calculated questions, and similar features in question types like varnumeric and STACK.
core_question\engine\variants\least_used_strategy::__construct | ( | \question_usage_by_activity | $quba, |
qubaid_condition | $qubaids ) |
Constructor.
question_usage_by_activity | $quba | the question usage we will be picking variants for. |
qubaid_condition | $qubaids | ids of the usages to consider when counting previous uses of each variant. |
core_question\engine\variants\least_used_strategy::choose_variant | ( | $maxvariants, | |
$seed ) |
int | $maxvariants | the num |
string | $seed | data that can be used to controls how the variant is selected in a semi-random way. |
int | the variant to use, a number betweeb 1 and $maxvariants inclusive. |
Implements question_variant_selection_strategy.