question improvements

This commit is contained in:
Daniel Bulant 2026-05-04 12:52:11 +02:00
parent 3977f101ad
commit 9ef6b48de0
No known key found for this signature in database
3 changed files with 12 additions and 4 deletions

View file

@ -38,7 +38,7 @@ async function getAlbumReleaseYear({
type: "numeric",
text: `What's the release year of ${subject}?`,
correct,
range: getQuestionRange(correct, 5),
range: getQuestionRange(correct, 10, 3),
points: 10,
};
}

View file

@ -77,10 +77,14 @@ export function getQuestionDistanceScore(
export function getQuestionRange(
correctValue: number,
tolerance: number,
randomness: number,
): { min: number; max: number } {
const min = Math.floor(correctValue - tolerance);
const max = Math.ceil(correctValue + tolerance);
const range = max - min;
return {
min: Math.floor(correctValue - tolerance),
max: Math.ceil(correctValue + tolerance),
min: min + Math.floor(Math.random() * range * randomness),
max: max - Math.floor(Math.random() * range * randomness),
};
}

View file

@ -54,7 +54,11 @@ export function Question() {
setSelectedValue(question.type === "numeric" ? question.range.min : null);
}, [question]);
if (!question) return null;
if (!question) return (
<Section>
<SectionTitle>Preparing quiz...</SectionTitle>
</Section>
);
const partyId = party.id;
const timeLeft = formatTimeLeft(question.endTimestamp - now);