@vue-skuilder/db 0.3.4 → 0.3.5
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "../_virtual/_rolldown/runtime.mjs";
|
|
2
2
|
//#region src/core/versionStamps.ts
|
|
3
3
|
/** This build's @vue-skuilder/db version, set at build time; `'dev'` when run from source. */
|
|
4
|
-
const FRAMEWORK_VERSION = "0.3.
|
|
4
|
+
const FRAMEWORK_VERSION = "0.3.5";
|
|
5
5
|
let hostAppVersion;
|
|
6
6
|
/** Record the host app's version (the data layer's `appVersion` option). */
|
|
7
7
|
function setAppVersion(version) {
|
package/dist/index.cjs
CHANGED
|
@@ -3773,7 +3773,7 @@ var FRAMEWORK_VERSION, hostAppVersion, DEFAULT_STRATEGY_HASH;
|
|
|
3773
3773
|
var init_versionStamps = __esm({
|
|
3774
3774
|
"src/core/versionStamps.ts"() {
|
|
3775
3775
|
"use strict";
|
|
3776
|
-
FRAMEWORK_VERSION = true ? "0.3.
|
|
3776
|
+
FRAMEWORK_VERSION = true ? "0.3.5" : "dev";
|
|
3777
3777
|
DEFAULT_STRATEGY_HASH = "default";
|
|
3778
3778
|
}
|
|
3779
3779
|
});
|
package/package.json
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"publishConfig": {
|
|
14
14
|
"access": "public"
|
|
15
15
|
},
|
|
16
|
-
"version": "0.3.
|
|
16
|
+
"version": "0.3.5",
|
|
17
17
|
"description": "Database layer for vue-skuilder",
|
|
18
18
|
"main": "dist/index.cjs",
|
|
19
19
|
"module": "dist/index.mjs",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
71
|
"@nilock2/pouchdb-authentication": "^1.0.2",
|
|
72
|
-
"@vue-skuilder/common": "0.3.
|
|
72
|
+
"@vue-skuilder/common": "0.3.5",
|
|
73
73
|
"cross-fetch": "^4.1.0",
|
|
74
74
|
"moment": "^2.29.4",
|
|
75
75
|
"pouchdb": "^9.0.0",
|
|
@@ -87,5 +87,5 @@
|
|
|
87
87
|
"vite": "^8.0.0",
|
|
88
88
|
"vitest": "^4.1.0"
|
|
89
89
|
},
|
|
90
|
-
"stableVersion": "0.3.
|
|
90
|
+
"stableVersion": "0.3.5"
|
|
91
91
|
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import {
|
|
3
|
+
adjustCourseScores,
|
|
4
|
+
adjustCourseScoresPerTag,
|
|
5
|
+
eloActual,
|
|
6
|
+
CourseElo,
|
|
7
|
+
} from '@vue-skuilder/common';
|
|
8
|
+
|
|
9
|
+
const expectedFor = (user: number, card: number) => 1 / (1 + Math.pow(10, (card - user) / 400));
|
|
10
|
+
|
|
11
|
+
function course(score: number, count = 50, tags: Record<string, number> = {}): CourseElo {
|
|
12
|
+
return {
|
|
13
|
+
global: { score, count },
|
|
14
|
+
tags: Object.fromEntries(Object.entries(tags).map(([k, v]) => [k, { score: v, count }])),
|
|
15
|
+
misc: {},
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
describe('ELO never flips the sign of a result', () => {
|
|
20
|
+
const gaps = [-600, -300, -100, 0, 100, 241, 300, 500, 800];
|
|
21
|
+
const scores = [0.05, 0.4, 0.5, 0.8, 0.9, 1];
|
|
22
|
+
|
|
23
|
+
it('a positive score never lowers the learner or raises the card', () => {
|
|
24
|
+
for (const gap of gaps) {
|
|
25
|
+
for (const s of scores) {
|
|
26
|
+
const before = course(1400, 50, { 'gpc:exercise:a-AE': 1400 });
|
|
27
|
+
const card = course(1400 - gap, 50, { 'gpc:exercise:a-AE': 1400 - gap });
|
|
28
|
+
const out = adjustCourseScoresPerTag(
|
|
29
|
+
structuredClone(before),
|
|
30
|
+
structuredClone(card),
|
|
31
|
+
{ _global: s, 'gpc:exercise:a-AE': s }
|
|
32
|
+
);
|
|
33
|
+
expect(out.userElo.global.score).toBeGreaterThanOrEqual(1400);
|
|
34
|
+
expect(out.userElo.tags['gpc:exercise:a-AE'].score).toBeGreaterThanOrEqual(1400);
|
|
35
|
+
expect(out.cardElo.global.score).toBeLessThanOrEqual(1400 - gap);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('a miss never raises the learner', () => {
|
|
41
|
+
for (const gap of gaps) {
|
|
42
|
+
const out = adjustCourseScores(course(1400), course(1400 - gap), 0);
|
|
43
|
+
expect(out.userElo.global.score).toBeLessThanOrEqual(1400);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('a faster answer gains at least as much as a slower one', () => {
|
|
48
|
+
for (const gap of gaps) {
|
|
49
|
+
const slow = adjustCourseScores(course(1400), course(1400 - gap), 0.8);
|
|
50
|
+
const fast = adjustCourseScores(course(1400), course(1400 - gap), 1);
|
|
51
|
+
expect(fast.userElo.global.score).toBeGreaterThanOrEqual(slow.userElo.global.score);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('the audit case: a slow correct answer on a card 300 below gains', () => {
|
|
56
|
+
const out = adjustCourseScores(course(1430), course(1130), 0.8);
|
|
57
|
+
expect(out.userElo.global.score).toBeGreaterThan(1430);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
describe('ELO equilibrium', () => {
|
|
62
|
+
// Expected change is zero where p·(actual − exp) + (1 − p)·(0 − exp) = 0,
|
|
63
|
+
// i.e. rating gap = true gap + 400·log10(t). The audit's §2 offset.
|
|
64
|
+
it('settles at the true gap plus 400·log10(t)', () => {
|
|
65
|
+
for (const t of [0.5, 0.8, 1]) {
|
|
66
|
+
for (const trueGap of [-200, 0, 300, 600]) {
|
|
67
|
+
const p = expectedFor(trueGap, 0);
|
|
68
|
+
const gap = trueGap + 400 * Math.log10(t);
|
|
69
|
+
const exp = expectedFor(gap, 0);
|
|
70
|
+
const drift = p * (eloActual(t, exp) - exp) + (1 - p) * (0 - exp);
|
|
71
|
+
expect(Math.abs(drift)).toBeLessThan(1e-9);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
});
|