question improvements
This commit is contained in:
parent
3977f101ad
commit
9ef6b48de0
3 changed files with 12 additions and 4 deletions
|
|
@ -38,7 +38,7 @@ async function getAlbumReleaseYear({
|
||||||
type: "numeric",
|
type: "numeric",
|
||||||
text: `What's the release year of ${subject}?`,
|
text: `What's the release year of ${subject}?`,
|
||||||
correct,
|
correct,
|
||||||
range: getQuestionRange(correct, 5),
|
range: getQuestionRange(correct, 10, 3),
|
||||||
points: 10,
|
points: 10,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -77,10 +77,14 @@ export function getQuestionDistanceScore(
|
||||||
export function getQuestionRange(
|
export function getQuestionRange(
|
||||||
correctValue: number,
|
correctValue: number,
|
||||||
tolerance: number,
|
tolerance: number,
|
||||||
|
randomness: number,
|
||||||
): { min: number; max: number } {
|
): { min: number; max: number } {
|
||||||
|
const min = Math.floor(correctValue - tolerance);
|
||||||
|
const max = Math.ceil(correctValue + tolerance);
|
||||||
|
const range = max - min;
|
||||||
return {
|
return {
|
||||||
min: Math.floor(correctValue - tolerance),
|
min: min + Math.floor(Math.random() * range * randomness),
|
||||||
max: Math.ceil(correctValue + tolerance),
|
max: max - Math.floor(Math.random() * range * randomness),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,11 @@ export function Question() {
|
||||||
setSelectedValue(question.type === "numeric" ? question.range.min : null);
|
setSelectedValue(question.type === "numeric" ? question.range.min : null);
|
||||||
}, [question]);
|
}, [question]);
|
||||||
|
|
||||||
if (!question) return null;
|
if (!question) return (
|
||||||
|
<Section>
|
||||||
|
<SectionTitle>Preparing quiz...</SectionTitle>
|
||||||
|
</Section>
|
||||||
|
);
|
||||||
|
|
||||||
const partyId = party.id;
|
const partyId = party.id;
|
||||||
const timeLeft = formatTimeLeft(question.endTimestamp - now);
|
const timeLeft = formatTimeLeft(question.endTimestamp - now);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue