From 26c8c062040f7d2e17e1b37f7e25c65b115e9320 Mon Sep 17 00:00:00 2001 From: teresagg Date: Sat, 27 Apr 2024 09:34:02 +0200 Subject: [PATCH 01/37] Filtering good questions --- .../services/generate-questions-service.js | 3 +- questions/services/wikidata-service.js | 11 +- questions/utils/question.json | 260 +----------------- 3 files changed, 16 insertions(+), 258 deletions(-) diff --git a/questions/services/generate-questions-service.js b/questions/services/generate-questions-service.js index fe467689..438190c8 100644 --- a/questions/services/generate-questions-service.js +++ b/questions/services/generate-questions-service.js @@ -24,7 +24,7 @@ async function generateQuestions(n, language, questionCategory) { // get data for selected entity let pos = Math.floor(Math.random() * entity.properties.length); - + //use only property of that required category if(questionCategory) { const filteredProperties = []; @@ -33,6 +33,7 @@ async function generateQuestions(n, language, questionCategory) { filteredProperties.push(property); } }); + const randomPos = Math.floor(Math.random() * filteredProperties.length); const propertyJson = filteredProperties[randomPos]; pos = entity.properties.findIndex(prop => prop === propertyJson); diff --git a/questions/services/wikidata-service.js b/questions/services/wikidata-service.js index 9684d293..f9f76bdb 100644 --- a/questions/services/wikidata-service.js +++ b/questions/services/wikidata-service.js @@ -1,6 +1,7 @@ const axios = require('axios'); async function getRandomEntity(entity, pos, language) { + const property = entity.properties[pos].property; const filt = entity.properties[pos].filter; var filter = ''; @@ -22,13 +23,12 @@ async function getRandomEntity(entity, pos, language) { `; // it is better to use the FILTER rather than SERVICE //SERVICE wikibase:label { bd:serviceParam wikibase:language "es". } - + const urlApiWikidata = 'https://query.wikidata.org/sparql'; const headers = { 'User-Agent': 'QuestionGeneration/1.0', 'Accept': 'application/json', }; - try { response = await axios.get(urlApiWikidata, { params: { @@ -37,14 +37,16 @@ async function getRandomEntity(entity, pos, language) { }, headers: headers, }); - + + const data = await response.data const entities = data.results.bindings; - + if (entities.length > 0) { const randomEntity = entities[Math.floor(Math.random() * entities.length)]; const entityName = randomEntity.entityLabel.value; const property = randomEntity.property.value; + console.log("ENTITY, PROPERTY: ",entityName, property); return [entityName, property]; } else { return null; @@ -95,6 +97,7 @@ async function getProperties(property, language, filt) { for(var i = 0; i < 3 ; i++) { properties[i] = list[Math.floor(Math.random() * list.length)].property.value; } + console.log("PROPERTIES: ",properties); return properties; } return null; diff --git a/questions/utils/question.json b/questions/utils/question.json index 9b48cb34..32aafbe5 100644 --- a/questions/utils/question.json +++ b/questions/utils/question.json @@ -91,7 +91,7 @@ "lang": "en", "question": "What country is x river in" }], - "category": ["Geography"] + "category": ["Geography", "River"] } ] }, @@ -112,18 +112,6 @@ }], "category": ["Art"] }, - { - "property": "P571", - "template": [{ - "lang": "es", - "question": "Cual es el año de creacion de x" - }, - { - "lang": "en", - "question": "What is the year of creation of x" - }], - "category": ["Art"] - }, { "property": "P136", "template": @@ -155,19 +143,6 @@ "question": "Who is the inventor of x" }], "category": ["Science"] - }, - { - "property": "P575", - "template": - [{ - "lang": "es", - "question": "En que año se inventó x" - }, - { - "lang": "en", - "question": "What was the year of invention of x" - }], - "category": ["Science"] } ] }, @@ -180,19 +155,20 @@ "template": [{ "lang": "es", - "question": "Cual es la altitud mxima del x" + "question": "Cual es la altitud de la montaña x" }, { "lang": "en", "question": "What is the maximum altitude of x" }], - "category": ["Geography"] + "filter": ">4000", + "category": ["Geography", "Mountains"] } ] }, { "name": "book", - "instance": "Q571", + "instance": "Q7725634", "properties": [ { "property": "P50", @@ -207,18 +183,6 @@ }], "category": ["Entertainment"] }, - { - "property": "P577", - "template": [{ - "lang": "es", - "question": "Cual es el año de publicacion de x" - }, - { - "lang": "en", - "question": "What is the year of publication of x" - }], - "category": ["Entertainment"] - }, { "property": "P136", "template": @@ -235,125 +199,7 @@ ] }, { - "name": "vehicle", - "instance": "Q42889", - "properties": [ - { - "property": "P176", - "template": - [{ - "lang": "es", - "question": "Quien es el fabricante de x" - }, - { - "lang": "en", - "question": "Who is the manufacturer of x" - }], - "category": ["Cars"] - }, - { - "property": "P3032", - "template": [{ - "lang": "es", - "question": "Cuál es la velocidad máxima de x" - }, - { - "lang": "en", - "question": "What is the maximum speed of x" - }], - "category": ["Cars"] - }, - { - "property": "P571", - "template": - [{ - "lang": "es", - "question": "En qué año fue introducido x al mercado" - }, - { - "lang": "en", - "question": "In what year was x introduced to the market" - }], - "category": ["Cars"] - } - ] - }, - { - "name": "dish", - "instance": "Q746549", - "properties": [ - { - "property": "P527", - "template": - [{ - "lang": "es", - "question": "Cuál es el ingrediente principal de x" - }, - { - "lang": "en", - "question": "What is the main ingredient of x" - }], - "category": ["Food"] - }, - { - "property": "P495", - "template": [{ - "lang": "es", - "question": "De qué región es originario x" - }, - { - "lang": "en", - "question": "What region is x originally from?" - }], - "category": ["Food"] - } - ] - }, - { - "name": "building", - "instance": "Q41176", - "properties": [ - { - "property": "P84", - "template": - [{ - "lang": "es", - "question": "Quién fue el arquitecto de x" - }, - { - "lang": "en", - "question": "Who was the architect of x" - }], - "category": ["Art"] - }, - { - "property": "P571", - "template": [{ - "lang": "es", - "question": "En qué año se completó x" - }, - { - "lang": "en", - "question": "In what year was it completed x" - }], - "category": ["Art"] - }, - { - "property": "P149", - "template": [{ - "lang": "es", - "question": "Cuál es el estilo arquitectónico de x" - }, - { - "lang": "en", - "question": "What is the architectural style of x" - }], - "category": ["Art"] - } - ] - }, - { - "name": "television series", + "name": "television series", "instance": "Q5398426", "properties": [ { @@ -379,41 +225,11 @@ "lang": "en", "question": "How many seasons does the series x have?" }], + "filter": ">0", "category": ["Entertainment"] } ] }, - { - "name": "software", - "instance": "Q7397", - "properties": [ - { - "property": "P178", - "template": - [{ - "lang": "es", - "question": "Quién desarrolló el software x" - }, - { - "lang": "en", - "question": "Who developed the software x" - }], - "category": ["Technology"] - }, - { - "property": "P277", - "template": [{ - "lang": "es", - "question": "En qué lenguaje de programación está escrito x" - }, - { - "lang": "en", - "question": "What programming language is x written in?" - }], - "category": ["Technology"] - } - ] - }, { "name": "athlete", "instance": "Q2066131", @@ -462,18 +278,6 @@ }], "category": ["Games"] }, - { - "property": "P577", - "template": [{ - "lang": "es", - "question": "En qué año fue lanzado el videojuego x" - }, - { - "lang": "en", - "question": "In what year was the video game x released?" - }], - "category": ["Games"] - }, { "property": "P400", "template": [{ @@ -488,37 +292,6 @@ } ] }, - { - "name": "jewelry", - "instance": "Q161439", - "properties": [ - { - "property": "P287", - "template": - [{ - "lang": "es", - "question": "Quién es el diseñador de la marca x" - }, - { - "lang": "en", - "question": "Who is the designer of the brand x" - }], - "category": ["Fashion"] - }, - { - "property": "P571", - "template": [{ - "lang": "es", - "question": "Cuándo fue fundada la casa de moda x" - }, - { - "lang": "en", - "question": "When was the fashion house founded x" - }], - "category": ["Fashion"] - } - ] - }, { "name": "taxon", "instance": "Q16521", @@ -549,24 +322,5 @@ "category": ["Animals"] } ] - }, - { - "name": "brands", - "instance": "Q431289", - "properties": [ - { - "property": "P571", - "template": - [{ - "lang": "es", - "question": "Cuándo fue fundada la marca x" - }, - { - "lang": "en", - "question": "When was the brand x founded?" - }], - "category": ["Brands"] - } - ] } ] \ No newline at end of file From 3b83319d8b924d0ce7fda3bd406bd112e52082ca Mon Sep 17 00:00:00 2001 From: teresagg Date: Sat, 27 Apr 2024 10:20:29 +0200 Subject: [PATCH 02/37] Changing categories to questions --- questions/utils/question.json | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/questions/utils/question.json b/questions/utils/question.json index 32aafbe5..683091da 100644 --- a/questions/utils/question.json +++ b/questions/utils/question.json @@ -40,7 +40,7 @@ "lang": "en", "question": "What currency x has" }], - "category": ["Political"] + "category": ["Geography"] } ] }, @@ -91,7 +91,7 @@ "lang": "en", "question": "What country is x river in" }], - "category": ["Geography", "River"] + "category": ["Geography"] } ] }, @@ -162,7 +162,7 @@ "question": "What is the maximum altitude of x" }], "filter": ">4000", - "category": ["Geography", "Mountains"] + "category": ["Geography"] } ] }, @@ -245,7 +245,7 @@ "lang": "en", "question": "Who developed the software x" }], - "category": ["Sport"] + "category": ["Sports"] }, { "property": "P27", @@ -257,7 +257,7 @@ "lang": "en", "question": "What is the nationality of the athlete x" }], - "category": ["Sport"] + "category": ["Sports"] } ] }, @@ -276,7 +276,7 @@ "lang": "en", "question": "Who is the developer of the video game x" }], - "category": ["Games"] + "category": ["Games","Entertainment"] }, { "property": "P400", @@ -288,7 +288,7 @@ "lang": "en", "question": "What are the platforms supported by x" }], - "category": ["Games"] + "category": ["Games","Entertainment"] } ] }, @@ -307,7 +307,7 @@ "lang": "en", "question": "What is the natural habitat of species x" }], - "category": ["Animals"] + "category": ["Animals","Science"] }, { "property": "P2670", @@ -319,7 +319,7 @@ "lang": "en", "question": "What species share the habitat with x" }], - "category": ["Animals"] + "category": ["Animals","Science"] } ] } From b506e3774e2f3c559947ca3ac3e9a889e145c069 Mon Sep 17 00:00:00 2001 From: Pablo Barrero Cruz Date: Sat, 27 Apr 2024 13:11:46 +0200 Subject: [PATCH 03/37] Updating Backgrounds --- webapp/src/index.css | 1 + webapp/src/pages/GroupDetails.js | 25 +++++++++++++++++++++++++ webapp/src/pages/Groups.js | 22 ++++++++++++++++++++++ webapp/src/pages/Instructions.js | 2 -- webapp/src/pages/Ranking.js | 19 +++++++++++++++++++ webapp/src/pages/Statistics.js | 22 ++++++++++++++++++++++ 6 files changed, 89 insertions(+), 2 deletions(-) diff --git a/webapp/src/index.css b/webapp/src/index.css index d0d08a2c..5bcaa367 100644 --- a/webapp/src/index.css +++ b/webapp/src/index.css @@ -1,4 +1,5 @@ body { + background-image: url('../public/hurta2.jpg'); background-size: cover; background-repeat: no-repeat; margin: 0; diff --git a/webapp/src/pages/GroupDetails.js b/webapp/src/pages/GroupDetails.js index 621fa121..f84a2ff5 100644 --- a/webapp/src/pages/GroupDetails.js +++ b/webapp/src/pages/GroupDetails.js @@ -35,9 +35,31 @@ const GroupDetails = () => { navigate(`/statistics/${name}`); }; + //Video settings + const styles = { + video: { + position: "absolute", + top: "50%", + left: "50%", + width: "100%", + height: "100%", + transform: "translate(-50%, -50%)", + objectFit: "cover", + zIndex: '-1', + userSelect: 'none', + pointerEvents: 'none' + }, + }; + + const videoRef = React.useRef(null); + React.useEffect(() => {if (videoRef.current) {videoRef.current.playbackRate = 0.85;}}, []); + if (error || !groupInfo) { return ( + {error} ) @@ -50,6 +72,9 @@ const GroupDetails = () => { // Returns all group data including the creator, the creation date and the members list return ( + {groupInfo.name} diff --git a/webapp/src/pages/Groups.js b/webapp/src/pages/Groups.js index e30383fd..25b28419 100644 --- a/webapp/src/pages/Groups.js +++ b/webapp/src/pages/Groups.js @@ -95,8 +95,30 @@ const Groups = () => { navigate(`/group/${groupName}`); }; + //Video settings + const styles = { + video: { + position: "absolute", + top: "50%", + left: "50%", + width: "100%", + height: "100%", + transform: "translate(-50%, -50%)", + objectFit: "cover", + zIndex: '-1', + userSelect: 'none', + pointerEvents: 'none' + }, + }; + const videoRef = React.useRef(null); + React.useEffect(() => {if (videoRef.current) {videoRef.current.playbackRate = 0.85;}}, []); + return ( + + { t("Groups.title") } diff --git a/webapp/src/pages/Instructions.js b/webapp/src/pages/Instructions.js index 0308bef6..c2f22c68 100644 --- a/webapp/src/pages/Instructions.js +++ b/webapp/src/pages/Instructions.js @@ -54,8 +54,6 @@ const Instructions = () => { pointerEvents: 'none', top:'0', left:'0', - opacity:'0.5', - }, gameDisplayRow:{ diff --git a/webapp/src/pages/Ranking.js b/webapp/src/pages/Ranking.js index a26ec4c5..b231dbab 100644 --- a/webapp/src/pages/Ranking.js +++ b/webapp/src/pages/Ranking.js @@ -47,6 +47,21 @@ const Ranking = () => { { field: 'totalGamesPlayed', headerName: 'TOTAL GAMES', flex: 1, align: 'center', headerAlign: 'center' } ]; + //Video settings + const styles = { + video:{ + position: "absolute", + width: "100%", + height: "100%", + objectFit: "cover", + zIndex:'-1', + userSelect:'none', + pointerEvents: 'none' + }, + }; + const videoRef = React.useRef(null); + React.useEffect(() => {if (videoRef.current) {videoRef.current.playbackRate = 0.85;}}, []); + return ( { flexGrow: 1 }}> +< video data-testid="video" ref={videoRef} autoPlay muted loop style={{ ...styles.video}}> + + + RANKING diff --git a/webapp/src/pages/Statistics.js b/webapp/src/pages/Statistics.js index 79b90b51..83b6b14c 100644 --- a/webapp/src/pages/Statistics.js +++ b/webapp/src/pages/Statistics.js @@ -273,8 +273,30 @@ const Statistics = () => { } }; + //Video settings + const styles = { + video: { + position: "absolute", + top: "50%", + left: "50%", + width: "100%", + height: "100%", + transform: "translate(-50%, -50%)", + objectFit: "cover", + zIndex: '-1', + userSelect: 'none', + pointerEvents: 'none' + }, + }; + + const videoRef = React.useRef(null); + React.useEffect(() => {if (videoRef.current) {videoRef.current.playbackRate = 0.85;}}, []); + return ( + { t("Statistics.title") } From f2c6261d58783771ae6a3348a7a3fd699bd77433 Mon Sep 17 00:00:00 2001 From: Pablo Barrero Cruz Date: Sat, 27 Apr 2024 13:11:59 +0200 Subject: [PATCH 04/37] Testing Backgrounds --- .../src/__tests__/pages/GroupDetails.test.js | 21 +++++++++++++++++-- webapp/src/__tests__/pages/Groups.test.js | 8 +++++++ webapp/src/__tests__/pages/Ranking.test.js | 11 ++++++++++ webapp/src/__tests__/pages/Statistics.test.js | 14 +++++++++++++ 4 files changed, 52 insertions(+), 2 deletions(-) diff --git a/webapp/src/__tests__/pages/GroupDetails.test.js b/webapp/src/__tests__/pages/GroupDetails.test.js index 8add14e0..507e5368 100644 --- a/webapp/src/__tests__/pages/GroupDetails.test.js +++ b/webapp/src/__tests__/pages/GroupDetails.test.js @@ -1,12 +1,12 @@ import React from 'react'; -import { render, waitFor } from '@testing-library/react'; +import { render, waitFor, screen } from '@testing-library/react'; import { BrowserRouter as Router, useParams } from 'react-router-dom'; import axios from 'axios'; import MockAdapter from 'axios-mock-adapter'; import GroupDetails from '../../pages/GroupDetails'; import '../../localize/i18n'; import { SessionContext } from '../../SessionContext'; - + const mockAxios = new MockAdapter(axios); jest.mock('react-router-dom', () => ({ @@ -51,6 +51,23 @@ describe('GroupDetails component', () => { }); }); + it('debe reproducir el video a una velocidad de 0.85', async () => { + render( + + + + + + ); + + await waitFor(() => { + const videoElement = screen.getByTestId('video'); + expect(videoElement).toBeInTheDocument(); + expect(videoElement.playbackRate).toBe(0.85); + }); + + }); + it('should render error message when failed to fetch group information', async () => { mockAxios.onGet(`http://localhost:8000/group/NonExistentGroup`).reply(404); diff --git a/webapp/src/__tests__/pages/Groups.test.js b/webapp/src/__tests__/pages/Groups.test.js index 1b131899..3f90b486 100644 --- a/webapp/src/__tests__/pages/Groups.test.js +++ b/webapp/src/__tests__/pages/Groups.test.js @@ -31,6 +31,14 @@ describe('Groups component', () => { }); }; + it('debe reproducir el video a una velocidad de 0.85', async () => { + renderGroupsComponent(); + const videoElement = screen.getByTestId('video'); + expect(videoElement).toBeInTheDocument(); + expect(videoElement.playbackRate).toBe(0.85); + + }); + it('should render groups list and creation elements', async () => { // It mocks a succesful request getting two groups from the database. mockAxios.onGet('http://localhost:8000/group').reply(200, { groups: [{ name: 'Group 1' }, { name: 'Group 2' }] }); diff --git a/webapp/src/__tests__/pages/Ranking.test.js b/webapp/src/__tests__/pages/Ranking.test.js index 76a32d0f..bebeab4c 100644 --- a/webapp/src/__tests__/pages/Ranking.test.js +++ b/webapp/src/__tests__/pages/Ranking.test.js @@ -32,6 +32,17 @@ describe('Ranking Component', () => { }); + it('debe reproducir el video a una velocidad de 0.85', async () => { + render(); + + setTimeout(() => { + const videoElement = screen.getByTestId('video'); + expect(videoElement).toBeInTheDocument(); + expect(videoElement.playbackRate).toBe(0.85); + }, 15); + + }); + it('should display group ranking when "GROUPS" button is clicked', async () => { const groupRanking = { data: { rank: [ diff --git a/webapp/src/__tests__/pages/Statistics.test.js b/webapp/src/__tests__/pages/Statistics.test.js index ed24cbd5..9600c720 100644 --- a/webapp/src/__tests__/pages/Statistics.test.js +++ b/webapp/src/__tests__/pages/Statistics.test.js @@ -136,6 +136,20 @@ describe('Statistics component', () => { expect(screen.getByText('2')).toBeInTheDocument(); }); + it('debe reproducir el video a una velocidad de 0.85', async () => { + render( + + + + + + ); + const videoElement = screen.getByTestId('video'); + expect(videoElement).toBeInTheDocument(); + expect(videoElement.playbackRate).toBe(0.85); + + }); + it('should render Statistics component with correct user statistics for Wise Men Stack mode', async () => { render( From e70a069a989c03501f8a92e5347852f6d1972fcf Mon Sep 17 00:00:00 2001 From: teresagg Date: Sat, 27 Apr 2024 13:57:00 +0200 Subject: [PATCH 05/37] Fixing mistaken method --- webapp/src/data/icons.js | 4 ++-- webapp/src/pages/Profile.js | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/webapp/src/data/icons.js b/webapp/src/data/icons.js index 2da14712..dcd5fb63 100644 --- a/webapp/src/data/icons.js +++ b/webapp/src/data/icons.js @@ -22,8 +22,8 @@ const getBarrero = () => { return "barreroIcon.jpg"; } -const getMaite = () => { +const getTeresa = () => { return "teresaIcon.jpg"; } -export { getHugo, getAlberto, getWiffo, getAndina, getSamu, getBarrero, getMaite }; \ No newline at end of file +export { getHugo, getAlberto, getWiffo, getAndina, getSamu, getBarrero, getTeresa }; \ No newline at end of file diff --git a/webapp/src/pages/Profile.js b/webapp/src/pages/Profile.js index e7bdb2db..685eba50 100644 --- a/webapp/src/pages/Profile.js +++ b/webapp/src/pages/Profile.js @@ -2,7 +2,7 @@ import React, { useEffect, useState, useCallback, useContext } from 'react'; import axios from 'axios'; import { Button, Container, Typography, Divider, Snackbar } from '@mui/material'; import { SessionContext } from '../SessionContext'; -import { getHugo, getAlberto, getWiffo, getAndina, getSamu, getBarrero, getMaite } from '../data/icons'; +import { getHugo, getAlberto, getWiffo, getAndina, getSamu, getBarrero, getTeresa } from '../data/icons'; import { useTranslation } from 'react-i18next'; const apiEndpoint = process.env.REACT_APP_API_ENDPOINT || 'http://localhost:8000'; @@ -83,7 +83,7 @@ const Profile = () => { + - From 93aec28bd5c2564b0cd8c1f3a16ff1985af33f9c Mon Sep 17 00:00:00 2001 From: teresagg Date: Sat, 27 Apr 2024 14:02:30 +0200 Subject: [PATCH 06/37] Fixing profile tests --- webapp/src/__tests__/pages/Profile.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/src/__tests__/pages/Profile.test.js b/webapp/src/__tests__/pages/Profile.test.js index 3f11cc61..3872bbd7 100644 --- a/webapp/src/__tests__/pages/Profile.test.js +++ b/webapp/src/__tests__/pages/Profile.test.js @@ -117,7 +117,7 @@ describe('Profile component', () => { fireEvent.click(screen.getByTestId('andina-button')); fireEvent.click(screen.getByTestId('samu-button')); fireEvent.click(screen.getByTestId('barrero-button')); - fireEvent.click(screen.getByTestId('maite-button')); + fireEvent.click(screen.getByTestId('teresa-button')); fireEvent.click(screen.getByTestId('confirm-button')); await waitFor(() => { From 171e153579f6bbf958831e836a477b9e511151b4 Mon Sep 17 00:00:00 2001 From: uo288543 Date: Sat, 27 Apr 2024 14:03:12 +0200 Subject: [PATCH 07/37] update games descriptions --- webapp/src/data/gameInfo.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/webapp/src/data/gameInfo.json b/webapp/src/data/gameInfo.json index 012e3110..e710ae1c 100644 --- a/webapp/src/data/gameInfo.json +++ b/webapp/src/data/gameInfo.json @@ -2,16 +2,16 @@ { "nombre": "Wise Men Stack", "descripcion": - "The player chooses a topic from five available options and must answer a battery of questions related to it within 60 seconds. For each question, the host provides two options. If the contestant guesses correctly, they move on to the next question.", + "The player chooses a topic from three available options and must answer a battery of questions related to it within 60 seconds. For each question, the host provides two options. If the contestant guesses correctly, they move on to the next question.", "foto": "../instructions/foto0.png", - "card":"The player chooses a topic from five available options and must answer a battery of questions related to it within 60 seconds.", + "card":"The player chooses a topic from three available options and must answer a battery of questions related to it within 60 seconds.", "cardFoto": "../homePage/foto0.png" }, { "nombre": "Warm Question", - "descripcion": "It consists of ten topics of varied themes. For each correct answer, €100 is earned, and €10 are lost if the contestant passes, does not respond, or answers incorrectly.", + "descripcion": "It consists of ten questions of varied themes. For each correct answer, 100 points are earned, and 10 points are lost if the contestant passes, does not respond, or answers incorrectly.", "foto": "../instructions/foto1.jpg", - "card":"It consists of ten topics of varied themes.", + "card":"It consists of ten questions of varied themes.", "cardFoto": "../homePage/foto1.jpg" }, { From f4a286a18ed5c160a8e83d3cf2b83485bec1c89f Mon Sep 17 00:00:00 2001 From: teresagg Date: Sat, 27 Apr 2024 14:12:04 +0200 Subject: [PATCH 08/37] Adding questions api yaml --- gatewayservice/apis/questions-api.yaml | 118 +++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 gatewayservice/apis/questions-api.yaml diff --git a/gatewayservice/apis/questions-api.yaml b/gatewayservice/apis/questions-api.yaml new file mode 100644 index 00000000..cb3637b4 --- /dev/null +++ b/gatewayservice/apis/questions-api.yaml @@ -0,0 +1,118 @@ +openapi: 3.0.0 +info: + title: Questionservice API + description: Question OpenAPI specification + version: 1.0.0 +servers: + # Added by API Auto Mocking Plugin + - description: SwaggerHub API Auto Mocking + url: https://virtserver.swaggerhub.com/UO288347_1/questions-api/1.0.0 + - url: http://localhost:8000 + description: Development server + - url: http://20.19.89.97:8000 + description: Production server +paths: + /questions/:lang: + get: + summary: Gests a question from the database. + operationId: questions + description: Gests a question from the database. If there are not enough questions, it asks wikidata for more + responses: + '200': + description: Returned question succesfully + content: + application/json: + schema: + type: object + properties: + _id: + type: string + description: Unique identification + example: 660549daa56f92f15a73f89c + question: + type: string + options: + type: array + items: + type: string + correctAnswer: + type: string + categories: + type: array + items: + type: string + language: + type: string + '400': + description: Failed to get question + content: + application/json: + schema: + type: object + properties: + error: + type: string + description: Error while getting a question. + '500': + description: Internal server error. + content: + application/json: + schema: + type: object + properties: + error: + type: string + description: Error information. + example: Internal Server Error + /questions/:lang/:category: + get: + summary: Gests a question from a specified category. + operationId: questionsByCategory + description: Gests a question from the database of a specified category. If there are not enough questions, it asks wikidata for more + responses: + '200': + description: Returned question succesfully + content: + application/json: + schema: + type: object + properties: + _id: + type: string + description: Unique identification + example: 660549daa56f92f15a73f89c + question: + type: string + options: + type: array + items: + type: string + correctAnswer: + type: string + categories: + type: array + items: + type: string + language: + type: string + '400': + description: Failed to get question + content: + application/json: + schema: + type: object + properties: + error: + type: string + description: Error while getting a question. + '500': + description: Internal server error. + content: + application/json: + schema: + type: object + properties: + error: + type: string + description: Error information. + example: Internal Server Error \ No newline at end of file From 2f4572874dca029cb8c21de93a9c4667e77a2ca8 Mon Sep 17 00:00:00 2001 From: uo288543 Date: Sat, 27 Apr 2024 17:44:00 +0200 Subject: [PATCH 09/37] remove comments in index.html --- webapp/public/index.html | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/webapp/public/index.html b/webapp/public/index.html index 77cb33c0..74761f2c 100644 --- a/webapp/public/index.html +++ b/webapp/public/index.html @@ -15,29 +15,10 @@ user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/ --> - WIQ - Wikidata Infinite Quest
- From 66ee8dbfec6fe16ea7a463380b5508004747ce01 Mon Sep 17 00:00:00 2001 From: uo288543 Date: Sat, 27 Apr 2024 18:11:47 +0200 Subject: [PATCH 10/37] adapt nav bar to mobile --- webapp/src/components/NavBar.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/webapp/src/components/NavBar.js b/webapp/src/components/NavBar.js index 1de1d56d..a4a81f98 100644 --- a/webapp/src/components/NavBar.js +++ b/webapp/src/components/NavBar.js @@ -103,6 +103,15 @@ function NavBar() { ))} + + + + { logo } @@ -130,8 +139,9 @@ function NavBar() { )} - {/* Internacionalization */} - + + {/* Internacionalization */} + - {isLoggedIn ? ( <> From b6896b24b165b7bd03e4920a2d1e5b8124daa3b7 Mon Sep 17 00:00:00 2001 From: uo288543 Date: Sat, 27 Apr 2024 19:51:55 +0200 Subject: [PATCH 11/37] fix navbar test --- webapp/src/__tests__/components/NavBar.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/src/__tests__/components/NavBar.test.js b/webapp/src/__tests__/components/NavBar.test.js index cd547778..8d400574 100644 --- a/webapp/src/__tests__/components/NavBar.test.js +++ b/webapp/src/__tests__/components/NavBar.test.js @@ -121,7 +121,7 @@ describe('NavBar component', () => { ); // Checks select menu is in the nav - const selectLang = screen.getByText("English"); + const selectLang = screen.getAllByText("English")[0]; await expect(selectLang).toBeInTheDocument(); // Click on it and check both options are there From 32195a8b643e4e7c555ed42c4e08f31737e1b7c0 Mon Sep 17 00:00:00 2001 From: uo288543 Date: Sat, 27 Apr 2024 20:31:17 +0200 Subject: [PATCH 12/37] fix typo --- webapp/src/data/gameInfo.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/webapp/src/data/gameInfo.json b/webapp/src/data/gameInfo.json index e710ae1c..24521bda 100644 --- a/webapp/src/data/gameInfo.json +++ b/webapp/src/data/gameInfo.json @@ -1,8 +1,7 @@ [ { "nombre": "Wise Men Stack", - "descripcion": - "The player chooses a topic from three available options and must answer a battery of questions related to it within 60 seconds. For each question, the host provides two options. If the contestant guesses correctly, they move on to the next question.", + "descripcion": "The player chooses a topic from three available options and must answer a battery of questions related to it within 60 seconds. For each question, the host provides two options. If the contestant guesses correctly, they move on to the next question.", "foto": "../instructions/foto0.png", "card":"The player chooses a topic from three available options and must answer a battery of questions related to it within 60 seconds.", "cardFoto": "../homePage/foto0.png" From d3a5857388bd644927dd22d556b478d6debe3079 Mon Sep 17 00:00:00 2001 From: uo288543 Date: Sat, 27 Apr 2024 20:44:20 +0200 Subject: [PATCH 13/37] update readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index fd53a788..5b026ea0 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # Wikidata Infinite Quest 🌐 [wikiquest.sytes.net](http://wikiquest.sytes.net/) +⚠️ If you entered the site time ago it requires log out and log in one time to remove errors. ## 👨‍💻 Contributors: | Contributor | Contact | From ac68ceae228d0f7033261263549b7a5f7db296cd Mon Sep 17 00:00:00 2001 From: Pablo Date: Sun, 28 Apr 2024 01:20:38 +0200 Subject: [PATCH 14/37] Solved chat layour in multiplayer room --- webapp/src/pages/games/MultiplayerRoom.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/webapp/src/pages/games/MultiplayerRoom.js b/webapp/src/pages/games/MultiplayerRoom.js index 423db081..f86f11ea 100644 --- a/webapp/src/pages/games/MultiplayerRoom.js +++ b/webapp/src/pages/games/MultiplayerRoom.js @@ -1,5 +1,5 @@ import React, { useState, useEffect } from 'react'; -import { useTheme, Button, TextField, Typography, Grid, Paper, List, ListItem, CircularProgress, Container, Box } from '@mui/material'; +import { useTheme, Button, TextField, Typography, Paper, List, ListItem, CircularProgress, Container, Box } from '@mui/material'; import io from 'socket.io-client'; import { useContext } from 'react'; import { SessionContext } from '../../SessionContext'; @@ -106,8 +106,11 @@ const MultiplayerRoom = () => { } return ( - - + + {roomCode && error === "" && ( + + )} + {t("Games.Multiplayer.name").toUpperCase()} @@ -201,12 +204,13 @@ const MultiplayerRoom = () => {
)} - {roomCode && error === "" && ( - - - - )} + + {roomCode && error === "" && ( + + + + )}
); } From b59957277dcc1d2345c7092beca67728b70e305f Mon Sep 17 00:00:00 2001 From: Pablo Date: Sun, 28 Apr 2024 01:30:28 +0200 Subject: [PATCH 15/37] Improves room style --- webapp/src/pages/games/MultiplayerRoom.js | 63 ++++++++++++----------- 1 file changed, 34 insertions(+), 29 deletions(-) diff --git a/webapp/src/pages/games/MultiplayerRoom.js b/webapp/src/pages/games/MultiplayerRoom.js index f86f11ea..13404e45 100644 --- a/webapp/src/pages/games/MultiplayerRoom.js +++ b/webapp/src/pages/games/MultiplayerRoom.js @@ -106,7 +106,7 @@ const MultiplayerRoom = () => { } return ( - + {roomCode && error === "" && ( )} @@ -116,34 +116,39 @@ const MultiplayerRoom = () => { {roomCode && error === "" ? ( - <> - - { t("Multiplayer.Room.code") }: - - - {roomCode} - - - - { t("Multiplayer.Room.participants") }: - - - {roomPlayers.map((player, index) => ( - - {player} - - ))} - - - {loadingQuestions && ( -
- - Loading questions... -
- )} - + + + + { t("Multiplayer.Room.code") }: + + + {roomCode} + + + + + { t("Multiplayer.Room.participants") }: + + + {roomPlayers.map((player, index) => ( + + {player} + + ))} + + + {loadingQuestions && ( +
+ + Loading questions... +
+ )} +
+
) : ( Date: Sun, 28 Apr 2024 01:32:28 +0200 Subject: [PATCH 16/37] Container does not allow width > 1200 px so this looks better --- webapp/src/pages/games/MultiplayerRoom.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webapp/src/pages/games/MultiplayerRoom.js b/webapp/src/pages/games/MultiplayerRoom.js index 13404e45..393a0b5f 100644 --- a/webapp/src/pages/games/MultiplayerRoom.js +++ b/webapp/src/pages/games/MultiplayerRoom.js @@ -106,7 +106,7 @@ const MultiplayerRoom = () => { } return ( - + {roomCode && error === "" && ( )} @@ -216,7 +216,7 @@ const MultiplayerRoom = () => { )} - + ); } From b6f0c5a9a5e94f100ce12cafc20a0f9d807623f8 Mon Sep 17 00:00:00 2001 From: Pablo Date: Sun, 28 Apr 2024 01:33:54 +0200 Subject: [PATCH 17/37] Even better --- webapp/src/pages/games/MultiplayerRoom.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/src/pages/games/MultiplayerRoom.js b/webapp/src/pages/games/MultiplayerRoom.js index 393a0b5f..94d82d8c 100644 --- a/webapp/src/pages/games/MultiplayerRoom.js +++ b/webapp/src/pages/games/MultiplayerRoom.js @@ -106,7 +106,7 @@ const MultiplayerRoom = () => { } return ( - + {roomCode && error === "" && ( )} From 1c8779715b4e2e915562c3fb3dac7ac9da3ff9a0 Mon Sep 17 00:00:00 2001 From: teresagg Date: Sun, 28 Apr 2024 08:23:51 +0200 Subject: [PATCH 18/37] Configuring grafana --- .../provisioning/dashboards/wiq-es04-dashboard.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gatewayservice/monitoring/grafana/provisioning/dashboards/wiq-es04-dashboard.json b/gatewayservice/monitoring/grafana/provisioning/dashboards/wiq-es04-dashboard.json index 28caba1c..9592baf6 100644 --- a/gatewayservice/monitoring/grafana/provisioning/dashboards/wiq-es04-dashboard.json +++ b/gatewayservice/monitoring/grafana/provisioning/dashboards/wiq-es04-dashboard.json @@ -80,9 +80,9 @@ "steppedLine": false, "targets": [ { - "expr": "sum(increase(http_request_duration_seconds_count[1h]))", + "expr": "sum(increase(http_request_duration_seconds_count[1m]))", "interval": "", - "legendFormat": "Requests per hour", + "legendFormat": "Requests per minute", "refId": "A" } ], @@ -90,7 +90,7 @@ "timeFrom": null, "timeRegions": [], "timeShift": null, - "title": "Rate (R): Number of requests per hour", + "title": "Rate (R): Number of requests per minute", "tooltip": { "shared": true, "sort": 0, @@ -199,7 +199,7 @@ "timeFrom": null, "timeRegions": [], "timeShift": null, - "title": "Errors (E): The number of failed requests", + "title": "Not found (NF): The number of not found requests", "tooltip": { "shared": true, "sort": 0, From 0abc7331d892cffda4da7a70f49e965495acbc79 Mon Sep 17 00:00:00 2001 From: teresagg Date: Sun, 28 Apr 2024 08:43:55 +0200 Subject: [PATCH 19/37] Configuring grafana --- .../grafana/provisioning/dashboards/wiq-es04-dashboard.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gatewayservice/monitoring/grafana/provisioning/dashboards/wiq-es04-dashboard.json b/gatewayservice/monitoring/grafana/provisioning/dashboards/wiq-es04-dashboard.json index 9592baf6..0e00fbf6 100644 --- a/gatewayservice/monitoring/grafana/provisioning/dashboards/wiq-es04-dashboard.json +++ b/gatewayservice/monitoring/grafana/provisioning/dashboards/wiq-es04-dashboard.json @@ -191,7 +191,7 @@ { "expr": "sum(increase(http_request_duration_seconds_count{status_code=~\"4.*\"}[1m]))", "interval": "", - "legendFormat": "", + "legendFormat": "Not found", "refId": "A" } ], From 0b3eb65c5a649af5ad8420d38683ad5915ad5383 Mon Sep 17 00:00:00 2001 From: uo288543 Date: Sun, 28 Apr 2024 12:16:37 +0200 Subject: [PATCH 20/37] make chat adaptable to mobile devices --- webapp/src/pages/games/MultiplayerRoom.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/src/pages/games/MultiplayerRoom.js b/webapp/src/pages/games/MultiplayerRoom.js index 94d82d8c..14dc751f 100644 --- a/webapp/src/pages/games/MultiplayerRoom.js +++ b/webapp/src/pages/games/MultiplayerRoom.js @@ -106,7 +106,7 @@ const MultiplayerRoom = () => { } return ( - + {roomCode && error === "" && ( )} From 8f58ee3037419c1d771b99dad92f6c6d4b713b47 Mon Sep 17 00:00:00 2001 From: Pablo Date: Sun, 28 Apr 2024 12:57:37 +0200 Subject: [PATCH 21/37] Removed redundancy in display --- webapp/src/pages/games/MultiplayerRoom.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/src/pages/games/MultiplayerRoom.js b/webapp/src/pages/games/MultiplayerRoom.js index 14dc751f..efc201d6 100644 --- a/webapp/src/pages/games/MultiplayerRoom.js +++ b/webapp/src/pages/games/MultiplayerRoom.js @@ -106,7 +106,7 @@ const MultiplayerRoom = () => { } return ( - + {roomCode && error === "" && ( )} From 01099c6fcbdb99966de0d21f33b239999c15b374 Mon Sep 17 00:00:00 2001 From: teresagg Date: Sun, 28 Apr 2024 13:52:50 +0200 Subject: [PATCH 22/37] Adding french to questions --- questions/utils/question.json | 83 ++++++++++++++++++++++++++++++++++- 1 file changed, 82 insertions(+), 1 deletion(-) diff --git a/questions/utils/question.json b/questions/utils/question.json index 683091da..0c57c240 100644 --- a/questions/utils/question.json +++ b/questions/utils/question.json @@ -13,7 +13,12 @@ { "lang": "en", "question": "What is the population of x" - }], + }, + { + "lang": "fr", + "question": "What is the population of x" + } + ], "filter": ">4000000", "category": ["Geography", "Cities"] }, @@ -26,6 +31,10 @@ { "lang": "en", "question": "What is the capital of x" + }, + { + "lang": "fr", + "question": "" }], "category": ["Geography", "Cities"] }, @@ -39,6 +48,10 @@ { "lang": "en", "question": "What currency x has" + }, + { + "lang": "fr", + "question": "" }], "category": ["Geography"] } @@ -58,6 +71,10 @@ { "lang": "en", "question": "What is the stadium of x team" + }, + { + "lang": "fr", + "question": "" }], "category": ["Sports"] }, @@ -71,6 +88,10 @@ { "lang": "en", "question": "What is the country of x team" + }, + { + "lang": "fr", + "question": "" }], "category": ["Sports", "Geography"] } @@ -90,6 +111,10 @@ { "lang": "en", "question": "What country is x river in" + }, + { + "lang": "fr", + "question": "" }], "category": ["Geography"] } @@ -109,6 +134,10 @@ { "lang": "en", "question": "Who is the author of x" + }, + { + "lang": "fr", + "question": "" }], "category": ["Art"] }, @@ -122,6 +151,10 @@ { "lang": "en", "question": "What is the artistic style of x" + }, + { + "lang": "fr", + "question": "" }], "category": ["Art"] } @@ -141,6 +174,10 @@ { "lang": "en", "question": "Who is the inventor of x" + }, + { + "lang": "fr", + "question": "" }], "category": ["Science"] } @@ -160,6 +197,10 @@ { "lang": "en", "question": "What is the maximum altitude of x" + }, + { + "lang": "fr", + "question": "" }], "filter": ">4000", "category": ["Geography"] @@ -180,6 +221,10 @@ { "lang": "en", "question": "Who is the author of x" + }, + { + "lang": "fr", + "question": "" }], "category": ["Entertainment"] }, @@ -193,6 +238,10 @@ { "lang": "en", "question": "What is the genre of x" + }, + { + "lang": "fr", + "question": "" }], "category": ["Entertainment"] } @@ -212,6 +261,10 @@ { "lang": "en", "question": "Who is the creator of the series x" + }, + { + "lang": "fr", + "question": "" }], "category": ["Entertainment"] }, @@ -224,6 +277,10 @@ { "lang": "en", "question": "How many seasons does the series x have?" + }, + { + "lang": "fr", + "question": "" }], "filter": ">0", "category": ["Entertainment"] @@ -244,6 +301,10 @@ { "lang": "en", "question": "Who developed the software x" + }, + { + "lang": "fr", + "question": "" }], "category": ["Sports"] }, @@ -256,6 +317,10 @@ { "lang": "en", "question": "What is the nationality of the athlete x" + }, + { + "lang": "fr", + "question": "" }], "category": ["Sports"] } @@ -275,6 +340,10 @@ { "lang": "en", "question": "Who is the developer of the video game x" + }, + { + "lang": "fr", + "question": "" }], "category": ["Games","Entertainment"] }, @@ -287,6 +356,10 @@ { "lang": "en", "question": "What are the platforms supported by x" + }, + { + "lang": "fr", + "question": "" }], "category": ["Games","Entertainment"] } @@ -306,6 +379,10 @@ { "lang": "en", "question": "What is the natural habitat of species x" + }, + { + "lang": "fr", + "question": "" }], "category": ["Animals","Science"] }, @@ -318,6 +395,10 @@ { "lang": "en", "question": "What species share the habitat with x" + }, + { + "lang": "fr", + "question": "" }], "category": ["Animals","Science"] } From 1e1bb42cc7fa0c6430e40500f8b50efa2795f053 Mon Sep 17 00:00:00 2001 From: teresagg Date: Sun, 28 Apr 2024 13:57:26 +0200 Subject: [PATCH 23/37] Stablishing french templates --- questions/utils/question.json | 44 +++++++++++++++++------------------ 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/questions/utils/question.json b/questions/utils/question.json index 0c57c240..a69fb689 100644 --- a/questions/utils/question.json +++ b/questions/utils/question.json @@ -16,7 +16,7 @@ }, { "lang": "fr", - "question": "What is the population of x" + "question": "Quelle est la population de x?" } ], "filter": ">4000000", @@ -34,7 +34,7 @@ }, { "lang": "fr", - "question": "" + "question": "Quelle est la capitale de x?" }], "category": ["Geography", "Cities"] }, @@ -51,7 +51,7 @@ }, { "lang": "fr", - "question": "" + "question": "Quelle est la monnaie de x?" }], "category": ["Geography"] } @@ -74,7 +74,7 @@ }, { "lang": "fr", - "question": "" + "question": "Quel est le stade de l'équipe x?" }], "category": ["Sports"] }, @@ -91,7 +91,7 @@ }, { "lang": "fr", - "question": "" + "question": "Quel est le pays de l'équipe x?" }], "category": ["Sports", "Geography"] } @@ -114,7 +114,7 @@ }, { "lang": "fr", - "question": "" + "question": "Dans quel pays se trouve le fleuve x?" }], "category": ["Geography"] } @@ -137,7 +137,7 @@ }, { "lang": "fr", - "question": "" + "question": "Qui est l'auteur de x?" }], "category": ["Art"] }, @@ -154,7 +154,7 @@ }, { "lang": "fr", - "question": "" + "question": "Quel est le style artistique de x?" }], "category": ["Art"] } @@ -177,7 +177,7 @@ }, { "lang": "fr", - "question": "" + "question": "Qui est l'inventeur de x?" }], "category": ["Science"] } @@ -196,11 +196,11 @@ }, { "lang": "en", - "question": "What is the maximum altitude of x" + "question": "What is the altitude of x" }, { "lang": "fr", - "question": "" + "question": "Quelle est l'altitude de la montagne x?" }], "filter": ">4000", "category": ["Geography"] @@ -224,7 +224,7 @@ }, { "lang": "fr", - "question": "" + "question": "Qui est l'auteur de x?" }], "category": ["Entertainment"] }, @@ -241,7 +241,7 @@ }, { "lang": "fr", - "question": "" + "question": "Quel est le genre de x?" }], "category": ["Entertainment"] } @@ -264,7 +264,7 @@ }, { "lang": "fr", - "question": "" + "question": "Qui est le créateur de la série x?" }], "category": ["Entertainment"] }, @@ -280,7 +280,7 @@ }, { "lang": "fr", - "question": "" + "question": "Combien de saisons compte la série x?" }], "filter": ">0", "category": ["Entertainment"] @@ -300,11 +300,11 @@ }, { "lang": "en", - "question": "Who developed the software x" + "question": "What sport does x compite in?" }, { "lang": "fr", - "question": "" + "question": "Dans quel sport concourt x?" }], "category": ["Sports"] }, @@ -320,7 +320,7 @@ }, { "lang": "fr", - "question": "" + "question": "Quelle est la nationalité de l'athlète x?" }], "category": ["Sports"] } @@ -343,7 +343,7 @@ }, { "lang": "fr", - "question": "" + "question": "Qui est le développeur du jeu vidéo x?" }], "category": ["Games","Entertainment"] }, @@ -359,7 +359,7 @@ }, { "lang": "fr", - "question": "" + "question": "Quelles sont les plateformes compatibles avec x?" }], "category": ["Games","Entertainment"] } @@ -382,7 +382,7 @@ }, { "lang": "fr", - "question": "" + "question": "Quel est l'habitat naturel de l'espèce x?" }], "category": ["Animals","Science"] }, @@ -398,7 +398,7 @@ }, { "lang": "fr", - "question": "" + "question": "Quelles espèces partagent l'habitat avec x?" }], "category": ["Animals","Science"] } From 653679323ba6254d5b733168f61e9d13e8193f88 Mon Sep 17 00:00:00 2001 From: uo288543 Date: Sun, 28 Apr 2024 14:14:04 +0200 Subject: [PATCH 24/37] remove templates --- questions/utils/question.json | 137 ---------------------------------- 1 file changed, 137 deletions(-) diff --git a/questions/utils/question.json b/questions/utils/question.json index 9b48cb34..f063b62a 100644 --- a/questions/utils/question.json +++ b/questions/utils/question.json @@ -112,18 +112,6 @@ }], "category": ["Art"] }, - { - "property": "P571", - "template": [{ - "lang": "es", - "question": "Cual es el año de creacion de x" - }, - { - "lang": "en", - "question": "What is the year of creation of x" - }], - "category": ["Art"] - }, { "property": "P136", "template": @@ -155,38 +143,6 @@ "question": "Who is the inventor of x" }], "category": ["Science"] - }, - { - "property": "P575", - "template": - [{ - "lang": "es", - "question": "En que año se inventó x" - }, - { - "lang": "en", - "question": "What was the year of invention of x" - }], - "category": ["Science"] - } - ] - }, - { - "name": "mountain", - "instance": "Q8502", - "properties": [ - { - "property": "P2044", - "template": - [{ - "lang": "es", - "question": "Cual es la altitud mxima del x" - }, - { - "lang": "en", - "question": "What is the maximum altitude of x" - }], - "category": ["Geography"] } ] }, @@ -207,18 +163,6 @@ }], "category": ["Entertainment"] }, - { - "property": "P577", - "template": [{ - "lang": "es", - "question": "Cual es el año de publicacion de x" - }, - { - "lang": "en", - "question": "What is the year of publication of x" - }], - "category": ["Entertainment"] - }, { "property": "P136", "template": @@ -262,19 +206,6 @@ "question": "What is the maximum speed of x" }], "category": ["Cars"] - }, - { - "property": "P571", - "template": - [{ - "lang": "es", - "question": "En qué año fue introducido x al mercado" - }, - { - "lang": "en", - "question": "In what year was x introduced to the market" - }], - "category": ["Cars"] } ] }, @@ -282,19 +213,6 @@ "name": "dish", "instance": "Q746549", "properties": [ - { - "property": "P527", - "template": - [{ - "lang": "es", - "question": "Cuál es el ingrediente principal de x" - }, - { - "lang": "en", - "question": "What is the main ingredient of x" - }], - "category": ["Food"] - }, { "property": "P495", "template": [{ @@ -326,18 +244,6 @@ }], "category": ["Art"] }, - { - "property": "P571", - "template": [{ - "lang": "es", - "question": "En qué año se completó x" - }, - { - "lang": "en", - "question": "In what year was it completed x" - }], - "category": ["Art"] - }, { "property": "P149", "template": [{ @@ -462,18 +368,6 @@ }], "category": ["Games"] }, - { - "property": "P577", - "template": [{ - "lang": "es", - "question": "En qué año fue lanzado el videojuego x" - }, - { - "lang": "en", - "question": "In what year was the video game x released?" - }], - "category": ["Games"] - }, { "property": "P400", "template": [{ @@ -504,18 +398,6 @@ "question": "Who is the designer of the brand x" }], "category": ["Fashion"] - }, - { - "property": "P571", - "template": [{ - "lang": "es", - "question": "Cuándo fue fundada la casa de moda x" - }, - { - "lang": "en", - "question": "When was the fashion house founded x" - }], - "category": ["Fashion"] } ] }, @@ -549,24 +431,5 @@ "category": ["Animals"] } ] - }, - { - "name": "brands", - "instance": "Q431289", - "properties": [ - { - "property": "P571", - "template": - [{ - "lang": "es", - "question": "Cuándo fue fundada la marca x" - }, - { - "lang": "en", - "question": "When was the brand x founded?" - }], - "category": ["Brands"] - } - ] } ] \ No newline at end of file From 040091291df41f13fd48468c13db2f27b6131116 Mon Sep 17 00:00:00 2001 From: teresagg Date: Sun, 28 Apr 2024 14:20:47 +0200 Subject: [PATCH 25/37] Including new categories --- webapp/src/localize/en.json | 7 ++++++- webapp/src/localize/es.json | 9 +++++++-- webapp/src/localize/fr.json | 16 ++++++++++++---- webapp/src/pages/games/WiseMenStackGame.js | 5 +++++ 4 files changed, 30 insertions(+), 7 deletions(-) diff --git a/webapp/src/localize/en.json b/webapp/src/localize/en.json index 9af93067..b2845352 100644 --- a/webapp/src/localize/en.json +++ b/webapp/src/localize/en.json @@ -73,7 +73,12 @@ "categories": { "geography": "Geography", "political":"Political", - "sports":"Sports" + "sports":"Sports", + "cities": "Cities", + "art": "Art", + "entertainment": "Entertainment", + "games": "Games", + "animals": "Animals" } }, diff --git a/webapp/src/localize/es.json b/webapp/src/localize/es.json index b37511e8..3ecabaef 100644 --- a/webapp/src/localize/es.json +++ b/webapp/src/localize/es.json @@ -73,7 +73,12 @@ "categories": { "geography": "Geografía", "political":"Política", - "sports":"Deporte" + "sports":"Deporte", + "cities": "Ciudades", + "art": "Arte", + "entertainment": "Entretenimiento", + "games": "Juegos", + "animals": "Animales" } }, @@ -125,7 +130,7 @@ "title": "ESTADÍSTICAS", "game": "Partida", "table": { - "money": "Puntos Ganado", + "money": "Puntos Ganados", "questions_corr": "Preguntas Respondidas Correctamente", "questions_incorr": "Preguntas Respondidas Incorrectamente", "questions_pass": "Preguntas Pasadas", diff --git a/webapp/src/localize/fr.json b/webapp/src/localize/fr.json index 0eecd49c..ae89b9b7 100644 --- a/webapp/src/localize/fr.json +++ b/webapp/src/localize/fr.json @@ -72,9 +72,14 @@ "category": "Catégorie" }, "categories": { - "password": "Mot de passe", - "button": "Se connecter", - "register_link": "Vous n'avez pas de compte ? Inscrivez-vous ici." + "geography": "Gréographie", + "political":"Politique", + "sports":"Sport", + "cities": "Villes", + "art": "Art", + "entertainment": "Divertissement", + "games": "Jeux", + "animals": "Animaux" } }, @@ -86,7 +91,10 @@ "Login": { "title": "Connecter", - "username": "Nom d'utilisateur" + "username": "Nom d'utilisateur", + "password": "Mot de passe", + "button": "Se connecter", + "register_link": "Vous n'avez pas de compte ? Inscrivez-vous ici." }, "Register": { diff --git a/webapp/src/pages/games/WiseMenStackGame.js b/webapp/src/pages/games/WiseMenStackGame.js index f056c511..7fab6f37 100644 --- a/webapp/src/pages/games/WiseMenStackGame.js +++ b/webapp/src/pages/games/WiseMenStackGame.js @@ -255,6 +255,11 @@ const WiseMenStackGame = () => { {t("Game.categories.geography")} {t("Game.categories.political")} {t("Game.categories.sports")} + {t("Game.categories.cities")} + {t("Game.categories.art")} + {t("Game.categories.entertainment")} + {t("Game.categories.games")} + {t("Game.categories.animals")} From 86cf4e6c86991a32c34370c8c5f2f32df0fc2162 Mon Sep 17 00:00:00 2001 From: teresagg Date: Sun, 28 Apr 2024 14:24:31 +0200 Subject: [PATCH 26/37] ADapt game to new categories --- webapp/src/pages/games/TheChallengeGame.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/webapp/src/pages/games/TheChallengeGame.js b/webapp/src/pages/games/TheChallengeGame.js index 8ea6bf80..e333ff77 100644 --- a/webapp/src/pages/games/TheChallengeGame.js +++ b/webapp/src/pages/games/TheChallengeGame.js @@ -279,6 +279,11 @@ const TheChallengeGame = () => { {t("Game.categories.geography")} {t("Game.categories.political")} {t("Game.categories.sports")} + {t("Game.categories.cities")} + {t("Game.categories.art")} + {t("Game.categories.entertainment")} + {t("Game.categories.games")} + {t("Game.categories.animals")}
From ef7d9b4a75761baf6af31a39ffaccdfb020e815a Mon Sep 17 00:00:00 2001 From: Pablo Date: Sun, 28 Apr 2024 14:36:58 +0200 Subject: [PATCH 27/37] Change json structure to reflect the languages --- questions/utils/question.json | 370 ++++++++++------------------------ 1 file changed, 111 insertions(+), 259 deletions(-) diff --git a/questions/utils/question.json b/questions/utils/question.json index 9b48cb34..f763cd52 100644 --- a/questions/utils/question.json +++ b/questions/utils/question.json @@ -6,40 +6,28 @@ { "property": "P1082", "template": - [{ - "lang": "es", - "question": "Cuál es la población de x" - }, { - "lang": "en", - "question": "What is the population of x" - }], + "es": "Cuál es la población de x", + "en": "What is the population of x" + }, "filter": ">4000000", "category": ["Geography", "Cities"] }, { "property": "P36", - "template": [{ - "lang": "es", - "question": "Cuál es la capital de x" + "template": { + "es": "Cuál es la capital de x", + "en": "What is the capital of x" }, - { - "lang": "en", - "question": "What is the capital of x" - }], "category": ["Geography", "Cities"] }, { "property": "P38", "template": - [{ - "lang": "es", - "question": "Que moneda tiene x" - }, { - "lang": "en", - "question": "What currency x has" - }], + "es": "Que moneda tiene x", + "en": "What currency x has" + }, "category": ["Political"] } ] @@ -51,27 +39,19 @@ { "property": "P115", "template": - [{ - "lang": "es", - "question": "Cuál es el estadio del equipo x" - }, { - "lang": "en", - "question": "What is the stadium of x team" - }], + "es": "Cuál es el estadio del equipo x", + "en": "What is the stadium of x team" + }, "category": ["Sports"] }, { "property": "P17", "template": - [{ - "lang": "es", - "question": "Cuál es el pais del equipo x" - }, { - "lang": "en", - "question": "What is the country of x team" - }], + "es": "Cuál es el pais del equipo x", + "en": "What is the country of x team" + }, "category": ["Sports", "Geography"] } ] @@ -83,14 +63,10 @@ { "property": "P205", "template": - [{ - "lang": "es", - "question": "En qué país está el río x" - }, { - "lang": "en", - "question": "What country is x river in" - }], + "es": "En qué país está el río x", + "en": "What country is x river in" + }, "category": ["Geography"] } ] @@ -102,39 +78,27 @@ { "property": "P170", "template": - [{ - "lang": "es", - "question": "Quien es el autor de x" - }, { - "lang": "en", - "question": "Who is the author of x" - }], + "es": "Quien es el autor de x", + "en": "Who is the author of x" + }, "category": ["Art"] }, { "property": "P571", - "template": [{ - "lang": "es", - "question": "Cual es el año de creacion de x" + "template": { + "es": "Cual es el año de creacion de x", + "en": "What is the year of creation of x" }, - { - "lang": "en", - "question": "What is the year of creation of x" - }], "category": ["Art"] }, { "property": "P136", "template": - [{ - "lang": "es", - "question": "Cual es el estilo artistico de x" - }, { - "lang": "en", - "question": "What is the artistic style of x" - }], + "es": "Cual es el estilo artistico de x", + "en": "What is the artistic style of x" + }, "category": ["Art"] } ] @@ -146,27 +110,19 @@ { "property": "P61", "template": - [{ - "lang": "es", - "question": "Quien es el inventor de x" - }, { - "lang": "en", - "question": "Who is the inventor of x" - }], + "es": "Quien es el inventor de x", + "en": "Who is the inventor of x" + }, "category": ["Science"] }, { "property": "P575", "template": - [{ - "lang": "es", - "question": "En que año se inventó x" - }, { - "lang": "en", - "question": "What was the year of invention of x" - }], + "es": "En que año se inventó x", + "en": "What was the year of invention of x" + }, "category": ["Science"] } ] @@ -178,14 +134,10 @@ { "property": "P2044", "template": - [{ - "lang": "es", - "question": "Cual es la altitud mxima del x" - }, { - "lang": "en", - "question": "What is the maximum altitude of x" - }], + "es": "Cual es la altitud mxima del x", + "en": "What is the maximum altitude of x" + }, "category": ["Geography"] } ] @@ -197,39 +149,27 @@ { "property": "P50", "template": - [{ - "lang": "es", - "question": "Quien es el autor de x" - }, { - "lang": "en", - "question": "Who is the author of x" - }], + "es": "Quien es el autor de x", + "en": "Who is the author of x" + }, "category": ["Entertainment"] }, { "property": "P577", - "template": [{ - "lang": "es", - "question": "Cual es el año de publicacion de x" + "template": { + "es": "Cual es el año de publicacion de x", + "en": "What is the year of publication of x" }, - { - "lang": "en", - "question": "What is the year of publication of x" - }], "category": ["Entertainment"] }, { "property": "P136", "template": - [{ - "lang": "es", - "question": "Cual es el genero de x" - }, { - "lang": "en", - "question": "What is the genre of x" - }], + "es": "Cual es el genero de x", + "en": "What is the genre of x" + }, "category": ["Entertainment"] } ] @@ -241,39 +181,27 @@ { "property": "P176", "template": - [{ - "lang": "es", - "question": "Quien es el fabricante de x" - }, { - "lang": "en", - "question": "Who is the manufacturer of x" - }], + "es": "Quien es el fabricante de x", + "en": "Who is the manufacturer of x" + }, "category": ["Cars"] }, { "property": "P3032", - "template": [{ - "lang": "es", - "question": "Cuál es la velocidad máxima de x" + "template": { + "es": "Cuál es la velocidad máxima de x", + "en": "What is the maximum speed of x" }, - { - "lang": "en", - "question": "What is the maximum speed of x" - }], "category": ["Cars"] }, { "property": "P571", "template": - [{ - "lang": "es", - "question": "En qué año fue introducido x al mercado" - }, { - "lang": "en", - "question": "In what year was x introduced to the market" - }], + "es": "En qué año fue introducido x al mercado", + "en": "In what year was x introduced to the market" + }, "category": ["Cars"] } ] @@ -285,26 +213,18 @@ { "property": "P527", "template": - [{ - "lang": "es", - "question": "Cuál es el ingrediente principal de x" - }, { - "lang": "en", - "question": "What is the main ingredient of x" - }], + "es": "Cuál es el ingrediente principal de x", + "en": "What is the main ingredient of x" + }, "category": ["Food"] }, { "property": "P495", - "template": [{ - "lang": "es", - "question": "De qué región es originario x" + "template": { + "es": "De qué región es originario x", + "en": "What region is x originally from?" }, - { - "lang": "en", - "question": "What region is x originally from?" - }], "category": ["Food"] } ] @@ -316,38 +236,26 @@ { "property": "P84", "template": - [{ - "lang": "es", - "question": "Quién fue el arquitecto de x" - }, { - "lang": "en", - "question": "Who was the architect of x" - }], + "es": "Quién fue el arquitecto de x", + "en": "Who was the architect of x" + }, "category": ["Art"] }, { "property": "P571", - "template": [{ - "lang": "es", - "question": "En qué año se completó x" + "template": { + "es": "En qué año se completó x", + "en": "In what year was it completed x" }, - { - "lang": "en", - "question": "In what year was it completed x" - }], "category": ["Art"] }, { "property": "P149", - "template": [{ - "lang": "es", - "question": "Cuál es el estilo arquitectónico de x" + "template": { + "es": "Cuál es el estilo arquitectónico de x", + "en": "What is the architectural style of x" }, - { - "lang": "en", - "question": "What is the architectural style of x" - }], "category": ["Art"] } ] @@ -359,26 +267,18 @@ { "property": "P178", "template": - [{ - "lang": "es", - "question": "Quién es el creador de la serie x" - }, { - "lang": "en", - "question": "Who is the creator of the series x" - }], + "es": "Quién es el creador de la serie x", + "en": "Who is the creator of the series x" + }, "category": ["Entertainment"] }, { "property": "P2437", - "template": [{ - "lang": "es", - "question": "Cuántas temporadas tiene la serie x" + "template": { + "es": "Cuántas temporadas tiene la serie x", + "en": "How many seasons does the series x have?" }, - { - "lang": "en", - "question": "How many seasons does the series x have?" - }], "category": ["Entertainment"] } ] @@ -390,26 +290,18 @@ { "property": "P178", "template": - [{ - "lang": "es", - "question": "Quién desarrolló el software x" - }, { - "lang": "en", - "question": "Who developed the software x" - }], + "es": "Quién desarrolló el software x", + "en": "Who developed the software x" + }, "category": ["Technology"] }, { "property": "P277", - "template": [{ - "lang": "es", - "question": "En qué lenguaje de programación está escrito x" + "template": { + "es": "En qué lenguaje de programación está escrito x", + "en": "What programminge iwritten in?" }, - { - "lang": "en", - "question": "What programming language is x written in?" - }], "category": ["Technology"] } ] @@ -421,26 +313,18 @@ { "property": "P641", "template": - [{ - "lang": "es", - "question": "En qué deporte compite x" - }, { - "lang": "en", - "question": "Who developed the software x" - }], + "es": "En qué deporte compite x", + "en": "Who developed the software x" + }, "category": ["Sport"] }, { "property": "P27", - "template": [{ - "lang": "es", - "question": "Cuál es la nacionalidad del atleta x" + "template": { + "es": "Cuál es la nacionalidad del atleta x", + "en": "What is the nationality of the athlete x" }, - { - "lang": "en", - "question": "What is the nationality of the athlete x" - }], "category": ["Sport"] } ] @@ -452,38 +336,26 @@ { "property": "P178", "template": - [{ - "lang": "es", - "question": "Quien es el desarrollador del videojuego x" - }, { - "lang": "en", - "question": "Who is the developer of the video game x" - }], + "es": "Quien es el desarrollador del videojuego x", + "en": "Who is the developer of the video game x" + }, "category": ["Games"] }, { "property": "P577", - "template": [{ - "lang": "es", - "question": "En qué año fue lanzado el videojuego x" + "template": { + "es": "En qué año fue lanzado el videojuego x", + "en": "In what year was the video game x released?" }, - { - "lang": "en", - "question": "In what year was the video game x released?" - }], "category": ["Games"] }, { "property": "P400", - "template": [{ - "lang": "es", - "question": "Cuáles son las plataformas compatibles con x" + "template": { + "es": "Cuáles son las plataformas compatibles con x", + "en": "What are the platforms supported by x" }, - { - "lang": "en", - "question": "What are the platforms supported by x" - }], "category": ["Games"] } ] @@ -495,26 +367,18 @@ { "property": "P287", "template": - [{ - "lang": "es", - "question": "Quién es el diseñador de la marca x" - }, { - "lang": "en", - "question": "Who is the designer of the brand x" - }], + "es": "Quién es el diseñador de la marca x", + "en": "Who is the designer of the brand x" + }, "category": ["Fashion"] }, { "property": "P571", - "template": [{ - "lang": "es", - "question": "Cuándo fue fundada la casa de moda x" + "template": { + "es": "Cuándo fue fundada la casa de moda x", + "en": "When was the fashion house founded x" }, - { - "lang": "en", - "question": "When was the fashion house founded x" - }], "category": ["Fashion"] } ] @@ -526,26 +390,18 @@ { "property": "P2973", "template": - [{ - "lang": "es", - "question": "Cuál es el hábitat natural de la especie x" - }, { - "lang": "en", - "question": "What is the natural habitat of species x" - }], + "es": "Cuál es el hábitat natural de la especie x", + "en": "What is the natural habitat of species x" + }, "category": ["Animals"] }, { "property": "P2670", - "template": [{ - "lang": "es", - "question": "Qué especies comparten el hábitat con x" + "template": { + "es": "Qué especies comparten el hábitat con x", + "en": "What species share the habitat with x" }, - { - "lang": "en", - "question": "What species share the habitat with x" - }], "category": ["Animals"] } ] @@ -557,14 +413,10 @@ { "property": "P571", "template": - [{ - "lang": "es", - "question": "Cuándo fue fundada la marca x" - }, { - "lang": "en", - "question": "When was the brand x founded?" - }], + "es": "Cuándo fue fundada la marca x", + "en": "When was the brand x founded?" + }, "category": ["Brands"] } ] From 3cdc552507f07932ea2bb59c79312919ad3a6bc4 Mon Sep 17 00:00:00 2001 From: Pablo Date: Sun, 28 Apr 2024 14:41:54 +0200 Subject: [PATCH 28/37] Added french templates --- questions/utils/question.json | 254 ++++++++++++++++++---------------- 1 file changed, 134 insertions(+), 120 deletions(-) diff --git a/questions/utils/question.json b/questions/utils/question.json index f763cd52..03e98c0a 100644 --- a/questions/utils/question.json +++ b/questions/utils/question.json @@ -5,11 +5,11 @@ "properties": [ { "property": "P1082", - "template": - { + "template": { "es": "Cuál es la población de x", - "en": "What is the population of x" - }, + "en": "What is the population of x", + "fr": "Quelle est la population de x" + }, "filter": ">4000000", "category": ["Geography", "Cities"] }, @@ -17,17 +17,18 @@ "property": "P36", "template": { "es": "Cuál es la capital de x", - "en": "What is the capital of x" - }, + "en": "What is the capital of x", + "fr": "Quelle est la capitale de x" + }, "category": ["Geography", "Cities"] }, { "property": "P38", - "template": - { + "template": { "es": "Que moneda tiene x", - "en": "What currency x has" - }, + "en": "What currency x has", + "fr": "Quelle est la devise de x" + }, "category": ["Political"] } ] @@ -38,20 +39,20 @@ "properties": [ { "property": "P115", - "template": - { + "template": { "es": "Cuál es el estadio del equipo x", - "en": "What is the stadium of x team" - }, + "en": "What is the stadium of x team", + "fr": "Quel est le stade de l'équipe x" + }, "category": ["Sports"] }, { "property": "P17", - "template": - { + "template": { "es": "Cuál es el pais del equipo x", - "en": "What is the country of x team" - }, + "en": "What is the country of x team", + "fr": "Quel est le pays de l'équipe x" + }, "category": ["Sports", "Geography"] } ] @@ -62,11 +63,11 @@ "properties": [ { "property": "P205", - "template": - { + "template": { "es": "En qué país está el río x", - "en": "What country is x river in" - }, + "en": "What country is x river in", + "fr": "Dans quel pays se trouve le fleuve x" + }, "category": ["Geography"] } ] @@ -77,28 +78,29 @@ "properties": [ { "property": "P170", - "template": - { + "template": { "es": "Quien es el autor de x", - "en": "Who is the author of x" - }, + "en": "Who is the author of x", + "fr": "Qui est l'auteur de x" + }, "category": ["Art"] }, { "property": "P571", "template": { "es": "Cual es el año de creacion de x", - "en": "What is the year of creation of x" - }, + "en": "What is the year of creation of x", + "fr": "Quelle est l'année de création de x" + }, "category": ["Art"] }, { "property": "P136", - "template": - { + "template": { "es": "Cual es el estilo artistico de x", - "en": "What is the artistic style of x" - }, + "en": "What is the artistic style of x", + "fr": "Quel est le style artistique de x" + }, "category": ["Art"] } ] @@ -109,20 +111,20 @@ "properties": [ { "property": "P61", - "template": - { + "template": { "es": "Quien es el inventor de x", - "en": "Who is the inventor of x" - }, + "en": "Who is the inventor of x", + "fr": "Qui est l'inventeur de x" + }, "category": ["Science"] }, { "property": "P575", - "template": - { + "template": { "es": "En que año se inventó x", - "en": "What was the year of invention of x" - }, + "en": "What was the year of invention of x", + "fr": "En quelle année x a été inventé" + }, "category": ["Science"] } ] @@ -133,11 +135,11 @@ "properties": [ { "property": "P2044", - "template": - { + "template": { "es": "Cual es la altitud mxima del x", - "en": "What is the maximum altitude of x" - }, + "en": "What is the maximum altitude of x", + "fr": "Quelle est l'altitude maximale de x" + }, "category": ["Geography"] } ] @@ -148,28 +150,29 @@ "properties": [ { "property": "P50", - "template": - { + "template": { "es": "Quien es el autor de x", - "en": "Who is the author of x" - }, + "en": "Who is the author of x", + "fr": "Qui est l'auteur de x" + }, "category": ["Entertainment"] }, { "property": "P577", "template": { "es": "Cual es el año de publicacion de x", - "en": "What is the year of publication of x" - }, + "en": "What is the year of publication of x", + "fr": "Quelle est l'année de publication de x" + }, "category": ["Entertainment"] }, { "property": "P136", - "template": - { + "template": { "es": "Cual es el genero de x", - "en": "What is the genre of x" - }, + "en": "What is the genre of x", + "fr": "Quel est le genre de x" + }, "category": ["Entertainment"] } ] @@ -180,28 +183,29 @@ "properties": [ { "property": "P176", - "template": - { + "template": { "es": "Quien es el fabricante de x", - "en": "Who is the manufacturer of x" - }, + "en": "Who is the manufacturer of x", + "fr": "Qui est le fabricant de x" + }, "category": ["Cars"] }, { "property": "P3032", "template": { "es": "Cuál es la velocidad máxima de x", - "en": "What is the maximum speed of x" - }, + "en": "What is the maximum speed of x", + "fr": "Quelle est la vitesse maximale de x" + }, "category": ["Cars"] }, { "property": "P571", - "template": - { + "template": { "es": "En qué año fue introducido x al mercado", - "en": "In what year was x introduced to the market" - }, + "en": "In what year was x introduced to the market", + "fr": "En quelle année x a été introduit sur le marché" + }, "category": ["Cars"] } ] @@ -212,19 +216,20 @@ "properties": [ { "property": "P527", - "template": - { + "template": { "es": "Cuál es el ingrediente principal de x", - "en": "What is the main ingredient of x" - }, + "en": "What is the main ingredient of x", + "fr": "Quel est l'ingrédient principal de x" + }, "category": ["Food"] }, { "property": "P495", "template": { "es": "De qué región es originario x", - "en": "What region is x originally from?" - }, + "en": "What region is x originally from?", + "fr": "De quelle région x est-il originaire?" + }, "category": ["Food"] } ] @@ -235,27 +240,29 @@ "properties": [ { "property": "P84", - "template": - { + "template": { "es": "Quién fue el arquitecto de x", - "en": "Who was the architect of x" - }, + "en": "Who was the architect of x", + "fr": "Qui était l'architecte de x" + }, "category": ["Art"] }, { "property": "P571", "template": { "es": "En qué año se completó x", - "en": "In what year was it completed x" - }, + "en": "In what year was it completed x", + "fr": "En quelle année x a-t-il été achevé" + }, "category": ["Art"] }, { "property": "P149", "template": { "es": "Cuál es el estilo arquitectónico de x", - "en": "What is the architectural style of x" - }, + "en": "What is the architectural style of x", + "fr": "Quel est le style architectural de x" + }, "category": ["Art"] } ] @@ -266,19 +273,20 @@ "properties": [ { "property": "P178", - "template": - { + "template": { "es": "Quién es el creador de la serie x", - "en": "Who is the creator of the series x" - }, + "en": "Who is the creator of the series x", + "fr": "Qui est le créateur de la série x" + }, "category": ["Entertainment"] }, { "property": "P2437", "template": { "es": "Cuántas temporadas tiene la serie x", - "en": "How many seasons does the series x have?" - }, + "en": "How many seasons does the series x have?", + "fr": "Combien de saisons la série x a-t-elle?" + }, "category": ["Entertainment"] } ] @@ -289,19 +297,20 @@ "properties": [ { "property": "P178", - "template": - { + "template": { "es": "Quién desarrolló el software x", - "en": "Who developed the software x" - }, + "en": "Who developed the software x", + "fr": "Qui a développé le logiciel x" + }, "category": ["Technology"] }, { "property": "P277", "template": { "es": "En qué lenguaje de programación está escrito x", - "en": "What programminge iwritten in?" - }, + "en": "What programming language is x written in?", + "fr": "Dans quel langage de programmation x est-il écrit?" + }, "category": ["Technology"] } ] @@ -312,19 +321,20 @@ "properties": [ { "property": "P641", - "template": - { + "template": { "es": "En qué deporte compite x", - "en": "Who developed the software x" - }, + "en": "In what sport does x compete", + "fr": "Dans quel sport x compétitionne-t-il" + }, "category": ["Sport"] }, { "property": "P27", "template": { "es": "Cuál es la nacionalidad del atleta x", - "en": "What is the nationality of the athlete x" - }, + "en": "What is the nationality of the athlete x", + "fr": "Quelle est la nationalité de l'athlète x" + }, "category": ["Sport"] } ] @@ -335,26 +345,28 @@ "properties": [ { "property": "P178", - "template": - { + "template": { "es": "Quien es el desarrollador del videojuego x", - "en": "Who is the developer of the video game x" - }, + "en": "Who is the developer of the video game x", + "fr": "Qui est le développeur du jeu vidéo x" + }, "category": ["Games"] }, { "property": "P577", "template": { "es": "En qué año fue lanzado el videojuego x", - "en": "In what year was the video game x released?" - }, + "en": "In what year was the video game x released?", + "fr": "En quelle année le jeu vidéo x a-t-il été lancé?" + }, "category": ["Games"] }, { "property": "P400", "template": { "es": "Cuáles son las plataformas compatibles con x", - "en": "What are the platforms supported by x" + "en": "What are the platforms supported by x", + "fr": "Quelles sont les plates-formes supportées par x" }, "category": ["Games"] } @@ -366,19 +378,20 @@ "properties": [ { "property": "P287", - "template": - { + "template": { "es": "Quién es el diseñador de la marca x", - "en": "Who is the designer of the brand x" - }, + "en": "Who is the designer of the brand x", + "fr": "Qui est le designer de la marque x" + }, "category": ["Fashion"] }, { "property": "P571", "template": { "es": "Cuándo fue fundada la casa de moda x", - "en": "When was the fashion house founded x" - }, + "en": "When was the fashion house founded x", + "fr": "Quand la maison de mode x a-t-elle été fondée" + }, "category": ["Fashion"] } ] @@ -389,19 +402,20 @@ "properties": [ { "property": "P2973", - "template": - { + "template": { "es": "Cuál es el hábitat natural de la especie x", - "en": "What is the natural habitat of species x" - }, + "en": "What is the natural habitat of species x", + "fr": "Quel est l'habitat naturel de l'espèce x" + }, "category": ["Animals"] }, { "property": "P2670", "template": { "es": "Qué especies comparten el hábitat con x", - "en": "What species share the habitat with x" - }, + "en": "What species share the habitat with x", + "fr": "Quelles espèces partagent l'habitat avec x" + }, "category": ["Animals"] } ] @@ -412,13 +426,13 @@ "properties": [ { "property": "P571", - "template": - { + "template": { "es": "Cuándo fue fundada la marca x", - "en": "When was the brand x founded?" - }, + "en": "When was the brand x founded?", + "fr": "Quand la marque x a-t-elle été fondée?" + }, "category": ["Brands"] } ] } -] \ No newline at end of file +] From d510b2b659b03749775e4e6e6fdaa9bab4b32cee Mon Sep 17 00:00:00 2001 From: teresagg Date: Sun, 28 Apr 2024 14:42:01 +0200 Subject: [PATCH 29/37] Add french labelling --- questions/services/wikidata-service.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/questions/services/wikidata-service.js b/questions/services/wikidata-service.js index f9f76bdb..1a8c710b 100644 --- a/questions/services/wikidata-service.js +++ b/questions/services/wikidata-service.js @@ -121,6 +121,9 @@ async function getEntityLabel(entityUrl) { if(entity.labels.es) { return entity.labels.es.value; } + if(entity.labels.fr) { + return entity.labels.fr.value; + } return "no label (TEST)"; } From acac2c1cb231b2878922992026ce35692265822a Mon Sep 17 00:00:00 2001 From: teresagg Date: Sun, 28 Apr 2024 14:46:22 +0200 Subject: [PATCH 30/37] Restablishing labels as before --- questions/services/wikidata-service.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/questions/services/wikidata-service.js b/questions/services/wikidata-service.js index 1a8c710b..1a2dad36 100644 --- a/questions/services/wikidata-service.js +++ b/questions/services/wikidata-service.js @@ -121,10 +121,7 @@ async function getEntityLabel(entityUrl) { if(entity.labels.es) { return entity.labels.es.value; } - if(entity.labels.fr) { - return entity.labels.fr.value; - } - + return "no label (TEST)"; } From d71cd6224acde0667e34438bb375c5f1585dd63e Mon Sep 17 00:00:00 2001 From: Pablo Date: Sun, 28 Apr 2024 14:53:23 +0200 Subject: [PATCH 31/37] Improved access to the lang template --- questions/services/generate-questions-service.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/questions/services/generate-questions-service.js b/questions/services/generate-questions-service.js index fe467689..cb93d865 100644 --- a/questions/services/generate-questions-service.js +++ b/questions/services/generate-questions-service.js @@ -41,8 +41,8 @@ async function generateQuestions(n, language, questionCategory) { const property = entity.properties[pos].property; const categories = entity.properties[pos].category; const filter = entity.properties[pos].filter; - const lang = language=="es"?0:1; //0 spanish, 1 english - const question = entity.properties[pos].template[lang].question; + // Now language is accessed directly: + const question = entity.properties[pos].template[language]; //let [entityName, searched_property] = await wikidataService.getRandomEntity(instance, property, filter); let [entityName, searched_property] = await wikidataService.getRandomEntity(entity, pos, language); From 16166a968a6e18d4bbd0f0857d70ae3517bdcf04 Mon Sep 17 00:00:00 2001 From: Pablo Date: Sun, 28 Apr 2024 16:38:53 +0200 Subject: [PATCH 32/37] Error management for the target entity (solved no label (?)) --- questions/services/generate-questions-service.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/questions/services/generate-questions-service.js b/questions/services/generate-questions-service.js index cb93d865..021c2fbf 100644 --- a/questions/services/generate-questions-service.js +++ b/questions/services/generate-questions-service.js @@ -44,8 +44,15 @@ async function generateQuestions(n, language, questionCategory) { // Now language is accessed directly: const question = entity.properties[pos].template[language]; - //let [entityName, searched_property] = await wikidataService.getRandomEntity(instance, property, filter); - let [entityName, searched_property] = await wikidataService.getRandomEntity(entity, pos, language); + let [entityName, searched_property] = [null, null] + while (!entityName || !searched_property) { + try { + [entityName, searched_property] = await wikidataService.getRandomEntity(entity, pos, language); + } catch (error) { + console.error("Error generating label for the answer: ", error.message); + console.error("Line:", error.stack.split("\n")[1]); + } + } if (searched_property !== null) { //This way we can ask questions with different structures From 809127d3b8b5e526e7315c86bf5118a8365d584d Mon Sep 17 00:00:00 2001 From: uo289689 Date: Sun, 28 Apr 2024 16:46:54 +0200 Subject: [PATCH 33/37] Added users-api.yaml and fixed the challenge timmer bug --- gatewayservice/apis/users-api.yaml | 422 +++++++++++++++++++++ webapp/src/pages/games/TheChallengeGame.js | 2 +- 2 files changed, 423 insertions(+), 1 deletion(-) create mode 100644 gatewayservice/apis/users-api.yaml diff --git a/gatewayservice/apis/users-api.yaml b/gatewayservice/apis/users-api.yaml new file mode 100644 index 00000000..1d3214da --- /dev/null +++ b/gatewayservice/apis/users-api.yaml @@ -0,0 +1,422 @@ +--- +openapi: 3.0.0 +info: + title: UsersService API + description: User OpenAPI specification + version: 1.0.0 +servers: +- url: https://virtserver.swaggerhub.com/UO289689_1/users-api/1.0.0 + description: SwaggerHub API Auto Mocking +- url: http://localhost:8000 + description: Development server +- url: http://20.19.89.97:8000 + description: Production server +paths: + /user: + get: + summary: Get all users + responses: + "200": + description: Successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/inline_response_200' + "400": + description: Bad request + post: + summary: Add a new user + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/user_body' + required: true + responses: + "200": + description: Successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/inline_response_200_1' + "500": + description: Internal Server Error + /user/{username}: + get: + summary: Get user by username + parameters: + - name: username + in: path + description: Username + required: true + style: simple + explode: false + schema: + type: string + responses: + "200": + description: Successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/inline_response_200_2' + "400": + description: Bad request + /ranking: + get: + summary: Get users sorted by correct answers + responses: + "200": + description: Successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/inline_response_200' + "400": + description: Bad request + /statistics/{username}: + get: + summary: Get user statistics by username + parameters: + - name: username + in: path + description: Username + required: true + style: simple + explode: false + schema: + type: string + responses: + "200": + description: Successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/inline_response_200_3' + "400": + description: Bad request + /statistics: + put: + summary: Update user statistics + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/statistics_body' + required: true + responses: + "200": + description: Successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/inline_response_200_4' + "500": + description: Internal Server Error + /questionsRecord/{username}/{gameMode}: + get: + summary: Get users questions record by username and game mode + parameters: + - name: username + in: path + description: Username + required: true + style: simple + explode: false + schema: + type: string + - name: gameMode + in: path + description: Game mode + required: true + style: simple + explode: false + schema: + type: string + responses: + "200": + description: Successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/inline_response_200_5' + "500": + description: Internal Server Error + /questionsRecord: + put: + summary: Update users questions record + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/questionsRecord_body' + required: true + responses: + "200": + description: Successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/questionsRecord_body' + "500": + description: Internal Server Error + /group: + get: + summary: Get all users groups + responses: + "200": + description: Successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/inline_response_200_6' + "500": + description: Internal Server Error + post: + summary: Add a new group + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/group_body' + required: true + responses: + "200": + description: Successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/inline_response_200_7' + "400": + description: Bad request + /group/{name}: + get: + summary: Get group by name + parameters: + - name: name + in: path + description: Group name + required: true + style: simple + explode: false + schema: + type: string + responses: + "200": + description: Successful operation + content: + application/json: + schema: + $ref: '#/components/schemas/inline_response_200_7' + "404": + description: Group not found + "400": + description: Bad request +components: + schemas: + inline_response_200: + type: object + properties: + users: + type: array + items: + type: object + properties: + username: + type: string + password: + type: string + name: + type: string + surname: + type: string + createdAt: + type: string + imageUrl: + type: string + user_body: + type: object + properties: + username: + type: string + password: + type: string + name: + type: string + surname: + type: string + inline_response_200_1: + type: object + properties: + username: + type: string + password: + type: string + name: + type: string + surname: + type: string + createdAt: + type: string + inline_response_200_2: + type: object + properties: + username: + type: string + password: + type: string + name: + type: string + surname: + type: string + createdAt: + type: string + imageUrl: + type: string + inline_response_200_3: + type: object + properties: + username: + type: string + the_callenge_earned_money: + type: integer + the_callenge_correctly_answered_questions: + type: integer + the_callenge_incorrectly_answered_questions: + type: integer + the_callenge_total_time_played: + type: integer + the_callenge_games_played: + type: integer + wise_men_stack_earned_money: + type: integer + wise_men_stack_correctly_answered_questions: + type: integer + wise_men_stack_incorrectly_answered_questions: + type: integer + wise_men_stack_games_played: + type: integer + warm_question_earned_money: + type: integer + warm_question_correctly_answered_questions: + type: integer + warm_question_incorrectly_answered_questions: + type: integer + warm_question_passed_questions: + type: integer + warm_question_games_played: + type: integer + discovering_cities_earned_money: + type: integer + discovering_cities_correctly_answered_questions: + type: integer + discovering_cities_incorrectly_answered_questions: + type: integer + discovering_cities_games_played: + type: integer + statistics_body: + type: object + properties: + username: + type: string + the_callenge_earned_money: + type: integer + the_callenge_correctly_answered_questions: + type: integer + the_callenge_incorrectly_answered_questions: + type: integer + the_callenge_total_time_played: + type: integer + the_callenge_games_played: + type: integer + wise_men_stack_earned_money: + type: integer + wise_men_stack_correctly_answered_questions: + type: integer + wise_men_stack_incorrectly_answered_questions: + type: integer + wise_men_stack_games_played: + type: integer + warm_question_earned_money: + type: integer + warm_question_correctly_answered_questions: + type: integer + warm_question_incorrectly_answered_questions: + type: integer + warm_question_passed_questions: + type: integer + warm_question_games_played: + type: integer + discovering_cities_earned_money: + type: integer + discovering_cities_correctly_answered_questions: + type: integer + discovering_cities_incorrectly_answered_questions: + type: integer + discovering_cities_games_played: + type: integer + online_earned_money: + type: integer + online_correctly_answered_questions: + type: integer + online_incorrectly_answered_questions: + type: integer + online_total_time_played: + type: integer + online_games_played: + type: integer + inline_response_200_4: + type: object + properties: + username: + type: string + message: + type: string + inline_response_200_5: + type: object + properties: + username: + type: string + questionsRecord: + type: object + gameMode: + type: string + questionsRecord_body: + type: object + properties: + username: + type: string + questionsRecord: + type: object + gameMode: + type: string + inline_response_200_6: + type: object + properties: + groups: + type: array + items: + type: object + properties: + name: + type: string + creator: + type: string + createdAt: + type: string + group_body: + type: object + properties: + name: + type: string + username: + type: string + inline_response_200_7: + type: object + properties: + name: + type: string + creator: + type: string + createdAt: + type: string diff --git a/webapp/src/pages/games/TheChallengeGame.js b/webapp/src/pages/games/TheChallengeGame.js index e333ff77..d9c9c440 100644 --- a/webapp/src/pages/games/TheChallengeGame.js +++ b/webapp/src/pages/games/TheChallengeGame.js @@ -358,7 +358,7 @@ const TheChallengeGame = () => { : // Cronómetro - selectResponse(-1, "FAILED")}> {({ remainingTime }) => { return ( From 7cc655b9515ceb5ff953c6a9bb17901a0827f8ba Mon Sep 17 00:00:00 2001 From: Pablo Date: Sun, 28 Apr 2024 18:21:23 +0200 Subject: [PATCH 34/37] Added validation for the entity search and its result --- .../services/generate-questions-service.js | 30 ++++++++++++++++--- questions/services/wikidata-service.js | 3 +- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/questions/services/generate-questions-service.js b/questions/services/generate-questions-service.js index 021c2fbf..843b8e0c 100644 --- a/questions/services/generate-questions-service.js +++ b/questions/services/generate-questions-service.js @@ -1,6 +1,6 @@ const utils = require('../utils/generalQuestions'); const wikidataService = require('./wikidata-service'); -const dbService = require('./question-data-service') +const dbService = require('./question-data-service'); /** * Asynchronously generates a specified number of questions using data from the JSON file and stores them in the DB. @@ -45,14 +45,25 @@ async function generateQuestions(n, language, questionCategory) { const question = entity.properties[pos].template[language]; let [entityName, searched_property] = [null, null] - while (!entityName || !searched_property) { + let invalidEntity = false; + while ((!entityName || !searched_property) && !invalidEntity) { try { - [entityName, searched_property] = await wikidataService.getRandomEntity(entity, pos, language); + // If result for the entity is invalid, stops and logs the entity + let response = await wikidataService.getRandomEntity(entity, pos, language); + if (response && response.length === 2) { + [entityName, searched_property] = response; + } else { + console.error(`Error: getRandomEntity returned an invalid response for the entity: ${entity.name}`); + invalidEntity = true; + } } catch (error) { console.error("Error generating label for the answer: ", error.message); console.error("Line:", error.stack.split("\n")[1]); } } + if (invalidEntity) { + continue; + } if (searched_property !== null) { //This way we can ask questions with different structures @@ -60,7 +71,18 @@ async function generateQuestions(n, language, questionCategory) { let correctAnswer = searched_property; // options will contain 3 wrong answers plus the correct one - let options = await wikidataService.getProperties(property, language, filter); + let options; + try { + options = await wikidataService.getProperties(property, language, filter); + + } catch (error) { + console.error(`Error generating options for ${entityName}: `, error.message); + console.error("Line:", error.stack.split("\n")[1]); + continue; + } + if (!options) { + continue; + } options.push(correctAnswer); //If properties are entities diff --git a/questions/services/wikidata-service.js b/questions/services/wikidata-service.js index 9684d293..db875fbd 100644 --- a/questions/services/wikidata-service.js +++ b/questions/services/wikidata-service.js @@ -80,7 +80,7 @@ async function getProperties(property, language, filt) { query: consultaSparql, format: 'json' }, - timeout: 15000 //means error + timeout: 30000 //means error }); const endTime = new Date(); const elapsedTime = endTime - startTime; @@ -99,7 +99,6 @@ async function getProperties(property, language, filt) { } return null; } catch (error) { - console.error(error.stack); console.error(`Error obtaining properties: ${error.message}`); console.error("Line:", error.stack.split("\n")[1]); return null; From 278b07184f8d4968a7335954c6fa7ddbe8de9932 Mon Sep 17 00:00:00 2001 From: Pablo Date: Sun, 28 Apr 2024 18:42:23 +0200 Subject: [PATCH 35/37] Checked question being added is not already in DB --- questions/services/generate-questions-service.js | 7 +++++++ questions/services/question-data-service.js | 7 +------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/questions/services/generate-questions-service.js b/questions/services/generate-questions-service.js index 843b8e0c..1babbb39 100644 --- a/questions/services/generate-questions-service.js +++ b/questions/services/generate-questions-service.js @@ -68,6 +68,13 @@ async function generateQuestions(n, language, questionCategory) { if (searched_property !== null) { //This way we can ask questions with different structures const questionText = question.replace('x',entityName.charAt(0).toUpperCase() + entityName.slice(1)) +`?`; + // If that question is already in db, it goes on: + const questionAlreadyInDb = await dbService.getQuestion({"question": questionText}); + if (!questionAlreadyInDb === "undefined") { + console.log(`Question ${questionText} already in db, skipping`); + continue; + } + let correctAnswer = searched_property; // options will contain 3 wrong answers plus the correct one diff --git a/questions/services/question-data-service.js b/questions/services/question-data-service.js index ef6a054e..1b17cdc8 100644 --- a/questions/services/question-data-service.js +++ b/questions/services/question-data-service.js @@ -20,7 +20,6 @@ module.exports = { }, - //TODO - Filter func not yet implemented /** * Returns a question from the database that could be filtered using a dictionary and removes it. * @param {dict} filter - The dict containing the filter options for mongoose. @@ -28,17 +27,13 @@ module.exports = { */ getQuestion : async function(filter = {}) { try { - //const question = await Question.findOne(filter); - //return question; - //if there is filter if (Object.keys(filter).length !== 0) { - + const q = await Question.aggregate([ { $match: filter }, { $sample: { size: 1 } } ]); - return q[0]; } else { //if not filter -> just random question From 7f263b57f804194d022c7b6e3a4aec53c77b4cae Mon Sep 17 00:00:00 2001 From: Pablo Date: Sun, 28 Apr 2024 19:25:27 +0200 Subject: [PATCH 36/37] Mocked existance of the question in unit tests for question generation --- .../question-generation-service.test.js | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/questions/__tests/services/question-generation-service.test.js b/questions/__tests/services/question-generation-service.test.js index a999966c..42cf160f 100644 --- a/questions/__tests/services/question-generation-service.test.js +++ b/questions/__tests/services/question-generation-service.test.js @@ -6,6 +6,7 @@ const generalQuestions = require('../../utils/generalQuestions'); jest.mock('../../utils/generalQuestions'); jest.mock('../../services/wikidata-service'); jest.mock('../../services/question-data-service', () => ({ + getQuestion: jest.fn(), addQuestion: jest.fn(), // Mockear la función addQuestion para que no haga nada })); @@ -15,15 +16,10 @@ const entity = { "properties": [ { "property": "P1082", - "template": - [{ - "lang": "es", - "question": "Cuál es la población de x" - }, - { - "lang": "en", - "question": "What is the population of x" - }], + "template": { + "es": "Cuál es la población de x", + "en": "What is the population of x" + }, "filter": ">1000000", "category": ["Geography"] } @@ -48,8 +44,9 @@ describe('Question generation', function() { wikidataService.getProperties.mockResolvedValue(['Barcelona', 'Paris', 'London']); wikidataService.convertUrlsToLabels.mockResolvedValue(['Barcelona', 'Paris', 'London','Madrid']); - generalQuestions.shuffleArray.mockResolvedValue(['Barcelona', 'Paris', 'London','Madrid']) + generalQuestions.shuffleArray.mockResolvedValue(['Barcelona', 'Paris', 'London','Madrid']); + dbService.getQuestion.mockResolvedValue("undefined"); dbService.addQuestion.mockResolvedValue(); // Llama a la función que deseas probar await generator.generateQuestions(1,"en","Geography"); From b1a69f1d5939618d6715b4ac5ade69359dcf7feb Mon Sep 17 00:00:00 2001 From: Pablo Date: Sun, 28 Apr 2024 19:36:47 +0200 Subject: [PATCH 37/37] Fighting against sonarcloud monster --- questions/services/generate-questions-service.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/questions/services/generate-questions-service.js b/questions/services/generate-questions-service.js index feddfa79..f6b4d666 100644 --- a/questions/services/generate-questions-service.js +++ b/questions/services/generate-questions-service.js @@ -71,7 +71,7 @@ async function generateQuestions(n, language, questionCategory) { const questionText = question.replace('x',entityName.charAt(0).toUpperCase() + entityName.slice(1)) +`?`; // If that question is already in db, it goes on: const questionAlreadyInDb = await dbService.getQuestion({"question": questionText}); - if (!questionAlreadyInDb === "undefined") { + if (!questionAlreadyInDb === undefined) { console.log(`Question ${questionText} already in db, skipping`); continue; }