feat(VocabPracticeDialog): improve SRS handling for incorrect answers
All checks were successful
Deploy to production / deploy (push) Successful in 2m8s

- Introduced logic to reinsert incorrectly answered items into the SRS queue, allowing them to be reviewed again before the session ends.
- Added a constant for the reinsert offset to control the position of requeued items.
- Updated session management to ensure incorrect answers are not marked as completed, enhancing the learning experience.
This commit is contained in:
Torsten Schulz (local)
2026-05-07 08:46:33 +02:00
parent ab3e8d14e5
commit cfab56f63d

View File

@@ -160,6 +160,7 @@ import apiClient from '@/utils/axios.js';
const PRACTICE_MIN_EXPOSURES = 3;
const SRS_SESSION_STORAGE_VERSION = 2;
const HARD_REQUIRED_CONSECUTIVE_CORRECT = 5;
const SRS_AGAIN_REINSERT_OFFSET = 3;
export default {
name: 'VocabPracticeDialog',
@@ -1063,18 +1064,33 @@ export default {
this.locked = true;
await this.reportSrsReview(this.lastCorrect, rating);
// Mark current due item as completed for this session and persist.
const id = this.current?.id;
const treatAsAgain = rating === 'again' || !this.lastCorrect;
if (id && this.srsSession) {
const done = Array.isArray(this.srsSession.doneIds) ? this.srsSession.doneIds : [];
if (!done.includes(id)) {
done.push(id);
this.srsSession.doneIds = done;
}
if (Array.isArray(this.srsQueueIds) && this.srsQueueIds[0] === id) {
this.srsQueueIds = this.srsQueueIds.slice(1);
} else if (Array.isArray(this.srsQueueIds)) {
this.srsQueueIds = this.srsQueueIds.filter((x) => x !== id);
if (treatAsAgain) {
// Wrong answers are not done yet: requeue near the end so the user
// sees them again before the session finishes.
if (Array.isArray(this.srsQueueIds)) {
const remaining = this.srsQueueIds.filter((x) => x !== id);
const insertAt = Math.min(remaining.length, SRS_AGAIN_REINSERT_OFFSET);
remaining.splice(insertAt, 0, id);
this.srsQueueIds = remaining;
}
if (Array.isArray(this.srsSession.doneIds)) {
this.srsSession.doneIds = this.srsSession.doneIds.filter((x) => x !== id);
}
} else {
const done = Array.isArray(this.srsSession.doneIds) ? this.srsSession.doneIds : [];
if (!done.includes(id)) {
done.push(id);
this.srsSession.doneIds = done;
}
if (Array.isArray(this.srsQueueIds) && this.srsQueueIds[0] === id) {
this.srsQueueIds = this.srsQueueIds.slice(1);
} else if (Array.isArray(this.srsQueueIds)) {
this.srsQueueIds = this.srsQueueIds.filter((x) => x !== id);
}
}
this.saveSrsSession();
}