Stop an infinite loop that occurs if you have questions all in the same category. Bug found by ltost.

This commit is contained in:
ian%hixie.ch 2003-09-24 21:22:50 +00:00
parent 1adea54304
commit 6d3257f5c7

View File

@ -292,8 +292,10 @@ sub quizQuestion { # called from quizStart or delayed from quizAnswer
if ($self->{'remainingQuestions'}->{$event->{'channel'}} != 0) {
$self->{'remainingQuestions'}->{$event->{'channel'}}--;
my $category = $self->{'questions'}->[$self->{'currentQuestion'}->{$event->{'channel'}}]->{'category'};
while ($category eq $self->{'questions'}->[$self->{'currentQuestion'}->{$event->{'channel'}}]->{'category'}
and my $try++ < keys %{$self->{'questions'}}) {
my $try = 0;
my $$questionCount = scalar keys %{$self->{'questions'}};
while ($self->{'questions'}->[$self->{'currentQuestion'}->{$event->{'channel'}}]->{'category'} eq $category
and $try++ < $questionCount) {
$self->{'currentQuestion'}->{$event->{'channel'}} = $self->pickQuestion();
}
$self->{'questionsTime'}->{$event->{'channel'}} = time();