From 14ba7fd8ea82d6bf7d600cab751ddfacd093c6f4 Mon Sep 17 00:00:00 2001 From: uo277310 Date: Wed, 1 May 2024 21:38:36 +0200 Subject: [PATCH 1/2] prueba --- gatewayservice/gateway-service.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/gatewayservice/gateway-service.js b/gatewayservice/gateway-service.js index 72f0080d..935e276a 100644 --- a/gatewayservice/gateway-service.js +++ b/gatewayservice/gateway-service.js @@ -7,10 +7,7 @@ const swaggerUi = require('swagger-ui-express'); const fs = require("fs") const YAML = require('yaml') -require('dotenv').config(); - const app = express(); -app.disable("x-powered-by"); const port = 8000; const authServiceUrl = process.env.AUTH_SERVICE_URL || 'http://localhost:8002'; @@ -21,11 +18,6 @@ const genQuestServiceUrl = process.env.GEN_SERVICE_URL || 'http://localhost:8003 const rankingServiceUrl = process.env.RANK_SERVICE_URL || 'http://localhost:8004'; const questiongeneratorserviceUrl = process.env.QTEST_SERVICE_URL || 'http://localhost:8007'; -app.use((req, res, next) => { - res.header('Access-Control-Allow-Origin', '*'); - next(); -}); - app.use(cors()); app.use(express.json()); From c535b495edf72a9b1fbe443f67b71dfb78d7d995 Mon Sep 17 00:00:00 2001 From: uo283055 Date: Wed, 1 May 2024 22:48:40 +0200 Subject: [PATCH 2/2] edits game --- webapp/src/components/Game.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/webapp/src/components/Game.js b/webapp/src/components/Game.js index fd83d6b0..07abcce7 100644 --- a/webapp/src/components/Game.js +++ b/webapp/src/components/Game.js @@ -9,6 +9,7 @@ const Game = ({ username, totalQuestions, timeLimit, themes }) => { const [error, setError] = useState(''); const [correctQuestions, setCorrectQuestions] = useState(0); const [timer, setTimer] = useState(0); + const [themesSelected, setThemesSelected] = useState(themes); const [numberClics, setNumberClics] = useState(0); const [finished, setFinished] = useState(false); const [selectedAnswer, setSelectedAnswer] = useState(''); @@ -16,7 +17,7 @@ const Game = ({ username, totalQuestions, timeLimit, themes }) => { const [almacenado, setAlmacenado] = useState(false); const pricePerQuestion = 25; const delayBeforeNextQuestion = 3000; // 3 segundos de retardo antes de pasar a la siguiente pregunta - const themesSelected = themes; + const apiEndpoint = process.env.REACT_APP_API_ENDPOINT || 'http://localhost:8000'; function getRandomIndex(length) { @@ -57,7 +58,7 @@ const Game = ({ username, totalQuestions, timeLimit, themes }) => { .map(([tema]) => tema); const randomIndex = getRandomIndex(temas.length); const temaAleatorio = temas[randomIndex]; - console.log(selectedAnswer); + const response = await axios.get(`${apiEndpoint}/getRandomQuestion${temaAleatorio}`); setQuestion(response.data); const respuestas = [...response.data.incorrectas, response.data.correcta]; @@ -69,7 +70,7 @@ const Game = ({ username, totalQuestions, timeLimit, themes }) => { }; obtenerPreguntaAleatoria(); - }, [apiEndpoint, setQuestion, setRespuestasAleatorias, setError, themesSelected, selectedAnswer]); + }, [apiEndpoint, setQuestion, setRespuestasAleatorias, setError, themesSelected]); const handleTimeRemaining = () => { let minsR = Math.floor((timeLimit - timer) / 60); @@ -111,7 +112,7 @@ const Game = ({ username, totalQuestions, timeLimit, themes }) => { const respuestas = [...response.data.incorrectas, response.data.correcta]; setRespuestasAleatorias(respuestas.sort(randomSort).slice(0, 4)); // Mostrar solo 4 respuestas } catch (error) { - console.error("Error al obtener la pregunta aleatoria", error); + console.error("Error al obtener la pregunta aleatoria "+selectedAnswer, error); setError('Error al obtener la pregunta aleatoria'); } }; @@ -158,6 +159,9 @@ const Game = ({ username, totalQuestions, timeLimit, themes }) => { }); } catch (error) { setError(error.response.data.error); + if (timeLimit>15000) { + setThemesSelected(themes); + } } };