@vue-skuilder/db 0.2.32 → 0.2.34
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/core/index.js +2 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.mjs +2 -1
- package/dist/core/index.mjs.map +1 -1
- package/dist/impl/couch/index.d.cts +9 -0
- package/dist/impl/couch/index.d.ts +9 -0
- package/dist/impl/couch/index.js +2 -1
- package/dist/impl/couch/index.js.map +1 -1
- package/dist/impl/couch/index.mjs +2 -1
- package/dist/impl/couch/index.mjs.map +1 -1
- package/dist/impl/static/index.js +2 -1
- package/dist/impl/static/index.js.map +1 -1
- package/dist/impl/static/index.mjs +2 -1
- package/dist/impl/static/index.mjs.map +1 -1
- package/dist/index.d.cts +12 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.js +65 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +70 -22
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/courseConfigRegistration.ts +22 -10
- package/src/study/SpacedRepetition.ts +23 -6
- package/src/study/services/EloService.ts +49 -4
package/dist/index.d.cts
CHANGED
|
@@ -6,7 +6,7 @@ import { c as CardHistory, b as CardRecord, Q as QuestionRecord } from './types-
|
|
|
6
6
|
export { C as CardData, g as CourseListData, h as DataShapeData, a as DisplayableData, D as DocType, f as DocTypePrefixes, F as Field, G as GuestUsername, d as QualifiedCardID, i as QuestionData, S as SkuilderCourseData, T as Tag, e as TagStub, l as log } from './types-legacy-BkOYOR6U.cjs';
|
|
7
7
|
import { SrsBacklogDebug, StrategyPressureDebug, Loggable } from './core/index.cjs';
|
|
8
8
|
export { BulkCardProcessorConfig, DIVERSITY_FLOOR, DIVERSITY_STRENGTH, DiversityRerankOptions, GradientObservation, GradientResult, ImportResult, PeriodUpdateInput, PeriodUpdateResult, PressureGaugeDebug, SignalConfig, StrategyLearningState, StrategyStateDoc, StrategyStateId, aggregateOutcomesForGradient, areQuestionRecords, buildStrategyStateId, captureStrategyPressure, clearSrsBacklogDebug, clearStrategyPressureDebug, computeOutcomeSignal, computeStrategyGradient, diversityRerank, docIsDeleted, getCardHistoryID, getDefaultLearnableWeight, getSrsBacklogDebug, getStrategyPressureDebug, importParsedCards, isQuestionRecord, mountUserDBDebugger, parseCardHistoryID, recordUserOutcome, runPeriodUpdate, scoreAccuracyInZone, updateLearningState, updateStrategyWeight, userDBDebugAPI, validateProcessorConfig } from './core/index.cjs';
|
|
9
|
-
import { TaggedPerformance, TagFilter, DataShape, CourseConfig } from '@vue-skuilder/common';
|
|
9
|
+
import { TaggedPerformance, TagFilter, DataShape, SeedMeta, CourseConfig } from '@vue-skuilder/common';
|
|
10
10
|
import { S as StaticCourseManifest } from './types-D0oQeJAi.cjs';
|
|
11
11
|
export { A as AttachmentData, C as ChunkMetadata, D as DesignDocument, I as IndexMetadata, a as PackedCourseData, P as PackerConfig } from './types-D0oQeJAi.cjs';
|
|
12
12
|
import { F as FileSystemAdapter } from './index-Ktg72jKb.cjs';
|
|
@@ -19,7 +19,16 @@ import moment from 'moment';
|
|
|
19
19
|
declare class EloService {
|
|
20
20
|
private dataLayer;
|
|
21
21
|
private user;
|
|
22
|
+
/** Per course ID: its compiled `CourseConfig.qaUsernamePattern`, or null. */
|
|
23
|
+
private qaPatterns;
|
|
22
24
|
constructor(dataLayer: DataLayerProvider, user: UserDBInterface);
|
|
25
|
+
/**
|
|
26
|
+
* Whether the current user is one of the course's QA accounts
|
|
27
|
+
* (`CourseConfig.qaUsernamePattern`), whose responses must not move card
|
|
28
|
+
* ELO. The pattern is read once per course. If the config is unreadable or
|
|
29
|
+
* the pattern doesn't compile, nobody is a QA account.
|
|
30
|
+
*/
|
|
31
|
+
private isQaUser;
|
|
23
32
|
/**
|
|
24
33
|
* Updates both user and card ELO ratings based on user performance.
|
|
25
34
|
* @param userScore Score between 0-1 representing user performance
|
|
@@ -1451,6 +1460,7 @@ interface CustomQuestionsData {
|
|
|
1451
1460
|
name?: string;
|
|
1452
1461
|
}[];
|
|
1453
1462
|
seedData?: unknown[];
|
|
1463
|
+
seedMeta?: (item: unknown) => SeedMeta;
|
|
1454
1464
|
}[];
|
|
1455
1465
|
dataShapes: DataShape[];
|
|
1456
1466
|
views: {
|
|
@@ -1478,6 +1488,7 @@ interface ProcessedQuestionData {
|
|
|
1478
1488
|
name?: string;
|
|
1479
1489
|
}[];
|
|
1480
1490
|
seedData?: unknown[];
|
|
1491
|
+
seedMeta?: (item: unknown) => SeedMeta;
|
|
1481
1492
|
};
|
|
1482
1493
|
dataShapes: DataShape[];
|
|
1483
1494
|
views: {
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { c as CardHistory, b as CardRecord, Q as QuestionRecord } from './types-
|
|
|
6
6
|
export { C as CardData, g as CourseListData, h as DataShapeData, a as DisplayableData, D as DocType, f as DocTypePrefixes, F as Field, G as GuestUsername, d as QualifiedCardID, i as QuestionData, S as SkuilderCourseData, T as Tag, e as TagStub, l as log } from './types-legacy-BkOYOR6U.js';
|
|
7
7
|
import { SrsBacklogDebug, StrategyPressureDebug, Loggable } from './core/index.js';
|
|
8
8
|
export { BulkCardProcessorConfig, DIVERSITY_FLOOR, DIVERSITY_STRENGTH, DiversityRerankOptions, GradientObservation, GradientResult, ImportResult, PeriodUpdateInput, PeriodUpdateResult, PressureGaugeDebug, SignalConfig, StrategyLearningState, StrategyStateDoc, StrategyStateId, aggregateOutcomesForGradient, areQuestionRecords, buildStrategyStateId, captureStrategyPressure, clearSrsBacklogDebug, clearStrategyPressureDebug, computeOutcomeSignal, computeStrategyGradient, diversityRerank, docIsDeleted, getCardHistoryID, getDefaultLearnableWeight, getSrsBacklogDebug, getStrategyPressureDebug, importParsedCards, isQuestionRecord, mountUserDBDebugger, parseCardHistoryID, recordUserOutcome, runPeriodUpdate, scoreAccuracyInZone, updateLearningState, updateStrategyWeight, userDBDebugAPI, validateProcessorConfig } from './core/index.js';
|
|
9
|
-
import { TaggedPerformance, TagFilter, DataShape, CourseConfig } from '@vue-skuilder/common';
|
|
9
|
+
import { TaggedPerformance, TagFilter, DataShape, SeedMeta, CourseConfig } from '@vue-skuilder/common';
|
|
10
10
|
import { S as StaticCourseManifest } from './types-dXWfyz9B.js';
|
|
11
11
|
export { A as AttachmentData, C as ChunkMetadata, D as DesignDocument, I as IndexMetadata, a as PackedCourseData, P as PackerConfig } from './types-dXWfyz9B.js';
|
|
12
12
|
import { F as FileSystemAdapter } from './index-CVGehe_t.js';
|
|
@@ -19,7 +19,16 @@ import moment from 'moment';
|
|
|
19
19
|
declare class EloService {
|
|
20
20
|
private dataLayer;
|
|
21
21
|
private user;
|
|
22
|
+
/** Per course ID: its compiled `CourseConfig.qaUsernamePattern`, or null. */
|
|
23
|
+
private qaPatterns;
|
|
22
24
|
constructor(dataLayer: DataLayerProvider, user: UserDBInterface);
|
|
25
|
+
/**
|
|
26
|
+
* Whether the current user is one of the course's QA accounts
|
|
27
|
+
* (`CourseConfig.qaUsernamePattern`), whose responses must not move card
|
|
28
|
+
* ELO. The pattern is read once per course. If the config is unreadable or
|
|
29
|
+
* the pattern doesn't compile, nobody is a QA account.
|
|
30
|
+
*/
|
|
31
|
+
private isQaUser;
|
|
23
32
|
/**
|
|
24
33
|
* Updates both user and card ELO ratings based on user performance.
|
|
25
34
|
* @param userScore Score between 0-1 representing user performance
|
|
@@ -1451,6 +1460,7 @@ interface CustomQuestionsData {
|
|
|
1451
1460
|
name?: string;
|
|
1452
1461
|
}[];
|
|
1453
1462
|
seedData?: unknown[];
|
|
1463
|
+
seedMeta?: (item: unknown) => SeedMeta;
|
|
1454
1464
|
}[];
|
|
1455
1465
|
dataShapes: DataShape[];
|
|
1456
1466
|
views: {
|
|
@@ -1478,6 +1488,7 @@ interface ProcessedQuestionData {
|
|
|
1478
1488
|
name?: string;
|
|
1479
1489
|
}[];
|
|
1480
1490
|
seedData?: unknown[];
|
|
1491
|
+
seedMeta?: (item: unknown) => SeedMeta;
|
|
1481
1492
|
};
|
|
1482
1493
|
dataShapes: DataShape[];
|
|
1483
1494
|
views: {
|
package/dist/index.js
CHANGED
|
@@ -5539,7 +5539,7 @@ var FRAMEWORK_VERSION, hostAppVersion, DEFAULT_STRATEGY_HASH;
|
|
|
5539
5539
|
var init_versionStamps = __esm({
|
|
5540
5540
|
"src/core/versionStamps.ts"() {
|
|
5541
5541
|
"use strict";
|
|
5542
|
-
FRAMEWORK_VERSION = true ? "0.2.
|
|
5542
|
+
FRAMEWORK_VERSION = true ? "0.2.34" : "dev";
|
|
5543
5543
|
DEFAULT_STRATEGY_HASH = "default";
|
|
5544
5544
|
}
|
|
5545
5545
|
});
|
|
@@ -8121,21 +8121,26 @@ function newQuestionInterval(user, cardHistory) {
|
|
|
8121
8121
|
const interval = lastInterval * (0.75 + skill);
|
|
8122
8122
|
cardHistory.lapses = getLapses(cardHistory.records);
|
|
8123
8123
|
cardHistory.streak = getStreak(cardHistory.records);
|
|
8124
|
+
let ret = interval;
|
|
8124
8125
|
if (cardHistory.lapses && cardHistory.streak && cardHistory.bestInterval && (cardHistory.lapses >= 0 || cardHistory.streak >= 0)) {
|
|
8125
|
-
|
|
8126
|
+
ret = (cardHistory.lapses * interval + cardHistory.streak * cardHistory.bestInterval) / (cardHistory.lapses + cardHistory.streak);
|
|
8126
8127
|
logger.debug(`Weighted average interval calculation:
|
|
8127
8128
|
(${cardHistory.lapses} * ${interval} + ${cardHistory.streak} * ${cardHistory.bestInterval}) / (${cardHistory.lapses} + ${cardHistory.streak}) = ${ret}`);
|
|
8128
|
-
return ret;
|
|
8129
|
-
} else {
|
|
8130
|
-
return interval;
|
|
8131
8129
|
}
|
|
8130
|
+
if (currentAttempt.fluent === false) {
|
|
8131
|
+
logger.debug(
|
|
8132
|
+
`Correct but not fluent: capping interval ${ret}s at ${SLOW_CORRECT_MAX_INTERVAL}s`
|
|
8133
|
+
);
|
|
8134
|
+
return Math.min(ret, SLOW_CORRECT_MAX_INTERVAL);
|
|
8135
|
+
}
|
|
8136
|
+
return ret;
|
|
8132
8137
|
} else {
|
|
8133
8138
|
return 0;
|
|
8134
8139
|
}
|
|
8135
8140
|
}
|
|
8136
8141
|
function lastSuccessfulInterval(cardHistory) {
|
|
8137
8142
|
for (let i = cardHistory.length - 1; i >= 1; i--) {
|
|
8138
|
-
if (cardHistory[i].priorAttemps === 0 && cardHistory[i].isCorrect) {
|
|
8143
|
+
if (cardHistory[i].priorAttemps === 0 && cardHistory[i].isCorrect && cardHistory[i].fluent !== false) {
|
|
8139
8144
|
const lastInterval = secondsBetween(cardHistory[i - 1].timeStamp, cardHistory[i].timeStamp);
|
|
8140
8145
|
const ret = Math.max(lastInterval, 20 * 60 * 60);
|
|
8141
8146
|
logger.debug(`Last interval w/ this card was: ${lastInterval}s, returning ${ret}s`);
|
|
@@ -8166,7 +8171,7 @@ function secondsBetween(start, end) {
|
|
|
8166
8171
|
const ret = duration(end.diff(start)).asSeconds();
|
|
8167
8172
|
return ret;
|
|
8168
8173
|
}
|
|
8169
|
-
var import_moment4, import_common14, duration;
|
|
8174
|
+
var import_moment4, import_common14, duration, SLOW_CORRECT_MAX_INTERVAL;
|
|
8170
8175
|
var init_SpacedRepetition = __esm({
|
|
8171
8176
|
"src/study/SpacedRepetition.ts"() {
|
|
8172
8177
|
"use strict";
|
|
@@ -8175,6 +8180,7 @@ var init_SpacedRepetition = __esm({
|
|
|
8175
8180
|
import_common14 = require("@vue-skuilder/common");
|
|
8176
8181
|
init_logger();
|
|
8177
8182
|
duration = import_moment4.default.duration;
|
|
8183
|
+
SLOW_CORRECT_MAX_INTERVAL = 20 * 60 * 60;
|
|
8178
8184
|
}
|
|
8179
8185
|
});
|
|
8180
8186
|
|
|
@@ -8286,10 +8292,30 @@ var init_EloService = __esm({
|
|
|
8286
8292
|
EloService = class {
|
|
8287
8293
|
dataLayer;
|
|
8288
8294
|
user;
|
|
8295
|
+
/** Per course ID: its compiled `CourseConfig.qaUsernamePattern`, or null. */
|
|
8296
|
+
qaPatterns = /* @__PURE__ */ new Map();
|
|
8289
8297
|
constructor(dataLayer, user) {
|
|
8290
8298
|
this.dataLayer = dataLayer;
|
|
8291
8299
|
this.user = user;
|
|
8292
8300
|
}
|
|
8301
|
+
/**
|
|
8302
|
+
* Whether the current user is one of the course's QA accounts
|
|
8303
|
+
* (`CourseConfig.qaUsernamePattern`), whose responses must not move card
|
|
8304
|
+
* ELO. The pattern is read once per course. If the config is unreadable or
|
|
8305
|
+
* the pattern doesn't compile, nobody is a QA account.
|
|
8306
|
+
*/
|
|
8307
|
+
async isQaUser(courseDB) {
|
|
8308
|
+
const courseId = courseDB.getCourseID();
|
|
8309
|
+
let pattern = this.qaPatterns.get(courseId);
|
|
8310
|
+
if (!pattern) {
|
|
8311
|
+
pattern = courseDB.getCourseConfig().then((cfg) => cfg.qaUsernamePattern ? new RegExp(cfg.qaUsernamePattern, "i") : null).catch((e) => {
|
|
8312
|
+
logger.warn(`[EloService] No QA username pattern for ${courseId}: ${e}`);
|
|
8313
|
+
return null;
|
|
8314
|
+
});
|
|
8315
|
+
this.qaPatterns.set(courseId, pattern);
|
|
8316
|
+
}
|
|
8317
|
+
return (await pattern)?.test(this.user.getUsername()) ?? false;
|
|
8318
|
+
}
|
|
8293
8319
|
/**
|
|
8294
8320
|
* Updates both user and card ELO ratings based on user performance.
|
|
8295
8321
|
* @param userScore Score between 0-1 representing user performance
|
|
@@ -8316,6 +8342,7 @@ var init_EloService = __esm({
|
|
|
8316
8342
|
const userElo = (0, import_common16.toCourseElo)(courseReg.elo);
|
|
8317
8343
|
const cardElo = (await courseDB.getCardEloData([currentCard.card.card_id]))[0];
|
|
8318
8344
|
if (cardElo && userElo) {
|
|
8345
|
+
const writeCard = !await this.isQaUser(courseDB);
|
|
8319
8346
|
const beforeUserGlobal = userElo.global.score;
|
|
8320
8347
|
const beforeCardGlobal = cardElo.global.score;
|
|
8321
8348
|
const cardTagKeys = Object.keys(cardElo.tags);
|
|
@@ -8339,12 +8366,18 @@ var init_EloService = __esm({
|
|
|
8339
8366
|
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
8340
8367
|
userScore,
|
|
8341
8368
|
global: { before: beforeUserGlobal, after: eloUpdate.userElo.global.score },
|
|
8342
|
-
card: {
|
|
8369
|
+
card: {
|
|
8370
|
+
before: beforeCardGlobal,
|
|
8371
|
+
after: writeCard ? eloUpdate.cardElo.global.score : beforeCardGlobal
|
|
8372
|
+
},
|
|
8343
8373
|
...cardTagKeys.length ? { tags } : {}
|
|
8344
8374
|
};
|
|
8375
|
+
if (!writeCard) {
|
|
8376
|
+
logger.info(`[EloService] QA account: card ELO for ${card_id} not written`);
|
|
8377
|
+
}
|
|
8345
8378
|
const results = await Promise.allSettled([
|
|
8346
8379
|
this.user.updateUserElo(course_id, eloUpdate.userElo),
|
|
8347
|
-
courseDB.updateCardElo(card_id, eloUpdate.cardElo)
|
|
8380
|
+
writeCard ? courseDB.updateCardElo(card_id, eloUpdate.cardElo) : Promise.resolve(null)
|
|
8348
8381
|
]);
|
|
8349
8382
|
const userEloStatus = results[0].status === "fulfilled";
|
|
8350
8383
|
const cardEloStatus = results[1].status === "fulfilled";
|
|
@@ -8411,6 +8444,7 @@ var init_EloService = __esm({
|
|
|
8411
8444
|
}
|
|
8412
8445
|
}
|
|
8413
8446
|
if (cardElo && userElo) {
|
|
8447
|
+
const writeCard = !await this.isQaUser(courseDB);
|
|
8414
8448
|
const beforeUserGlobal = userElo.global.score;
|
|
8415
8449
|
const beforeCardGlobal = cardElo.global.score;
|
|
8416
8450
|
const touchedTags = Object.keys(enriched).filter((key) => key !== "_global");
|
|
@@ -8442,12 +8476,18 @@ var init_EloService = __esm({
|
|
|
8442
8476
|
at,
|
|
8443
8477
|
userScore: globalScore,
|
|
8444
8478
|
global: { before: beforeUserGlobal, after: eloUpdate.userElo.global.score },
|
|
8445
|
-
card: {
|
|
8479
|
+
card: {
|
|
8480
|
+
before: beforeCardGlobal,
|
|
8481
|
+
after: writeCard ? eloUpdate.cardElo.global.score : beforeCardGlobal
|
|
8482
|
+
},
|
|
8446
8483
|
...touchedTags.length ? { tags } : {}
|
|
8447
8484
|
};
|
|
8485
|
+
if (!writeCard) {
|
|
8486
|
+
logger.info(`[EloService] QA account: card ELO for ${card_id} not written`);
|
|
8487
|
+
}
|
|
8448
8488
|
const results = await Promise.allSettled([
|
|
8449
8489
|
this.user.updateUserElo(course_id, eloUpdate.userElo),
|
|
8450
|
-
courseDB.updateCardElo(card_id, eloUpdate.cardElo)
|
|
8490
|
+
writeCard ? courseDB.updateCardElo(card_id, eloUpdate.cardElo) : Promise.resolve(null)
|
|
8451
8491
|
]);
|
|
8452
8492
|
const userEloStatus = results[0].status === "fulfilled";
|
|
8453
8493
|
const cardEloStatus = results[1].status === "fulfilled";
|
|
@@ -16792,16 +16832,20 @@ async function registerSeedData(question, courseDB, username) {
|
|
|
16792
16832
|
if (question.questionClass.seedData && Array.isArray(question.questionClass.seedData)) {
|
|
16793
16833
|
logger.info(`Registering seed data for question: ${question.name}`);
|
|
16794
16834
|
try {
|
|
16795
|
-
|
|
16796
|
-
(seedDataItem
|
|
16797
|
-
question.
|
|
16798
|
-
|
|
16799
|
-
|
|
16800
|
-
|
|
16801
|
-
|
|
16802
|
-
|
|
16803
|
-
|
|
16804
|
-
|
|
16835
|
+
if (question.dataShapes.length > 0) {
|
|
16836
|
+
for (const seedDataItem of question.questionClass.seedData) {
|
|
16837
|
+
const meta = question.questionClass.seedMeta?.(seedDataItem) ?? {};
|
|
16838
|
+
await courseDB.addNote(
|
|
16839
|
+
question.course,
|
|
16840
|
+
question.dataShapes[0],
|
|
16841
|
+
seedDataItem,
|
|
16842
|
+
username,
|
|
16843
|
+
meta.tags ?? [],
|
|
16844
|
+
void 0,
|
|
16845
|
+
meta.elo !== void 0 ? (0, import_common28.toCourseElo)(meta.elo) : void 0
|
|
16846
|
+
);
|
|
16847
|
+
}
|
|
16848
|
+
}
|
|
16805
16849
|
logger.info(`Seed data registered for question: ${question.name}`);
|
|
16806
16850
|
} catch (error) {
|
|
16807
16851
|
logger.warn(
|