diff --git a/ui/src/components/CorrectionReference.svelte b/ui/src/components/CorrectionReference.svelte index 83b62fd..f1c51e1 100644 --- a/ui/src/components/CorrectionReference.svelte +++ b/ui/src/components/CorrectionReference.svelte @@ -19,6 +19,35 @@ templates = templates; } + function genTemplates() { + question.getProposals().then((proposals) => { + let i = 0; + for (const p of proposals) { + // Search proposal in templates + let found = false; + for (const tpl of templates) { + if (tpl.regexp.indexOf(p.id.toString()) !== -1) { + found = true; + break; + } + } + + if (!found) { + const ct = new CorrectionTemplate() + ct.id_question = question.id; + ct.regexp = p.id.toString(); + ct.label = String.fromCharCode(97 + i); + ct.save().then((ct) => { + templates.push(ct); + templates = templates; + }); + } + + i++; + } + }) + } + function delTemplate(tpl) { tpl.delete().then(() => { const idx = templates.findIndex((e) => e.id === tpl.id); @@ -109,4 +138,13 @@ > Ajouter un template + {#if question.kind == "mcq" || question.kind == "ucq"} + + {/if}