mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
MDL-53065 quiz redo question: avoid PHP notice in edge case
When selecting the variant of the new question, we need to add the new question to the usage before trying to select a variant. Also, we need to acutally use the selected variant number!
This commit is contained in:
parent
9d5d9c64ff
commit
293f5d1b11
2 changed files with 16 additions and 2 deletions
|
@ -90,6 +90,15 @@ class least_used_strategy implements \question_variant_selection_strategy {
|
|||
return $this->selectedvariant[$seed];
|
||||
}
|
||||
|
||||
// Catch a possible programming error, and make the problem clear.
|
||||
if (!isset($this->variantsusecounts[$seed])) {
|
||||
debugging('Variant requested for unknown seed ' . $seed . '. ' .
|
||||
'You must add all questions to the usage before creating the least_used_strategy. ' .
|
||||
'Continuing, but the variant choses may not actually be least used.',
|
||||
DEBUG_DEVELOPER);
|
||||
$this->variantsusecounts[$seed] = array();
|
||||
}
|
||||
|
||||
if ($maxvariants > 2 * count($this->variantsusecounts[$seed])) {
|
||||
// Many many more variants exist than have been used so far.
|
||||
// It will be quicker to just pick until we miss a collision.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue