@vue-skuilder/common 0.2.29 → 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/course-data.d.ts +3 -0
- package/dist/course-data.d.ts.map +1 -1
- package/dist/course-data.js.map +1 -1
- package/dist/elo.d.ts +4 -0
- package/dist/elo.d.ts.map +1 -1
- package/dist/elo.js +28 -12
- package/dist/elo.js.map +1 -1
- package/dist/elo.mjs +27 -11
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -0
- package/dist/tagRoles.d.ts +12 -0
- package/dist/tagRoles.d.ts.map +1 -0
- package/dist/tagRoles.js +47 -0
- package/dist/tagRoles.js.map +1 -0
- package/dist/tagRoles.mjs +41 -0
- package/package.json +2 -2
- package/src/course-data.ts +3 -0
- package/src/elo.ts +28 -11
- package/src/index.ts +1 -0
- package/src/tagRoles.ts +46 -0
package/dist/course-data.d.ts
CHANGED
|
@@ -34,6 +34,8 @@ export type Performance = number | TaggedPerformance;
|
|
|
34
34
|
* Tags can have scores (for exercise tags) or `null` (for count-only exposure tags).
|
|
35
35
|
* Count-only tags increment their count but maintain a sentinel score of -1,
|
|
36
36
|
* making them easily identifiable and preventing them from polluting real ELO data.
|
|
37
|
+
* Bookkeeping roles (`expose`, `intro`; see tagRoles.ts) are always count-only:
|
|
38
|
+
* a number sent for one is counted, not graded.
|
|
37
39
|
*
|
|
38
40
|
* @example
|
|
39
41
|
* // Spelling "cat" as "kat" - got 'a' and 't' right, but 'c' wrong
|
|
@@ -65,6 +67,7 @@ export interface TaggedPerformance {
|
|
|
65
67
|
*
|
|
66
68
|
* - **Number (0-1)**: Tag is exercised; score updates via ELO formula
|
|
67
69
|
* - **null**: Count-only tag (e.g., exposure); increments count, score stays -1 (sentinel)
|
|
70
|
+
* - Bookkeeping roles (`expose`, `intro`) are count-only whatever is sent
|
|
68
71
|
*
|
|
69
72
|
* Tags not present on the card will be created dynamically.
|
|
70
73
|
* Count-only tags (null) do not update card ELO.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"course-data.d.ts","sourceRoot":"","sources":["../src/course-data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAW,MAAM,SAAS,CAAC;AAEnD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAKtD,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,SAAS,EAGhB,IAAI,EAAE,GAAG,EACT,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EAAE,EACf,OAAO,CAAC,EAAE;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,cAAc,CAAA;CAAE,GACrD,eAAe,CAsFjB;AAED;;GAEG;AAEH,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,WAAW,CAAC;IAEzB;;;;;;;;OAQG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,iBAAiB,CAAC;AAErD
|
|
1
|
+
{"version":3,"file":"course-data.d.ts","sourceRoot":"","sources":["../src/course-data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAW,MAAM,SAAS,CAAC;AAEnD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAKtD,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,SAAS,EAGhB,IAAI,EAAE,GAAG,EACT,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EAAE,EACf,OAAO,CAAC,EAAE;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,cAAc,CAAA;CAAE,GACrD,eAAe,CAsFjB;AAED;;GAEG;AAEH,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,WAAW,CAAC;IAEzB;;;;;;;;OAQG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,iBAAiB,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;;;;;;;OASG;IACH,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,WAAW,GAAG,CAAC,IAAI,iBAAiB,CAE1E"}
|
package/dist/course-data.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"course-data.js","sourceRoot":"","sources":["../src/course-data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,OAAO,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAI7C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,MAAM,UAAU,aAAa,CAC3B,QAAgB,EAChB,UAAkB,EAClB,KAAgB;AAChB,iBAAiB;AACjB,8DAA8D;AAC9D,IAAS,EACT,MAAc,EACd,KAAe,EACf,OAAsD;IAEtD,MAAM,WAAW,GAAG,UAAU,CAAC,kBAAkB,CAAC;QAChD,MAAM,EAAE,UAAU;QAClB,SAAS,EAAE,KAAK,CAAC,IAAI;KACtB,CAAC,CAAC;IAEH,MAAM,gBAAgB,GAAG,KAAK,CAAC,MAAM;SAClC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QACb,uDAAuD;QACvD,MAAM,IAAI,GAAoB;Y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,CAAC,EAAE,CAAC;QAC9E,OAAO,CAAC,YAAY,GAAG,WAAW,CAAC;IACrC,CAAC;IAED,KAAK,CAAC,MAAM;SACT,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;QAChB,OAAO,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,KAAK,CAAC;IAC1E,CAAC,CAAC;SACD,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;QACjB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;YAChB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;SACvB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEL,OAAO,OAAO,CAAC;AACjB,CAAC;AA+ED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,CAAc;IAChD,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAI,SAAS,IAAI,CAAC,CAAC;AAC/D,CAAC"}
|
package/dist/elo.d.ts
CHANGED
|
@@ -51,6 +51,8 @@ export type EloRank = {
|
|
|
51
51
|
*/
|
|
52
52
|
export declare function pushTagPresentation(rank: EloRank, entry: TagPresentation, max?: number): EloRank;
|
|
53
53
|
type Eloish = number | EloRank | CourseElo;
|
|
54
|
+
/** Score held by a count-only tag rating: clearly not a real ELO. */
|
|
55
|
+
export declare const COUNT_ONLY_SCORE = -1;
|
|
54
56
|
export declare function blankCourseElo(): CourseElo;
|
|
55
57
|
export declare function EloToNumber(elo: Eloish): number;
|
|
56
58
|
export declare function toElo(elo: number | EloRank): EloRank;
|
|
@@ -80,6 +82,8 @@ export declare function adjustCourseScores(aElo: Eloish, bElo: Eloish, userScore
|
|
|
80
82
|
* Tags can be scored (number 0-1) or count-only (null). Count-only tags are
|
|
81
83
|
* useful for exposure tracking (e.g., gpc:expose:*) where we only care about
|
|
82
84
|
* "how many times has the user seen this?" without measuring performance.
|
|
85
|
+
* Bookkeeping roles (`expose`, `intro`; see tagRoles.ts) are count-only
|
|
86
|
+
* whatever score is sent for them.
|
|
83
87
|
*
|
|
84
88
|
* @param aElo - User's current ELO (will be converted to CourseElo)
|
|
85
89
|
* @param bElo - Card's current ELO (will be converted to CourseElo)
|
package/dist/elo.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"elo.d.ts","sourceRoot":"","sources":["../src/elo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"elo.d.ts","sourceRoot":"","sources":["../src/elo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGrD,qBAAa,SAAS;IACD,CAAC,EAAE,MAAM;gBAAT,CAAC,GAAE,MAAW;IAEjC,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAG3B,UAAU,IAAI,MAAM;IAIpB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM;IAGzC,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM;CAGxE;AAED,MAAM,MAAM,SAAS,GAAG;IACtB,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE;QACJ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;KAC1B,CAAC;IACF,IAAI,EAAE;QACJ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;KAC1B,CAAC;CACH,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,wCAAwC;IACxC,EAAE,EAAE,MAAM,CAAC;IACX,4BAA4B;IAC5B,EAAE,EAAE,OAAO,CAAC;IACZ,iDAAiD;IACjD,IAAI,EAAE,MAAM,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BAAiB,GACnC;IACD,OAAO,EAAE,SAAS,CAAC;IACnB,OAAO,EAAE,SAAS,CAAC;CACpB,CA6DA"}
|
package/dist/elo.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TAG_RECENT_MAX = exports.EloRanker = void 0;
|
|
3
|
+
exports.COUNT_ONLY_SCORE = exports.TAG_RECENT_MAX = exports.EloRanker = void 0;
|
|
4
4
|
exports.pushTagPresentation = pushTagPresentation;
|
|
5
5
|
exports.blankCourseElo = blankCourseElo;
|
|
6
6
|
exports.EloToNumber = EloToNumber;
|
|
@@ -9,6 +9,7 @@ exports.toCourseElo = toCourseElo;
|
|
|
9
9
|
exports.isCourseElo = isCourseElo;
|
|
10
10
|
exports.adjustCourseScores = adjustCourseScores;
|
|
11
11
|
exports.adjustCourseScoresPerTag = adjustCourseScoresPerTag;
|
|
12
|
+
const tagRoles_js_1 = require("./tagRoles.js");
|
|
12
13
|
class EloRanker {
|
|
13
14
|
k;
|
|
14
15
|
constructor(k = 32) {
|
|
@@ -40,6 +41,20 @@ function pushTagPresentation(rank, entry, max = exports.TAG_RECENT_MAX) {
|
|
|
40
41
|
const trimmed = next.length > max ? next.slice(next.length - max) : next;
|
|
41
42
|
return { ...rank, recent: trimmed };
|
|
42
43
|
}
|
|
44
|
+
/** Score held by a count-only tag rating: clearly not a real ELO. */
|
|
45
|
+
exports.COUNT_ONLY_SCORE = -1;
|
|
46
|
+
/**
|
|
47
|
+
* One count-only touch on a learner's tag rating: the count goes up, no ELO
|
|
48
|
+
* moves. A bookkeeping-role tag (see tagRoles.ts) holds the sentinel, having
|
|
49
|
+
* no rating by definition. Any other tag keeps a real score it already has: a
|
|
50
|
+
* course may send null on a graded tag, and that must not erase its rating.
|
|
51
|
+
*/
|
|
52
|
+
function countOnlyTouch(tag, rank) {
|
|
53
|
+
if (!rank)
|
|
54
|
+
return { count: 1, score: exports.COUNT_ONLY_SCORE };
|
|
55
|
+
const score = (0, tagRoles_js_1.isCountOnlyTag)(tag) ? exports.COUNT_ONLY_SCORE : rank.score;
|
|
56
|
+
return { ...rank, count: rank.count + 1, score };
|
|
57
|
+
}
|
|
43
58
|
function blankCourseElo() {
|
|
44
59
|
return {
|
|
45
60
|
global: {
|
|
@@ -129,8 +144,12 @@ function adjustCourseScores(aElo, bElo, userScore, options) {
|
|
|
129
144
|
const userElo = toCourseElo(aElo);
|
|
130
145
|
const cardElo = toCourseElo(bElo);
|
|
131
146
|
if (options == undefined || !options.globalOnly) {
|
|
132
|
-
// grade on each tag present for the card
|
|
147
|
+
// grade on each tag present for the card; bookkeeping roles are only counted
|
|
133
148
|
Object.keys(cardElo.tags).forEach((k) => {
|
|
149
|
+
if ((0, tagRoles_js_1.isCountOnlyTag)(k)) {
|
|
150
|
+
userElo.tags[k] = countOnlyTouch(k, userElo.tags[k]);
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
134
153
|
const userTagElo = userElo.tags[k]
|
|
135
154
|
? userElo.tags[k]
|
|
136
155
|
: {
|
|
@@ -196,6 +215,8 @@ function adjustScores(userElo, cardElo, userScore) {
|
|
|
196
215
|
* Tags can be scored (number 0-1) or count-only (null). Count-only tags are
|
|
197
216
|
* useful for exposure tracking (e.g., gpc:expose:*) where we only care about
|
|
198
217
|
* "how many times has the user seen this?" without measuring performance.
|
|
218
|
+
* Bookkeeping roles (`expose`, `intro`; see tagRoles.ts) are count-only
|
|
219
|
+
* whatever score is sent for them.
|
|
199
220
|
*
|
|
200
221
|
* @param aElo - User's current ELO (will be converted to CourseElo)
|
|
201
222
|
* @param bElo - Card's current ELO (will be converted to CourseElo)
|
|
@@ -231,15 +252,10 @@ function adjustCourseScoresPerTag(aElo, bElo, taggedPerformance) {
|
|
|
231
252
|
for (const [key, tagScore] of Object.entries(taggedPerformance)) {
|
|
232
253
|
if (key === '_global')
|
|
233
254
|
continue;
|
|
234
|
-
// Count-only
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
userElo.tags[key] =
|
|
238
|
-
...userElo.tags[key],
|
|
239
|
-
count: userElo.tags[key].count + 1,
|
|
240
|
-
score: -1, // Sentinel: clearly not a real ELO score
|
|
241
|
-
};
|
|
242
|
-
// Skip card ELO update for count-only tags
|
|
255
|
+
// Count-only: sent as null, or a bookkeeping role (whatever was sent).
|
|
256
|
+
// The count goes up; no ELO moves, the card's included.
|
|
257
|
+
if (tagScore === null || (0, tagRoles_js_1.isCountOnlyTag)(key)) {
|
|
258
|
+
userElo.tags[key] = countOnlyTouch(key, userElo.tags[key]);
|
|
243
259
|
continue;
|
|
244
260
|
}
|
|
245
261
|
if (typeof tagScore !== 'number' || tagScore < 0 || tagScore > 1) {
|
|
@@ -252,7 +268,7 @@ function adjustCourseScoresPerTag(aElo, bElo, taggedPerformance) {
|
|
|
252
268
|
// fictitiously low prior. Preserve accumulated count so exposure-based
|
|
253
269
|
// count-threshold progress is not discarded.
|
|
254
270
|
const existingUserTagElo = userElo.tags[key];
|
|
255
|
-
const userTagElo = (existingUserTagElo && existingUserTagElo.score !==
|
|
271
|
+
const userTagElo = (existingUserTagElo && existingUserTagElo.score !== exports.COUNT_ONLY_SCORE)
|
|
256
272
|
? existingUserTagElo
|
|
257
273
|
: {
|
|
258
274
|
...(existingUserTagElo ?? {}),
|
package/dist/elo.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"elo.js","sourceRoot":"","sources":["../src/elo.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"elo.js","sourceRoot":"","sources":["../src/elo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,MAAM,OAAO,SAAS;IACD;IAAnB,YAAmB,IAAY,EAAE;QAAd,MAAC,GAAD,CAAC,CAAa;IAAG,CAAC;IAErC,UAAU,CAAC,CAAS;QAClB,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;IACb,CAAC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OAAO,CAAC,MAAM,CAAC,KAAK;aAC5B,CAAC;QAEN,uEAAuE;QACvE,MAAM,UAAU,GAAY,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI;YAC/C,KAAK,EAAE,CAAC;YACR,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,KAAK;SAC5B,CAAC;QAEF,sBAAsB;QACtB,MAAM,QAAQ,GAAG,YAAY,CAAC,UAAU,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;QAChE,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC;QACrC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC;IACvC,CAAC;IAED,mCAAmC;IACnC,MAAM,cAAc,GAAG,YAAY,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACjF,OAAO,CAAC,MAAM,GAAG,cAAc,CAAC,OAAO,CAAC;IACxC,OAAO,CAAC,MAAM,GAAG,cAAc,CAAC,OAAO,CAAC;IAExC,OAAO;QACL,OAAO;QACP,OAAO;KACR,CAAC;AACJ,CAAC"}
|
package/dist/elo.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isCountOnlyTag } from './tagRoles.mjs';
|
|
1
2
|
export class EloRanker {
|
|
2
3
|
k;
|
|
3
4
|
constructor(k = 32) {
|
|
@@ -28,6 +29,20 @@ export function pushTagPresentation(rank, entry, max = TAG_RECENT_MAX) {
|
|
|
28
29
|
const trimmed = next.length > max ? next.slice(next.length - max) : next;
|
|
29
30
|
return { ...rank, recent: trimmed };
|
|
30
31
|
}
|
|
32
|
+
/** Score held by a count-only tag rating: clearly not a real ELO. */
|
|
33
|
+
export const COUNT_ONLY_SCORE = -1;
|
|
34
|
+
/**
|
|
35
|
+
* One count-only touch on a learner's tag rating: the count goes up, no ELO
|
|
36
|
+
* moves. A bookkeeping-role tag (see tagRoles.ts) holds the sentinel, having
|
|
37
|
+
* no rating by definition. Any other tag keeps a real score it already has: a
|
|
38
|
+
* course may send null on a graded tag, and that must not erase its rating.
|
|
39
|
+
*/
|
|
40
|
+
function countOnlyTouch(tag, rank) {
|
|
41
|
+
if (!rank)
|
|
42
|
+
return { count: 1, score: COUNT_ONLY_SCORE };
|
|
43
|
+
const score = isCountOnlyTag(tag) ? COUNT_ONLY_SCORE : rank.score;
|
|
44
|
+
return { ...rank, count: rank.count + 1, score };
|
|
45
|
+
}
|
|
31
46
|
export function blankCourseElo() {
|
|
32
47
|
return {
|
|
33
48
|
global: {
|
|
@@ -117,8 +132,12 @@ export function adjustCourseScores(aElo, bElo, userScore, options) {
|
|
|
117
132
|
const userElo = toCourseElo(aElo);
|
|
118
133
|
const cardElo = toCourseElo(bElo);
|
|
119
134
|
if (options == undefined || !options.globalOnly) {
|
|
120
|
-
// grade on each tag present for the card
|
|
135
|
+
// grade on each tag present for the card; bookkeeping roles are only counted
|
|
121
136
|
Object.keys(cardElo.tags).forEach((k) => {
|
|
137
|
+
if (isCountOnlyTag(k)) {
|
|
138
|
+
userElo.tags[k] = countOnlyTouch(k, userElo.tags[k]);
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
122
141
|
const userTagElo = userElo.tags[k]
|
|
123
142
|
? userElo.tags[k]
|
|
124
143
|
: {
|
|
@@ -184,6 +203,8 @@ function adjustScores(userElo, cardElo, userScore) {
|
|
|
184
203
|
* Tags can be scored (number 0-1) or count-only (null). Count-only tags are
|
|
185
204
|
* useful for exposure tracking (e.g., gpc:expose:*) where we only care about
|
|
186
205
|
* "how many times has the user seen this?" without measuring performance.
|
|
206
|
+
* Bookkeeping roles (`expose`, `intro`; see tagRoles.ts) are count-only
|
|
207
|
+
* whatever score is sent for them.
|
|
187
208
|
*
|
|
188
209
|
* @param aElo - User's current ELO (will be converted to CourseElo)
|
|
189
210
|
* @param bElo - Card's current ELO (will be converted to CourseElo)
|
|
@@ -219,15 +240,10 @@ export function adjustCourseScoresPerTag(aElo, bElo, taggedPerformance) {
|
|
|
219
240
|
for (const [key, tagScore] of Object.entries(taggedPerformance)) {
|
|
220
241
|
if (key === '_global')
|
|
221
242
|
continue;
|
|
222
|
-
// Count-only
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
userElo.tags[key] =
|
|
226
|
-
...userElo.tags[key],
|
|
227
|
-
count: userElo.tags[key].count + 1,
|
|
228
|
-
score: -1, // Sentinel: clearly not a real ELO score
|
|
229
|
-
};
|
|
230
|
-
// Skip card ELO update for count-only tags
|
|
243
|
+
// Count-only: sent as null, or a bookkeeping role (whatever was sent).
|
|
244
|
+
// The count goes up; no ELO moves, the card's included.
|
|
245
|
+
if (tagScore === null || isCountOnlyTag(key)) {
|
|
246
|
+
userElo.tags[key] = countOnlyTouch(key, userElo.tags[key]);
|
|
231
247
|
continue;
|
|
232
248
|
}
|
|
233
249
|
if (typeof tagScore !== 'number' || tagScore < 0 || tagScore > 1) {
|
|
@@ -240,7 +256,7 @@ export function adjustCourseScoresPerTag(aElo, bElo, taggedPerformance) {
|
|
|
240
256
|
// fictitiously low prior. Preserve accumulated count so exposure-based
|
|
241
257
|
// count-threshold progress is not discarded.
|
|
242
258
|
const existingUserTagElo = userElo.tags[key];
|
|
243
|
-
const userTagElo = (existingUserTagElo && existingUserTagElo.score !==
|
|
259
|
+
const userTagElo = (existingUserTagElo && existingUserTagElo.score !== COUNT_ONLY_SCORE)
|
|
244
260
|
? existingUserTagElo
|
|
245
261
|
: {
|
|
246
262
|
...(existingUserTagElo ?? {}),
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAE5B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AAGtC,cAAc,uBAAuB,CAAC;AAGtC,cAAc,kBAAkB,CAAC;AAGjC,cAAc,6BAA6B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAE5B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AAGtC,cAAc,uBAAuB,CAAC;AAGtC,cAAc,kBAAkB,CAAC;AAGjC,cAAc,6BAA6B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./wire-format.js"), exports);
|
|
18
18
|
__exportStar(require("./course-data.js"), exports);
|
|
19
19
|
__exportStar(require("./elo.js"), exports);
|
|
20
|
+
__exportStar(require("./tagRoles.js"), exports);
|
|
20
21
|
__exportStar(require("./namespacer.js"), exports);
|
|
21
22
|
__exportStar(require("./logshim.js"), exports);
|
|
22
23
|
__exportStar(require("./validators.js"), exports);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAE5B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AAEtC,aAAa;AACb,cAAc,uBAAuB,CAAC;AAEtC,QAAQ;AACR,cAAc,kBAAkB,CAAC;AAEjC,UAAU;AACV,cAAc,6BAA6B,CAAC;AAE5C,yFAAyF;AACzF,oFAAoF"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAE5B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AAEtC,aAAa;AACb,cAAc,uBAAuB,CAAC;AAEtC,QAAQ;AACR,cAAc,kBAAkB,CAAC;AAEjC,UAAU;AACV,cAAc,6BAA6B,CAAC;AAE5C,yFAAyF;AACzF,oFAAoF"}
|
package/dist/index.mjs
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const TAG_ROLES: readonly ["intro", "exercise", "expose"];
|
|
2
|
+
export type TagRole = (typeof TAG_ROLES)[number];
|
|
3
|
+
/** The tag's role, or null if it has none. */
|
|
4
|
+
export declare function tagRole(tag: string): TagRole | null;
|
|
5
|
+
/** Whether the tag is bookkeeping (`intro` or `expose`): counted, never graded. */
|
|
6
|
+
export declare function isCountOnlyTag(tag: string): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* The same tag with its role swapped, e.g. `gpc:intro:x` → `gpc:expose:x`.
|
|
9
|
+
* Null if the tag has no role.
|
|
10
|
+
*/
|
|
11
|
+
export declare function withTagRole(tag: string, role: TagRole): string | null;
|
|
12
|
+
//# sourceMappingURL=tagRoles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tagRoles.d.ts","sourceRoot":"","sources":["../src/tagRoles.ts"],"names":[],"mappings":"AAkBA,eAAO,MAAM,SAAS,0CAA2C,CAAC;AAElE,MAAM,MAAM,OAAO,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC;AAIjD,8CAA8C;AAC9C,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,CAGnD;AAED,mFAAmF;AACnF,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAGnD;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAKrE"}
|
package/dist/tagRoles.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ============================================================================
|
|
3
|
+
// TAG ROLES
|
|
4
|
+
// ============================================================================
|
|
5
|
+
//
|
|
6
|
+
// A framework convention for what a tag records about a learner. The role is
|
|
7
|
+
// a colon-delimited segment with more after it: `expose:x`, or namespaced,
|
|
8
|
+
// `gpc:expose:x`. The leftmost role segment wins.
|
|
9
|
+
//
|
|
10
|
+
// - `exercise`: a graded skill. Responses move its ELO.
|
|
11
|
+
// - `expose`: bookkeeping. The learner was shown it, but not tested on it.
|
|
12
|
+
// - `intro`: bookkeeping. The learner was introduced to it.
|
|
13
|
+
//
|
|
14
|
+
// Bookkeeping roles are count-only: a response increments the learner's count
|
|
15
|
+
// on the tag and never moves an ELO, the learner's or the card's, whatever
|
|
16
|
+
// score a question sends. Tags without a role are graded.
|
|
17
|
+
//
|
|
18
|
+
// ============================================================================
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.TAG_ROLES = void 0;
|
|
21
|
+
exports.tagRole = tagRole;
|
|
22
|
+
exports.isCountOnlyTag = isCountOnlyTag;
|
|
23
|
+
exports.withTagRole = withTagRole;
|
|
24
|
+
exports.TAG_ROLES = ['intro', 'exercise', 'expose'];
|
|
25
|
+
const ROLE_SEGMENT = /(^|:)(intro|exercise|expose):(?=.)/;
|
|
26
|
+
/** The tag's role, or null if it has none. */
|
|
27
|
+
function tagRole(tag) {
|
|
28
|
+
const match = ROLE_SEGMENT.exec(tag);
|
|
29
|
+
return match ? match[2] : null;
|
|
30
|
+
}
|
|
31
|
+
/** Whether the tag is bookkeeping (`intro` or `expose`): counted, never graded. */
|
|
32
|
+
function isCountOnlyTag(tag) {
|
|
33
|
+
const role = tagRole(tag);
|
|
34
|
+
return role === 'intro' || role === 'expose';
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The same tag with its role swapped, e.g. `gpc:intro:x` → `gpc:expose:x`.
|
|
38
|
+
* Null if the tag has no role.
|
|
39
|
+
*/
|
|
40
|
+
function withTagRole(tag, role) {
|
|
41
|
+
const match = ROLE_SEGMENT.exec(tag);
|
|
42
|
+
if (!match)
|
|
43
|
+
return null;
|
|
44
|
+
const start = match.index + match[1].length;
|
|
45
|
+
return tag.slice(0, start) + role + tag.slice(start + match[2].length);
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=tagRoles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tagRoles.js","sourceRoot":"","sources":["../src/tagRoles.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,YAAY;AACZ,+EAA+E;AAC/E,EAAE;AACF,6EAA6E;AAC7E,2EAA2E;AAC3E,kDAAkD;AAClD,EAAE;AACF,wDAAwD;AACxD,2EAA2E;AAC3E,4DAA4D;AAC5D,EAAE;AACF,8EAA8E;AAC9E,2EAA2E;AAC3E,0DAA0D;AAC1D,EAAE;AACF,+EAA+E;AAE/E,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,OAAO,EAAE,UAAU,EAAE,QAAQ,CAAU,CAAC;AAIlE,MAAM,YAAY,GAAG,oCAAoC,CAAC;AAE1D,8CAA8C;AAC9C,MAAM,UAAU,OAAO,CAAC,GAAW;IACjC,MAAM,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACrC,OAAO,KAAK,CAAC,CAAC,CAAE,KAAK,CAAC,CAAC,CAAa,CAAC,CAAC,CAAC,IAAI,CAAC;AAC9C,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,cAAc,CAAC,GAAW;IACxC,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAC1B,OAAO,IAAI,KAAK,OAAO,IAAI,IAAI,KAAK,QAAQ,CAAC;AAC/C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,GAAW,EAAE,IAAa;IACpD,MAAM,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACrC,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACxB,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IAC5C,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,GAAG,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AACzE,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// TAG ROLES
|
|
3
|
+
// ============================================================================
|
|
4
|
+
//
|
|
5
|
+
// A framework convention for what a tag records about a learner. The role is
|
|
6
|
+
// a colon-delimited segment with more after it: `expose:x`, or namespaced,
|
|
7
|
+
// `gpc:expose:x`. The leftmost role segment wins.
|
|
8
|
+
//
|
|
9
|
+
// - `exercise`: a graded skill. Responses move its ELO.
|
|
10
|
+
// - `expose`: bookkeeping. The learner was shown it, but not tested on it.
|
|
11
|
+
// - `intro`: bookkeeping. The learner was introduced to it.
|
|
12
|
+
//
|
|
13
|
+
// Bookkeeping roles are count-only: a response increments the learner's count
|
|
14
|
+
// on the tag and never moves an ELO, the learner's or the card's, whatever
|
|
15
|
+
// score a question sends. Tags without a role are graded.
|
|
16
|
+
//
|
|
17
|
+
// ============================================================================
|
|
18
|
+
export const TAG_ROLES = ['intro', 'exercise', 'expose'];
|
|
19
|
+
const ROLE_SEGMENT = /(^|:)(intro|exercise|expose):(?=.)/;
|
|
20
|
+
/** The tag's role, or null if it has none. */
|
|
21
|
+
export function tagRole(tag) {
|
|
22
|
+
const match = ROLE_SEGMENT.exec(tag);
|
|
23
|
+
return match ? match[2] : null;
|
|
24
|
+
}
|
|
25
|
+
/** Whether the tag is bookkeeping (`intro` or `expose`): counted, never graded. */
|
|
26
|
+
export function isCountOnlyTag(tag) {
|
|
27
|
+
const role = tagRole(tag);
|
|
28
|
+
return role === 'intro' || role === 'expose';
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The same tag with its role swapped, e.g. `gpc:intro:x` → `gpc:expose:x`.
|
|
32
|
+
* Null if the tag has no role.
|
|
33
|
+
*/
|
|
34
|
+
export function withTagRole(tag, role) {
|
|
35
|
+
const match = ROLE_SEGMENT.exec(tag);
|
|
36
|
+
if (!match)
|
|
37
|
+
return null;
|
|
38
|
+
const start = match.index + match[1].length;
|
|
39
|
+
return tag.slice(0, start) + role + tag.slice(start + match[2].length);
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=tagRoles.js.map
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.2.
|
|
6
|
+
"version": "0.2.31",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "dist/index.js",
|
|
9
9
|
"module": "dist/index.mjs",
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"zod": "^3.23.8",
|
|
37
37
|
"zod-to-json-schema": "^3.23.5"
|
|
38
38
|
},
|
|
39
|
-
"stableVersion": "0.2.
|
|
39
|
+
"stableVersion": "0.2.31"
|
|
40
40
|
}
|
package/src/course-data.ts
CHANGED
|
@@ -138,6 +138,8 @@ export type Performance = number | TaggedPerformance;
|
|
|
138
138
|
* Tags can have scores (for exercise tags) or `null` (for count-only exposure tags).
|
|
139
139
|
* Count-only tags increment their count but maintain a sentinel score of -1,
|
|
140
140
|
* making them easily identifiable and preventing them from polluting real ELO data.
|
|
141
|
+
* Bookkeeping roles (`expose`, `intro`; see tagRoles.ts) are always count-only:
|
|
142
|
+
* a number sent for one is counted, not graded.
|
|
141
143
|
*
|
|
142
144
|
* @example
|
|
143
145
|
* // Spelling "cat" as "kat" - got 'a' and 't' right, but 'c' wrong
|
|
@@ -170,6 +172,7 @@ export interface TaggedPerformance {
|
|
|
170
172
|
*
|
|
171
173
|
* - **Number (0-1)**: Tag is exercised; score updates via ELO formula
|
|
172
174
|
* - **null**: Count-only tag (e.g., exposure); increments count, score stays -1 (sentinel)
|
|
175
|
+
* - Bookkeeping roles (`expose`, `intro`) are count-only whatever is sent
|
|
173
176
|
*
|
|
174
177
|
* Tags not present on the card will be created dynamically.
|
|
175
178
|
* Count-only tags (null) do not update card ELO.
|
package/src/elo.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { TaggedPerformance } from './course-data.js';
|
|
2
|
+
import { isCountOnlyTag } from './tagRoles.js';
|
|
2
3
|
|
|
3
4
|
export class EloRanker {
|
|
4
5
|
constructor(public k: number = 32) {}
|
|
@@ -77,6 +78,21 @@ export function pushTagPresentation(
|
|
|
77
78
|
|
|
78
79
|
type Eloish = number | EloRank | CourseElo;
|
|
79
80
|
|
|
81
|
+
/** Score held by a count-only tag rating: clearly not a real ELO. */
|
|
82
|
+
export const COUNT_ONLY_SCORE = -1;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* One count-only touch on a learner's tag rating: the count goes up, no ELO
|
|
86
|
+
* moves. A bookkeeping-role tag (see tagRoles.ts) holds the sentinel, having
|
|
87
|
+
* no rating by definition. Any other tag keeps a real score it already has: a
|
|
88
|
+
* course may send null on a graded tag, and that must not erase its rating.
|
|
89
|
+
*/
|
|
90
|
+
function countOnlyTouch(tag: string, rank: EloRank | undefined): EloRank {
|
|
91
|
+
if (!rank) return { count: 1, score: COUNT_ONLY_SCORE };
|
|
92
|
+
const score = isCountOnlyTag(tag) ? COUNT_ONLY_SCORE : rank.score;
|
|
93
|
+
return { ...rank, count: rank.count + 1, score };
|
|
94
|
+
}
|
|
95
|
+
|
|
80
96
|
export function blankCourseElo(): CourseElo {
|
|
81
97
|
return {
|
|
82
98
|
global: {
|
|
@@ -177,8 +193,12 @@ export function adjustCourseScores(
|
|
|
177
193
|
const cardElo: CourseElo = toCourseElo(bElo);
|
|
178
194
|
|
|
179
195
|
if (options == undefined || !options.globalOnly) {
|
|
180
|
-
// grade on each tag present for the card
|
|
196
|
+
// grade on each tag present for the card; bookkeeping roles are only counted
|
|
181
197
|
Object.keys(cardElo.tags).forEach((k) => {
|
|
198
|
+
if (isCountOnlyTag(k)) {
|
|
199
|
+
userElo.tags[k] = countOnlyTouch(k, userElo.tags[k]);
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
182
202
|
const userTagElo: EloRank = userElo.tags[k]
|
|
183
203
|
? userElo.tags[k]
|
|
184
204
|
: {
|
|
@@ -260,6 +280,8 @@ function adjustScores(
|
|
|
260
280
|
* Tags can be scored (number 0-1) or count-only (null). Count-only tags are
|
|
261
281
|
* useful for exposure tracking (e.g., gpc:expose:*) where we only care about
|
|
262
282
|
* "how many times has the user seen this?" without measuring performance.
|
|
283
|
+
* Bookkeeping roles (`expose`, `intro`; see tagRoles.ts) are count-only
|
|
284
|
+
* whatever score is sent for them.
|
|
263
285
|
*
|
|
264
286
|
* @param aElo - User's current ELO (will be converted to CourseElo)
|
|
265
287
|
* @param bElo - Card's current ELO (will be converted to CourseElo)
|
|
@@ -305,15 +327,10 @@ export function adjustCourseScoresPerTag(
|
|
|
305
327
|
for (const [key, tagScore] of Object.entries(taggedPerformance)) {
|
|
306
328
|
if (key === '_global') continue;
|
|
307
329
|
|
|
308
|
-
// Count-only
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
userElo.tags[key] =
|
|
312
|
-
...userElo.tags[key],
|
|
313
|
-
count: userElo.tags[key].count + 1,
|
|
314
|
-
score: -1, // Sentinel: clearly not a real ELO score
|
|
315
|
-
};
|
|
316
|
-
// Skip card ELO update for count-only tags
|
|
330
|
+
// Count-only: sent as null, or a bookkeeping role (whatever was sent).
|
|
331
|
+
// The count goes up; no ELO moves, the card's included.
|
|
332
|
+
if (tagScore === null || isCountOnlyTag(key)) {
|
|
333
|
+
userElo.tags[key] = countOnlyTouch(key, userElo.tags[key]);
|
|
317
334
|
continue;
|
|
318
335
|
}
|
|
319
336
|
|
|
@@ -328,7 +345,7 @@ export function adjustCourseScoresPerTag(
|
|
|
328
345
|
// fictitiously low prior. Preserve accumulated count so exposure-based
|
|
329
346
|
// count-threshold progress is not discarded.
|
|
330
347
|
const existingUserTagElo = userElo.tags[key];
|
|
331
|
-
const userTagElo: EloRank = (existingUserTagElo && existingUserTagElo.score !==
|
|
348
|
+
const userTagElo: EloRank = (existingUserTagElo && existingUserTagElo.score !== COUNT_ONLY_SCORE)
|
|
332
349
|
? existingUserTagElo
|
|
333
350
|
: {
|
|
334
351
|
...(existingUserTagElo ?? {}),
|
package/src/index.ts
CHANGED
package/src/tagRoles.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// TAG ROLES
|
|
3
|
+
// ============================================================================
|
|
4
|
+
//
|
|
5
|
+
// A framework convention for what a tag records about a learner. The role is
|
|
6
|
+
// a colon-delimited segment with more after it: `expose:x`, or namespaced,
|
|
7
|
+
// `gpc:expose:x`. The leftmost role segment wins.
|
|
8
|
+
//
|
|
9
|
+
// - `exercise`: a graded skill. Responses move its ELO.
|
|
10
|
+
// - `expose`: bookkeeping. The learner was shown it, but not tested on it.
|
|
11
|
+
// - `intro`: bookkeeping. The learner was introduced to it.
|
|
12
|
+
//
|
|
13
|
+
// Bookkeeping roles are count-only: a response increments the learner's count
|
|
14
|
+
// on the tag and never moves an ELO, the learner's or the card's, whatever
|
|
15
|
+
// score a question sends. Tags without a role are graded.
|
|
16
|
+
//
|
|
17
|
+
// ============================================================================
|
|
18
|
+
|
|
19
|
+
export const TAG_ROLES = ['intro', 'exercise', 'expose'] as const;
|
|
20
|
+
|
|
21
|
+
export type TagRole = (typeof TAG_ROLES)[number];
|
|
22
|
+
|
|
23
|
+
const ROLE_SEGMENT = /(^|:)(intro|exercise|expose):(?=.)/;
|
|
24
|
+
|
|
25
|
+
/** The tag's role, or null if it has none. */
|
|
26
|
+
export function tagRole(tag: string): TagRole | null {
|
|
27
|
+
const match = ROLE_SEGMENT.exec(tag);
|
|
28
|
+
return match ? (match[2] as TagRole) : null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Whether the tag is bookkeeping (`intro` or `expose`): counted, never graded. */
|
|
32
|
+
export function isCountOnlyTag(tag: string): boolean {
|
|
33
|
+
const role = tagRole(tag);
|
|
34
|
+
return role === 'intro' || role === 'expose';
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The same tag with its role swapped, e.g. `gpc:intro:x` → `gpc:expose:x`.
|
|
39
|
+
* Null if the tag has no role.
|
|
40
|
+
*/
|
|
41
|
+
export function withTagRole(tag: string, role: TagRole): string | null {
|
|
42
|
+
const match = ROLE_SEGMENT.exec(tag);
|
|
43
|
+
if (!match) return null;
|
|
44
|
+
const start = match.index + match[1].length;
|
|
45
|
+
return tag.slice(0, start) + role + tag.slice(start + match[2].length);
|
|
46
|
+
}
|