Moodle PHP Documentation 4.3
Moodle 4.3.5 (Build: 20240610) (7dcfaa79f78)
question_variant_forced_choices_selection_strategy Class Reference

A question_variant_selection_strategy designed ONLY for testing. More...

Inheritance diagram for question_variant_forced_choices_selection_strategy:
question_variant_selection_strategy

Public Member Functions

 __construct (array $forcedchoices, question_variant_selection_strategy $basestrategy)
 Constructor.
 
 choose_variant ($maxvariants, $seed)
 

Static Public Member Functions

static prepare_forced_choices_array (array $variantsbyslot, question_usage_by_activity $quba)
 Helper method for preparing the $forcedchoices array.
 

Protected Attributes

question_variant_selection_strategy $basestrategy
 strategy used to make the non-forced choices.
 
array $forcedchoices
 seed => variant to select.
 

Detailed Description

A question_variant_selection_strategy designed ONLY for testing.

For selected questions it wil return a specific variants. For the other slots it will use a fallback strategy.

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

Constructor & Destructor Documentation

◆ __construct()

question_variant_forced_choices_selection_strategy::__construct ( array $forcedchoices,
question_variant_selection_strategy $basestrategy )

Constructor.

Parameters
array$forcedchoicesarray seed => variant to select.
question_variant_selection_strategy$basestrategystrategy used to make the non-forced choices.

Member Function Documentation

◆ choose_variant()

question_variant_forced_choices_selection_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.

◆ prepare_forced_choices_array()

static question_variant_forced_choices_selection_strategy::prepare_forced_choices_array ( array $variantsbyslot,
question_usage_by_activity $quba )
static

Helper method for preparing the $forcedchoices array.

Parameters
array$variantsbyslotslot number => variant to select.
question_usage_by_activity$qubathe question usage we need a strategy for.
Exceptions
coding_exceptionwhen variant cannot be forced as doesn't work.
Return values
arraythat can be passed to the constructor as $forcedchoices.

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