From 7d1fe83f72dd4d4bc6f70face5750ba76cd7ed1b Mon Sep 17 00:00:00 2001 From: RaymondVerhoef Date: Mon, 25 May 2026 19:41:20 +0200 Subject: [PATCH] fix --- src/lib/testService.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/lib/testService.js b/src/lib/testService.js index e0828f5..d0a9657 100644 --- a/src/lib/testService.js +++ b/src/lib/testService.js @@ -94,10 +94,14 @@ async function selectTestTopics(userId, isoWeekNumber) { const weekContent = await getCurrentWeekContent(isoWeekNumber); if (weekContent && weekContent.topics && weekContent.topics.length > 0) { - const primaryTopic = weekContent.topics[0]; // Use first topic as primary for now - const others = topics.filter(t => t.id !== primaryTopic.id); - const reviewTopics = sample(others, Math.min(5, others.length)); - return { primaryTopic, reviewTopics, isReviewWeek: false }; + const primaryTopic = weekContent.topics[0]; + if (!primaryTopic?.id) { + console.warn('[Test] First curriculum topic has no id — falling back to hash'); + } else { + const others = topics.filter(t => t.id !== primaryTopic.id); + const reviewTopics = sample(others, Math.min(5, others.length)); + return { primaryTopic, reviewTopics, isReviewWeek: false }; + } } } catch (e) { console.warn('[Test] Curriculum lookup failed, falling back to hash:', e.message);