From 6acdf5e7bd8be81e4e87f514f59fc4dd86225bd0 Mon Sep 17 00:00:00 2001 From: carlospelazas Date: Mon, 8 Apr 2024 13:05:27 +0200 Subject: [PATCH] fix question generation query --- game/qgservice/generatorLogic/queries.js | 10 ++++++---- game/qgservice/generatorLogic/questiongenerator.js | 4 ++-- .../game/singleplayer/PlayingGameSinglePlayer.tsx | 9 +++++++-- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/game/qgservice/generatorLogic/queries.js b/game/qgservice/generatorLogic/queries.js index 8f355a6..7dfd197 100644 --- a/game/qgservice/generatorLogic/queries.js +++ b/game/qgservice/generatorLogic/queries.js @@ -47,12 +47,14 @@ const chemicalElementQuery = `SELECT ?element ?elementLabel ?symbol WHERE { } ` -const monumentQuery = `SELECT ?monument ?monumentLabel ?country ?countryLabel WHERE { - ?monument wdt:P31 wd:Q4989906; # Instance of historical monument - wdt:P17 ?country. # Country of the monument +const monumentQuery = `SELECT ?monument ?monumentLabel ?country ?countryLabel ?followers WHERE { + ?monument wdt:P31 wd:Q570116; # Instance of historical monument + wdt:P8687 ?followers; # Social media followers count + wdt:P17 ?country. # Country of the monument SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } } -LIMIT 1000 +ORDER BY DESC(?followers) +LIMIT 100 ` diff --git a/game/qgservice/generatorLogic/questiongenerator.js b/game/qgservice/generatorLogic/questiongenerator.js index e259aa5..780ed34 100644 --- a/game/qgservice/generatorLogic/questiongenerator.js +++ b/game/qgservice/generatorLogic/questiongenerator.js @@ -95,7 +95,7 @@ function generateQuestionCapital(countryCapitalMap) { // Create the question object const question = { uuid: uuid.v4(), - question: `What is the symbol of ${chemical}?`, + question: `What is the chemical symbol of ${chemical}?`, correctAnswer: symbol, incorrectAnswer1: incorrectAnswers[0], incorrectAnswer2: incorrectAnswers[1], @@ -125,7 +125,7 @@ function generateQuestionMonument(monumentMap) { while (incorrectAnswers.length < 3) { const randomMonument = monumentArray[Math.floor(Math.random() * monumentArray.length)]; const [randomMonumentLabel, randomCountry] = randomMonument; - if (randomMonumentLabel !== monumentLabel && !incorrectAnswers.includes(randomCountry)) { + if (randomMonumentLabel !== monumentLabel && !incorrectAnswers.includes(randomCountry) && randomCountry!= countryLabel) { incorrectAnswers.push(randomCountry); } } diff --git a/webapp/src/components/game/singleplayer/PlayingGameSinglePlayer.tsx b/webapp/src/components/game/singleplayer/PlayingGameSinglePlayer.tsx index d82a4d6..d0455fe 100644 --- a/webapp/src/components/game/singleplayer/PlayingGameSinglePlayer.tsx +++ b/webapp/src/components/game/singleplayer/PlayingGameSinglePlayer.tsx @@ -88,8 +88,13 @@ const PlayingGame: FC = ({questions, setCurrentStage, setPlaye } const getAnswers = () => { - console.log(answersShuffled[currentQuestion]) - return answersShuffled[currentQuestion]; + const answers = answersShuffled[currentQuestion]; + if (answers.length > 4) { + console.log(answers) + const removeCount = answers.length - 4; + answers.splice(0, removeCount); + } + return answers; }; return (