@vue-skuilder/db 0.2.23 → 0.2.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{contentSource-DT9NaX69.d.cts → contentSource-CrRnbjBx.d.cts} +63 -2
- package/dist/{contentSource-BvOpKUeU.d.ts → contentSource-kD35o65m.d.ts} +63 -2
- package/dist/core/index.d.cts +3 -3
- package/dist/core/index.d.ts +3 -3
- package/dist/core/index.js +2474 -481
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.mjs +2464 -466
- package/dist/core/index.mjs.map +1 -1
- package/dist/{dataLayerProvider-CY2B2lyW.d.ts → dataLayerProvider-CtzddVdy.d.ts} +1 -1
- package/dist/{dataLayerProvider-wY6s_4x9.d.cts → dataLayerProvider-IecbidDO.d.cts} +1 -1
- package/dist/impl/couch/index.d.cts +2 -2
- package/dist/impl/couch/index.d.ts +2 -2
- package/dist/impl/couch/index.js +2237 -238
- package/dist/impl/couch/index.js.map +1 -1
- package/dist/impl/couch/index.mjs +2231 -227
- package/dist/impl/couch/index.mjs.map +1 -1
- package/dist/impl/static/index.d.cts +2 -2
- package/dist/impl/static/index.d.ts +2 -2
- package/dist/impl/static/index.js +2319 -320
- package/dist/impl/static/index.js.map +1 -1
- package/dist/impl/static/index.mjs +2309 -305
- package/dist/impl/static/index.mjs.map +1 -1
- package/dist/index.d.cts +32 -7
- package/dist/index.d.ts +32 -7
- package/dist/index.js +8194 -7868
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8059 -7734
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/core/types/studySession.ts +42 -0
- package/src/impl/common/BaseUserDB.ts +13 -4
- package/src/study/SessionController.ts +24 -1
- package/src/study/SpacedRepetition.ts +11 -2
- package/src/study/services/EloService.ts +97 -5
- package/src/study/services/ResponseProcessor.ts +79 -27
- package/src/study/services/tagRecent.test.ts +101 -0
- package/src/study/services/tagRecent.ts +70 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CourseElo,
|
|
3
|
+
EloRank,
|
|
4
|
+
TaggedPerformance,
|
|
5
|
+
TagPresentation,
|
|
6
|
+
pushTagPresentation,
|
|
7
|
+
} from '@vue-skuilder/common';
|
|
8
|
+
import { CardRecord } from '@db/core';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Mastery signal: per-tag ring buffer of recent presentations.
|
|
12
|
+
*
|
|
13
|
+
* Written on the same path as the per-tag ELO update, one entry per
|
|
14
|
+
* *presentation* of a card. Retries within a presentation (a record with
|
|
15
|
+
* `priorAttemps > 0`, or any record after the first on the current card)
|
|
16
|
+
* are not evidence and add nothing — including the "dismiss-failed" final
|
|
17
|
+
* penalty, which reaches the ELO path on a retry record.
|
|
18
|
+
*
|
|
19
|
+
* Only tags the question actually graded (numeric perf) get an entry;
|
|
20
|
+
* count-only exposure tags (`null`) carry no correctness signal.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/** The record for the presentation being graded, or null if none is visible. */
|
|
24
|
+
function currentRecord(records: readonly CardRecord[]): CardRecord | null {
|
|
25
|
+
return records.length ? records[records.length - 1] : null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Whether the record under grading is the first attempt of its presentation.
|
|
30
|
+
*
|
|
31
|
+
* `priorAttemps` is the authoritative marker (written by the question view).
|
|
32
|
+
* When it is absent (non-question records, or a caller that did not push the
|
|
33
|
+
* record onto `currentCard.records`), fall back to the presentation's record
|
|
34
|
+
* count. With no record visible at all we cannot tell, and say no.
|
|
35
|
+
*/
|
|
36
|
+
export function isFirstAttempt(records: readonly CardRecord[]): boolean {
|
|
37
|
+
const rec = currentRecord(records);
|
|
38
|
+
if (!rec) return false;
|
|
39
|
+
const prior = (rec as { priorAttemps?: unknown }).priorAttemps;
|
|
40
|
+
if (typeof prior === 'number') return prior === 0;
|
|
41
|
+
return records.length === 1;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Append a presentation entry to every scored tag in `perf`, mutating
|
|
46
|
+
* `userElo.tags[tag]` in place (each rank object is replaced, not mutated).
|
|
47
|
+
* No-op for retries. Returns the tags that received an entry.
|
|
48
|
+
*/
|
|
49
|
+
export function recordTagPresentations(
|
|
50
|
+
userElo: CourseElo,
|
|
51
|
+
perf: TaggedPerformance,
|
|
52
|
+
records: readonly CardRecord[],
|
|
53
|
+
cardId: string,
|
|
54
|
+
at: string
|
|
55
|
+
): string[] {
|
|
56
|
+
if (!isFirstAttempt(records)) return [];
|
|
57
|
+
const rec = currentRecord(records) as { isCorrect?: unknown } | null;
|
|
58
|
+
const ok = rec?.isCorrect === true;
|
|
59
|
+
|
|
60
|
+
const written: string[] = [];
|
|
61
|
+
for (const [tag, score] of Object.entries(perf)) {
|
|
62
|
+
if (tag === '_global') continue;
|
|
63
|
+
if (typeof score !== 'number') continue; // count-only exposure tag
|
|
64
|
+
const rank: EloRank = userElo.tags[tag] ?? { score: userElo.global.score, count: 0 };
|
|
65
|
+
const entry: TagPresentation = { at, ok, perf: score, card: cardId };
|
|
66
|
+
userElo.tags[tag] = pushTagPresentation(rank, entry);
|
|
67
|
+
written.push(tag);
|
|
68
|
+
}
|
|
69
|
+
return written;
|
|
70
|
+
}
|