Don't validate answer without valid correction template
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
8fd9908d59
commit
140935e15d
@ -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;
|
||||
|
Reference in New Issue
Block a user