From 7e3f637df3f33305ccb7281b3b14f27a310d4e9e Mon Sep 17 00:00:00 2001 From: uo277310 Date: Wed, 21 Feb 2024 20:51:31 +0100 Subject: [PATCH] =?UTF-8?q?Obtenci=C3=B3n=20de=20capital=20de=20pa=C3=ADs?= =?UTF-8?q?=20con=20bot=C3=B3n=20en=20pantalla,?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webapp/src/components/Game.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/webapp/src/components/Game.js b/webapp/src/components/Game.js index 1106afe1..b899c00c 100644 --- a/webapp/src/components/Game.js +++ b/webapp/src/components/Game.js @@ -10,6 +10,7 @@ import Link from '@mui/material/Link'; const Game=() =>{ const [questionBody, setquestionBody] = useState('');//pregunta aleatoria cuerpo const [informacionWikidata, setInformacionWikidata] = useState(''); + const [respuestaCorrecta, setRespuestaCorrecta] = useState(''); const [questionType, setQuestionType] = useState('');;//para el tipo de pregunta a buscar const [answerType, setAnswerType] = useState('');;//para el tipo de respuesta a buscar @@ -44,9 +45,10 @@ const Game=() =>{ try { // Consulta SPARQL//obtengo const sparqlQuery = ` - SELECT ?country ?countryLabel + SELECT ?country ?countryLabel ?capital ?capitalLabel WHERE { ?country wdt:P31 wd:Q6256. # P31 instancias de -> wd:Q6256 (paĆ­s) + ?country wdt:P36 ?capital. # P36 instancias de -> ?capital (capital) SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],es". } @@ -75,6 +77,8 @@ const Game=() =>{ setInformacionWikidata(result.countryLabel.value+`?`); + setRespuestaCorrecta(result.capitalLabel.value); + } else { console.error("Error al realizar la consulta en Wikidata. Estado de respuesta:", respuestaWikidata.status); } @@ -112,6 +116,9 @@ const Game=() =>{ Generar pregunta + ); }