GitLab wurde aktualisiert. Dank regelmäßiger Updates bleibt das THM GitLab sicher und Sie profitieren von den neuesten Funktionen. Vielen Dank für Ihre Geduld.

Commit 6d6974e9 authored by Christopher Mark Fullarton's avatar Christopher Mark Fullarton
Browse files

Improves the freetext answer config parsing to exclude dashes in the given answers

parent f0a0c263
......@@ -277,20 +277,26 @@ export class Leaderboard {
result = refValue === response;
}
if (answerOption.configTrimWhitespaces) {
refValue = refValue.replace(/ /g, '');
response = response.replace(/ /g, '');
refValue = refValue.replace(/[ ]/g, '');
response = response.replace(/[ ]/g, '');
result = refValue === response;
} else {
refValue = refValue.replace(/[-]/g, ' ');
response = response.replace(/[-]/g, ' ');
if (!answerOption.configUsePunctuation) {
refValue = refValue.replace(/[,:\(\)\[\]\.\*\?]/g, '');
response = response.replace(/[,:\(\)\[\]\.\*\?]/g, '');
}
if (!answerOption.configUseKeywords) {
result = refValue.split(' ').filter((elem) => {
return response.indexOf(elem) === -1;
}).length === 0;
const revValueSplitted = refValue.split(/[ ]/);
const revSplitted = response.split(/[ ]/);
if (answerOption.configUseKeywords) {
result = revSplitted.length === revValueSplitted.length &&
revSplitted.every((elem, index) => revValueSplitted[index] === elem);
} else {
result = refValue === response;
result = revSplitted.length === revValueSplitted.length &&
revSplitted.every((elem) => revValueSplitted.includes(elem));
}
}
return result;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment