Don't validate answer without valid correction template
continuous-integration/drone/push Build is passing Details

This commit is contained in:
nemunaire 2022-11-16 09:37:15 +01:00
parent 8fd9908d59
commit 140935e15d
1 changed files with 8 additions and 0 deletions

View File

@ -38,17 +38,25 @@
export async function applyCorrections() {
for (const r of filteredResponses) {
const my_correction = { };
let has_no_lost_answer = false;
let completed_correction = false;
for (const tpl of templates) {
if (tpl.score >= 0) has_no_lost_answer = true;
if (!tpl.regexp && tpl.label) continue;
if (tpl.regexp && (tpl.regexp[0] == '!' && !r.value.match(tpl.regexp.substring(1))) || r.value.match(tpl.regexp)) {
my_correction[tpl.id] = true;
completed_correction = true;
} else {
my_correction[tpl.id] = false;
}
}
// If no valid correction template AND valid answer is defined,
// don't consider the absence of match as valid answer.
if (!completed_correction && has_no_lost_answer) continue;
const auto = await autoCorrection(r.id_user, my_correction);
r.score = auto.score;
r.score_explaination = auto.score_explaination;