From 898bdbc061c3c9297f21cd996d97c0ff11ccf51c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81ngel=20Mac=C3=ADas?= Date: Wed, 1 May 2024 17:51:39 +0200 Subject: [PATCH] trying to fix the stats bug --- webapp/src/components/Game/Game.tsx | 12 ++++++++---- webapp/src/components/stats/StatsTable.tsx | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/webapp/src/components/Game/Game.tsx b/webapp/src/components/Game/Game.tsx index 0142ce2..628e98f 100644 --- a/webapp/src/components/Game/Game.tsx +++ b/webapp/src/components/Game/Game.tsx @@ -34,6 +34,7 @@ export default function Game(props: Props) { const [loadingdata, setLoadingData] = useState(true); const [score, setScore] = useState(0); const [correctSelected, setCorrectSelected] = useState(false); + const [gameNotFinished, setGameNotFinished] = useState(true); var questionTime = 100; if(props.difficulty === getHardString()) @@ -73,9 +74,9 @@ export default function Game(props: Props) { const handleNextQuestion = () => { if(count===0) saveAnswer(' '); - setTimeout(() => { - goToNextQuestion(); - }, 3000); + setTimeout(() => { + goToNextQuestion(); + }, 3000); }; @@ -91,7 +92,10 @@ export default function Game(props: Props) { if (questionCount === 10) { - updateStats(questionCount, score/10); + if(gameNotFinished){ + setGameNotFinished(false); + updateStats(questionCount, score/10); + } return ; } diff --git a/webapp/src/components/stats/StatsTable.tsx b/webapp/src/components/stats/StatsTable.tsx index 5e906b0..7447e18 100644 --- a/webapp/src/components/stats/StatsTable.tsx +++ b/webapp/src/components/stats/StatsTable.tsx @@ -17,7 +17,7 @@ export default function StatsTable() { if(user != null){ getUser(user.username).then((u) => { setQuestionAnswered(u.questions_answered); - setQuestionCorrect(u.correctly_answered_questions + u.cheeseCount); + setQuestionCorrect(u.correctly_answered_questions); setChesses(u.cheeseCount); }).catch((error) => { console.error('Error during retrieving the user', error);