feat(backend): Rendering van meerkeuzevragen en open vragen (essay) toegevoegd + getest

This commit is contained in:
Gerald Schmittinger 2025-03-11 02:00:27 +01:00
parent 164a547dd1
commit bc0ac63c92
20 changed files with 126 additions and 16 deletions

View file

@ -36,18 +36,22 @@ class GiftProcessor extends StringProcessor {
override renderFn(giftString: string) {
const quizQuestions: GIFTQuestion[] = parse(giftString);
let html = "<div class='gift'>";
let html = "<div class='learning-object-gift'>\n";
let i = 1;
for (let question of quizQuestions) {
html += this.renderQuestion(question);
html += ` <div class='gift-question' id='gift-q${i}'>\n`;
html += " " + this.renderQuestion(question, i).replaceAll(/\n(.+)/g, "\n $1"); // replace for indentation.
html += ` </div>\n`;
i++;
}
html += "</div>"
html += "</div>\n"
return DOMPurify.sanitize(html);
}
private renderQuestion<T extends GIFTQuestion>(question: T): string {
private renderQuestion<T extends GIFTQuestion>(question: T, questionNumber: number): string {
const renderer = this.renderers[question.type] as GIFTQuestionRenderer<T>;
return renderer.render(question);
return renderer.render(question, questionNumber);
}
}