diff --git a/WikidataPrueba/consultas.txt b/WikidataPrueba/consultas.txt new file mode 100644 index 00000000..b54719a6 --- /dev/null +++ b/WikidataPrueba/consultas.txt @@ -0,0 +1,158 @@ + --CONSULTAS GEOGRAFIA -- +--Consulta que devuelve pais y capital -- + +SELECT ?country ?countryLabel ?capitalLabel +WHERE +{ + ?country wdt:P31 wd:Q3624078. # Instance of country + ?country wdt:P36 ?capital. # Has capital + SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } +} + + +--Consulta que devuelve pais y poblacion -- +SELECT ?country ?countryLabel ?population +WHERE +{ + ?country wdt:P31 wd:Q3624078. # Instance of country + ?country wdt:P1082 ?population. # Has population + SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } +} + +--Consulta que devuelve pais, capital y poblacion -- +SELECT ?country ?countryLabel ?capitalLabel ?population +WHERE +{ + ?country wdt:P31 wd:Q3624078. # Instance of country + ?country wdt:P36 ?capital. # Has capital + ?country wdt:P1082 ?population. # Has population + SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } +} + +--Consulta estado de EEUU y su capital -- +SELECT ?state ?stateLabel ?capitalLabel +WHERE { + ?state wdt:P31 wd:Q35657 . + ?state p:P36 ?statement . + ?statement ps:P36 ?capital . + SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } +} + + +--Consulta estados de EEUU, capital y poblacion +SELECT ?state ?stateLabel ?capitalLabel ?poblation +WHERE { + ?state wdt:P31 wd:Q35657 . + ?state wdt:P36 ?capital . + ?state wdt:P1082 ?poblation . + SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".} +} + + + --CONSULTAS DEPORTES-- +--Consulta que devuelve club de futbol y su estadio -- + +SELECT ?club ?clubLabel ?stadiumLabel +WHERE { + ?club wdt:P31 wd:Q17270000 . + ?club p:P115 ?statement . + ?statement ps:P115 ?stadium . + SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } +} + + + --CONSULTAS ARTE--- +--Consulta libro y su autor -- +SELECT ?book ?bookLabel ?authorLabel +WHERE { + ?book wdt:P31 wd:Q571 . + ?book wdt:P50 ?author . + SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".} +} + + +--Consulta que devuelve libre y su autor pero solo 4 resultados -- + +SELECT ?book ?bookLabel ?authorLabel +WHERE { + ?book wdt:P31 wd:Q571 . + ?book wdt:P50 ?author . + SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en".} +} +LIMIT 4 + +--Consulta que me da peliculas su genero y año de publicacion del director Steven Spielberg -- + +SELECT ?film ?filmLabel ?genere ?d WHERE { + { + SELECT ?film (GROUP_CONCAT(DISTINCT ?gL; SEPARATOR = ", ") AS ?genere) (MIN(YEAR(?date)) AS ?d) WHERE { + ?sitelink schema:about ?director; + schema:isPartOf ; + schema:name "Steven Spielberg"@en. # Edit this with different director's name to see their films. Use the English Wikipedia title only. + ?film wdt:P31 wd:Q11424; + wdt:P136 ?g, ?g. + ?g rdfs:label ?gL. + ?film wdt:P57 ?director; + wdt:P577 ?date. + FILTER((LANG(?gL)) = "en") + SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } + } + GROUP BY ?film + } + SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } +} + + --CONSULTAS ENTRETENIMIENTO-- +# Consulta para obtener videojuegos y sus plataformas de desarrollo +SELECT ?videojuego ?nombreVideojuego ?plataforma ?nombrePlataforma +WHERE { + ?videojuego wdt:P31 wd:Q7889. # Videojuegos (clase) + ?videojuego wdt:P178 ?plataforma. # Relación "desarrollado para" + ?videojuego rdfs:label ?nombreVideojuego filter (lang(?nombreVideojuego) = "es"). + ?plataforma rdfs:label ?nombrePlataforma filter (lang(?nombrePlataforma) = "es"). +} +LIMIT 100 + + +# Consulta para obtener el nombre del videojuego y su género +SELECT ?videojuego ?nombreVideojuego ?genero ?nombreGenero +WHERE { + ?videojuego wdt:P31 wd:Q7889. # Videojuegos (clase) + ?videojuego wdt:P136 ?genero. # Relación "género" + ?videojuego rdfs:label ?nombreVideojuego filter (lang(?nombreVideojuego) = "es"). + ?genero rdfs:label ?nombreGenero filter (lang(?nombreGenero) = "es"). +} +LIMIT 100 + + + --CONSULTAS CIENCIA-- + + --CONSULTAS HISTORIA-- + + + --OTRAS CONSULTAS-- + + +--Consulta que me devuelve por orden descendente y solo 4 resultados las ciudades mas grandes por pais +me devuelve el nombre de la ciudad, pais y poblacion -- + +SELECT DISTINCT ?city ?cityLabel ?population ?countryLabel WHERE { + { + SELECT (MAX(?population_) AS ?population) ?country WHERE { + ?city wdt:P31/wdt:P279* wd:Q515 . + ?city wdt:P1082 ?population_ . + ?city wdt:P17 ?country . + } + GROUP BY ?country + ORDER BY DESC(?population) + } + ?city wdt:P31/wdt:P279* wd:Q515 . + ?city wdt:P1082 ?population . + ?city wdt:P17 ?country . + ?city wdt:P625 ?loc . + SERVICE wikibase:label { + bd:serviceParam wikibase:language "en" . + } +} +ORDER BY DESC(?population) +LIMIT 4 \ No newline at end of file diff --git a/docs/images/3.BusinessContext.png b/docs/images/3.BusinessContext.png new file mode 100644 index 00000000..05ea95b0 Binary files /dev/null and b/docs/images/3.BusinessContext.png differ diff --git a/docs/images/Business Context.png b/docs/images/Business Context.png new file mode 100644 index 00000000..8e15964a Binary files /dev/null and b/docs/images/Business Context.png differ diff --git "a/docs/images/Sin t\303\255tulo.png" "b/docs/images/Sin t\303\255tulo.png" new file mode 100644 index 00000000..6f99ad3f Binary files /dev/null and "b/docs/images/Sin t\303\255tulo.png" differ diff --git a/docs/src/03_system_scope_and_context.adoc b/docs/src/03_system_scope_and_context.adoc index 40ed146f..7b3e43a6 100644 --- a/docs/src/03_system_scope_and_context.adoc +++ b/docs/src/03_system_scope_and_context.adoc @@ -4,75 +4,24 @@ ifndef::imagesdir[:imagesdir: ../images] == System Scope and Context -[role="arc42help"] -**** -.Contents -System scope and context - as the name suggests - delimits your system (i.e. your scope) from all its communication partners -(neighboring systems and users, i.e. the context of your system). It thereby specifies the external interfaces. - -If necessary, differentiate the business context (domain specific inputs and outputs) from the technical context (channels, protocols, hardware). - -.Motivation -The domain interfaces and technical interfaces to communication partners are among your system's most critical aspects. Make sure that you completely understand them. - -.Form -Various options: - -* Context diagrams -* Lists of communication partners and their interfaces. - - -.Further Information - -See https://docs.arc42.org/section-3/[Context and Scope] in the arc42 documentation. - -**** - - === Business Context -[role="arc42help"] -**** -.Contents -Specification of *all* communication partners (users, IT-systems, ...) with explanations of domain specific inputs and outputs or interfaces. -Optionally you can add domain specific formats or communication protocols. - -.Motivation -All stakeholders should understand which data are exchanged with the environment of the system. - -.Form -All kinds of diagrams that show the system as a black box and specify the domain interfaces to communication partners. - -Alternatively (or additionally) you can use a table. -The title of the table is the name of your system, the three columns contain the name of the communication partner, the inputs, and the outputs. - -**** -In our business setting, we have developed a web application called WIQ, where users engage in a question-based game. -This application draws inspiration from the renowned Spanish television program "Saber y Ganar," providing users with an interactive and entertaining experience. - - - +image::Business Context.png["Business Context Diagram"] +[options="header",cols="1,2"] +|=== +|Element |Description +|User | +|Application | +|WikiData | +|=== * Users authenticate themselves within the system using their personal information. * The application offers a question-based game similar to "Saber y Ganar" . -* The primary objective of the project is to provide an interactive and enjoyable platform for users to engage in question and answer contests, promoting both entertainment and learning. * Users have access to various metrics regarding their participation, including the number of games played, correct and incorrect answers, and time spent on each question. === Technical Context -[role="arc42help"] -**** -.Contents -Technical interfaces (channels and transmission media) linking your system to its environment. In addition a mapping of domain specific input/output to the channels, i.e. an explanation which I/O uses which channel. - -.Motivation -Many stakeholders make architectural decision based on the technical interfaces between the system and its context. Especially infrastructure or hardware designers decide these technical interfaces. - -.Form -E.g. UML deployment diagram describing channels to neighboring systems, -together with a mapping table showing the relationships between channels and input/output. -**** [options="header",cols="1,2"] |=== diff --git a/docs/src/08_concepts.adoc b/docs/src/08_concepts.adoc index fff7b092..9de9a2a3 100644 --- a/docs/src/08_concepts.adoc +++ b/docs/src/08_concepts.adoc @@ -5,65 +5,16 @@ ifndef::imagesdir[:imagesdir: ../images] [role="arc42help"] -**** -.Content -This section describes overall, principal regulations and solution ideas that are relevant in multiple parts (= cross-cutting) of your system. -Such concepts are often related to multiple building blocks. -They can include many different topics, such as -* models, especially domain models -* architecture or design patterns -* rules for using specific technology -* principal, often technical decisions of an overarching (= cross-cutting) nature -* implementation rules - - -.Motivation -Concepts form the basis for _conceptual integrity_ (consistency, homogeneity) of the architecture. -Thus, they are an important contribution to achieve inner qualities of your system. - -Some of these concepts cannot be assigned to individual building blocks, e.g. security or safety. - - -.Form -The form can be varied: - -* concept papers with any kind of structure -* cross-cutting model excerpts or scenarios using notations of the architecture views -* sample implementations, especially for technical concepts -* reference to typical usage of standard frameworks (e.g. using Hibernate for object/relational mapping) - -.Structure -A potential (but not mandatory) structure for this section could be: - -* Domain concepts -* User Experience concepts (UX) -* Safety and security concepts -* Architecture and design patterns -* "Under-the-hood" -* development concepts -* operational concepts - -Note: it might be difficult to assign individual concepts to one specific topic -on this list. - -image::08-Crosscutting-Concepts-Structure-EN.png["Possible topics for crosscutting concepts"] - - -.Further Information - -See https://docs.arc42.org/section-8/[Concepts] in the arc42 documentation. -**** === Domain concepts User Model -- ID (Primary Key) -- First Name -- Last Name -- Email -- Password -- Role + - ID (Primary Key) + - First Name + - Last Name + - Email + - Password === User Experience @@ -84,9 +35,6 @@ Additionally, they can start a new game at any time and, upon completion, view t === Architecture and design patterns In development... -=== Under the hood -In development... - === Development concepts @@ -96,9 +44,6 @@ In development... * Configurability - - - === Operation concepts - + In development... diff --git a/questionsService/obtenerPreguntasBaseDatos.js b/questionsService/obtenerPreguntasBaseDatos.js new file mode 100644 index 00000000..c33ac85d --- /dev/null +++ b/questionsService/obtenerPreguntasBaseDatos.js @@ -0,0 +1,51 @@ +const mongoose = require('mongoose'); +class ObtenerPreguntas{ + + obtenerPregunta(){ + // Connect to MongoDB + const mongoUri = process.env.MONGODB_URI || 'mongodb://localhost:27017/questionsdb'; + mongoose.connect(mongoUri); + + var pregunta; + var respuestaCorrecta; + var respuestaIncorrecta1; + var respuestaIncorrecta2; + var respuestaIncorrecta3; + + Pregunta.aggregate([ + { $sample: { size: 1 } } + ]).then(pregunta => { + var pregunta_id = pregunta._id; + pregunta = pregunta.textoPregunta; + Tipo.findOne({ _id: { $in: pregunta.pregunta_id } }).then(tipo => { + console.log(tipo_id); + respuestaCorrecta = pregunta.respuestaCorrecta; + console.log(respuestaCorrecta); + Respuesta.aggregate([ + { $match: { nombreTipo: tipo._id, texto: { $ne: [respuestaCorrecta, "Ninguna de las anteriores" ]} } }, + { $sample: { size: 3 } } + + ]).then(respuestas => { + console.log(respuestas); + respuestaIncorrecta1 = respuestas[0].textoRespuesta; + respuestaIncorrecta2 = respuestas[1].textoRespuesta; + respuestaIncorrecta3 = respuestas[2].textoRespuesta; + }).catch(err => { + console.error(err); + }); + }) + console.log(pregunta_id); + + }).catch(err => { + console.error(err); + }); + + return resultado = { + pregunta: pregunta.textoPregunta, + correcta: respuestaCorrecta, + respuestasIncorrecta1: respuestaIncorrecta1, + respuestasIncorrecta2: respuestaIncorrecta2, + respuestasIncorrecta3: respuestaIncorrecta3 + }; + } +} \ No newline at end of file