Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

ADR 12 (Question Templates)

Manueluz edited this page Apr 2, 2024 · 3 revisions

ADR 12 (Question Templates)

Decision

We will use a template-driven design when generating the questions from WikiData, the templates will be stored and retrieved from a MongoDB database so that they can be hot-swapped without reloading or recompiling the application.

The format of the templates will be the following:

{
    "question": "Cuál es el país de esta bandera",
    "selector": "<countryLabel>",
    "tags": ["country", "image"],
    "lang": "es",
    "query": "SELECT ?countryLabel ?flagLabel ?flag WHERE { ?country wdt:P31 wd:Q6256. ?country wdt:P41 ?flag. SERVICE wikibase:label { bd:serviceParam wikibase:language \"[AUTO_LANGUAGE],es\". } }",
    "imageurl": "<flag>"
}

Where imageurl is an optional parameter and all of the others are required. In question selector and imageurl you can use the <parameter> operator to extract data from the provided query (The parameter must mach one of the SELECT ?parameter values)

Status

Accepted.

Consequences

Designing questions has become way easier than before, also the questions are more consistent an less error prone. This also opens the door to make a system that allows users to submit their own templates to the template database.

During the implementation of this ADR, we also realized that the implementation of a tag system to identify the questions became trivial.

Risks

We are creating additional complexity when adding the template processor, also if we go the route of user submitted templates there is a risk to code injection.