1+ import { createEncryptedAnswersBlob } from '@/lib/quiz/quiz-crypto' ;
2+ import { stripCorrectAnswers } from '@/db/queries/quiz' ;
13import { getQuizBySlug , getQuizQuestionsRandomized } from '@/db/queries/quiz' ;
24import { notFound } from 'next/navigation' ;
35import { getTranslations } from 'next-intl/server' ;
@@ -8,11 +10,13 @@ import { getCurrentUser } from '@/lib/auth';
810
911interface QuizPageProps {
1012 params : Promise < { locale : string ; slug : string } > ;
13+ searchParams : Promise < { seed ?: string } > ;
1114}
1215
13- export default async function QuizPage ( { params } : QuizPageProps ) {
16+ export default async function QuizPage ( { params, searchParams } : QuizPageProps ) {
1417 const { locale, slug } = await params ;
1518 const t = await getTranslations ( { locale, namespace : 'quiz.page' } ) ;
19+ const { seed : seedParam } = await searchParams ;
1620
1721 const user = await getCurrentUser ( ) ;
1822
@@ -22,9 +26,12 @@ export default async function QuizPage({ params }: QuizPageProps) {
2226 notFound ( ) ;
2327 }
2428
25- const seed = Date . now ( ) ;
29+ const seed = seedParam ? parseInt ( seedParam , 10 ) : Date . now ( ) ;
2630 const questions = await getQuizQuestionsRandomized ( quiz . id , locale , seed ) ;
2731
32+ const encryptedAnswers = createEncryptedAnswersBlob ( questions ) ;
33+ const clientQuestions = stripCorrectAnswers ( questions ) ;
34+
2835 if ( ! questions . length ) {
2936 return (
3037 < div className = "min-h-screen flex items-center justify-center" >
@@ -56,9 +63,12 @@ export default async function QuizPage({ params }: QuizPageProps) {
5663 < QuizContainer
5764 quizSlug = { slug }
5865 quizId = { quiz . id }
59- questions = { questions }
66+ questions = { clientQuestions }
67+ encryptedAnswers = { encryptedAnswers }
6068 userId = { user ?. id ?? null }
6169 timeLimitSeconds = { quiz . timeLimitSeconds ?? questions . length * 30 }
70+ seed = { seed }
71+ categorySlug = { quiz . categorySlug }
6272 />
6373 { user && < PendingResultHandler userId = { user . id } /> }
6474 </ div >
0 commit comments