@vue-skuilder/db 0.2.30 → 0.2.31
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-CqJmbOZN.d.ts → contentSource-DMduBjDC.d.ts} +19 -4
- package/dist/{contentSource-B6FrSihy.d.cts → contentSource-Doh1aVBJ.d.cts} +19 -4
- package/dist/core/index.d.cts +3 -3
- package/dist/core/index.d.ts +3 -3
- package/dist/core/index.js +88 -76
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.mjs +40 -27
- package/dist/core/index.mjs.map +1 -1
- package/dist/{dataLayerProvider-DUxDqMtZ.d.cts → dataLayerProvider-BW1CBAbb.d.cts} +1 -1
- package/dist/{dataLayerProvider-B9_UCvkR.d.ts → dataLayerProvider-Cxfe4nSK.d.ts} +1 -1
- package/dist/diagnostics/index.d.cts +18 -3
- package/dist/diagnostics/index.d.ts +18 -3
- package/dist/diagnostics/index.js +159 -135
- package/dist/diagnostics/index.js.map +1 -1
- package/dist/diagnostics/index.mjs +156 -135
- package/dist/diagnostics/index.mjs.map +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 +92 -80
- package/dist/impl/couch/index.js.map +1 -1
- package/dist/impl/couch/index.mjs +40 -27
- 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 +79 -67
- package/dist/impl/static/index.js.map +1 -1
- package/dist/impl/static/index.mjs +40 -27
- package/dist/impl/static/index.mjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +141 -110
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +65 -33
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/core/navigators/PipelineDebugger.ts +42 -23
- package/src/core/navigators/filters/eloDistance.ts +7 -8
- package/src/core/navigators/generators/elo.ts +8 -2
- package/src/core/navigators/generators/prescribed.ts +7 -5
- package/src/core/types/studySession.ts +12 -1
- package/src/diagnostics/derive.ts +5 -2
- package/src/diagnostics/pipeline.ts +28 -0
- package/src/diagnostics/text.ts +11 -4
- package/src/study/SessionController.ts +3 -1
- package/src/study/services/EloService.ts +33 -6
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.2.
|
|
7
|
+
"version": "0.2.31",
|
|
8
8
|
"description": "Database layer for vue-skuilder",
|
|
9
9
|
"main": "dist/index.js",
|
|
10
10
|
"module": "dist/index.mjs",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
62
|
"@nilock2/pouchdb-authentication": "^1.0.2",
|
|
63
|
-
"@vue-skuilder/common": "0.2.
|
|
63
|
+
"@vue-skuilder/common": "0.2.31",
|
|
64
64
|
"cross-fetch": "^4.1.0",
|
|
65
65
|
"moment": "^2.29.4",
|
|
66
66
|
"pouchdb": "^9.0.0",
|
|
@@ -75,5 +75,5 @@
|
|
|
75
75
|
"vite": "^8.0.0",
|
|
76
76
|
"vitest": "^4.1.0"
|
|
77
77
|
},
|
|
78
|
-
"stableVersion": "0.2.
|
|
78
|
+
"stableVersion": "0.2.31"
|
|
79
79
|
}
|
|
@@ -82,8 +82,12 @@ export interface FilterImpact {
|
|
|
82
82
|
export interface RunReportCard {
|
|
83
83
|
cardId: string;
|
|
84
84
|
courseId: string;
|
|
85
|
-
|
|
85
|
+
/** `'review'`: a scheduled review. `'new'`: anything else. */
|
|
86
|
+
origin: 'new' | 'review';
|
|
87
|
+
/** The strategy that produced the card (first provenance entry). Absent if a hint injected it. */
|
|
86
88
|
generator?: string;
|
|
89
|
+
/** The hint that made the card mandatory, if one did. Its source, over `generator`. */
|
|
90
|
+
required?: string;
|
|
87
91
|
finalScore: number;
|
|
88
92
|
/** Card's ELO (parsed from ELO generator provenance, if available) */
|
|
89
93
|
cardElo?: number;
|
|
@@ -140,7 +144,7 @@ export interface PipelineRunReport {
|
|
|
140
144
|
/**
|
|
141
145
|
* The two unselected non-review cards most worth explaining when a run
|
|
142
146
|
* picks no new content. Non-review means no `reviewID`, so prescribed and
|
|
143
|
-
* required cards count
|
|
147
|
+
* required cards count.
|
|
144
148
|
*
|
|
145
149
|
* - `nextInLine`: highest final score. How close new content came.
|
|
146
150
|
* - `topGenerated`: highest generator score, zero-scored cards included.
|
|
@@ -240,17 +244,24 @@ export function clearRunHistory(): void {
|
|
|
240
244
|
}
|
|
241
245
|
|
|
242
246
|
/**
|
|
243
|
-
*
|
|
247
|
+
* What a card is to the learner's queue: a scheduled review (it carries a
|
|
248
|
+
* `reviewID`) or new. The same test as the generator counts and
|
|
249
|
+
* `unselectedNew`. What put it in the queue is {@link RunReportCard.generator}
|
|
250
|
+
* and {@link RunReportCard.required}.
|
|
244
251
|
*/
|
|
245
|
-
function getOrigin(card: WeightedCard): 'new' | 'review'
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
252
|
+
function getOrigin(card: WeightedCard): 'new' | 'review' {
|
|
253
|
+
return card.reviewID ? 'review' : 'new';
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* The hint that made a card mandatory (its provenance name), if one did.
|
|
258
|
+
* applyHints marks a requireCards/requireTags requirement with an infinite
|
|
259
|
+
* score, and nothing else scores a card infinite.
|
|
260
|
+
*/
|
|
261
|
+
function requiredBy(card: WeightedCard): string | undefined {
|
|
262
|
+
return card.provenance.find(
|
|
263
|
+
(p) => p.strategy === 'ephemeralHint' && p.score === Number.POSITIVE_INFINITY
|
|
264
|
+
)?.strategyName;
|
|
254
265
|
}
|
|
255
266
|
|
|
256
267
|
/**
|
|
@@ -309,17 +320,25 @@ export function buildRunReport(
|
|
|
309
320
|
// into selected vs not-selected, then retain only the top-N of the
|
|
310
321
|
// non-selected group to bound memory. The remaining low-score tail is
|
|
311
322
|
// summarized rather than kept (see discardedTail).
|
|
312
|
-
const toReport = (card: WeightedCard): RunReportCard =>
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
generator
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
+
const toReport = (card: WeightedCard): RunReportCard => {
|
|
324
|
+
const required = requiredBy(card);
|
|
325
|
+
// A required card no generator produced starts at its hint: no generator.
|
|
326
|
+
const first = card.provenance[0];
|
|
327
|
+
const generator =
|
|
328
|
+
first && first.strategy !== 'ephemeralHint' ? first.strategyName || first.strategy : undefined;
|
|
329
|
+
return {
|
|
330
|
+
cardId: card.cardId,
|
|
331
|
+
courseId: card.courseId,
|
|
332
|
+
origin: getOrigin(card),
|
|
333
|
+
...(generator ? { generator } : {}),
|
|
334
|
+
...(required ? { required } : {}),
|
|
335
|
+
finalScore: card.score,
|
|
336
|
+
cardElo: card.cardElo ?? parseCardElo(card.provenance),
|
|
337
|
+
provenance: card.provenance,
|
|
338
|
+
tags: card.tags,
|
|
339
|
+
selected: selectedIds.has(card.cardId),
|
|
340
|
+
};
|
|
341
|
+
};
|
|
323
342
|
|
|
324
343
|
const selectedReported: RunReportCard[] = [];
|
|
325
344
|
const nearMissReported: RunReportCard[] = [];
|
|
@@ -5,7 +5,7 @@ import { ContentNavigator } from '../index';
|
|
|
5
5
|
import type { WeightedCard } from '../index';
|
|
6
6
|
import type { GeneratorResult } from '../generators/types';
|
|
7
7
|
import type { CardFilter, FilterContext, FilterKind } from './types';
|
|
8
|
-
import type
|
|
8
|
+
import { COUNT_ONLY_SCORE, isCountOnlyTag, type CourseElo } from '@vue-skuilder/common';
|
|
9
9
|
import { logger } from '../../../util/logger';
|
|
10
10
|
|
|
11
11
|
// ============================================================================
|
|
@@ -99,9 +99,6 @@ export const DEFAULT_ELO_DISTANCE_CONFIG: Required<EloDistanceConfig> = {
|
|
|
99
99
|
*/
|
|
100
100
|
const TAG_CONFIDENCE_HALF = 10;
|
|
101
101
|
|
|
102
|
-
/** Count-only tag ratings (exposure tracking) carry this sentinel score. */
|
|
103
|
-
const COUNT_ONLY_SENTINEL = -1;
|
|
104
|
-
|
|
105
102
|
/** Fallback card ELO when a card has none recorded. */
|
|
106
103
|
const DEFAULT_CARD_ELO = 1000;
|
|
107
104
|
|
|
@@ -186,9 +183,9 @@ interface TagGap {
|
|
|
186
183
|
* read on the tags they share.
|
|
187
184
|
*
|
|
188
185
|
* - Shared tags: the card's tags on which the learner has a real rating
|
|
189
|
-
* (not the count-only sentinel) resting on at least
|
|
190
|
-
* responses. A card with no rating of its own on a tag
|
|
191
|
-
* the ELO update does when it first grades that tag.
|
|
186
|
+
* (not a bookkeeping role, nor the count-only sentinel) resting on at least
|
|
187
|
+
* `minTagCount` graded responses. A card with no rating of its own on a tag
|
|
188
|
+
* uses its global, as the ELO update does when it first grades that tag.
|
|
192
189
|
* - Each tag's gap is weighted by the learner's evidence on it,
|
|
193
190
|
* n / (n + TAG_CONFIDENCE_HALF).
|
|
194
191
|
* - The weighted mean of the tag gaps is blended with the global gap by the
|
|
@@ -232,7 +229,9 @@ export function tagAwareGap(
|
|
|
232
229
|
const tags: TagGap[] = [];
|
|
233
230
|
for (const tag of cardTags) {
|
|
234
231
|
const user = userElo.tags[tag];
|
|
235
|
-
if (!user || user.score ===
|
|
232
|
+
if (isCountOnlyTag(tag) || !user || user.score === COUNT_ONLY_SCORE || user.count < minTagCount) {
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
236
235
|
const card = cardElo.tags[tag]?.score ?? cardElo.global.score;
|
|
237
236
|
tags.push({
|
|
238
237
|
tag,
|
|
@@ -75,12 +75,18 @@ export default class ELONavigator extends ContentNavigator implements CardGenera
|
|
|
75
75
|
}
|
|
76
76
|
// const tUser = performance.now(); // [perf] parked
|
|
77
77
|
|
|
78
|
-
|
|
78
|
+
// Not new: cards with a pending review, and cards seen without one (e.g.
|
|
79
|
+
// `srs:skip` intros, which must not resurface). As the prescribed generator.
|
|
80
|
+
const [activeCards, seenCards] = await Promise.all([
|
|
81
|
+
this.user.getActiveCards(),
|
|
82
|
+
this.user.getSeenCards(this.course.getCourseID()).catch(() => [] as string[]),
|
|
83
|
+
]);
|
|
84
|
+
const notNew = new Set([...activeCards.map((ac) => ac.cardID), ...seenCards]);
|
|
79
85
|
// const tActive = performance.now(); // [perf] parked
|
|
80
86
|
const newCards = (
|
|
81
87
|
await this.course.getCardsCenteredAtELO(
|
|
82
88
|
{ limit, elo: 'user' },
|
|
83
|
-
(c: QualifiedCardID) => !
|
|
89
|
+
(c: QualifiedCardID) => !notNew.has(c.cardID)
|
|
84
90
|
)
|
|
85
91
|
).map((c) => ({ ...c, status: 'new' as const }));
|
|
86
92
|
// const tCentered = performance.now(); // [perf] parked
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { tagRole, withTagRole } from '@vue-skuilder/common';
|
|
1
2
|
import type { CourseDBInterface } from '../../interfaces/courseDB';
|
|
2
3
|
import type { UserDBInterface } from '../../interfaces/userDB';
|
|
3
4
|
import { ContentNavigator } from '../index';
|
|
@@ -234,7 +235,8 @@ function formatAge(ms: number): string {
|
|
|
234
235
|
|
|
235
236
|
/**
|
|
236
237
|
* The exposure tags an intro target still lacks before it may surface: its own
|
|
237
|
-
* `
|
|
238
|
+
* `expose` tags plus the `expose` counterpart of each `intro` tag (tag roles,
|
|
239
|
+
* see common's tagRoles.ts: `gpc:intro:X` → `gpc:expose:X`), each needing
|
|
238
240
|
* `minCount` attempts. A `minCount` of 0 requires nothing — not even an entry
|
|
239
241
|
* in `userTagElo`.
|
|
240
242
|
*/
|
|
@@ -245,11 +247,11 @@ export function unmetIntroExposeTags(
|
|
|
245
247
|
): string[] {
|
|
246
248
|
if (minCount <= 0) return [];
|
|
247
249
|
|
|
248
|
-
const exposeTags = new Set(tags.filter((tag) => tag
|
|
250
|
+
const exposeTags = new Set(tags.filter((tag) => tagRole(tag) === 'expose'));
|
|
249
251
|
for (const tag of tags) {
|
|
250
|
-
if (
|
|
251
|
-
const
|
|
252
|
-
if (
|
|
252
|
+
if (tagRole(tag) !== 'intro') continue;
|
|
253
|
+
const expose = withTagRole(tag, 'expose');
|
|
254
|
+
if (expose) exposeTags.add(expose);
|
|
253
255
|
}
|
|
254
256
|
|
|
255
257
|
return [...exposeTags].filter((tag) => {
|
|
@@ -127,9 +127,20 @@ export interface StudySessionRunSummary {
|
|
|
127
127
|
/** A card as persisted on a run. `origin` is as counted in `newSelected`/`reviewsSelected`. */
|
|
128
128
|
export interface StudySessionRunCard {
|
|
129
129
|
cardId: string;
|
|
130
|
+
/**
|
|
131
|
+
* `'review'`: a scheduled review. `'new'`: anything else. `'unknown'` only on
|
|
132
|
+
* older runs, which counted prescribed and hint-required cards as neither.
|
|
133
|
+
*/
|
|
130
134
|
origin: 'new' | 'review' | 'unknown';
|
|
135
|
+
/**
|
|
136
|
+
* The strategy that produced the card. Absent if a hint injected it (older
|
|
137
|
+
* runs name the hint here instead).
|
|
138
|
+
*/
|
|
131
139
|
generator?: string;
|
|
132
|
-
|
|
140
|
+
/** The hint that made the card mandatory, if one did. Its source, over `generator`. */
|
|
141
|
+
required?: string;
|
|
142
|
+
/** Final score; null for a mandatory (required) card, whose score is infinite. */
|
|
143
|
+
score: number | null;
|
|
133
144
|
selected: boolean;
|
|
134
145
|
}
|
|
135
146
|
|
|
@@ -298,7 +298,10 @@ function toResponseEloDelta(
|
|
|
298
298
|
|
|
299
299
|
/**
|
|
300
300
|
* Attach each ELO event to its response. The event carries no record id, so
|
|
301
|
-
* join by card and nearest time, using each response at most once.
|
|
301
|
+
* join by card and nearest time, using each response at most once. A record
|
|
302
|
+
* is stamped when the card is shown and an event when the answer is
|
|
303
|
+
* submitted, so the join is on the response's end (shown + time spent):
|
|
304
|
+
* joined on the start, a long response's event lands on the next attempt.
|
|
302
305
|
*/
|
|
303
306
|
function attachEloEvents(
|
|
304
307
|
responses: TimelineResponse[],
|
|
@@ -312,7 +315,7 @@ function attachEloEvents(
|
|
|
312
315
|
let bestGap = Infinity;
|
|
313
316
|
responses.forEach((r, i) => {
|
|
314
317
|
if (used.has(i) || r.cardId !== ev.cardId) return;
|
|
315
|
-
const gap = Math.abs(Date.parse(r.at) - evT);
|
|
318
|
+
const gap = Math.abs(Date.parse(r.at) + r.timeSpentMs - evT);
|
|
316
319
|
if (gap < bestGap) {
|
|
317
320
|
bestGap = gap;
|
|
318
321
|
best = i;
|
|
@@ -1,6 +1,34 @@
|
|
|
1
1
|
import type { DatasetRecord, LearnerDataset } from './dataset';
|
|
2
2
|
import type { FilterKind } from '../core/navigators/filters/types';
|
|
3
3
|
import type { RegulatorName, RegulatorReading } from '../core/navigators/regulators';
|
|
4
|
+
import type { StudySessionRunCard, StudySessionRunSummary } from '../core/types/studySession';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* What put a run's card in the queue: the hint that required it, else the
|
|
8
|
+
* generator that produced it. Its `origin` says what it is (review or new).
|
|
9
|
+
*/
|
|
10
|
+
export function runCardSource(card: Pick<StudySessionRunCard, 'generator' | 'required'>): string {
|
|
11
|
+
if (card.required) return `required: ${card.required}`;
|
|
12
|
+
return card.generator ?? 'unknown';
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A run's selected cards counted by source, most first. Empty for runs that
|
|
17
|
+
* don't persist their cards (before 0.2.28).
|
|
18
|
+
*/
|
|
19
|
+
export function selectedBySource(
|
|
20
|
+
run: Pick<StudySessionRunSummary, 'cards'>
|
|
21
|
+
): Array<{ source: string; count: number }> {
|
|
22
|
+
const counts = new Map<string, number>();
|
|
23
|
+
for (const c of run.cards ?? []) {
|
|
24
|
+
if (!c.selected) continue;
|
|
25
|
+
const source = runCardSource(c);
|
|
26
|
+
counts.set(source, (counts.get(source) ?? 0) + 1);
|
|
27
|
+
}
|
|
28
|
+
return [...counts]
|
|
29
|
+
.map(([source, count]) => ({ source, count }))
|
|
30
|
+
.sort((a, b) => b.count - a.count);
|
|
31
|
+
}
|
|
4
32
|
|
|
5
33
|
// ============================================================================
|
|
6
34
|
// Pipeline run stats
|
package/src/diagnostics/text.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { StudySessionRunCardTrail, StudySessionRunSummary } from '../core/types/studySession';
|
|
7
7
|
import type { RegulatorReading } from '../core/navigators/regulators';
|
|
8
|
+
import { runCardSource, selectedBySource } from './pipeline';
|
|
8
9
|
import {
|
|
9
10
|
shortTag,
|
|
10
11
|
type DiagnosticsInterpreters,
|
|
@@ -42,13 +43,15 @@ export function fmtAnswer(a: unknown, max = 40): string {
|
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
|
|
46
|
+
/** Two decimals, or one significant figure when tiny; `∞` for a required card's score (persisted as null). */
|
|
47
|
+
export function fmtScore(n: number | null): string {
|
|
48
|
+
if (n === null || !Number.isFinite(n)) return '∞';
|
|
46
49
|
return Math.abs(n) >= 0.01 || n === 0 ? n.toFixed(2) : n.toExponential(1);
|
|
47
50
|
}
|
|
48
51
|
|
|
49
52
|
function trailText(label: string, t: StudySessionRunCardTrail): string[] {
|
|
50
53
|
const lines = [
|
|
51
|
-
` ${label}: ${t.cardId} (${t.origin}, ${t
|
|
54
|
+
` ${label}: ${t.cardId} (${t.origin}, ${runCardSource(t)}) final ${fmtScore(t.score)}`,
|
|
52
55
|
];
|
|
53
56
|
for (const p of t.trail) {
|
|
54
57
|
lines.push(` ${p.action} ${p.strategyName} → ${fmtScore(p.score)}: ${p.reason}`);
|
|
@@ -106,10 +109,12 @@ export function runText(run: StudySessionRunSummary): string {
|
|
|
106
109
|
}
|
|
107
110
|
if (run.hints) L.push(` hints: ${JSON.stringify(run.hints)}`);
|
|
108
111
|
if (run.cards?.length) {
|
|
112
|
+
const sources = selectedBySource(run).map((s) => `${s.source} ${s.count}`);
|
|
113
|
+
if (sources.length) L.push(` selected by source: ${sources.join(' · ')}`);
|
|
109
114
|
L.push(' selection (✓ selected, · runner-up):');
|
|
110
115
|
for (const c of run.cards) {
|
|
111
116
|
L.push(
|
|
112
|
-
` ${c.selected ? '✓' : '·'} ${c.cardId} (${c.origin}, ${c
|
|
117
|
+
` ${c.selected ? '✓' : '·'} ${c.cardId} (${c.origin}, ${runCardSource(c)}) ${fmtScore(c.score)}`
|
|
113
118
|
);
|
|
114
119
|
}
|
|
115
120
|
}
|
|
@@ -178,7 +183,9 @@ export function sessionText(
|
|
|
178
183
|
L.push(' hints: the ReplanHints the navigator was told (_label = replan reason).');
|
|
179
184
|
L.push(' selection: the chosen cards and top runners-up. "next new in line" / "top-generated');
|
|
180
185
|
L.push(' new (sunk)": the unselected new cards worth explaining, with each score change.');
|
|
181
|
-
L.push('
|
|
186
|
+
L.push(' Each card reads (origin, source). origin: review = a scheduled review, new = anything');
|
|
187
|
+
L.push(' else. source: the generator that produced it, or "required: <hint>" when a hint forced');
|
|
188
|
+
L.push(' it. Older runs show origin "unknown" for prescribed and hint-required cards.');
|
|
182
189
|
L.push('- RESP "✓/✗ type <cardId> [tags] Ts (attempt k) \'answer\'": one presentation and');
|
|
183
190
|
L.push(' its outcome. A trailing "ELO g:before→after (Δ) | tag:Δ …" is the exchange it');
|
|
184
191
|
L.push(' produced. Only first attempts move ELO.');
|
|
@@ -239,7 +239,9 @@ function toRunCard(c: RunReportCard): StudySessionRunCard {
|
|
|
239
239
|
cardId: c.cardId,
|
|
240
240
|
origin: c.origin,
|
|
241
241
|
...(c.generator ? { generator: c.generator } : {}),
|
|
242
|
-
|
|
242
|
+
...(c.required ? { required: c.required } : {}),
|
|
243
|
+
// A required card's score is infinite, which JSON can't hold: say so with null.
|
|
244
|
+
score: Number.isFinite(c.finalScore) ? sig4(c.finalScore) : null,
|
|
243
245
|
selected: c.selected,
|
|
244
246
|
};
|
|
245
247
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
adjustCourseScores,
|
|
3
3
|
adjustCourseScoresPerTag,
|
|
4
|
+
isCountOnlyTag,
|
|
4
5
|
toCourseElo,
|
|
5
6
|
TaggedPerformance,
|
|
6
7
|
} from '@vue-skuilder/common';
|
|
@@ -14,6 +15,28 @@ import { StudySessionRecord } from '../SessionController';
|
|
|
14
15
|
import { logger } from '@db/util/logger';
|
|
15
16
|
import { recordTagPresentations } from './tagRecent';
|
|
16
17
|
|
|
18
|
+
/**
|
|
19
|
+
* The question's performance with bookkeeping-role tags (`expose`, `intro`;
|
|
20
|
+
* see common's tagRoles.ts) as count-only. A score sent for one is counted,
|
|
21
|
+
* not graded, and logged: it's a question-side slip against the convention.
|
|
22
|
+
*/
|
|
23
|
+
function withCountOnlyRoles(perf: TaggedPerformance, cardId: string): TaggedPerformance {
|
|
24
|
+
const out: TaggedPerformance = { ...perf };
|
|
25
|
+
const counted: string[] = [];
|
|
26
|
+
for (const [tag, score] of Object.entries(perf)) {
|
|
27
|
+
if (tag === '_global' || score === null || !isCountOnlyTag(tag)) continue;
|
|
28
|
+
out[tag] = null;
|
|
29
|
+
counted.push(tag);
|
|
30
|
+
}
|
|
31
|
+
if (counted.length) {
|
|
32
|
+
logger.warn(
|
|
33
|
+
`[EloService] ${cardId} sent scores for bookkeeping tags [${counted.join(', ')}]; ` +
|
|
34
|
+
`counted, not graded`
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
return out;
|
|
38
|
+
}
|
|
39
|
+
|
|
17
40
|
/**
|
|
18
41
|
* Service responsible for ELO rating calculations and updates.
|
|
19
42
|
*/
|
|
@@ -77,10 +100,12 @@ export class EloService {
|
|
|
77
100
|
|
|
78
101
|
const tags: NonNullable<SessionEloEvent['tags']> = {};
|
|
79
102
|
for (const tag of cardTagKeys) {
|
|
103
|
+
// Bookkeeping roles are only counted: recorded as count-only, as below.
|
|
104
|
+
const countOnly = isCountOnlyTag(tag);
|
|
80
105
|
tags[tag] = {
|
|
81
106
|
before: beforeUserTag[tag],
|
|
82
|
-
after: eloUpdate.userElo.tags[tag].score,
|
|
83
|
-
score: userScore,
|
|
107
|
+
after: countOnly ? beforeUserTag[tag] : eloUpdate.userElo.tags[tag].score,
|
|
108
|
+
score: countOnly ? null : userScore,
|
|
84
109
|
};
|
|
85
110
|
}
|
|
86
111
|
const event: SessionEloEvent = {
|
|
@@ -174,13 +199,15 @@ export class EloService {
|
|
|
174
199
|
// the question's evaluate(). Category tags (concept:*, ui:*, etc.) are not
|
|
175
200
|
// emitted by individual question types; applying the global score as a proxy
|
|
176
201
|
// keeps hierarchy filter ELO thresholds functional without overriding any
|
|
177
|
-
// fine-grained per-GPC scores the question already provided.
|
|
202
|
+
// fine-grained per-GPC scores the question already provided. Bookkeeping
|
|
203
|
+
// roles (expose, intro) are counted instead, whoever supplies them.
|
|
178
204
|
const cardTags = cardTagsMap.get(card_id) ?? [];
|
|
179
|
-
const
|
|
205
|
+
const graded = withCountOnlyRoles(taggedPerformance, card_id);
|
|
206
|
+
const enriched: TaggedPerformance = { ...graded };
|
|
180
207
|
const globalScore = taggedPerformance._global;
|
|
181
208
|
for (const tag of cardTags) {
|
|
182
209
|
if (!(tag in enriched)) {
|
|
183
|
-
enriched[tag] = globalScore;
|
|
210
|
+
enriched[tag] = isCountOnlyTag(tag) ? null : globalScore;
|
|
184
211
|
}
|
|
185
212
|
}
|
|
186
213
|
|
|
@@ -207,7 +234,7 @@ export class EloService {
|
|
|
207
234
|
// enriched with the global score above.
|
|
208
235
|
const recorded = recordTagPresentations(
|
|
209
236
|
eloUpdate.userElo,
|
|
210
|
-
|
|
237
|
+
graded,
|
|
211
238
|
currentCard.records,
|
|
212
239
|
card_id,
|
|
213
240
|
at
|