From e80c658add3e53d1661079b0b711d858ee8f0b75 Mon Sep 17 00:00:00 2001 From: uo264915 Date: Mon, 1 Apr 2024 11:36:03 +0200 Subject: [PATCH 1/3] =?UTF-8?q?Implementaci=C3=B3n=20CSS=20de=20Historical?= =?UTF-8?q?Data=20y=20otros=20cambios?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webapp/src/components/HistoricalData.css | 50 ++++++++++++++++++++ webapp/src/components/HistoricalData.js | 15 +++--- webapp/src/components/HistoricalQuestions.js | 39 +++++++++++++++ webapp/src/components/MainPage.js | 8 ++++ 4 files changed, 105 insertions(+), 7 deletions(-) create mode 100644 webapp/src/components/HistoricalData.css create mode 100644 webapp/src/components/HistoricalQuestions.js diff --git a/webapp/src/components/HistoricalData.css b/webapp/src/components/HistoricalData.css new file mode 100644 index 00000000..1e20a1c4 --- /dev/null +++ b/webapp/src/components/HistoricalData.css @@ -0,0 +1,50 @@ +.contenedor { + display: flex; + flex-direction: column; + align-items: center; +} + +div[title="botones"]{ + display: grid; + grid-template-columns: 1fr 1fr; + align-items: center; + margin-top: 2em; + margin-bottom: 2em; + grid-gap: 2em; +} + +button{ + margin: 1em; + padding: 0.25em; + background-color: rgba(31, 60, 134, 0.764); + color: white; + font-size: 0.75em; +} + +table { + width: 90%; + border-collapse: collapse; + color: black; + } + + th, td { + padding: 0.25em; + text-align: center; + border: 0.1em solid #000; + } + + th[title='pregunta'] { + background-color: rgba(41, 120, 152, 0.764); + } + + th[title='correcta'] { + background-color: rgba(79, 141, 18, 0.726); + } + + th[title='incorrecta'] { + background-color: rgba(230, 72, 72, 0.952); + } + + td{ + background-color: rgba(61, 178, 224, 0.764); + } \ No newline at end of file diff --git a/webapp/src/components/HistoricalData.js b/webapp/src/components/HistoricalData.js index 6e746026..379f4b8b 100644 --- a/webapp/src/components/HistoricalData.js +++ b/webapp/src/components/HistoricalData.js @@ -2,6 +2,7 @@ import axios from 'axios'; import React, { useState} from 'react'; import { useNavigate} from 'react-router-dom'; import { Container, Button} from '@mui/material'; +import './HistoricalData.css'; const HistoricalData = () => { const navigate = useNavigate(); @@ -26,9 +27,9 @@ const HistoricalData = () => { return ( - + -
+
@@ -41,11 +42,11 @@ const HistoricalData = () => { - - - - - + + + + + diff --git a/webapp/src/components/HistoricalQuestions.js b/webapp/src/components/HistoricalQuestions.js new file mode 100644 index 00000000..2e734412 --- /dev/null +++ b/webapp/src/components/HistoricalQuestions.js @@ -0,0 +1,39 @@ +import axios from 'axios'; +import React, { useState} from 'react'; +import { useNavigate} from 'react-router-dom'; +import { Container, Button} from '@mui/material'; + +const HistoricalQuestions = () => { + const navigate = useNavigate(); + const apiEndpoint = process.env.REACT_APP_API_ENDPOINT || 'http://localhost:8000'; + + const [questionsHistory, setQuestionsHistory] = useState([]); + + const handleShowHistory = async () => { + try{ + // It makes a petition to the api and store the response + const response = await axios.post(`${apiEndpoint}/getquestionshistory`, { }); + setQuestionsHistory(response.data); + }catch (error){ + console.error('Error:', error); + } + } + + const handlePreviousPage = async () => { + let path= '/MainPage'; + navigate(path); + } + + return ( + + + +
+ +
+
+ + ); +}; + +export default HistoricalQuestions; \ No newline at end of file diff --git a/webapp/src/components/MainPage.js b/webapp/src/components/MainPage.js index 09ecef3c..ea0152d1 100644 --- a/webapp/src/components/MainPage.js +++ b/webapp/src/components/MainPage.js @@ -16,6 +16,11 @@ const MainPage = () => { navigate(path); }; + const handleShowHistoricalQuestions = () => { + let path= '/HistoricalQuestions'; + navigate(path); + }; + return (
@@ -33,6 +38,9 @@ const MainPage = () => { +
) From 3d1d556284293d39e1dfc4c4b41f0f04a46ec06d Mon Sep 17 00:00:00 2001 From: baraganio Date: Mon, 1 Apr 2024 13:30:10 +0200 Subject: [PATCH 2/3] Error despliegue --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d97540f6..4ce47e3e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -162,5 +162,5 @@ jobs: command: | wget https://raw.githubusercontent.com/arquisoft/wiq_es2b/master/docker-compose.yml -O docker-compose.yml wget https://raw.githubusercontent.com/arquisoft/wiq_es2b/master/.env -O .env - docker compose down - docker compose --profile prod up -d + docker compose --profile prod down + docker compose --profile prod up -d --pull always From 92cce230eec3adf794d20888c088f0e6b8896de3 Mon Sep 17 00:00:00 2001 From: uo264915 Date: Sun, 7 Apr 2024 14:10:14 +0200 Subject: [PATCH 3/3] Resolucion problemas fin de partida --- .github/workflows/release.yml | 4 -- webapp/src/components/Game.js | 22 ++++++----- webapp/src/components/HistoricalQuestions.js | 39 -------------------- webapp/src/components/MainPage.js | 7 ---- 4 files changed, 12 insertions(+), 60 deletions(-) delete mode 100644 webapp/src/components/HistoricalQuestions.js diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d79bea68..fc3e6a08 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -169,8 +169,4 @@ jobs: docker compose --profile prod down docker compose --profile prod up -d --pull always - wget https://raw.githubusercontent.com/arquisoft/wiq_0/master/docker-compose.yml -O docker-compose.yml - wget https://raw.githubusercontent.com/arquisoft/wiq_0/master/.env -O .env - docker compose --profile prod down - docker compose --profile prod up -d --pull always diff --git a/webapp/src/components/Game.js b/webapp/src/components/Game.js index d394909d..a96ed7ba 100644 --- a/webapp/src/components/Game.js +++ b/webapp/src/components/Game.js @@ -23,8 +23,8 @@ const Game = () => { const [questionCounter, setQuestionCounter] = useState(0); const [incorrectCounter, setIncorrectCounter] = useState(0); - const [numberOfQuestions, setNumberOfQuestions] = useState(10); - const [questionsToAnswer, setQuestionsToAnswer] = useState(10); + const [numberOfQuestions] = useState(3); + const [questionsToAnswer, setQuestionsToAnswer] = useState(3); const [isFinished, setFinished] = useState(false); const [percentage, setPercentage] = useState(0); @@ -55,9 +55,16 @@ const Game = () => { useEffect(() => { if (isGameFinished() && !isFinished){ finishGame(); - setFinished(true) + setFinished(true); ; } }, [correctCounter]); + + useEffect(() => { + if (isGameFinished() && !isFinished){ + finishGame(); + setFinished(true); +; } + }, [incorrectCounter]); // This method will call the create question service const handleShowQuestion = async () => { @@ -84,11 +91,8 @@ const Game = () => { button.onmouse = colorOnMousePreguntas; }); - - incrementQuestion(); - }catch (error){ console.error('Error:', error); } @@ -134,13 +138,11 @@ const Game = () => { decrementQuestionsToAnswer(); - - if (!isFinished){ + if (!isGameFinished()) { setTimeout(() => { handleShowQuestion(); - }, 850); + }, 1000); } - } const isGameFinished = () => { diff --git a/webapp/src/components/HistoricalQuestions.js b/webapp/src/components/HistoricalQuestions.js deleted file mode 100644 index 2e734412..00000000 --- a/webapp/src/components/HistoricalQuestions.js +++ /dev/null @@ -1,39 +0,0 @@ -import axios from 'axios'; -import React, { useState} from 'react'; -import { useNavigate} from 'react-router-dom'; -import { Container, Button} from '@mui/material'; - -const HistoricalQuestions = () => { - const navigate = useNavigate(); - const apiEndpoint = process.env.REACT_APP_API_ENDPOINT || 'http://localhost:8000'; - - const [questionsHistory, setQuestionsHistory] = useState([]); - - const handleShowHistory = async () => { - try{ - // It makes a petition to the api and store the response - const response = await axios.post(`${apiEndpoint}/getquestionshistory`, { }); - setQuestionsHistory(response.data); - }catch (error){ - console.error('Error:', error); - } - } - - const handlePreviousPage = async () => { - let path= '/MainPage'; - navigate(path); - } - - return ( - - - -
- -
-
- - ); -}; - -export default HistoricalQuestions; \ No newline at end of file diff --git a/webapp/src/components/MainPage.js b/webapp/src/components/MainPage.js index 6a2231c8..9bba6333 100644 --- a/webapp/src/components/MainPage.js +++ b/webapp/src/components/MainPage.js @@ -21,10 +21,6 @@ const MainPage = () => { navigate(path); }; - const handleShowHistoricalQuestions = () => { - let path= '/HistoricalQuestions'; - navigate(path); - }; return ( @@ -46,9 +42,6 @@ const MainPage = () => { - )
PreguntaOpción correctaOpción incorrecta 1Opción incorrecta 2Opción incorrecta 3PreguntaOpción correctaOpción incorrecta 1Opción incorrecta 2Opción incorrecta 3