Skip to content

Commit

Permalink
trying to fix the stats bug
Browse files Browse the repository at this point in the history
  • Loading branch information
angelmaciasr committed May 1, 2024
1 parent c9e29a2 commit 898bdbc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions webapp/src/components/Game/Game.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -73,9 +74,9 @@ export default function Game(props: Props) {
const handleNextQuestion = () => {
if(count===0) saveAnswer(' ');

setTimeout(() => {
goToNextQuestion();
}, 3000);
setTimeout(() => {
goToNextQuestion();
}, 3000);

};

Expand All @@ -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 <GameOver data-testid="game-over-component" answers={answerSelected} questions={questions} finalMessage="Game Over" />;
}

Expand Down
2 changes: 1 addition & 1 deletion webapp/src/components/stats/StatsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 898bdbc

Please sign in to comment.