This commit is contained in:
RaymondVerhoef
2026-05-25 19:09:17 +02:00
parent 6968bebbc2
commit 8291a52ba9

View File

@@ -207,26 +207,27 @@ export async function generateWeeklyQuiz(userId, weekNumber, force = false) {
const questions = [];
const primaryQs = await getOrGenerateTopicQuestions(primaryTopic, 5);
const primaryQs = await getOrGenerateTopicQuestions(primaryTopic, 3);
questions.push(...primaryQs);
for (const rt of reviewTopics) {
if (questions.length >= 5) break;
const rtQs = await getOrGenerateTopicQuestions(rt, 1);
questions.push(...rtQs);
}
if (questions.length < 10) {
const needed = 10 - questions.length;
if (questions.length < 5) {
const needed = 5 - questions.length;
const extraQs = await getOrGenerateTopicQuestions(primaryTopic, needed + 5);
const existingIds = new Set(questions.map(q => q.id));
for (const eq of extraQs) {
if (!existingIds.has(eq.id) && questions.length < 10) {
if (!existingIds.has(eq.id) && questions.length < 5) {
questions.push(eq);
}
}
}
const shuffled = shuffle(questions);
const shuffled = shuffle(questions).slice(0, 5);
const quiz = {
questions: shuffled,