feat(VocabPracticeDialog): implement immediate retry feature for incorrect answers
All checks were successful
Deploy to production / deploy (push) Successful in 1m47s

- Added a `pendingRetry` property to manage immediate retries after incorrect answers, enhancing user experience during vocabulary practice.
- Updated logic to handle retries, allowing users to quickly attempt the last question again with the correct direction.
- Ensured that the retry state is reset appropriately after correct answers or when skipping questions, maintaining clarity in the training flow.
This commit is contained in:
Torsten Schulz (local)
2026-04-20 10:02:32 +02:00
parent 1500f01875
commit 8ce15441bf

View File

@@ -178,6 +178,7 @@ export default {
// current question // current question
current: null, // { id, learning, reference } current: null, // { id, learning, reference }
direction: 'L2R', // L2R: learning->reference, R2L: reference->learning direction: 'L2R', // L2R: learning->reference, R2L: reference->learning
pendingRetry: null, // { id, direction } for immediate retry after wrong answers
acceptableAnswers: [], acceptableAnswers: [],
submittedAnswer: '', submittedAnswer: '',
lastWrongReview: null, lastWrongReview: null,
@@ -378,6 +379,7 @@ export default {
this.perId = {}; this.perId = {};
this.lastIds = []; this.lastIds = [];
this.lastWrongReview = null; this.lastWrongReview = null;
this.pendingRetry = null;
this.pool = []; this.pool = [];
this.locked = false; this.locked = false;
this.resetQuestion(); this.resetQuestion();
@@ -659,6 +661,13 @@ export default {
if (!nextId) return null; if (!nextId) return null;
return items.find((it) => it.id === nextId) || null; return items.find((it) => it.id === nextId) || null;
} }
if (this.pendingRetry?.id) {
const retryItem = items.find((it) => it.id === this.pendingRetry.id);
if (retryItem) {
return retryItem;
}
this.pendingRetry = null;
}
const recent = new Set(this.lastIds); const recent = new Set(this.lastIds);
const underexposed = items const underexposed = items
.map((item) => { .map((item) => {
@@ -749,6 +758,7 @@ export default {
if (isCorrect) { if (isCorrect) {
this.correctCount += 1; this.correctCount += 1;
this.lastWrongReview = null; this.lastWrongReview = null;
this.pendingRetry = null;
} else { } else {
this.wrongCount += 1; this.wrongCount += 1;
const answers = this.visibleCorrectAnswers.length > 0 const answers = this.visibleCorrectAnswers.length > 0
@@ -759,6 +769,12 @@ export default {
submittedAnswer: this.submittedAnswer, submittedAnswer: this.submittedAnswer,
answers answers
}; };
if (!this.srsMode && this.current?.id) {
this.pendingRetry = {
id: this.current.id,
direction: this.direction
};
}
} }
if (!this.srsMode) { if (!this.srsMode) {
this.reportSrsReview(isCorrect); this.reportSrsReview(isCorrect);
@@ -836,6 +852,7 @@ export default {
} }
}, },
skip() { skip() {
this.pendingRetry = null;
this.next(); this.next();
}, },
next() { next() {
@@ -851,7 +868,11 @@ export default {
this.resetQuestion(); this.resetQuestion();
return; return;
} }
const retryDirection = this.pendingRetry?.direction || null;
this.resetQuestion(); this.resetQuestion();
if (retryDirection) {
this.direction = retryDirection;
}
this.current = this.pickNextItem(); this.current = this.pickNextItem();
if (!this.current) return; if (!this.current) return;
const prompt = this.currentPrompt; const prompt = this.currentPrompt;