From 6890c93cf88bfeba204ecd7e7c76b2b67a94cf04 Mon Sep 17 00:00:00 2001 From: Krish Chothani <143370415+KrishChothani@users.noreply.github.com> Date: Sat, 12 Oct 2024 08:20:04 +0530 Subject: [PATCH] Quiz Ui Redesign (#70) * Improve Quize UI * Improve --- frontend/src/appComponents/QuizPage.tsx | 205 ++++++++++++++---------- 1 file changed, 119 insertions(+), 86 deletions(-) diff --git a/frontend/src/appComponents/QuizPage.tsx b/frontend/src/appComponents/QuizPage.tsx index c3035aa..d330a44 100644 --- a/frontend/src/appComponents/QuizPage.tsx +++ b/frontend/src/appComponents/QuizPage.tsx @@ -24,12 +24,10 @@ export default function QuizPage() { const { id } = useParams<{ id: string }>(); const navigate = useNavigate(); + useEffect(() => { if (userId && secretCode != "") { fetchQuiz(); - } else { - console.log("userId", userId); - console.log("secretCode", secretCode); } }, [userId]); @@ -43,8 +41,6 @@ export default function QuizPage() { }, ); const data = response.data; - console.log("data"); - console.log(data); setQuiz(data); setUserAnswers({}); } catch (error) { @@ -81,7 +77,9 @@ export default function QuizPage() { correctAnswers++; } }); - const finalScore = quiz ? (correctAnswers / quiz.questions.length) * 100 : 0; + const finalScore = quiz + ? (correctAnswers / quiz.questions.length) * 100 + : 0; setScore(finalScore); axios @@ -97,7 +95,8 @@ export default function QuizPage() { "Content-Type": "application/json", }, }, - ).then(() => { + ) + .then(() => { alert("Quiz submitted successfully"); navigate("/"); }) @@ -108,100 +107,134 @@ export default function QuizPage() { if (!userId) { return ( -