diff --git a/README.md b/README.md index 25a08a54..296fda3f 100644 --- a/README.md +++ b/README.md @@ -34,13 +34,15 @@ This is a repo for the [Software Architecture course](http://arquisoft.github.io/) in [2023/2024 edition](https://arquisoft.github.io/course2324.html) composed of the following components. -- **Game service**. +- **Game service**. Express server that mainly send requests from gateway to question generator service - **Gateway service**. Express service that is exposed to the public and serves as a proxy to the two previous ones. -- **Question service**. -- **Store question service**. +- **Question Generator service**. Express service that is going to generate the questions based on the wikidata information and the parameters given by the user +- **Store question service**. Express service that is going to store all the generated questions - **User service**. Express service that handles the insertion of new users in the system. - **Auth service**. Express service that handles the authentication of users. -- **User stats service**. +- **User stats service**. Express service that is going to store all the users data so we are going to be able to access to it later +- **Api's Gateway Service** Express service that is exposed to check the users information and the questions generated +- **Wikidata Extractor Service** Express service that extracts and update information from wikidata to a related topic each 30 minutes - **Webapp**. React web application that uses the gateway service to allow basic login and new user features. diff --git a/webapp/public/favicon.ico b/webapp/public/favicon.ico index a11777cc..277e6175 100644 Binary files a/webapp/public/favicon.ico and b/webapp/public/favicon.ico differ diff --git a/webapp/public/index.html b/webapp/public/index.html index a199db46..ca4fa740 100644 --- a/webapp/public/index.html +++ b/webapp/public/index.html @@ -26,7 +26,7 @@ work correctly both with client-side routing and a non-root public URL. Learn how to configure a non-root public URL by running `npm run build`. --> - React App + WIQEII diff --git a/webapp/src/components/Menu.js b/webapp/src/components/Menu.js index 2f42aa50..9af47859 100644 --- a/webapp/src/components/Menu.js +++ b/webapp/src/components/Menu.js @@ -7,6 +7,7 @@ import Button from './Button' import { Footer } from './footer/Footer'; import { Nav } from './nav/Nav'; import axios from 'axios'; +import { generateGameId } from './Util'; const apiEndpoint = process.env.REACT_APP_API_ENDPOINT|| 'http://localhost:8000'; @@ -31,7 +32,8 @@ const Menu = () => { } const initiateCalculator = async () => { - navigation("/calculator") + let gameId = await generateGameId(); + navigation("/calculator", {state: {gameId}}) } return ( diff --git a/webapp/src/components/game/Calculator.js b/webapp/src/components/game/Calculator.js index 8d66f85c..c4df72aa 100644 --- a/webapp/src/components/game/Calculator.js +++ b/webapp/src/components/game/Calculator.js @@ -4,25 +4,25 @@ import { Container, Typography, Box, LinearProgress } from '@mui/material'; import { Footer } from '../footer/Footer'; import { Nav } from '../nav/Nav'; import Button from '../Button'; -import { useNavigate } from 'react-router-dom'; +import { useLocation, useNavigate } from 'react-router-dom'; let questions = []; let load = true; const previousBackgroundColor = '#1a1a1a'; let points = 0; let answeredQuestions = []; +let enter = false const Calculator = () => { let username = localStorage.getItem("username") const [questionIndex, setQuestionIndex] = useState(0); - const id = generateGameId(); + let id = useLocation().state.gameId; const navigator = useNavigate(); const [remTime, setRemTime] = useState(0); - const [totalTime, setTotalTime] = useState(0); if(questions.length === 0) generateQuestion(); @@ -31,9 +31,13 @@ const Calculator = () => { const time = setInterval(() => { setRemTime((progress) => { if(progress === 100){ - setTotalTime(totalTime + (80-progress/10)/questions.length) - gameStore(id, username, points, answeredQuestions, totalTime/answeredQuestions.length); - init(); + console.log("Imprimimos id", id) + console.log("Answered questions", answeredQuestions) + let avgtime = 80/questions.length + if (!enter) { + gameStore(id, username, points, answeredQuestions, avgtime); + init(); + } navigator('/menu') return 0; }