Erweitere die Funktionalität zur Verarbeitung von Antwortvarianten; füge Unterstützung für Klammerinhalte und alternative Phrasen hinzu.
This commit is contained in:
@@ -4353,14 +4353,31 @@ export default {
|
||||
expandAnswerVariants(answer) {
|
||||
const base = String(answer || '').trim();
|
||||
if (!base) return [];
|
||||
const variants = new Set([base]);
|
||||
|
||||
const phraseAlternatives = this.splitPhraseAlternatives(base);
|
||||
const withoutParentheses = base.replace(/\s*\([^)]*\)\s*/g, ' ').replace(/\s+/g, ' ').trim();
|
||||
if (withoutParentheses) {
|
||||
variants.add(withoutParentheses);
|
||||
}
|
||||
|
||||
const parenMatches = base.match(/\(([^)]+)\)/g) || [];
|
||||
parenMatches.forEach((chunk) => {
|
||||
const content = chunk.replace(/[()]/g, '').trim();
|
||||
if (content) {
|
||||
variants.add(content);
|
||||
}
|
||||
});
|
||||
|
||||
const phraseAlternatives = Array.from(variants).flatMap((entry) => this.splitPhraseAlternatives(entry));
|
||||
if (phraseAlternatives.length >= 2) {
|
||||
const expanded = phraseAlternatives.flatMap((part) => this.expandSingleAnswerVariants(part));
|
||||
return [...new Set(expanded)];
|
||||
}
|
||||
|
||||
return this.expandSingleAnswerVariants(base);
|
||||
return [...new Set(
|
||||
this.expandSingleAnswerVariants(base)
|
||||
.concat(withoutParentheses ? this.expandSingleAnswerVariants(withoutParentheses) : [])
|
||||
)];
|
||||
},
|
||||
reportSrsReviewForCurrentQuestion(isCorrect) {
|
||||
if (!this.currentVocabQuestion?.vocab || !this.courseId) {
|
||||
|
||||
Reference in New Issue
Block a user