feat(bisaya): enhance situational response exercises with keyword hints and minimum match requirements
This commit is contained in:
@@ -4593,7 +4593,17 @@ export default class VocabService {
|
||||
const keywords = parsedQuestionData.keywords || parsedAnswerData.keywords || [];
|
||||
if (keywords.length > 0) {
|
||||
const normalizedUser = this._normalizeTextAnswer(userAnswer);
|
||||
return keywords.every((keyword) => normalizedUser.includes(this._normalizeTextAnswer(keyword)));
|
||||
const matches = keywords.filter((keyword) => (
|
||||
normalizedUser.includes(this._normalizeTextAnswer(keyword))
|
||||
)).length;
|
||||
const configuredMinimum = Number(
|
||||
parsedQuestionData.minKeywordMatches ?? parsedAnswerData.minKeywordMatches
|
||||
);
|
||||
const requiredMatches = Number.isInteger(configuredMinimum)
|
||||
&& configuredMinimum > 0
|
||||
? Math.min(configuredMinimum, keywords.length)
|
||||
: keywords.length;
|
||||
return matches >= requiredMatches;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user