From 744fc5e1af3c4c3a06164f453abb021b4b755109 Mon Sep 17 00:00:00 2001 From: CANCI0 Date: Thu, 7 Mar 2024 18:21:22 +0100 Subject: [PATCH 1/6] Ya no puede coincidir el nombre de la entidad con el de una de sus propiedades --- questionservice/questionGen/GenericGenerator.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/questionservice/questionGen/GenericGenerator.js b/questionservice/questionGen/GenericGenerator.js index 6886f99f..400df6ba 100644 --- a/questionservice/questionGen/GenericGenerator.js +++ b/questionservice/questionGen/GenericGenerator.js @@ -128,7 +128,9 @@ class GenericGenerator { if ( !questionObj.respuestas.includes(prop) && !entidad[propiedadPregunta].includes(prop) && - !/^Q\d+/.test(prop) + !/^Q\d+/.test(prop) && + entidadLabel != prop + ) { questionObj.respuestas.push(prop); } From b21fca39892ecdfdfc90b02ebe1cabbd6ea2cbee Mon Sep 17 00:00:00 2001 From: CANCI0 Date: Thu, 7 Mar 2024 18:28:12 +0100 Subject: [PATCH 2/6] =?UTF-8?q?M=C3=A1s=20correcciones?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- questionservice/questionGen/GenericGenerator.js | 4 ++-- webapp/src/pages/Bateria/Bateria.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/questionservice/questionGen/GenericGenerator.js b/questionservice/questionGen/GenericGenerator.js index 400df6ba..590369ab 100644 --- a/questionservice/questionGen/GenericGenerator.js +++ b/questionservice/questionGen/GenericGenerator.js @@ -145,8 +145,8 @@ class GenericGenerator { questionObj.correcta = this.#dateFormatter(questionObj.correcta); break; case "num": - questionObj.respuestas = questionObj.respuestas.map(x => Math.floor(x)); - questionObj.correcta = Math.floor(questionObj.correcta); + questionObj.respuestas = questionObj.respuestas.map(x => parseFloat(x).toFixed(2)); + questionObj.correcta = parseFloat(questionObj.correcta).toFixed(2); break; default: break; diff --git a/webapp/src/pages/Bateria/Bateria.js b/webapp/src/pages/Bateria/Bateria.js index 56dc8c7b..79418989 100644 --- a/webapp/src/pages/Bateria/Bateria.js +++ b/webapp/src/pages/Bateria/Bateria.js @@ -8,7 +8,7 @@ import { Link } from 'react-router-dom'; const JuegoPreguntas = () => { const [indicePregunta, setIndicePregunta] = useState(0); const [puntuacion, setPuntuacion] = useState(0); - const [tiempoRestante, setTiempoRestante] = useState(10); + const [tiempoRestante, setTiempoRestante] = useState(180); const [juegoTerminado, setJuegoTerminado] = useState(false); const preguntaActual = Preguntas[indicePregunta]; From bfd195bde61a40325f3a487bc7dc6734f1634aaf Mon Sep 17 00:00:00 2001 From: CANCI0 Date: Thu, 7 Mar 2024 19:12:39 +0100 Subject: [PATCH 3/6] =?UTF-8?q?Cambios=20en=20la=20l=C3=B3gica=20de=20los?= =?UTF-8?q?=20modos=20de=20juego?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- questionservice/data/tematicas.json | 1 - webapp/src/pages/Bateria/Bateria.css | 17 ++++ webapp/src/pages/Bateria/Bateria.js | 68 ++++++++++----- webapp/src/pages/Clasico/Clasico.js | 126 +++++++++++++-------------- webapp/src/pages/Home/Home.js | 4 +- 5 files changed, 126 insertions(+), 90 deletions(-) diff --git a/questionservice/data/tematicas.json b/questionservice/data/tematicas.json index 6e285adf..daa5ca22 100644 --- a/questionservice/data/tematicas.json +++ b/questionservice/data/tematicas.json @@ -12,7 +12,6 @@ "¿Cuál es la esperanza de vida media de ", "¿En qué fecha se fundó ", "¿Cuál es la forma de gobierno de ", - "¿Cuál es el lema de " ] }, diff --git a/webapp/src/pages/Bateria/Bateria.css b/webapp/src/pages/Bateria/Bateria.css index 3684928a..7da203ed 100644 --- a/webapp/src/pages/Bateria/Bateria.css +++ b/webapp/src/pages/Bateria/Bateria.css @@ -68,3 +68,20 @@ button{ margin: 0; } +/* HTML:
*/ +.loader { + width: 50px; + padding: 8px; + aspect-ratio: 1; + border-radius: 50%; + background: #25b09b; + --_m: + conic-gradient(#0000 10%,#000), + linear-gradient(#000 0 0) content-box; + -webkit-mask: var(--_m); + mask: var(--_m); + -webkit-mask-composite: source-out; + mask-composite: subtract; + animation: l3 1s infinite linear; +} +@keyframes l3 {to{transform: rotate(1turn)}} diff --git a/webapp/src/pages/Bateria/Bateria.js b/webapp/src/pages/Bateria/Bateria.js index 79418989..30ccce9f 100644 --- a/webapp/src/pages/Bateria/Bateria.js +++ b/webapp/src/pages/Bateria/Bateria.js @@ -1,18 +1,38 @@ import React, { useState, useEffect } from "react"; import "./Bateria.css"; -import Nav from '../../components/Nav/Nav.js'; +import Nav from "../../components/Nav/Nav.js"; import Footer from "../../components/Footer/Footer.js"; import Preguntas from "./prueba"; -import { Link } from 'react-router-dom'; +import { Link, useNavigate } from "react-router-dom"; const JuegoPreguntas = () => { + const [isLoading, setIsLoading] = useState(true); const [indicePregunta, setIndicePregunta] = useState(0); const [puntuacion, setPuntuacion] = useState(0); const [tiempoRestante, setTiempoRestante] = useState(180); const [juegoTerminado, setJuegoTerminado] = useState(false); - const preguntaActual = Preguntas[indicePregunta]; + const [preguntas, setPreguntas] = useState([]); + const [preguntaActual, setPreguntaActual] = useState(""); + const navigate = useNavigate(); useEffect(() => { + fetch("http://localhost:8003/questions?tematica=all&n=10000") + .then((response) => response.json()) + .then((data) => { + setPreguntas(data); + setPreguntaActual(data[0]); + setIsLoading(false); + }) + .catch((error) => { + console.error("Error al obtener las preguntas:", error); + navigate("/home"); + }); + }, []); + + useEffect(() => { + if(isLoading){ + return + } if (tiempoRestante === 0 || indicePregunta === Preguntas.length) { setJuegoTerminado(true); } @@ -47,9 +67,7 @@ const JuegoPreguntas = () => {