Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
core_question\engine\variants\least_used_strategy Class Reference

A question_variant_selection_strategy that randomly selects variants that were not used yet. More...

Inheritance diagram for core_question\engine\variants\least_used_strategy:
question_variant_selection_strategy

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.
 

Detailed Description

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.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Constructor & Destructor Documentation

◆ __construct()

core_question\engine\variants\least_used_strategy::__construct ( \question_usage_by_activity $quba,
qubaid_condition $qubaids )

Constructor.

Parameters
question_usage_by_activity$qubathe question usage we will be picking variants for.
qubaid_condition$qubaidsids of the usages to consider when counting previous uses of each variant.

Member Function Documentation

◆ choose_variant()

core_question\engine\variants\least_used_strategy::choose_variant ( $maxvariants,
$seed )
Parameters
int$maxvariantsthe num
string$seeddata that can be used to controls how the variant is selected in a semi-random way.
Return values
intthe variant to use, a number betweeb 1 and $maxvariants inclusive.

Implements question_variant_selection_strategy.


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