feat(vocab): improve answer matching by accepting both displayed solutions and individual variants
This commit is contained in:
@@ -4360,7 +4360,13 @@ export default {
|
||||
}
|
||||
});
|
||||
|
||||
const phraseAlternatives = Array.from(variants).flatMap((entry) => this.splitPhraseAlternatives(entry));
|
||||
// Keep the original text as an acceptable variant as well. In multiple
|
||||
// choice, an option such as "A / B" can be displayed verbatim; splitting
|
||||
// it into A and B must not make that displayed option invalid.
|
||||
const phraseAlternatives = Array.from(variants).flatMap((entry) => [
|
||||
entry,
|
||||
...this.splitPhraseAlternatives(entry)
|
||||
]);
|
||||
if (phraseAlternatives.length >= 2) {
|
||||
const expanded = phraseAlternatives.flatMap((part) => this.expandSingleAnswerVariants(part));
|
||||
return [...new Set(expanded)];
|
||||
@@ -4402,7 +4408,14 @@ export default {
|
||||
|
||||
// Treat parenthetical notes as optional for answer matching.
|
||||
const normalizedUser = this.normalizeVocab(userAnswer);
|
||||
const rawAnswers = this.currentVocabQuestion.answers || [this.currentVocabQuestion.answer];
|
||||
// `answer` is what we display as the correct solution. It may combine
|
||||
// valid alternatives (for example "A / B"), while `answers` contains
|
||||
// the individual variants. Accept both, so a displayed solution can
|
||||
// never be rejected when entered verbatim.
|
||||
const rawAnswers = [
|
||||
...(Array.isArray(this.currentVocabQuestion.answers) ? this.currentVocabQuestion.answers : []),
|
||||
this.currentVocabQuestion.answer
|
||||
].filter(Boolean);
|
||||
// Expand alternatives like "A / B" into separate acceptable answers
|
||||
const expandedAnswers = rawAnswers.flatMap(a => this.expandAnswerVariants(a));
|
||||
const normalizedCorrectAnswers = expandedAnswers
|
||||
|
||||
Reference in New Issue
Block a user