From 9ef6b48de0455f6cbe83dcb27cb935de901d715b Mon Sep 17 00:00:00 2001 From: Daniel Bulant Date: Mon, 4 May 2026 12:52:11 +0200 Subject: [PATCH] question improvements --- api/src/party/numeric-question-generator.ts | 2 +- api/src/party/question-utils.ts | 8 ++++++-- web/src/components/party/question.tsx | 6 +++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/api/src/party/numeric-question-generator.ts b/api/src/party/numeric-question-generator.ts index 87c4dda..a91d3ff 100644 --- a/api/src/party/numeric-question-generator.ts +++ b/api/src/party/numeric-question-generator.ts @@ -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, }; } diff --git a/api/src/party/question-utils.ts b/api/src/party/question-utils.ts index ae8f557..47591a7 100644 --- a/api/src/party/question-utils.ts +++ b/api/src/party/question-utils.ts @@ -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), }; } diff --git a/web/src/components/party/question.tsx b/web/src/components/party/question.tsx index 74e10cf..9de88d9 100644 --- a/web/src/components/party/question.tsx +++ b/web/src/components/party/question.tsx @@ -54,7 +54,11 @@ export function Question() { setSelectedValue(question.type === "numeric" ? question.range.min : null); }, [question]); - if (!question) return null; + if (!question) return ( +
+ Preparing quiz... +
+ ); const partyId = party.id; const timeLeft = formatTimeLeft(question.endTimestamp - now);