diff --git a/frontend/src/dialogues/socialnetwork/VocabPracticeDialog.vue b/frontend/src/dialogues/socialnetwork/VocabPracticeDialog.vue index 853fc9a..d229a60 100644 --- a/frontend/src/dialogues/socialnetwork/VocabPracticeDialog.vue +++ b/frontend/src/dialogues/socialnetwork/VocabPracticeDialog.vue @@ -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(); }