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