I created several SQL queries that generate an exercise. The queries all generate the necessary data which is needed to properly render it in de frontend.

The above (sub)query returns the amount of correct letters that need to be displayed in the exercise

The above (sub)query returns an array of all correct letters that need to be rendered, this also include duplicate letters.

Combining the two sub-queries and added logic to generate the incorrect letters, we get this somewhat complex query. The result: an array which contains correct and incorrect letters.
The above query should generate data which can be used to render the following exercise component.
