fix(srs): retain scheduled cards after course updates

This commit is contained in:
Torsten Schulz (local)
2026-08-31 12:48:33 +02:00
parent 7ad83f4299
commit 0119048c82

View File

@@ -2060,22 +2060,19 @@ export default class VocabService {
['stage', 'ASC']
]
});
const validPool = await this.getCompletedLessonVocabPool(hashedUserId, course.id);
const validPairs = new Set(
(Array.isArray(validPool?.vocabs) ? validPool.vocabs : [])
.map((entry) => this._buildSrsPairFingerprint(entry))
.filter(Boolean)
);
// Do not require a scheduled card to be present verbatim in today's
// regenerated lesson pool. Course content can be corrected after a card
// has been scheduled; comparing against the regenerated pool then hid all
// legitimate older SRS cards. `_isTrainableSrsPair` above remains the
// content-level guard for malformed fragments, hints and task prompts.
const validDueRows = scheduledRows.filter((item) =>
this._isTrainableSrsPair(item)
&& (!validPairs.size || validPairs.has(this._buildSrsPairFingerprint(item)))
&& this._getSrsScheduleDateKey(item.nextDueAt) <= todayKey
);
const upcomingByDate = new Map();
scheduledRows
.filter((item) => (
this._isTrainableSrsPair(item)
&& (!validPairs.size || validPairs.has(this._buildSrsPairFingerprint(item)))
&& this._getSrsScheduleDateKey(item.nextDueAt) > todayKey
))
.forEach((item) => {