Skip to content

Commit

Permalink
fix question generation query
Browse files Browse the repository at this point in the history
  • Loading branch information
pelazas committed Apr 8, 2024
1 parent cb2cdde commit 6acdf5e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
10 changes: 6 additions & 4 deletions game/qgservice/generatorLogic/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
`


Expand Down
4 changes: 2 additions & 2 deletions game/qgservice/generatorLogic/questiongenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down Expand Up @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,13 @@ const PlayingGame: FC<PlayingGameProps> = ({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 (
Expand Down

0 comments on commit 6acdf5e

Please sign in to comment.