Skip to content

Commit

Permalink
Now number of correct and incorrect questions are saved during the game
Browse files Browse the repository at this point in the history
  • Loading branch information
iyanfdezz committed Feb 22, 2024
1 parent 61ce2fe commit f0dadc1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions webapp/src/pages/Clasico/Clasico.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ const JuegoPreguntas = () => {
const [preguntaActual, setPreguntaActual] = useState("");
const navigate = useNavigate();

var preguntasCorrectas=0;
var preguntasFalladas=0;

useEffect(() => {
fetch("http://localhost:8003/questions?tematica=all&n=10")
.then((response) => response.json())
Expand Down Expand Up @@ -80,13 +83,18 @@ const JuegoPreguntas = () => {
const handleSiguientePregunta = () => {
if (respuestaSeleccionada === preguntaActual.correcta) {
setPuntuacion(puntuacion + 1);
preguntasCorrectas++;
}else{
preguntasFalladas++;
}
setRespuestaSeleccionada(null);
setTiempoRestante(10);
if (indicePregunta + 1 < preguntas.length) {
setIndicePregunta(indicePregunta + 1);
setPreguntaActual(preguntas[indicePregunta]);
} else {

//TODO: Introducir puntos, preguntas correctas y preguntas falladas en la BD
setJuegoTerminado(true);
}
};
Expand Down

0 comments on commit f0dadc1

Please sign in to comment.