diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index c950a041..a9f85e12 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -22,6 +22,7 @@ jobs:
- run: npm --prefix storeQuestionService ci
- run: npm --prefix userStatsService ci
- run: npm --prefix gameservice ci
+ - run: npm --prefix gameservice ci
- run: npm --prefix users/authservice test -- --coverage
- run: npm --prefix users/userservice test -- --coverage
- run: npm --prefix gatewayservice test -- --coverage
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 8bcd249f..ff86a356 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -232,7 +232,7 @@ jobs:
deploy:
name: Deploy over SSH
runs-on: ubuntu-latest
- needs: [docker-push-userservice,docker-push-authservice,docker-push-gatewayservice,docker-push-webapp, docker-push-questiongeneratorservice, docker-push-storequestionservice, docker-push-userstatsservice, docker-push-wikidataextractorservice]
+ needs: [docker-push-userservice,docker-push-authservice,docker-push-gatewayservice,docker-push-webapp, docker-push-questiongeneratorservice, docker-push-storequestionservice, docker-push-userstatsservice, docker-push-wikidataextractorservice, docker-push-gameservice]
steps:
- name: Deploy over SSH
uses: fifsky/ssh-action@master
diff --git a/docker-compose.yml b/docker-compose.yml
index ebf0671b..a0fbc49f 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -10,6 +10,7 @@ services:
- "27017:27017"
networks:
- mynetwork
+ restart: always
mongodb_wiki:
container_name: mongodb-wiki-${teamname:-defaultASW}
@@ -21,6 +22,7 @@ services:
- "27018:27017"
networks:
- mynetwork
+ restart: always
authservice:
container_name: authservice-${teamname:-defaultASW}
@@ -35,6 +37,7 @@ services:
- mynetwork
environment:
MONGODB_URI: mongodb://mongodb:27017/userdb
+ restart: always
userservice:
container_name: userservice-${teamname:-defaultASW}
@@ -49,6 +52,7 @@ services:
- mynetwork
environment:
MONGODB_URI: mongodb://mongodb:27017/userdb
+ restart: always
gameservice:
container_name: gameservice-${teamname:-defaultASW}
@@ -64,6 +68,7 @@ services:
environment:
QUESTIONS_GENERATOR_SERVICE_URL: http://questiongeneratorservice:8007
STORE_STATS_SERVICE: http://userstatsservice:8003
+ restart: always
questiongeneratorservice:
container_name: questiongeneratorservice-${teamname:-defaultASW}
@@ -80,6 +85,7 @@ services:
environment:
MONGODB_URI: mongodb://mongodb_wiki:27017/questions
STORE_QUESTION_SERVICE_URL: http://storequestionservice:8004
+ restart: always
wikidataextractorservice:
container_name: wikidataextractorservice-${teamname:-defaultASW}
@@ -94,6 +100,7 @@ services:
- mynetwork
environment:
MONGODB_URI: mongodb://mongodb_wiki:27017/questions
+ restart: always
gatewayservice:
container_name: gatewayservice-${teamname:-defaultASW}
@@ -115,6 +122,7 @@ services:
STORE_QUESTION_SERVICE_URL: http://storequestionservice:8004
QUESTIONS_GENERATOR_SERVICE_URL: http://questiongeneratorservice:8007
GAME_SERVICE_URL: http://gameservice:8005
+ restart: always
webapp:
@@ -126,6 +134,7 @@ services:
- gatewayservice
ports:
- "3000:3000"
+ restart: always
prometheus:
image: prom/prometheus
@@ -173,6 +182,7 @@ services:
- mynetwork
environment:
MONGODB_URI: mongodb://mongodb:27017/storedquestion
+ restart: always
userstatsservice:
container_name: userstats-${teamname:-defaultASW}
@@ -187,6 +197,7 @@ services:
- mynetwork
environment:
MONGODB_URI: mongodb://mongodb:27017/statsdb
+ restart: always
volumes:
diff --git a/questionsservice/questiongeneratorservice/questiongenerator.js b/questionsservice/questiongeneratorservice/questiongenerator.js
index 89206f31..3d96a1ee 100644
--- a/questionsservice/questiongeneratorservice/questiongenerator.js
+++ b/questionsservice/questiongeneratorservice/questiongenerator.js
@@ -4,21 +4,27 @@ class QuestionGenerator {
static temas = new Map([
["paises", [0, 1, 2]],
- ['capital', [0]],
- ["lenguaje", [1]]
+ ['capital', [0, 1]],
+ ["lenguaje", [2]]
]);
;
static plantillas = [
{
- pregunta: (param) => `¿Cual es la capital de ${param}?`,
- filtro: { capital: { $exists: true } },
+ pregunta: (param) => `¿Cuál es la capital de ${param}?`,
+ filtro: { pais: { $exists: true }, capital: { $exists: true } },
campo_pregunta: 'pais',
campo_respuesta: 'capital'
},
+ {
+ pregunta: (param) => `¿De qué país es capital ${param}?`,
+ filtro: { capital: { $exists: true }, pais: { $exists: true } },
+ campo_pregunta: 'capital',
+ campo_respuesta: 'pais'
+ },
{
pregunta: (param) => `¿Qué lengua se habla en ${param}?`,
- filtro: { lenguaje: { $exists: true } },
+ filtro: { pais: { $exists: true }, lenguaje: { $exists: true } },
campo_pregunta: 'pais',
campo_respuesta: 'lenguaje'
}
diff --git a/userStatsService/user-stats-service.js b/userStatsService/user-stats-service.js
index 7cbf2439..ae751c12 100644
--- a/userStatsService/user-stats-service.js
+++ b/userStatsService/user-stats-service.js
@@ -61,7 +61,7 @@ app.get('/history/games/:username', async (req, res) => {
questions: user.questions,
createdAt: user.createdAt
}));
- res.json(userInformation.slice(0, req.query.limit || userInformation.length));
+ res.json(userInformation.slice(0, req.query.limit || userInformation.length).reverse());
} else {
res.status(404).json({ error: 'User not found!' });
}
diff --git a/webapp/package-lock.json b/webapp/package-lock.json
index c4822bae..a4083cb2 100644
--- a/webapp/package-lock.json
+++ b/webapp/package-lock.json
@@ -5,6 +5,7 @@
"requires": true,
"packages": {
"": {
+ "name": "webapp",
"version": "0.1.0",
"dependencies": {
"@emotion/react": "^11.11.3",
@@ -6593,8 +6594,6 @@
"version": "8.12.0",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz",
"integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==",
- "optional": true,
- "peer": true,
"dependencies": {
"fast-deep-equal": "^3.1.1",
"json-schema-traverse": "^1.0.0",
@@ -6609,9 +6608,7 @@
"node_modules/ajv-formats/node_modules/json-schema-traverse": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz",
- "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==",
- "optional": true,
- "peer": true
+ "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug=="
},
"node_modules/ajv-keywords": {
"version": "3.5.2",
@@ -32559,13 +32556,14 @@
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-2.1.1.tgz",
"integrity": "sha512-Wx0Kx52hxE7C18hkMEggYlEifqWZtYaRgouJor+WMdPnQyEK13vgEWyVNup7SoeeoLMsr4kf5h6dOW11I15MUA==",
- "requires": {},
+ "requires": {
+ "ajv": "^8.0.0"
+ },
"dependencies": {
"ajv": {
- "version": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz",
+ "version": "8.12.0",
+ "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz",
"integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==",
- "optional": true,
- "peer": true,
"requires": {
"fast-deep-equal": "^3.1.1",
"json-schema-traverse": "^1.0.0",
@@ -32576,9 +32574,7 @@
"json-schema-traverse": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz",
- "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==",
- "optional": true,
- "peer": true
+ "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug=="
}
}
},
diff --git a/webapp/src/components/FirstGame.css b/webapp/src/components/FirstGame.css
index 8ab4704e..ad7935b5 100644
--- a/webapp/src/components/FirstGame.css
+++ b/webapp/src/components/FirstGame.css
@@ -22,6 +22,11 @@
border-image: linear-gradient(to bottom, rgba(0, 255, 0,var(--border-alpha)), rgba(0, 0, 255,var(--border-alpha))) 1;
}
+.questionStructure h1{
+ justify-content: center;
+ color: #F0F0F0;
+}
+
.questionStructure .answers {
display: flex;
justify-content: center; /* Alinea los elementos en el centro horizontal /
@@ -34,6 +39,13 @@
grid-template-columns: auto auto;
}
+.allAnswers > div{
+ width: 100%;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+}
+
.asnwers {
width:100%;
}
@@ -41,6 +53,7 @@
.questionFirstGame {
height: 100%;
+ width: 100%;
display: inline-block;
}
diff --git a/webapp/src/components/FirstGame.js b/webapp/src/components/FirstGame.js
index be5fb0a8..96e54769 100644
--- a/webapp/src/components/FirstGame.js
+++ b/webapp/src/components/FirstGame.js
@@ -5,7 +5,6 @@ import 'react-circular-progressbar/dist/styles.css';
import axios from 'axios';
import { useLocation, useNavigate } from 'react-router-dom';
import Button from './Button';
-import GoBackButton from './GoBackButton';
import { Footer } from './footer/Footer';
import { Nav } from './nav/Nav';
import {shuffleArray} from './Util'
@@ -18,12 +17,14 @@ var isCorrect = false
var questions = [];
var points = 0;
var load = true;
+const previousBackgroundColor = '#1a1a1a'
+
const Quiz = () => {
const navigator = useNavigate();
var allQuestions = useLocation().state.questions;
-
+ var haveEnter = false
var id = useLocation().state.gameId;
console.log(id)
@@ -35,7 +36,7 @@ const Quiz = () => {
const time = setInterval(() => {
setRemTime((progress) => {
if(progress === 100){
- newQuestion();
+ checkAnswer(-1);
return 0;
}
const diff = 4;
@@ -90,52 +91,45 @@ const Quiz = () => {
}
}
- const newQuestion = async () => {
- //Generamos las preguntas
- getQuestions()
+ const checkAnswer = async (option) => {
+ if (haveEnter) {
+ return
+ }
+ load = false
+
- //Desactivamos botones
- changeButtons("true")
+ console.log("Todas las preguntas", allQuestions)
+ // console.log(option === questions[currentQuestionIndex].correctAnswer)
+ isCorrect = (option === allQuestions[currentQuestionIndex].correctAnswer);
- //Marcamos la respuesta correcta
+ changeButtons("true")
+ // changeButtons(true);
+
const numberAnswer = allQuestions[currentQuestionIndex].options.indexOf(allQuestions[currentQuestionIndex].correctAnswer)
const botonCorrecta = document.getElementById('option-' + numberAnswer)
- const previousBackgroundColor = '#1a1a1a'
botonCorrecta.style.backgroundColor = 'green'
-
- // Pasar a la siguiente pregunta después de responder
- var indexAnswers = [numberAnswer, null]
-
- questions.push({
+ if (option < 0 && !haveEnter) {
+ haveEnter = true
+ questions.push({
title: allQuestions[currentQuestionIndex].question,
answers: allQuestions[currentQuestionIndex].options,
- ansIndex: indexAnswers
- }
- )
- load=false;
- await esperar(2000); // Espera 2000 milisegundos (2 segundos)
- botonCorrecta.style.backgroundColor = previousBackgroundColor
- if (allQuestions.length-1 !== currentQuestionIndex) {
+ ansIndex: [-1, numberAnswer]
+ })
+
+ await esperar(2000)
+ console.log(option)
currentQuestionIndex = (currentQuestionIndex + 1);
+ botonCorrecta.style.backgroundColor = previousBackgroundColor
+ changeButtons("false")
+ await gameStore()
+ haveFailedQuestion = false;
+ load = true
+ navigator('/menu')
+ return
}
- isCorrect = (false)
- //setRemTime(0)
- load=true
-
- //Habilitamos botones
- changeButtons("false")
- }
-
- const checkAnswer = async (option) => {
- getQuestions()
- // console.log(option === questions[currentQuestionIndex].correctAnswer)
- isCorrect = (option === allQuestions[currentQuestionIndex].correctAnswer);
- changeButtons("true")
- // changeButtons(true);
-
+
const botonIncorrecta = document.getElementById('option-' + allQuestions[currentQuestionIndex].options.indexOf(option))
- const previousBackgroundColor = botonIncorrecta.style.backgroundColor
// console.log(haveFailedQuestion)
// console.log(isCorrect)
@@ -145,16 +139,16 @@ const Quiz = () => {
botonIncorrecta.style.backgroundColor = 'red'
// console.log("Entramos a cambiar")
haveFailedQuestion = true;
+
// console.log("Despues de modificar los valores")
} else {
+ getQuestions()
points = points += 100;
}
- const numberAnswer = allQuestions[currentQuestionIndex].options.indexOf(allQuestions[currentQuestionIndex].correctAnswer)
- const botonCorrecta = document.getElementById('option-' + numberAnswer)
- botonCorrecta.style.backgroundColor = 'green'
+
// Pasar a la siguiente pregunta después de responder
- var indexAnswers = [numberAnswer, allQuestions[currentQuestionIndex].options.indexOf(option)]
+ var indexAnswers = [allQuestions[currentQuestionIndex].options.indexOf(option), numberAnswer]
questions.push({
title: allQuestions[currentQuestionIndex].question,
@@ -169,16 +163,18 @@ const Quiz = () => {
if (allQuestions.length-1 !== currentQuestionIndex) {
currentQuestionIndex = (currentQuestionIndex + 1);
}
+
isCorrect = (false)
setRemTime(0)
-
+ load = true
changeButtons("false")
console.log(haveFailedQuestion)
if(haveFailedQuestion) {
console.log("Entramos a guardar el juego")
await gameStore()
haveFailedQuestion = false;
+ currentQuestionIndex += 1
navigator('/menu')
}
};
@@ -223,7 +219,6 @@ const Quiz = () => {
-
{isCorrect ? '¡Respuesta correcta!' : 'Respuesta incorrecta.'}
diff --git a/webapp/src/components/GoBackButton.jsx b/webapp/src/components/GoBackButton.jsx deleted file mode 100644 index 563d5934..00000000 --- a/webapp/src/components/GoBackButton.jsx +++ /dev/null @@ -1,20 +0,0 @@ -import Button from "./Button"; -import { useNavigate } from 'react-router-dom'; // Importa useHistory - - - -function GoBackButton(){ - const navigation = useNavigate(); - - const goBack = async () => { - navigation('/menu') - } - - return ( -