@vue-skuilder/db 0.1.17 → 0.1.20
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/{userDB-BqwxtJ_7.d.mts → classroomDB-CZdMBiTU.d.ts} +427 -104
- package/dist/{userDB-DNa0XPtn.d.ts → classroomDB-PxDZTky3.d.cts} +427 -104
- package/dist/core/index.d.cts +304 -0
- package/dist/core/index.d.ts +237 -25
- package/dist/core/index.js +2246 -118
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.mjs +2235 -114
- package/dist/core/index.mjs.map +1 -1
- package/dist/{dataLayerProvider-VlngD19_.d.mts → dataLayerProvider-D0MoZMjH.d.cts} +1 -1
- package/dist/{dataLayerProvider-BV5iZqt_.d.ts → dataLayerProvider-D8o6ZnKW.d.ts} +1 -1
- package/dist/impl/couch/{index.d.mts → index.d.cts} +47 -5
- package/dist/impl/couch/index.d.ts +46 -4
- package/dist/impl/couch/index.js +2250 -134
- package/dist/impl/couch/index.js.map +1 -1
- package/dist/impl/couch/index.mjs +2212 -97
- package/dist/impl/couch/index.mjs.map +1 -1
- package/dist/impl/static/{index.d.mts → index.d.cts} +6 -6
- package/dist/impl/static/index.d.ts +5 -5
- package/dist/impl/static/index.js +1950 -143
- package/dist/impl/static/index.js.map +1 -1
- package/dist/impl/static/index.mjs +1922 -117
- package/dist/impl/static/index.mjs.map +1 -1
- package/dist/{index-Bmll7Xse.d.mts → index-B_j6u5E4.d.cts} +1 -1
- package/dist/{index-CD8BZz2k.d.ts → index-Dj0SEgk3.d.ts} +1 -1
- package/dist/{index.d.mts → index.d.cts} +97 -13
- package/dist/index.d.ts +96 -12
- package/dist/index.js +2439 -180
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2386 -135
- package/dist/index.mjs.map +1 -1
- package/dist/pouch/index.js +3 -3
- package/dist/{types-Dbp5DaRR.d.mts → types-Bn0itutr.d.cts} +1 -1
- package/dist/{types-CewsN87z.d.ts → types-DQaXnuoc.d.ts} +1 -1
- package/dist/{types-legacy-6ettoclI.d.ts → types-legacy-DDY4N-Uq.d.cts} +3 -1
- package/dist/{types-legacy-6ettoclI.d.mts → types-legacy-DDY4N-Uq.d.ts} +3 -1
- package/dist/util/packer/{index.d.mts → index.d.cts} +3 -3
- package/dist/util/packer/index.d.ts +3 -3
- package/dist/util/packer/index.js.map +1 -1
- package/dist/util/packer/index.mjs.map +1 -1
- package/docs/brainstorm-navigation-paradigm.md +369 -0
- package/docs/navigators-architecture.md +370 -0
- package/docs/todo-evolutionary-orchestration.md +310 -0
- package/docs/todo-nominal-tag-types.md +121 -0
- package/docs/todo-strategy-authoring.md +401 -0
- package/eslint.config.mjs +1 -1
- package/package.json +9 -4
- package/src/core/index.ts +1 -0
- package/src/core/interfaces/contentSource.ts +88 -4
- package/src/core/interfaces/courseDB.ts +13 -0
- package/src/core/interfaces/navigationStrategyManager.ts +0 -5
- package/src/core/interfaces/userDB.ts +32 -0
- package/src/core/navigators/CompositeGenerator.ts +268 -0
- package/src/core/navigators/Pipeline.ts +318 -0
- package/src/core/navigators/PipelineAssembler.ts +194 -0
- package/src/core/navigators/elo.ts +104 -15
- package/src/core/navigators/filters/eloDistance.ts +132 -0
- package/src/core/navigators/filters/index.ts +9 -0
- package/src/core/navigators/filters/types.ts +115 -0
- package/src/core/navigators/filters/userTagPreference.ts +232 -0
- package/src/core/navigators/generators/index.ts +2 -0
- package/src/core/navigators/generators/types.ts +107 -0
- package/src/core/navigators/hardcodedOrder.ts +111 -12
- package/src/core/navigators/hierarchyDefinition.ts +266 -0
- package/src/core/navigators/index.ts +404 -3
- package/src/core/navigators/inferredPreference.ts +107 -0
- package/src/core/navigators/interferenceMitigator.ts +355 -0
- package/src/core/navigators/relativePriority.ts +255 -0
- package/src/core/navigators/srs.ts +195 -0
- package/src/core/navigators/userGoal.ts +136 -0
- package/src/core/types/strategyState.ts +84 -0
- package/src/core/types/types-legacy.ts +2 -0
- package/src/impl/common/BaseUserDB.ts +74 -7
- package/src/impl/couch/adminDB.ts +1 -2
- package/src/impl/couch/classroomDB.ts +51 -0
- package/src/impl/couch/courseDB.ts +147 -49
- package/src/impl/static/courseDB.ts +11 -4
- package/src/study/SessionController.ts +149 -1
- package/src/study/TagFilteredContentSource.ts +255 -0
- package/src/study/index.ts +1 -0
- package/src/util/dataDirectory.test.ts +51 -22
- package/src/util/logger.ts +0 -1
- package/tests/core/navigators/CompositeGenerator.test.ts +455 -0
- package/tests/core/navigators/Pipeline.test.ts +406 -0
- package/tests/core/navigators/PipelineAssembler.test.ts +351 -0
- package/tests/core/navigators/SRSNavigator.test.ts +344 -0
- package/tests/core/navigators/eloDistanceFilter.test.ts +192 -0
- package/tests/core/navigators/navigators.test.ts +710 -0
- package/tsconfig.json +1 -1
- package/vitest.config.ts +29 -0
- package/dist/core/index.d.mts +0 -92
- /package/dist/{SyncStrategy-CyATpyLQ.d.mts → SyncStrategy-CyATpyLQ.d.cts} +0 -0
- /package/dist/pouch/{index.d.mts → index.d.cts} +0 -0
package/dist/index.js
CHANGED
|
@@ -122,6 +122,7 @@ var init_types_legacy = __esm({
|
|
|
122
122
|
DocType3["SCHEDULED_CARD"] = "SCHEDULED_CARD";
|
|
123
123
|
DocType3["TAG"] = "TAG";
|
|
124
124
|
DocType3["NAVIGATION_STRATEGY"] = "NAVIGATION_STRATEGY";
|
|
125
|
+
DocType3["STRATEGY_STATE"] = "STRATEGY_STATE";
|
|
125
126
|
return DocType3;
|
|
126
127
|
})(DocType || {});
|
|
127
128
|
DocTypePrefixes = {
|
|
@@ -135,7 +136,8 @@ var init_types_legacy = __esm({
|
|
|
135
136
|
["QUESTION" /* QUESTIONTYPE */]: "QUESTION",
|
|
136
137
|
["VIEW" /* VIEW */]: "VIEW",
|
|
137
138
|
["PEDAGOGY" /* PEDAGOGY */]: "PEDAGOGY",
|
|
138
|
-
["NAVIGATION_STRATEGY" /* NAVIGATION_STRATEGY */]: "NAVIGATION_STRATEGY"
|
|
139
|
+
["NAVIGATION_STRATEGY" /* NAVIGATION_STRATEGY */]: "NAVIGATION_STRATEGY",
|
|
140
|
+
["STRATEGY_STATE" /* STRATEGY_STATE */]: "STRATEGY_STATE"
|
|
139
141
|
};
|
|
140
142
|
}
|
|
141
143
|
});
|
|
@@ -181,9 +183,9 @@ var import_pouchdb, import_pouchdb_find, import_pouchdb_authentication, pouchdb_
|
|
|
181
183
|
var init_pouchdb_setup = __esm({
|
|
182
184
|
"src/impl/couch/pouchdb-setup.ts"() {
|
|
183
185
|
"use strict";
|
|
184
|
-
import_pouchdb = __toESM(require("pouchdb"));
|
|
185
|
-
import_pouchdb_find = __toESM(require("pouchdb-find"));
|
|
186
|
-
import_pouchdb_authentication = __toESM(require("@nilock2/pouchdb-authentication"));
|
|
186
|
+
import_pouchdb = __toESM(require("pouchdb"), 1);
|
|
187
|
+
import_pouchdb_find = __toESM(require("pouchdb-find"), 1);
|
|
188
|
+
import_pouchdb_authentication = __toESM(require("@nilock2/pouchdb-authentication"), 1);
|
|
187
189
|
import_pouchdb.default.plugin(import_pouchdb_find.default);
|
|
188
190
|
import_pouchdb.default.plugin(import_pouchdb_authentication.default);
|
|
189
191
|
import_pouchdb.default.defaults({
|
|
@@ -264,8 +266,8 @@ var fs, path, logFile, isNodeEnvironment, logger2;
|
|
|
264
266
|
var init_tuiLogger = __esm({
|
|
265
267
|
"src/util/tuiLogger.ts"() {
|
|
266
268
|
"use strict";
|
|
267
|
-
fs = __toESM(require("fs"));
|
|
268
|
-
path = __toESM(require("path"));
|
|
269
|
+
fs = __toESM(require("fs"), 1);
|
|
270
|
+
path = __toESM(require("path"), 1);
|
|
269
271
|
init_dataDirectory();
|
|
270
272
|
logFile = null;
|
|
271
273
|
isNodeEnvironment = false;
|
|
@@ -316,9 +318,9 @@ var fs2, path2, os;
|
|
|
316
318
|
var init_dataDirectory = __esm({
|
|
317
319
|
"src/util/dataDirectory.ts"() {
|
|
318
320
|
"use strict";
|
|
319
|
-
fs2 = __toESM(require("fs"));
|
|
320
|
-
path2 = __toESM(require("path"));
|
|
321
|
-
os = __toESM(require("os"));
|
|
321
|
+
fs2 = __toESM(require("fs"), 1);
|
|
322
|
+
path2 = __toESM(require("path"), 1);
|
|
323
|
+
os = __toESM(require("os"), 1);
|
|
322
324
|
init_tuiLogger();
|
|
323
325
|
init_factory();
|
|
324
326
|
}
|
|
@@ -404,7 +406,7 @@ var import_moment, REVIEW_TIME_FORMAT, log2;
|
|
|
404
406
|
var init_userDBHelpers = __esm({
|
|
405
407
|
"src/impl/common/userDBHelpers.ts"() {
|
|
406
408
|
"use strict";
|
|
407
|
-
import_moment = __toESM(require("moment"));
|
|
409
|
+
import_moment = __toESM(require("moment"), 1);
|
|
408
410
|
init_core();
|
|
409
411
|
init_logger();
|
|
410
412
|
init_pouchdb_setup();
|
|
@@ -560,7 +562,7 @@ var import_moment2, UsrCrsData;
|
|
|
560
562
|
var init_user_course_relDB = __esm({
|
|
561
563
|
"src/impl/couch/user-course-relDB.ts"() {
|
|
562
564
|
"use strict";
|
|
563
|
-
import_moment2 = __toESM(require("moment"));
|
|
565
|
+
import_moment2 = __toESM(require("moment"), 1);
|
|
564
566
|
init_logger();
|
|
565
567
|
UsrCrsData = class {
|
|
566
568
|
user;
|
|
@@ -945,23 +947,518 @@ var init_courseLookupDB = __esm({
|
|
|
945
947
|
}
|
|
946
948
|
});
|
|
947
949
|
|
|
950
|
+
// src/core/navigators/CompositeGenerator.ts
|
|
951
|
+
var CompositeGenerator_exports = {};
|
|
952
|
+
__export(CompositeGenerator_exports, {
|
|
953
|
+
AggregationMode: () => AggregationMode,
|
|
954
|
+
default: () => CompositeGenerator
|
|
955
|
+
});
|
|
956
|
+
var AggregationMode, DEFAULT_AGGREGATION_MODE, FREQUENCY_BOOST_FACTOR, CompositeGenerator;
|
|
957
|
+
var init_CompositeGenerator = __esm({
|
|
958
|
+
"src/core/navigators/CompositeGenerator.ts"() {
|
|
959
|
+
"use strict";
|
|
960
|
+
init_navigators();
|
|
961
|
+
init_logger();
|
|
962
|
+
AggregationMode = /* @__PURE__ */ ((AggregationMode2) => {
|
|
963
|
+
AggregationMode2["MAX"] = "max";
|
|
964
|
+
AggregationMode2["AVERAGE"] = "average";
|
|
965
|
+
AggregationMode2["FREQUENCY_BOOST"] = "frequencyBoost";
|
|
966
|
+
return AggregationMode2;
|
|
967
|
+
})(AggregationMode || {});
|
|
968
|
+
DEFAULT_AGGREGATION_MODE = "frequencyBoost" /* FREQUENCY_BOOST */;
|
|
969
|
+
FREQUENCY_BOOST_FACTOR = 0.1;
|
|
970
|
+
CompositeGenerator = class _CompositeGenerator extends ContentNavigator {
|
|
971
|
+
/** Human-readable name for CardGenerator interface */
|
|
972
|
+
name = "Composite Generator";
|
|
973
|
+
generators;
|
|
974
|
+
aggregationMode;
|
|
975
|
+
constructor(generators, aggregationMode = DEFAULT_AGGREGATION_MODE) {
|
|
976
|
+
super();
|
|
977
|
+
this.generators = generators;
|
|
978
|
+
this.aggregationMode = aggregationMode;
|
|
979
|
+
if (generators.length === 0) {
|
|
980
|
+
throw new Error("CompositeGenerator requires at least one generator");
|
|
981
|
+
}
|
|
982
|
+
logger.debug(
|
|
983
|
+
`[CompositeGenerator] Created with ${generators.length} generators, mode: ${aggregationMode}`
|
|
984
|
+
);
|
|
985
|
+
}
|
|
986
|
+
/**
|
|
987
|
+
* Creates a CompositeGenerator from strategy data.
|
|
988
|
+
*
|
|
989
|
+
* This is a convenience factory for use by PipelineAssembler.
|
|
990
|
+
*/
|
|
991
|
+
static async fromStrategies(user, course, strategies, aggregationMode = DEFAULT_AGGREGATION_MODE) {
|
|
992
|
+
const generators = await Promise.all(
|
|
993
|
+
strategies.map((s) => ContentNavigator.create(user, course, s))
|
|
994
|
+
);
|
|
995
|
+
return new _CompositeGenerator(generators, aggregationMode);
|
|
996
|
+
}
|
|
997
|
+
/**
|
|
998
|
+
* Get weighted cards from all generators, merge and deduplicate.
|
|
999
|
+
*
|
|
1000
|
+
* Cards appearing in multiple generators receive a score boost.
|
|
1001
|
+
* Provenance tracks which generators produced each card and how scores were aggregated.
|
|
1002
|
+
*
|
|
1003
|
+
* This method supports both the legacy signature (limit only) and the
|
|
1004
|
+
* CardGenerator interface signature (limit, context).
|
|
1005
|
+
*
|
|
1006
|
+
* @param limit - Maximum number of cards to return
|
|
1007
|
+
* @param context - Optional GeneratorContext passed to child generators
|
|
1008
|
+
*/
|
|
1009
|
+
async getWeightedCards(limit, context) {
|
|
1010
|
+
const results = await Promise.all(
|
|
1011
|
+
this.generators.map((g) => g.getWeightedCards(limit, context))
|
|
1012
|
+
);
|
|
1013
|
+
const byCardId = /* @__PURE__ */ new Map();
|
|
1014
|
+
for (const cards of results) {
|
|
1015
|
+
for (const card of cards) {
|
|
1016
|
+
const existing = byCardId.get(card.cardId) || [];
|
|
1017
|
+
existing.push(card);
|
|
1018
|
+
byCardId.set(card.cardId, existing);
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
const merged = [];
|
|
1022
|
+
for (const [, cards] of byCardId) {
|
|
1023
|
+
const aggregatedScore = this.aggregateScores(cards);
|
|
1024
|
+
const finalScore = Math.min(1, aggregatedScore);
|
|
1025
|
+
const mergedProvenance = cards.flatMap((c) => c.provenance);
|
|
1026
|
+
const initialScore = cards[0].score;
|
|
1027
|
+
const action = finalScore > initialScore ? "boosted" : finalScore < initialScore ? "penalized" : "passed";
|
|
1028
|
+
const reason = this.buildAggregationReason(cards, finalScore);
|
|
1029
|
+
merged.push({
|
|
1030
|
+
...cards[0],
|
|
1031
|
+
score: finalScore,
|
|
1032
|
+
provenance: [
|
|
1033
|
+
...mergedProvenance,
|
|
1034
|
+
{
|
|
1035
|
+
strategy: "composite",
|
|
1036
|
+
strategyName: "Composite Generator",
|
|
1037
|
+
strategyId: "COMPOSITE_GENERATOR",
|
|
1038
|
+
action,
|
|
1039
|
+
score: finalScore,
|
|
1040
|
+
reason
|
|
1041
|
+
}
|
|
1042
|
+
]
|
|
1043
|
+
});
|
|
1044
|
+
}
|
|
1045
|
+
return merged.sort((a, b) => b.score - a.score).slice(0, limit);
|
|
1046
|
+
}
|
|
1047
|
+
/**
|
|
1048
|
+
* Build human-readable reason for score aggregation.
|
|
1049
|
+
*/
|
|
1050
|
+
buildAggregationReason(cards, finalScore) {
|
|
1051
|
+
const count = cards.length;
|
|
1052
|
+
const scores = cards.map((c) => c.score.toFixed(2)).join(", ");
|
|
1053
|
+
if (count === 1) {
|
|
1054
|
+
return `Single generator, score ${finalScore.toFixed(2)}`;
|
|
1055
|
+
}
|
|
1056
|
+
const strategies = cards.map((c) => c.provenance[0]?.strategy || "unknown").join(", ");
|
|
1057
|
+
switch (this.aggregationMode) {
|
|
1058
|
+
case "max" /* MAX */:
|
|
1059
|
+
return `Max of ${count} generators (${strategies}): scores [${scores}] \u2192 ${finalScore.toFixed(2)}`;
|
|
1060
|
+
case "average" /* AVERAGE */:
|
|
1061
|
+
return `Average of ${count} generators (${strategies}): scores [${scores}] \u2192 ${finalScore.toFixed(2)}`;
|
|
1062
|
+
case "frequencyBoost" /* FREQUENCY_BOOST */: {
|
|
1063
|
+
const avg = cards.reduce((sum, c) => sum + c.score, 0) / count;
|
|
1064
|
+
const boost = 1 + FREQUENCY_BOOST_FACTOR * (count - 1);
|
|
1065
|
+
return `Frequency boost from ${count} generators (${strategies}): avg ${avg.toFixed(2)} \xD7 ${boost.toFixed(2)} \u2192 ${finalScore.toFixed(2)}`;
|
|
1066
|
+
}
|
|
1067
|
+
default:
|
|
1068
|
+
return `Aggregated from ${count} generators: ${finalScore.toFixed(2)}`;
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
/**
|
|
1072
|
+
* Aggregate scores from multiple generators for the same card.
|
|
1073
|
+
*/
|
|
1074
|
+
aggregateScores(cards) {
|
|
1075
|
+
const scores = cards.map((c) => c.score);
|
|
1076
|
+
switch (this.aggregationMode) {
|
|
1077
|
+
case "max" /* MAX */:
|
|
1078
|
+
return Math.max(...scores);
|
|
1079
|
+
case "average" /* AVERAGE */:
|
|
1080
|
+
return scores.reduce((sum, s) => sum + s, 0) / scores.length;
|
|
1081
|
+
case "frequencyBoost" /* FREQUENCY_BOOST */: {
|
|
1082
|
+
const avg = scores.reduce((sum, s) => sum + s, 0) / scores.length;
|
|
1083
|
+
const frequencyBoost = 1 + FREQUENCY_BOOST_FACTOR * (cards.length - 1);
|
|
1084
|
+
return avg * frequencyBoost;
|
|
1085
|
+
}
|
|
1086
|
+
default:
|
|
1087
|
+
return scores[0];
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
/**
|
|
1091
|
+
* Get new cards from all generators, merged and deduplicated.
|
|
1092
|
+
*/
|
|
1093
|
+
async getNewCards(n) {
|
|
1094
|
+
const legacyGenerators = this.generators.filter(
|
|
1095
|
+
(g) => g instanceof ContentNavigator
|
|
1096
|
+
);
|
|
1097
|
+
const results = await Promise.all(legacyGenerators.map((g) => g.getNewCards(n)));
|
|
1098
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1099
|
+
const merged = [];
|
|
1100
|
+
for (const cards of results) {
|
|
1101
|
+
for (const card of cards) {
|
|
1102
|
+
if (!seen.has(card.cardID)) {
|
|
1103
|
+
seen.add(card.cardID);
|
|
1104
|
+
merged.push(card);
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
return n ? merged.slice(0, n) : merged;
|
|
1109
|
+
}
|
|
1110
|
+
/**
|
|
1111
|
+
* Get pending reviews from all generators, merged and deduplicated.
|
|
1112
|
+
*/
|
|
1113
|
+
async getPendingReviews() {
|
|
1114
|
+
const legacyGenerators = this.generators.filter(
|
|
1115
|
+
(g) => g instanceof ContentNavigator
|
|
1116
|
+
);
|
|
1117
|
+
const results = await Promise.all(legacyGenerators.map((g) => g.getPendingReviews()));
|
|
1118
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1119
|
+
const merged = [];
|
|
1120
|
+
for (const reviews of results) {
|
|
1121
|
+
for (const review of reviews) {
|
|
1122
|
+
if (!seen.has(review.cardID)) {
|
|
1123
|
+
seen.add(review.cardID);
|
|
1124
|
+
merged.push(review);
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
return merged;
|
|
1129
|
+
}
|
|
1130
|
+
};
|
|
1131
|
+
}
|
|
1132
|
+
});
|
|
1133
|
+
|
|
1134
|
+
// src/core/navigators/Pipeline.ts
|
|
1135
|
+
var Pipeline_exports = {};
|
|
1136
|
+
__export(Pipeline_exports, {
|
|
1137
|
+
Pipeline: () => Pipeline
|
|
1138
|
+
});
|
|
1139
|
+
function logPipelineConfig(generator, filters) {
|
|
1140
|
+
const filterList = filters.length > 0 ? "\n - " + filters.map((f) => f.name).join("\n - ") : " none";
|
|
1141
|
+
logger.info(
|
|
1142
|
+
`[Pipeline] Configuration:
|
|
1143
|
+
Generator: ${generator.name}
|
|
1144
|
+
Filters:${filterList}`
|
|
1145
|
+
);
|
|
1146
|
+
}
|
|
1147
|
+
function logTagHydration(cards, tagsByCard) {
|
|
1148
|
+
const totalTags = Array.from(tagsByCard.values()).reduce((sum, tags) => sum + tags.length, 0);
|
|
1149
|
+
const cardsWithTags = Array.from(tagsByCard.values()).filter((tags) => tags.length > 0).length;
|
|
1150
|
+
logger.debug(
|
|
1151
|
+
`[Pipeline] Tag hydration: ${cards.length} cards, ${cardsWithTags} have tags (${totalTags} total tags) - single batch query`
|
|
1152
|
+
);
|
|
1153
|
+
}
|
|
1154
|
+
function logExecutionSummary(generatorName, generatedCount, filterCount, finalCount, topScores) {
|
|
1155
|
+
const scoreDisplay = topScores.length > 0 ? topScores.map((s) => s.toFixed(2)).join(", ") : "none";
|
|
1156
|
+
logger.info(
|
|
1157
|
+
`[Pipeline] Execution: ${generatorName} produced ${generatedCount} \u2192 ${filterCount} filters \u2192 ${finalCount} results (top scores: ${scoreDisplay})`
|
|
1158
|
+
);
|
|
1159
|
+
}
|
|
1160
|
+
function logCardProvenance(cards, maxCards = 3) {
|
|
1161
|
+
const cardsToLog = cards.slice(0, maxCards);
|
|
1162
|
+
logger.debug(`[Pipeline] Provenance for top ${cardsToLog.length} cards:`);
|
|
1163
|
+
for (const card of cardsToLog) {
|
|
1164
|
+
logger.debug(`[Pipeline] ${card.cardId} (final score: ${card.score.toFixed(3)}):`);
|
|
1165
|
+
for (const entry of card.provenance) {
|
|
1166
|
+
const scoreChange = entry.score.toFixed(3);
|
|
1167
|
+
const action = entry.action.padEnd(9);
|
|
1168
|
+
logger.debug(
|
|
1169
|
+
`[Pipeline] ${action} ${scoreChange} - ${entry.strategyName}: ${entry.reason}`
|
|
1170
|
+
);
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
var import_common5, Pipeline;
|
|
1175
|
+
var init_Pipeline = __esm({
|
|
1176
|
+
"src/core/navigators/Pipeline.ts"() {
|
|
1177
|
+
"use strict";
|
|
1178
|
+
import_common5 = require("@vue-skuilder/common");
|
|
1179
|
+
init_navigators();
|
|
1180
|
+
init_logger();
|
|
1181
|
+
Pipeline = class extends ContentNavigator {
|
|
1182
|
+
generator;
|
|
1183
|
+
filters;
|
|
1184
|
+
/**
|
|
1185
|
+
* Create a new pipeline.
|
|
1186
|
+
*
|
|
1187
|
+
* @param generator - The generator (or CompositeGenerator) that produces candidates
|
|
1188
|
+
* @param filters - Filters to apply sequentially (order doesn't matter for multipliers)
|
|
1189
|
+
* @param user - User database interface
|
|
1190
|
+
* @param course - Course database interface
|
|
1191
|
+
*/
|
|
1192
|
+
constructor(generator, filters, user, course) {
|
|
1193
|
+
super();
|
|
1194
|
+
this.generator = generator;
|
|
1195
|
+
this.filters = filters;
|
|
1196
|
+
this.user = user;
|
|
1197
|
+
this.course = course;
|
|
1198
|
+
logPipelineConfig(generator, filters);
|
|
1199
|
+
}
|
|
1200
|
+
/**
|
|
1201
|
+
* Get weighted cards by running generator and applying filters.
|
|
1202
|
+
*
|
|
1203
|
+
* 1. Build shared context (user ELO, etc.)
|
|
1204
|
+
* 2. Get candidates from generator (passing context)
|
|
1205
|
+
* 3. Batch hydrate tags for all candidates
|
|
1206
|
+
* 4. Apply each filter sequentially
|
|
1207
|
+
* 5. Remove zero-score cards
|
|
1208
|
+
* 6. Sort by score descending
|
|
1209
|
+
* 7. Return top N
|
|
1210
|
+
*
|
|
1211
|
+
* @param limit - Maximum number of cards to return
|
|
1212
|
+
* @returns Cards sorted by score descending
|
|
1213
|
+
*/
|
|
1214
|
+
async getWeightedCards(limit) {
|
|
1215
|
+
const context = await this.buildContext();
|
|
1216
|
+
const overFetchMultiplier = 2 + this.filters.length * 0.5;
|
|
1217
|
+
const fetchLimit = Math.ceil(limit * overFetchMultiplier);
|
|
1218
|
+
logger.debug(
|
|
1219
|
+
`[Pipeline] Fetching ${fetchLimit} candidates from generator '${this.generator.name}'`
|
|
1220
|
+
);
|
|
1221
|
+
let cards = await this.generator.getWeightedCards(fetchLimit, context);
|
|
1222
|
+
const generatedCount = cards.length;
|
|
1223
|
+
logger.debug(`[Pipeline] Generator returned ${generatedCount} candidates`);
|
|
1224
|
+
cards = await this.hydrateTags(cards);
|
|
1225
|
+
for (const filter of this.filters) {
|
|
1226
|
+
const beforeCount = cards.length;
|
|
1227
|
+
cards = await filter.transform(cards, context);
|
|
1228
|
+
logger.debug(`[Pipeline] Filter '${filter.name}': ${beforeCount} \u2192 ${cards.length} cards`);
|
|
1229
|
+
}
|
|
1230
|
+
cards = cards.filter((c) => c.score > 0);
|
|
1231
|
+
cards.sort((a, b) => b.score - a.score);
|
|
1232
|
+
const result = cards.slice(0, limit);
|
|
1233
|
+
const topScores = result.slice(0, 3).map((c) => c.score);
|
|
1234
|
+
logExecutionSummary(this.generator.name, generatedCount, this.filters.length, result.length, topScores);
|
|
1235
|
+
logCardProvenance(result, 3);
|
|
1236
|
+
return result;
|
|
1237
|
+
}
|
|
1238
|
+
/**
|
|
1239
|
+
* Batch hydrate tags for all cards.
|
|
1240
|
+
*
|
|
1241
|
+
* Fetches tags for all cards in a single database query and attaches them
|
|
1242
|
+
* to the WeightedCard objects. Filters can then use card.tags instead of
|
|
1243
|
+
* making individual getAppliedTags() calls.
|
|
1244
|
+
*
|
|
1245
|
+
* @param cards - Cards to hydrate
|
|
1246
|
+
* @returns Cards with tags populated
|
|
1247
|
+
*/
|
|
1248
|
+
async hydrateTags(cards) {
|
|
1249
|
+
if (cards.length === 0) {
|
|
1250
|
+
return cards;
|
|
1251
|
+
}
|
|
1252
|
+
const cardIds = cards.map((c) => c.cardId);
|
|
1253
|
+
const tagsByCard = await this.course.getAppliedTagsBatch(cardIds);
|
|
1254
|
+
logTagHydration(cards, tagsByCard);
|
|
1255
|
+
return cards.map((card) => ({
|
|
1256
|
+
...card,
|
|
1257
|
+
tags: tagsByCard.get(card.cardId) ?? []
|
|
1258
|
+
}));
|
|
1259
|
+
}
|
|
1260
|
+
/**
|
|
1261
|
+
* Build shared context for generator and filters.
|
|
1262
|
+
*
|
|
1263
|
+
* Called once per getWeightedCards() invocation.
|
|
1264
|
+
* Contains data that the generator and multiple filters might need.
|
|
1265
|
+
*
|
|
1266
|
+
* The context satisfies both GeneratorContext and FilterContext interfaces.
|
|
1267
|
+
*/
|
|
1268
|
+
async buildContext() {
|
|
1269
|
+
let userElo = 1e3;
|
|
1270
|
+
try {
|
|
1271
|
+
const courseReg = await this.user.getCourseRegDoc(this.course.getCourseID());
|
|
1272
|
+
const courseElo = (0, import_common5.toCourseElo)(courseReg.elo);
|
|
1273
|
+
userElo = courseElo.global.score;
|
|
1274
|
+
} catch (e) {
|
|
1275
|
+
logger.debug(`[Pipeline] Could not get user ELO, using default: ${e}`);
|
|
1276
|
+
}
|
|
1277
|
+
return {
|
|
1278
|
+
user: this.user,
|
|
1279
|
+
course: this.course,
|
|
1280
|
+
userElo
|
|
1281
|
+
};
|
|
1282
|
+
}
|
|
1283
|
+
// ===========================================================================
|
|
1284
|
+
// Legacy StudyContentSource methods
|
|
1285
|
+
// ===========================================================================
|
|
1286
|
+
//
|
|
1287
|
+
// These delegate to the generator for backward compatibility.
|
|
1288
|
+
// Eventually SessionController will use getWeightedCards() exclusively.
|
|
1289
|
+
//
|
|
1290
|
+
/**
|
|
1291
|
+
* Get new cards via legacy API.
|
|
1292
|
+
* Delegates to the generator if it supports the legacy interface.
|
|
1293
|
+
*/
|
|
1294
|
+
async getNewCards(n) {
|
|
1295
|
+
if ("getNewCards" in this.generator && typeof this.generator.getNewCards === "function") {
|
|
1296
|
+
return this.generator.getNewCards(n);
|
|
1297
|
+
}
|
|
1298
|
+
return [];
|
|
1299
|
+
}
|
|
1300
|
+
/**
|
|
1301
|
+
* Get pending reviews via legacy API.
|
|
1302
|
+
* Delegates to the generator if it supports the legacy interface.
|
|
1303
|
+
*/
|
|
1304
|
+
async getPendingReviews() {
|
|
1305
|
+
if ("getPendingReviews" in this.generator && typeof this.generator.getPendingReviews === "function") {
|
|
1306
|
+
return this.generator.getPendingReviews();
|
|
1307
|
+
}
|
|
1308
|
+
return [];
|
|
1309
|
+
}
|
|
1310
|
+
/**
|
|
1311
|
+
* Get the course ID for this pipeline.
|
|
1312
|
+
*/
|
|
1313
|
+
getCourseID() {
|
|
1314
|
+
return this.course.getCourseID();
|
|
1315
|
+
}
|
|
1316
|
+
};
|
|
1317
|
+
}
|
|
1318
|
+
});
|
|
1319
|
+
|
|
1320
|
+
// src/core/navigators/PipelineAssembler.ts
|
|
1321
|
+
var PipelineAssembler_exports = {};
|
|
1322
|
+
__export(PipelineAssembler_exports, {
|
|
1323
|
+
PipelineAssembler: () => PipelineAssembler
|
|
1324
|
+
});
|
|
1325
|
+
var PipelineAssembler;
|
|
1326
|
+
var init_PipelineAssembler = __esm({
|
|
1327
|
+
"src/core/navigators/PipelineAssembler.ts"() {
|
|
1328
|
+
"use strict";
|
|
1329
|
+
init_navigators();
|
|
1330
|
+
init_Pipeline();
|
|
1331
|
+
init_types_legacy();
|
|
1332
|
+
init_logger();
|
|
1333
|
+
init_CompositeGenerator();
|
|
1334
|
+
PipelineAssembler = class {
|
|
1335
|
+
/**
|
|
1336
|
+
* Assembles a navigation pipeline from strategy documents.
|
|
1337
|
+
*
|
|
1338
|
+
* 1. Separates into generators and filters by role
|
|
1339
|
+
* 2. Validates at least one generator exists (or creates default ELO)
|
|
1340
|
+
* 3. Instantiates generators - wraps multiple in CompositeGenerator
|
|
1341
|
+
* 4. Instantiates filters
|
|
1342
|
+
* 5. Returns Pipeline(generator, filters)
|
|
1343
|
+
*
|
|
1344
|
+
* @param input - Strategy documents plus user/course interfaces
|
|
1345
|
+
* @returns Assembled pipeline and any warnings
|
|
1346
|
+
*/
|
|
1347
|
+
async assemble(input) {
|
|
1348
|
+
const { strategies, user, course } = input;
|
|
1349
|
+
const warnings = [];
|
|
1350
|
+
if (strategies.length === 0) {
|
|
1351
|
+
return {
|
|
1352
|
+
pipeline: null,
|
|
1353
|
+
generatorStrategies: [],
|
|
1354
|
+
filterStrategies: [],
|
|
1355
|
+
warnings
|
|
1356
|
+
};
|
|
1357
|
+
}
|
|
1358
|
+
const generatorStrategies = [];
|
|
1359
|
+
const filterStrategies = [];
|
|
1360
|
+
for (const s of strategies) {
|
|
1361
|
+
if (isGenerator(s.implementingClass)) {
|
|
1362
|
+
generatorStrategies.push(s);
|
|
1363
|
+
} else if (isFilter(s.implementingClass)) {
|
|
1364
|
+
filterStrategies.push(s);
|
|
1365
|
+
} else {
|
|
1366
|
+
warnings.push(`Unknown strategy type '${s.implementingClass}', skipping: ${s.name}`);
|
|
1367
|
+
}
|
|
1368
|
+
}
|
|
1369
|
+
if (generatorStrategies.length === 0) {
|
|
1370
|
+
if (filterStrategies.length > 0) {
|
|
1371
|
+
logger.debug(
|
|
1372
|
+
"[PipelineAssembler] No generator found, using default ELO with configured filters"
|
|
1373
|
+
);
|
|
1374
|
+
generatorStrategies.push(this.makeDefaultEloStrategy(course.getCourseID()));
|
|
1375
|
+
} else {
|
|
1376
|
+
warnings.push("No generator strategy found");
|
|
1377
|
+
return {
|
|
1378
|
+
pipeline: null,
|
|
1379
|
+
generatorStrategies: [],
|
|
1380
|
+
filterStrategies: [],
|
|
1381
|
+
warnings
|
|
1382
|
+
};
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
let generator;
|
|
1386
|
+
if (generatorStrategies.length === 1) {
|
|
1387
|
+
const nav = await ContentNavigator.create(user, course, generatorStrategies[0]);
|
|
1388
|
+
generator = nav;
|
|
1389
|
+
logger.debug(`[PipelineAssembler] Using single generator: ${generatorStrategies[0].name}`);
|
|
1390
|
+
} else {
|
|
1391
|
+
logger.debug(
|
|
1392
|
+
`[PipelineAssembler] Using CompositeGenerator for ${generatorStrategies.length} generators: ${generatorStrategies.map((g) => g.name).join(", ")}`
|
|
1393
|
+
);
|
|
1394
|
+
generator = await CompositeGenerator.fromStrategies(user, course, generatorStrategies);
|
|
1395
|
+
}
|
|
1396
|
+
const filters = [];
|
|
1397
|
+
const sortedFilterStrategies = [...filterStrategies].sort(
|
|
1398
|
+
(a, b) => a.name.localeCompare(b.name)
|
|
1399
|
+
);
|
|
1400
|
+
for (const filterStrategy of sortedFilterStrategies) {
|
|
1401
|
+
try {
|
|
1402
|
+
const nav = await ContentNavigator.create(user, course, filterStrategy);
|
|
1403
|
+
if ("transform" in nav && typeof nav.transform === "function") {
|
|
1404
|
+
filters.push(nav);
|
|
1405
|
+
logger.debug(`[PipelineAssembler] Added filter: ${filterStrategy.name}`);
|
|
1406
|
+
} else {
|
|
1407
|
+
warnings.push(
|
|
1408
|
+
`Filter '${filterStrategy.name}' does not implement CardFilter.transform(), skipping`
|
|
1409
|
+
);
|
|
1410
|
+
}
|
|
1411
|
+
} catch (e) {
|
|
1412
|
+
warnings.push(`Failed to instantiate filter '${filterStrategy.name}': ${e}`);
|
|
1413
|
+
}
|
|
1414
|
+
}
|
|
1415
|
+
const pipeline = new Pipeline(generator, filters, user, course);
|
|
1416
|
+
logger.debug(
|
|
1417
|
+
`[PipelineAssembler] Assembled pipeline with ${generatorStrategies.length} generator(s) and ${filters.length} filter(s)`
|
|
1418
|
+
);
|
|
1419
|
+
return {
|
|
1420
|
+
pipeline,
|
|
1421
|
+
generatorStrategies,
|
|
1422
|
+
filterStrategies: sortedFilterStrategies,
|
|
1423
|
+
warnings
|
|
1424
|
+
};
|
|
1425
|
+
}
|
|
1426
|
+
/**
|
|
1427
|
+
* Creates a default ELO generator strategy.
|
|
1428
|
+
* Used when filters are configured but no generator is specified.
|
|
1429
|
+
*/
|
|
1430
|
+
makeDefaultEloStrategy(courseId) {
|
|
1431
|
+
return {
|
|
1432
|
+
_id: "NAVIGATION_STRATEGY-ELO-default",
|
|
1433
|
+
course: courseId,
|
|
1434
|
+
docType: "NAVIGATION_STRATEGY" /* NAVIGATION_STRATEGY */,
|
|
1435
|
+
name: "ELO (default)",
|
|
1436
|
+
description: "Default ELO-based generator",
|
|
1437
|
+
implementingClass: "elo" /* ELO */,
|
|
1438
|
+
serializedData: ""
|
|
1439
|
+
};
|
|
1440
|
+
}
|
|
1441
|
+
};
|
|
1442
|
+
}
|
|
1443
|
+
});
|
|
1444
|
+
|
|
948
1445
|
// src/core/navigators/elo.ts
|
|
949
1446
|
var elo_exports = {};
|
|
950
1447
|
__export(elo_exports, {
|
|
951
1448
|
default: () => ELONavigator
|
|
952
1449
|
});
|
|
953
|
-
var ELONavigator;
|
|
1450
|
+
var import_common6, ELONavigator;
|
|
954
1451
|
var init_elo = __esm({
|
|
955
1452
|
"src/core/navigators/elo.ts"() {
|
|
956
1453
|
"use strict";
|
|
957
1454
|
init_navigators();
|
|
1455
|
+
import_common6 = require("@vue-skuilder/common");
|
|
958
1456
|
ELONavigator = class extends ContentNavigator {
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
constructor(user, course) {
|
|
962
|
-
super();
|
|
963
|
-
this.
|
|
964
|
-
this.course = course;
|
|
1457
|
+
/** Human-readable name for CardGenerator interface */
|
|
1458
|
+
name;
|
|
1459
|
+
constructor(user, course, strategyData) {
|
|
1460
|
+
super(user, course, strategyData);
|
|
1461
|
+
this.name = strategyData?.name || "ELO";
|
|
965
1462
|
}
|
|
966
1463
|
async getPendingReviews() {
|
|
967
1464
|
const reviews = await this.user.getPendingReviews(this.course.getCourseID());
|
|
@@ -1007,79 +1504,1125 @@ var init_elo = __esm({
|
|
|
1007
1504
|
};
|
|
1008
1505
|
});
|
|
1009
1506
|
}
|
|
1507
|
+
/**
|
|
1508
|
+
* Get new cards with suitability scores based on ELO distance.
|
|
1509
|
+
*
|
|
1510
|
+
* Cards closer to user's ELO get higher scores.
|
|
1511
|
+
* Score formula: max(0, 1 - distance / 500)
|
|
1512
|
+
*
|
|
1513
|
+
* NOTE: This generator only handles NEW cards. Reviews are handled by
|
|
1514
|
+
* SRSNavigator. Use CompositeGenerator to combine both.
|
|
1515
|
+
*
|
|
1516
|
+
* This method supports both the legacy signature (limit only) and the
|
|
1517
|
+
* CardGenerator interface signature (limit, context).
|
|
1518
|
+
*
|
|
1519
|
+
* @param limit - Maximum number of cards to return
|
|
1520
|
+
* @param context - Optional GeneratorContext (used when called via Pipeline)
|
|
1521
|
+
*/
|
|
1522
|
+
async getWeightedCards(limit, context) {
|
|
1523
|
+
let userGlobalElo;
|
|
1524
|
+
if (context?.userElo !== void 0) {
|
|
1525
|
+
userGlobalElo = context.userElo;
|
|
1526
|
+
} else {
|
|
1527
|
+
const courseReg = await this.user.getCourseRegDoc(this.course.getCourseID());
|
|
1528
|
+
const userElo = (0, import_common6.toCourseElo)(courseReg.elo);
|
|
1529
|
+
userGlobalElo = userElo.global.score;
|
|
1530
|
+
}
|
|
1531
|
+
const newCards = await this.getNewCards(limit);
|
|
1532
|
+
const cardIds = newCards.map((c) => c.cardID);
|
|
1533
|
+
const cardEloData = await this.course.getCardEloData(cardIds);
|
|
1534
|
+
const scored = newCards.map((c, i) => {
|
|
1535
|
+
const cardElo = cardEloData[i]?.global?.score ?? 1e3;
|
|
1536
|
+
const distance = Math.abs(cardElo - userGlobalElo);
|
|
1537
|
+
const score = Math.max(0, 1 - distance / 500);
|
|
1538
|
+
return {
|
|
1539
|
+
cardId: c.cardID,
|
|
1540
|
+
courseId: c.courseID,
|
|
1541
|
+
score,
|
|
1542
|
+
provenance: [
|
|
1543
|
+
{
|
|
1544
|
+
strategy: "elo",
|
|
1545
|
+
strategyName: this.strategyName || this.name,
|
|
1546
|
+
strategyId: this.strategyId || "NAVIGATION_STRATEGY-ELO-default",
|
|
1547
|
+
action: "generated",
|
|
1548
|
+
score,
|
|
1549
|
+
reason: `ELO distance ${Math.round(distance)} (card: ${Math.round(cardElo)}, user: ${Math.round(userGlobalElo)}), new card`
|
|
1550
|
+
}
|
|
1551
|
+
]
|
|
1552
|
+
};
|
|
1553
|
+
});
|
|
1554
|
+
scored.sort((a, b) => b.score - a.score);
|
|
1555
|
+
return scored.slice(0, limit);
|
|
1556
|
+
}
|
|
1010
1557
|
};
|
|
1011
1558
|
}
|
|
1012
1559
|
});
|
|
1013
1560
|
|
|
1014
|
-
// src/core/navigators/
|
|
1015
|
-
var
|
|
1016
|
-
__export(
|
|
1017
|
-
|
|
1561
|
+
// src/core/navigators/filters/eloDistance.ts
|
|
1562
|
+
var eloDistance_exports = {};
|
|
1563
|
+
__export(eloDistance_exports, {
|
|
1564
|
+
DEFAULT_HALF_LIFE: () => DEFAULT_HALF_LIFE,
|
|
1565
|
+
DEFAULT_MAX_MULTIPLIER: () => DEFAULT_MAX_MULTIPLIER,
|
|
1566
|
+
DEFAULT_MIN_MULTIPLIER: () => DEFAULT_MIN_MULTIPLIER,
|
|
1567
|
+
createEloDistanceFilter: () => createEloDistanceFilter
|
|
1018
1568
|
});
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1569
|
+
function computeMultiplier(distance, halfLife, minMultiplier, maxMultiplier) {
|
|
1570
|
+
const normalizedDistance = distance / halfLife;
|
|
1571
|
+
const decay = Math.exp(-(normalizedDistance * normalizedDistance));
|
|
1572
|
+
return minMultiplier + (maxMultiplier - minMultiplier) * decay;
|
|
1573
|
+
}
|
|
1574
|
+
function createEloDistanceFilter(config) {
|
|
1575
|
+
const halfLife = config?.halfLife ?? DEFAULT_HALF_LIFE;
|
|
1576
|
+
const minMultiplier = config?.minMultiplier ?? DEFAULT_MIN_MULTIPLIER;
|
|
1577
|
+
const maxMultiplier = config?.maxMultiplier ?? DEFAULT_MAX_MULTIPLIER;
|
|
1578
|
+
return {
|
|
1579
|
+
name: "ELO Distance Filter",
|
|
1580
|
+
async transform(cards, context) {
|
|
1581
|
+
const { course, userElo } = context;
|
|
1582
|
+
const cardIds = cards.map((c) => c.cardId);
|
|
1583
|
+
const cardElos = await course.getCardEloData(cardIds);
|
|
1584
|
+
return cards.map((card, i) => {
|
|
1585
|
+
const cardElo = cardElos[i]?.global?.score ?? 1e3;
|
|
1586
|
+
const distance = Math.abs(cardElo - userElo);
|
|
1587
|
+
const multiplier = computeMultiplier(distance, halfLife, minMultiplier, maxMultiplier);
|
|
1588
|
+
const newScore = card.score * multiplier;
|
|
1589
|
+
const action = multiplier < maxMultiplier - 0.01 ? "penalized" : "passed";
|
|
1590
|
+
return {
|
|
1591
|
+
...card,
|
|
1592
|
+
score: newScore,
|
|
1593
|
+
provenance: [
|
|
1594
|
+
...card.provenance,
|
|
1595
|
+
{
|
|
1596
|
+
strategy: "eloDistance",
|
|
1597
|
+
strategyName: "ELO Distance Filter",
|
|
1598
|
+
strategyId: "ELO_DISTANCE_FILTER",
|
|
1599
|
+
action,
|
|
1600
|
+
score: newScore,
|
|
1601
|
+
reason: `ELO distance ${Math.round(distance)} (card: ${Math.round(cardElo)}, user: ${Math.round(userElo)}) \u2192 ${multiplier.toFixed(2)}x`
|
|
1602
|
+
}
|
|
1603
|
+
]
|
|
1604
|
+
};
|
|
1605
|
+
});
|
|
1606
|
+
}
|
|
1607
|
+
};
|
|
1608
|
+
}
|
|
1609
|
+
var DEFAULT_HALF_LIFE, DEFAULT_MIN_MULTIPLIER, DEFAULT_MAX_MULTIPLIER;
|
|
1610
|
+
var init_eloDistance = __esm({
|
|
1611
|
+
"src/core/navigators/filters/eloDistance.ts"() {
|
|
1612
|
+
"use strict";
|
|
1613
|
+
DEFAULT_HALF_LIFE = 200;
|
|
1614
|
+
DEFAULT_MIN_MULTIPLIER = 0.3;
|
|
1615
|
+
DEFAULT_MAX_MULTIPLIER = 1;
|
|
1616
|
+
}
|
|
1617
|
+
});
|
|
1618
|
+
|
|
1619
|
+
// src/core/navigators/filters/userTagPreference.ts
|
|
1620
|
+
var userTagPreference_exports = {};
|
|
1621
|
+
__export(userTagPreference_exports, {
|
|
1622
|
+
default: () => UserTagPreferenceFilter
|
|
1623
|
+
});
|
|
1624
|
+
var UserTagPreferenceFilter;
|
|
1625
|
+
var init_userTagPreference = __esm({
|
|
1626
|
+
"src/core/navigators/filters/userTagPreference.ts"() {
|
|
1022
1627
|
"use strict";
|
|
1023
1628
|
init_navigators();
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
course;
|
|
1629
|
+
UserTagPreferenceFilter = class extends ContentNavigator {
|
|
1630
|
+
_strategyData;
|
|
1631
|
+
/** Human-readable name for CardFilter interface */
|
|
1632
|
+
name;
|
|
1029
1633
|
constructor(user, course, strategyData) {
|
|
1030
|
-
super();
|
|
1031
|
-
this.
|
|
1032
|
-
this.
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1634
|
+
super(user, course, strategyData);
|
|
1635
|
+
this._strategyData = strategyData;
|
|
1636
|
+
this.name = strategyData.name || "User Tag Preferences";
|
|
1637
|
+
}
|
|
1638
|
+
/**
|
|
1639
|
+
* Compute multiplier for a card based on its tags and user preferences.
|
|
1640
|
+
* Returns the maximum multiplier among all matching tags, or 1.0 if no matches.
|
|
1641
|
+
*/
|
|
1642
|
+
computeMultiplier(cardTags, boostMap) {
|
|
1643
|
+
const multipliers = cardTags.map((tag) => boostMap[tag]).filter((val) => val !== void 0);
|
|
1644
|
+
if (multipliers.length === 0) {
|
|
1645
|
+
return 1;
|
|
1039
1646
|
}
|
|
1647
|
+
return Math.max(...multipliers);
|
|
1040
1648
|
}
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1649
|
+
/**
|
|
1650
|
+
* Build human-readable reason for the filter's decision.
|
|
1651
|
+
*/
|
|
1652
|
+
buildReason(cardTags, boostMap, multiplier) {
|
|
1653
|
+
const matchingTags = cardTags.filter((tag) => boostMap[tag] === multiplier);
|
|
1654
|
+
if (multiplier === 0) {
|
|
1655
|
+
return `Excluded by user preference: ${matchingTags.join(", ")} (${multiplier}x)`;
|
|
1656
|
+
}
|
|
1657
|
+
if (multiplier < 1) {
|
|
1658
|
+
return `Penalized by user preference: ${matchingTags.join(", ")} (${multiplier.toFixed(2)}x)`;
|
|
1659
|
+
}
|
|
1660
|
+
if (multiplier > 1) {
|
|
1661
|
+
return `Boosted by user preference: ${matchingTags.join(", ")} (${multiplier.toFixed(2)}x)`;
|
|
1662
|
+
}
|
|
1663
|
+
return "No matching user preferences";
|
|
1054
1664
|
}
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1665
|
+
/**
|
|
1666
|
+
* CardFilter.transform implementation.
|
|
1667
|
+
*
|
|
1668
|
+
* Apply user tag preferences:
|
|
1669
|
+
* 1. Read preferences from strategy state
|
|
1670
|
+
* 2. If no preferences, pass through unchanged
|
|
1671
|
+
* 3. For each card:
|
|
1672
|
+
* - Look up tag in boost record
|
|
1673
|
+
* - If tag found: apply multiplier (0 = exclude, 1 = neutral, >1 = boost)
|
|
1674
|
+
* - If multiple tags match: use max multiplier
|
|
1675
|
+
* - Append provenance with clear reason
|
|
1676
|
+
*/
|
|
1677
|
+
async transform(cards, _context) {
|
|
1678
|
+
const prefs = await this.getStrategyState();
|
|
1679
|
+
if (!prefs || Object.keys(prefs.boost).length === 0) {
|
|
1680
|
+
return cards.map((card) => ({
|
|
1681
|
+
...card,
|
|
1682
|
+
provenance: [
|
|
1683
|
+
...card.provenance,
|
|
1684
|
+
{
|
|
1685
|
+
strategy: "userTagPreference",
|
|
1686
|
+
strategyName: this.strategyName || this.name,
|
|
1687
|
+
strategyId: this.strategyId || this._strategyData._id,
|
|
1688
|
+
action: "passed",
|
|
1689
|
+
score: card.score,
|
|
1690
|
+
reason: "No user tag preferences configured"
|
|
1691
|
+
}
|
|
1692
|
+
]
|
|
1693
|
+
}));
|
|
1694
|
+
}
|
|
1695
|
+
const adjusted = await Promise.all(
|
|
1696
|
+
cards.map(async (card) => {
|
|
1697
|
+
const cardTags = card.tags ?? [];
|
|
1698
|
+
const multiplier = this.computeMultiplier(cardTags, prefs.boost);
|
|
1699
|
+
const finalScore = Math.min(1, card.score * multiplier);
|
|
1700
|
+
let action;
|
|
1701
|
+
if (multiplier === 0 || multiplier < 1) {
|
|
1702
|
+
action = "penalized";
|
|
1703
|
+
} else if (multiplier > 1) {
|
|
1704
|
+
action = "boosted";
|
|
1705
|
+
} else {
|
|
1706
|
+
action = "passed";
|
|
1707
|
+
}
|
|
1708
|
+
return {
|
|
1709
|
+
...card,
|
|
1710
|
+
score: finalScore,
|
|
1711
|
+
provenance: [
|
|
1712
|
+
...card.provenance,
|
|
1713
|
+
{
|
|
1714
|
+
strategy: "userTagPreference",
|
|
1715
|
+
strategyName: this.strategyName || this.name,
|
|
1716
|
+
strategyId: this.strategyId || this._strategyData._id,
|
|
1717
|
+
action,
|
|
1718
|
+
score: finalScore,
|
|
1719
|
+
reason: this.buildReason(cardTags, prefs.boost, multiplier)
|
|
1720
|
+
}
|
|
1721
|
+
]
|
|
1722
|
+
};
|
|
1723
|
+
})
|
|
1724
|
+
);
|
|
1725
|
+
return adjusted;
|
|
1726
|
+
}
|
|
1727
|
+
/**
|
|
1728
|
+
* Legacy getWeightedCards - throws as filters should not be used as generators.
|
|
1729
|
+
*/
|
|
1730
|
+
async getWeightedCards(_limit) {
|
|
1731
|
+
throw new Error(
|
|
1732
|
+
"UserTagPreferenceFilter is a filter and should not be used as a generator. Use Pipeline with a generator and this filter via transform()."
|
|
1733
|
+
);
|
|
1734
|
+
}
|
|
1735
|
+
// Legacy methods - stub implementations since filters don't generate cards
|
|
1736
|
+
async getNewCards(_n) {
|
|
1737
|
+
return [];
|
|
1738
|
+
}
|
|
1739
|
+
async getPendingReviews() {
|
|
1740
|
+
return [];
|
|
1741
|
+
}
|
|
1742
|
+
};
|
|
1743
|
+
}
|
|
1744
|
+
});
|
|
1745
|
+
|
|
1746
|
+
// src/core/navigators/filters/index.ts
|
|
1747
|
+
var filters_exports = {};
|
|
1748
|
+
__export(filters_exports, {
|
|
1749
|
+
UserTagPreferenceFilter: () => UserTagPreferenceFilter,
|
|
1750
|
+
createEloDistanceFilter: () => createEloDistanceFilter
|
|
1751
|
+
});
|
|
1752
|
+
var init_filters = __esm({
|
|
1753
|
+
"src/core/navigators/filters/index.ts"() {
|
|
1754
|
+
"use strict";
|
|
1755
|
+
init_eloDistance();
|
|
1756
|
+
init_userTagPreference();
|
|
1757
|
+
}
|
|
1758
|
+
});
|
|
1759
|
+
|
|
1760
|
+
// src/core/navigators/filters/types.ts
|
|
1761
|
+
var types_exports = {};
|
|
1762
|
+
var init_types = __esm({
|
|
1763
|
+
"src/core/navigators/filters/types.ts"() {
|
|
1764
|
+
"use strict";
|
|
1765
|
+
}
|
|
1766
|
+
});
|
|
1767
|
+
|
|
1768
|
+
// src/core/navigators/generators/index.ts
|
|
1769
|
+
var generators_exports = {};
|
|
1770
|
+
var init_generators = __esm({
|
|
1771
|
+
"src/core/navigators/generators/index.ts"() {
|
|
1772
|
+
"use strict";
|
|
1773
|
+
}
|
|
1774
|
+
});
|
|
1775
|
+
|
|
1776
|
+
// src/core/navigators/generators/types.ts
|
|
1777
|
+
var types_exports2 = {};
|
|
1778
|
+
var init_types2 = __esm({
|
|
1779
|
+
"src/core/navigators/generators/types.ts"() {
|
|
1780
|
+
"use strict";
|
|
1781
|
+
}
|
|
1782
|
+
});
|
|
1783
|
+
|
|
1784
|
+
// src/core/navigators/hardcodedOrder.ts
|
|
1785
|
+
var hardcodedOrder_exports = {};
|
|
1786
|
+
__export(hardcodedOrder_exports, {
|
|
1787
|
+
default: () => HardcodedOrderNavigator
|
|
1788
|
+
});
|
|
1789
|
+
var HardcodedOrderNavigator;
|
|
1790
|
+
var init_hardcodedOrder = __esm({
|
|
1791
|
+
"src/core/navigators/hardcodedOrder.ts"() {
|
|
1792
|
+
"use strict";
|
|
1793
|
+
init_navigators();
|
|
1794
|
+
init_logger();
|
|
1795
|
+
HardcodedOrderNavigator = class extends ContentNavigator {
|
|
1796
|
+
/** Human-readable name for CardGenerator interface */
|
|
1797
|
+
name;
|
|
1798
|
+
orderedCardIds = [];
|
|
1799
|
+
constructor(user, course, strategyData) {
|
|
1800
|
+
super(user, course, strategyData);
|
|
1801
|
+
this.name = strategyData.name || "Hardcoded Order";
|
|
1802
|
+
if (strategyData.serializedData) {
|
|
1803
|
+
try {
|
|
1804
|
+
this.orderedCardIds = JSON.parse(strategyData.serializedData);
|
|
1805
|
+
} catch (e) {
|
|
1806
|
+
logger.error("Failed to parse serializedData for HardcodedOrderNavigator", e);
|
|
1807
|
+
}
|
|
1808
|
+
}
|
|
1809
|
+
}
|
|
1810
|
+
async getPendingReviews() {
|
|
1811
|
+
const reviews = await this.user.getPendingReviews(this.course.getCourseID());
|
|
1812
|
+
return reviews.map((r) => {
|
|
1813
|
+
return {
|
|
1814
|
+
...r,
|
|
1815
|
+
contentSourceType: "course",
|
|
1816
|
+
contentSourceID: this.course.getCourseID(),
|
|
1817
|
+
cardID: r.cardId,
|
|
1818
|
+
courseID: r.courseId,
|
|
1819
|
+
reviewID: r._id,
|
|
1820
|
+
status: "review"
|
|
1821
|
+
};
|
|
1822
|
+
});
|
|
1823
|
+
}
|
|
1824
|
+
async getNewCards(limit = 99) {
|
|
1825
|
+
const activeCardIds = (await this.user.getActiveCards()).map((c) => c.cardID);
|
|
1826
|
+
const newCardIds = this.orderedCardIds.filter((cardId) => !activeCardIds.includes(cardId));
|
|
1827
|
+
const cardsToReturn = newCardIds.slice(0, limit);
|
|
1828
|
+
return cardsToReturn.map((cardId) => {
|
|
1829
|
+
return {
|
|
1830
|
+
cardID: cardId,
|
|
1831
|
+
courseID: this.course.getCourseID(),
|
|
1065
1832
|
contentSourceType: "course",
|
|
1066
1833
|
contentSourceID: this.course.getCourseID(),
|
|
1067
1834
|
status: "new"
|
|
1068
1835
|
};
|
|
1069
1836
|
});
|
|
1070
1837
|
}
|
|
1838
|
+
/**
|
|
1839
|
+
* Get cards in hardcoded order with scores based on position.
|
|
1840
|
+
*
|
|
1841
|
+
* Earlier cards in the sequence get higher scores.
|
|
1842
|
+
* Score formula: 1.0 - (position / totalCards) * 0.5
|
|
1843
|
+
* This ensures scores range from 1.0 (first card) to 0.5+ (last card).
|
|
1844
|
+
*
|
|
1845
|
+
* This method supports both the legacy signature (limit only) and the
|
|
1846
|
+
* CardGenerator interface signature (limit, context).
|
|
1847
|
+
*
|
|
1848
|
+
* @param limit - Maximum number of cards to return
|
|
1849
|
+
* @param _context - Optional GeneratorContext (currently unused, but required for interface)
|
|
1850
|
+
*/
|
|
1851
|
+
async getWeightedCards(limit, _context) {
|
|
1852
|
+
const activeCardIds = (await this.user.getActiveCards()).map((c) => c.cardID);
|
|
1853
|
+
const reviews = await this.getPendingReviews();
|
|
1854
|
+
const newCardIds = this.orderedCardIds.filter((cardId) => !activeCardIds.includes(cardId));
|
|
1855
|
+
const totalCards = newCardIds.length;
|
|
1856
|
+
const scoredNew = newCardIds.slice(0, limit).map((cardId, index) => {
|
|
1857
|
+
const position = index + 1;
|
|
1858
|
+
const score = Math.max(0.5, 1 - index / totalCards * 0.5);
|
|
1859
|
+
return {
|
|
1860
|
+
cardId,
|
|
1861
|
+
courseId: this.course.getCourseID(),
|
|
1862
|
+
score,
|
|
1863
|
+
provenance: [
|
|
1864
|
+
{
|
|
1865
|
+
strategy: "hardcodedOrder",
|
|
1866
|
+
strategyName: this.strategyName || this.name,
|
|
1867
|
+
strategyId: this.strategyId || "NAVIGATION_STRATEGY-hardcoded",
|
|
1868
|
+
action: "generated",
|
|
1869
|
+
score,
|
|
1870
|
+
reason: `Position ${position} of ${totalCards} in fixed sequence, new card`
|
|
1871
|
+
}
|
|
1872
|
+
]
|
|
1873
|
+
};
|
|
1874
|
+
});
|
|
1875
|
+
const scoredReviews = reviews.map((r) => ({
|
|
1876
|
+
cardId: r.cardID,
|
|
1877
|
+
courseId: r.courseID,
|
|
1878
|
+
score: 1,
|
|
1879
|
+
provenance: [
|
|
1880
|
+
{
|
|
1881
|
+
strategy: "hardcodedOrder",
|
|
1882
|
+
strategyName: this.strategyName || this.name,
|
|
1883
|
+
strategyId: this.strategyId || "NAVIGATION_STRATEGY-hardcoded",
|
|
1884
|
+
action: "generated",
|
|
1885
|
+
score: 1,
|
|
1886
|
+
reason: "Scheduled review, highest priority"
|
|
1887
|
+
}
|
|
1888
|
+
]
|
|
1889
|
+
}));
|
|
1890
|
+
const all = [...scoredReviews, ...scoredNew];
|
|
1891
|
+
all.sort((a, b) => b.score - a.score);
|
|
1892
|
+
return all.slice(0, limit);
|
|
1893
|
+
}
|
|
1894
|
+
};
|
|
1895
|
+
}
|
|
1896
|
+
});
|
|
1897
|
+
|
|
1898
|
+
// src/core/navigators/hierarchyDefinition.ts
|
|
1899
|
+
var hierarchyDefinition_exports = {};
|
|
1900
|
+
__export(hierarchyDefinition_exports, {
|
|
1901
|
+
default: () => HierarchyDefinitionNavigator
|
|
1902
|
+
});
|
|
1903
|
+
var import_common7, DEFAULT_MIN_COUNT, HierarchyDefinitionNavigator;
|
|
1904
|
+
var init_hierarchyDefinition = __esm({
|
|
1905
|
+
"src/core/navigators/hierarchyDefinition.ts"() {
|
|
1906
|
+
"use strict";
|
|
1907
|
+
init_navigators();
|
|
1908
|
+
import_common7 = require("@vue-skuilder/common");
|
|
1909
|
+
DEFAULT_MIN_COUNT = 3;
|
|
1910
|
+
HierarchyDefinitionNavigator = class extends ContentNavigator {
|
|
1911
|
+
config;
|
|
1912
|
+
_strategyData;
|
|
1913
|
+
/** Human-readable name for CardFilter interface */
|
|
1914
|
+
name;
|
|
1915
|
+
constructor(user, course, _strategyData) {
|
|
1916
|
+
super(user, course, _strategyData);
|
|
1917
|
+
this._strategyData = _strategyData;
|
|
1918
|
+
this.config = this.parseConfig(_strategyData.serializedData);
|
|
1919
|
+
this.name = _strategyData.name || "Hierarchy Definition";
|
|
1920
|
+
}
|
|
1921
|
+
parseConfig(serializedData) {
|
|
1922
|
+
try {
|
|
1923
|
+
const parsed = JSON.parse(serializedData);
|
|
1924
|
+
return {
|
|
1925
|
+
prerequisites: parsed.prerequisites || {}
|
|
1926
|
+
};
|
|
1927
|
+
} catch {
|
|
1928
|
+
return {
|
|
1929
|
+
prerequisites: {}
|
|
1930
|
+
};
|
|
1931
|
+
}
|
|
1932
|
+
}
|
|
1933
|
+
/**
|
|
1934
|
+
* Check if a specific prerequisite is satisfied
|
|
1935
|
+
*/
|
|
1936
|
+
isPrerequisiteMet(prereq, userTagElo, userGlobalElo) {
|
|
1937
|
+
if (!userTagElo) return false;
|
|
1938
|
+
const minCount = prereq.masteryThreshold?.minCount ?? DEFAULT_MIN_COUNT;
|
|
1939
|
+
if (userTagElo.count < minCount) return false;
|
|
1940
|
+
if (prereq.masteryThreshold?.minElo !== void 0) {
|
|
1941
|
+
return userTagElo.score >= prereq.masteryThreshold.minElo;
|
|
1942
|
+
} else {
|
|
1943
|
+
return userTagElo.score >= userGlobalElo;
|
|
1944
|
+
}
|
|
1945
|
+
}
|
|
1946
|
+
/**
|
|
1947
|
+
* Get the set of tags the user has mastered.
|
|
1948
|
+
* A tag is "mastered" if it appears as a prerequisite somewhere and meets its threshold.
|
|
1949
|
+
*/
|
|
1950
|
+
async getMasteredTags(context) {
|
|
1951
|
+
const mastered = /* @__PURE__ */ new Set();
|
|
1952
|
+
try {
|
|
1953
|
+
const courseReg = await context.user.getCourseRegDoc(context.course.getCourseID());
|
|
1954
|
+
const userElo = (0, import_common7.toCourseElo)(courseReg.elo);
|
|
1955
|
+
for (const prereqs of Object.values(this.config.prerequisites)) {
|
|
1956
|
+
for (const prereq of prereqs) {
|
|
1957
|
+
const tagElo = userElo.tags[prereq.tag];
|
|
1958
|
+
if (this.isPrerequisiteMet(prereq, tagElo, userElo.global.score)) {
|
|
1959
|
+
mastered.add(prereq.tag);
|
|
1960
|
+
}
|
|
1961
|
+
}
|
|
1962
|
+
}
|
|
1963
|
+
} catch {
|
|
1964
|
+
}
|
|
1965
|
+
return mastered;
|
|
1966
|
+
}
|
|
1967
|
+
/**
|
|
1968
|
+
* Get the set of tags that are unlocked (prerequisites met)
|
|
1969
|
+
*/
|
|
1970
|
+
getUnlockedTags(masteredTags) {
|
|
1971
|
+
const unlocked = /* @__PURE__ */ new Set();
|
|
1972
|
+
for (const [tagId, prereqs] of Object.entries(this.config.prerequisites)) {
|
|
1973
|
+
const allPrereqsMet = prereqs.every((prereq) => masteredTags.has(prereq.tag));
|
|
1974
|
+
if (allPrereqsMet) {
|
|
1975
|
+
unlocked.add(tagId);
|
|
1976
|
+
}
|
|
1977
|
+
}
|
|
1978
|
+
return unlocked;
|
|
1979
|
+
}
|
|
1980
|
+
/**
|
|
1981
|
+
* Check if a tag has prerequisites defined in config
|
|
1982
|
+
*/
|
|
1983
|
+
hasPrerequisites(tagId) {
|
|
1984
|
+
return tagId in this.config.prerequisites;
|
|
1985
|
+
}
|
|
1986
|
+
/**
|
|
1987
|
+
* Check if a card is unlocked and generate reason.
|
|
1988
|
+
*/
|
|
1989
|
+
async checkCardUnlock(card, course, unlockedTags, masteredTags) {
|
|
1990
|
+
try {
|
|
1991
|
+
const cardTags = card.tags ?? [];
|
|
1992
|
+
const lockedTags = cardTags.filter(
|
|
1993
|
+
(tag) => this.hasPrerequisites(tag) && !unlockedTags.has(tag)
|
|
1994
|
+
);
|
|
1995
|
+
if (lockedTags.length === 0) {
|
|
1996
|
+
const tagList = cardTags.length > 0 ? cardTags.join(", ") : "none";
|
|
1997
|
+
return {
|
|
1998
|
+
isUnlocked: true,
|
|
1999
|
+
reason: `Prerequisites met, tags: ${tagList}`
|
|
2000
|
+
};
|
|
2001
|
+
}
|
|
2002
|
+
const missingPrereqs = lockedTags.flatMap((tag) => {
|
|
2003
|
+
const prereqs = this.config.prerequisites[tag] || [];
|
|
2004
|
+
return prereqs.filter((p) => !masteredTags.has(p.tag)).map((p) => p.tag);
|
|
2005
|
+
});
|
|
2006
|
+
return {
|
|
2007
|
+
isUnlocked: false,
|
|
2008
|
+
reason: `Blocked: missing prerequisites ${missingPrereqs.join(", ")} for tags ${lockedTags.join(", ")}`
|
|
2009
|
+
};
|
|
2010
|
+
} catch {
|
|
2011
|
+
return {
|
|
2012
|
+
isUnlocked: true,
|
|
2013
|
+
reason: "Prerequisites check skipped (tag lookup failed)"
|
|
2014
|
+
};
|
|
2015
|
+
}
|
|
2016
|
+
}
|
|
2017
|
+
/**
|
|
2018
|
+
* CardFilter.transform implementation.
|
|
2019
|
+
*
|
|
2020
|
+
* Apply prerequisite gating to cards. Cards with locked tags receive score: 0.
|
|
2021
|
+
*/
|
|
2022
|
+
async transform(cards, context) {
|
|
2023
|
+
const masteredTags = await this.getMasteredTags(context);
|
|
2024
|
+
const unlockedTags = this.getUnlockedTags(masteredTags);
|
|
2025
|
+
const gated = [];
|
|
2026
|
+
for (const card of cards) {
|
|
2027
|
+
const { isUnlocked, reason } = await this.checkCardUnlock(
|
|
2028
|
+
card,
|
|
2029
|
+
context.course,
|
|
2030
|
+
unlockedTags,
|
|
2031
|
+
masteredTags
|
|
2032
|
+
);
|
|
2033
|
+
const finalScore = isUnlocked ? card.score : 0;
|
|
2034
|
+
const action = isUnlocked ? "passed" : "penalized";
|
|
2035
|
+
gated.push({
|
|
2036
|
+
...card,
|
|
2037
|
+
score: finalScore,
|
|
2038
|
+
provenance: [
|
|
2039
|
+
...card.provenance,
|
|
2040
|
+
{
|
|
2041
|
+
strategy: "hierarchyDefinition",
|
|
2042
|
+
strategyName: this.strategyName || this.name,
|
|
2043
|
+
strategyId: this.strategyId || "NAVIGATION_STRATEGY-hierarchy",
|
|
2044
|
+
action,
|
|
2045
|
+
score: finalScore,
|
|
2046
|
+
reason
|
|
2047
|
+
}
|
|
2048
|
+
]
|
|
2049
|
+
});
|
|
2050
|
+
}
|
|
2051
|
+
return gated;
|
|
2052
|
+
}
|
|
2053
|
+
/**
|
|
2054
|
+
* Legacy getWeightedCards - now throws as filters should not be used as generators.
|
|
2055
|
+
*
|
|
2056
|
+
* Use transform() via Pipeline instead.
|
|
2057
|
+
*/
|
|
2058
|
+
async getWeightedCards(_limit) {
|
|
2059
|
+
throw new Error(
|
|
2060
|
+
"HierarchyDefinitionNavigator is a filter and should not be used as a generator. Use Pipeline with a generator and this filter via transform()."
|
|
2061
|
+
);
|
|
2062
|
+
}
|
|
2063
|
+
// Legacy methods - stub implementations since filters don't generate cards
|
|
2064
|
+
async getNewCards(_n) {
|
|
2065
|
+
return [];
|
|
2066
|
+
}
|
|
2067
|
+
async getPendingReviews() {
|
|
2068
|
+
return [];
|
|
2069
|
+
}
|
|
1071
2070
|
};
|
|
1072
2071
|
}
|
|
1073
2072
|
});
|
|
1074
2073
|
|
|
2074
|
+
// src/core/navigators/inferredPreference.ts
|
|
2075
|
+
var inferredPreference_exports = {};
|
|
2076
|
+
__export(inferredPreference_exports, {
|
|
2077
|
+
INFERRED_PREFERENCE_NAVIGATOR_STUB: () => INFERRED_PREFERENCE_NAVIGATOR_STUB
|
|
2078
|
+
});
|
|
2079
|
+
var INFERRED_PREFERENCE_NAVIGATOR_STUB;
|
|
2080
|
+
var init_inferredPreference = __esm({
|
|
2081
|
+
"src/core/navigators/inferredPreference.ts"() {
|
|
2082
|
+
"use strict";
|
|
2083
|
+
INFERRED_PREFERENCE_NAVIGATOR_STUB = true;
|
|
2084
|
+
}
|
|
2085
|
+
});
|
|
2086
|
+
|
|
2087
|
+
// src/core/navigators/interferenceMitigator.ts
|
|
2088
|
+
var interferenceMitigator_exports = {};
|
|
2089
|
+
__export(interferenceMitigator_exports, {
|
|
2090
|
+
default: () => InterferenceMitigatorNavigator
|
|
2091
|
+
});
|
|
2092
|
+
var import_common8, DEFAULT_MIN_COUNT2, DEFAULT_MIN_ELAPSED_DAYS, DEFAULT_INTERFERENCE_DECAY, InterferenceMitigatorNavigator;
|
|
2093
|
+
var init_interferenceMitigator = __esm({
|
|
2094
|
+
"src/core/navigators/interferenceMitigator.ts"() {
|
|
2095
|
+
"use strict";
|
|
2096
|
+
init_navigators();
|
|
2097
|
+
import_common8 = require("@vue-skuilder/common");
|
|
2098
|
+
DEFAULT_MIN_COUNT2 = 10;
|
|
2099
|
+
DEFAULT_MIN_ELAPSED_DAYS = 3;
|
|
2100
|
+
DEFAULT_INTERFERENCE_DECAY = 0.8;
|
|
2101
|
+
InterferenceMitigatorNavigator = class extends ContentNavigator {
|
|
2102
|
+
config;
|
|
2103
|
+
_strategyData;
|
|
2104
|
+
/** Human-readable name for CardFilter interface */
|
|
2105
|
+
name;
|
|
2106
|
+
/** Precomputed map: tag -> set of { partner, decay } it interferes with */
|
|
2107
|
+
interferenceMap;
|
|
2108
|
+
constructor(user, course, _strategyData) {
|
|
2109
|
+
super(user, course, _strategyData);
|
|
2110
|
+
this._strategyData = _strategyData;
|
|
2111
|
+
this.config = this.parseConfig(_strategyData.serializedData);
|
|
2112
|
+
this.interferenceMap = this.buildInterferenceMap();
|
|
2113
|
+
this.name = _strategyData.name || "Interference Mitigator";
|
|
2114
|
+
}
|
|
2115
|
+
parseConfig(serializedData) {
|
|
2116
|
+
try {
|
|
2117
|
+
const parsed = JSON.parse(serializedData);
|
|
2118
|
+
let sets = parsed.interferenceSets || [];
|
|
2119
|
+
if (sets.length > 0 && Array.isArray(sets[0])) {
|
|
2120
|
+
sets = sets.map((tags) => ({ tags }));
|
|
2121
|
+
}
|
|
2122
|
+
return {
|
|
2123
|
+
interferenceSets: sets,
|
|
2124
|
+
maturityThreshold: {
|
|
2125
|
+
minCount: parsed.maturityThreshold?.minCount ?? DEFAULT_MIN_COUNT2,
|
|
2126
|
+
minElo: parsed.maturityThreshold?.minElo,
|
|
2127
|
+
minElapsedDays: parsed.maturityThreshold?.minElapsedDays ?? DEFAULT_MIN_ELAPSED_DAYS
|
|
2128
|
+
},
|
|
2129
|
+
defaultDecay: parsed.defaultDecay ?? DEFAULT_INTERFERENCE_DECAY
|
|
2130
|
+
};
|
|
2131
|
+
} catch {
|
|
2132
|
+
return {
|
|
2133
|
+
interferenceSets: [],
|
|
2134
|
+
maturityThreshold: {
|
|
2135
|
+
minCount: DEFAULT_MIN_COUNT2,
|
|
2136
|
+
minElapsedDays: DEFAULT_MIN_ELAPSED_DAYS
|
|
2137
|
+
},
|
|
2138
|
+
defaultDecay: DEFAULT_INTERFERENCE_DECAY
|
|
2139
|
+
};
|
|
2140
|
+
}
|
|
2141
|
+
}
|
|
2142
|
+
/**
|
|
2143
|
+
* Build a map from each tag to its interference partners with decay coefficients.
|
|
2144
|
+
* If tags A, B, C are in an interference group with decay 0.8, then:
|
|
2145
|
+
* - A interferes with B (decay 0.8) and C (decay 0.8)
|
|
2146
|
+
* - B interferes with A (decay 0.8) and C (decay 0.8)
|
|
2147
|
+
* - etc.
|
|
2148
|
+
*/
|
|
2149
|
+
buildInterferenceMap() {
|
|
2150
|
+
const map = /* @__PURE__ */ new Map();
|
|
2151
|
+
for (const group of this.config.interferenceSets) {
|
|
2152
|
+
const decay = group.decay ?? this.config.defaultDecay ?? DEFAULT_INTERFERENCE_DECAY;
|
|
2153
|
+
for (const tag of group.tags) {
|
|
2154
|
+
if (!map.has(tag)) {
|
|
2155
|
+
map.set(tag, []);
|
|
2156
|
+
}
|
|
2157
|
+
const partners = map.get(tag);
|
|
2158
|
+
for (const other of group.tags) {
|
|
2159
|
+
if (other !== tag) {
|
|
2160
|
+
const existing = partners.find((p) => p.partner === other);
|
|
2161
|
+
if (existing) {
|
|
2162
|
+
existing.decay = Math.max(existing.decay, decay);
|
|
2163
|
+
} else {
|
|
2164
|
+
partners.push({ partner: other, decay });
|
|
2165
|
+
}
|
|
2166
|
+
}
|
|
2167
|
+
}
|
|
2168
|
+
}
|
|
2169
|
+
}
|
|
2170
|
+
return map;
|
|
2171
|
+
}
|
|
2172
|
+
/**
|
|
2173
|
+
* Get the set of tags that are currently immature for this user.
|
|
2174
|
+
* A tag is immature if the user has interacted with it but hasn't
|
|
2175
|
+
* reached the maturity threshold.
|
|
2176
|
+
*/
|
|
2177
|
+
async getImmatureTags(context) {
|
|
2178
|
+
const immature = /* @__PURE__ */ new Set();
|
|
2179
|
+
try {
|
|
2180
|
+
const courseReg = await context.user.getCourseRegDoc(context.course.getCourseID());
|
|
2181
|
+
const userElo = (0, import_common8.toCourseElo)(courseReg.elo);
|
|
2182
|
+
const minCount = this.config.maturityThreshold?.minCount ?? DEFAULT_MIN_COUNT2;
|
|
2183
|
+
const minElo = this.config.maturityThreshold?.minElo;
|
|
2184
|
+
const minElapsedDays = this.config.maturityThreshold?.minElapsedDays ?? DEFAULT_MIN_ELAPSED_DAYS;
|
|
2185
|
+
const minCountForElapsed = minElapsedDays * 2;
|
|
2186
|
+
for (const [tagId, tagElo] of Object.entries(userElo.tags)) {
|
|
2187
|
+
if (tagElo.count === 0) continue;
|
|
2188
|
+
const belowCount = tagElo.count < minCount;
|
|
2189
|
+
const belowElo = minElo !== void 0 && tagElo.score < minElo;
|
|
2190
|
+
const belowElapsed = tagElo.count < minCountForElapsed;
|
|
2191
|
+
if (belowCount || belowElo || belowElapsed) {
|
|
2192
|
+
immature.add(tagId);
|
|
2193
|
+
}
|
|
2194
|
+
}
|
|
2195
|
+
} catch {
|
|
2196
|
+
}
|
|
2197
|
+
return immature;
|
|
2198
|
+
}
|
|
2199
|
+
/**
|
|
2200
|
+
* Get all tags that interfere with any immature tag, along with their decay coefficients.
|
|
2201
|
+
* These are the tags we want to avoid introducing.
|
|
2202
|
+
*/
|
|
2203
|
+
getTagsToAvoid(immatureTags) {
|
|
2204
|
+
const avoid = /* @__PURE__ */ new Map();
|
|
2205
|
+
for (const immatureTag of immatureTags) {
|
|
2206
|
+
const partners = this.interferenceMap.get(immatureTag);
|
|
2207
|
+
if (partners) {
|
|
2208
|
+
for (const { partner, decay } of partners) {
|
|
2209
|
+
if (!immatureTags.has(partner)) {
|
|
2210
|
+
const existing = avoid.get(partner) ?? 0;
|
|
2211
|
+
avoid.set(partner, Math.max(existing, decay));
|
|
2212
|
+
}
|
|
2213
|
+
}
|
|
2214
|
+
}
|
|
2215
|
+
}
|
|
2216
|
+
return avoid;
|
|
2217
|
+
}
|
|
2218
|
+
/**
|
|
2219
|
+
* Compute interference score reduction for a card.
|
|
2220
|
+
* Returns: { multiplier, interfering tags, reason }
|
|
2221
|
+
*/
|
|
2222
|
+
computeInterferenceEffect(cardTags, tagsToAvoid, immatureTags) {
|
|
2223
|
+
if (tagsToAvoid.size === 0) {
|
|
2224
|
+
return {
|
|
2225
|
+
multiplier: 1,
|
|
2226
|
+
interferingTags: [],
|
|
2227
|
+
reason: "No interference detected"
|
|
2228
|
+
};
|
|
2229
|
+
}
|
|
2230
|
+
let multiplier = 1;
|
|
2231
|
+
const interferingTags = [];
|
|
2232
|
+
for (const tag of cardTags) {
|
|
2233
|
+
const decay = tagsToAvoid.get(tag);
|
|
2234
|
+
if (decay !== void 0) {
|
|
2235
|
+
interferingTags.push(tag);
|
|
2236
|
+
multiplier *= 1 - decay;
|
|
2237
|
+
}
|
|
2238
|
+
}
|
|
2239
|
+
if (interferingTags.length === 0) {
|
|
2240
|
+
return {
|
|
2241
|
+
multiplier: 1,
|
|
2242
|
+
interferingTags: [],
|
|
2243
|
+
reason: "No interference detected"
|
|
2244
|
+
};
|
|
2245
|
+
}
|
|
2246
|
+
const causingTags = /* @__PURE__ */ new Set();
|
|
2247
|
+
for (const tag of interferingTags) {
|
|
2248
|
+
for (const immatureTag of immatureTags) {
|
|
2249
|
+
const partners = this.interferenceMap.get(immatureTag);
|
|
2250
|
+
if (partners?.some((p) => p.partner === tag)) {
|
|
2251
|
+
causingTags.add(immatureTag);
|
|
2252
|
+
}
|
|
2253
|
+
}
|
|
2254
|
+
}
|
|
2255
|
+
const reason = `Interferes with immature tags ${Array.from(causingTags).join(", ")} (tags: ${interferingTags.join(", ")}, multiplier: ${multiplier.toFixed(2)})`;
|
|
2256
|
+
return { multiplier, interferingTags, reason };
|
|
2257
|
+
}
|
|
2258
|
+
/**
|
|
2259
|
+
* CardFilter.transform implementation.
|
|
2260
|
+
*
|
|
2261
|
+
* Apply interference-aware scoring. Cards with tags that interfere with
|
|
2262
|
+
* immature learnings get reduced scores.
|
|
2263
|
+
*/
|
|
2264
|
+
async transform(cards, context) {
|
|
2265
|
+
const immatureTags = await this.getImmatureTags(context);
|
|
2266
|
+
const tagsToAvoid = this.getTagsToAvoid(immatureTags);
|
|
2267
|
+
const adjusted = [];
|
|
2268
|
+
for (const card of cards) {
|
|
2269
|
+
const cardTags = card.tags ?? [];
|
|
2270
|
+
const { multiplier, reason } = this.computeInterferenceEffect(
|
|
2271
|
+
cardTags,
|
|
2272
|
+
tagsToAvoid,
|
|
2273
|
+
immatureTags
|
|
2274
|
+
);
|
|
2275
|
+
const finalScore = card.score * multiplier;
|
|
2276
|
+
const action = multiplier < 1 ? "penalized" : multiplier > 1 ? "boosted" : "passed";
|
|
2277
|
+
adjusted.push({
|
|
2278
|
+
...card,
|
|
2279
|
+
score: finalScore,
|
|
2280
|
+
provenance: [
|
|
2281
|
+
...card.provenance,
|
|
2282
|
+
{
|
|
2283
|
+
strategy: "interferenceMitigator",
|
|
2284
|
+
strategyName: this.strategyName || this.name,
|
|
2285
|
+
strategyId: this.strategyId || "NAVIGATION_STRATEGY-interference",
|
|
2286
|
+
action,
|
|
2287
|
+
score: finalScore,
|
|
2288
|
+
reason
|
|
2289
|
+
}
|
|
2290
|
+
]
|
|
2291
|
+
});
|
|
2292
|
+
}
|
|
2293
|
+
return adjusted;
|
|
2294
|
+
}
|
|
2295
|
+
/**
|
|
2296
|
+
* Legacy getWeightedCards - now throws as filters should not be used as generators.
|
|
2297
|
+
*
|
|
2298
|
+
* Use transform() via Pipeline instead.
|
|
2299
|
+
*/
|
|
2300
|
+
async getWeightedCards(_limit) {
|
|
2301
|
+
throw new Error(
|
|
2302
|
+
"InterferenceMitigatorNavigator is a filter and should not be used as a generator. Use Pipeline with a generator and this filter via transform()."
|
|
2303
|
+
);
|
|
2304
|
+
}
|
|
2305
|
+
// Legacy methods - stub implementations since filters don't generate cards
|
|
2306
|
+
async getNewCards(_n) {
|
|
2307
|
+
return [];
|
|
2308
|
+
}
|
|
2309
|
+
async getPendingReviews() {
|
|
2310
|
+
return [];
|
|
2311
|
+
}
|
|
2312
|
+
};
|
|
2313
|
+
}
|
|
2314
|
+
});
|
|
2315
|
+
|
|
2316
|
+
// src/core/navigators/relativePriority.ts
|
|
2317
|
+
var relativePriority_exports = {};
|
|
2318
|
+
__export(relativePriority_exports, {
|
|
2319
|
+
default: () => RelativePriorityNavigator
|
|
2320
|
+
});
|
|
2321
|
+
var DEFAULT_PRIORITY, DEFAULT_PRIORITY_INFLUENCE, DEFAULT_COMBINE_MODE, RelativePriorityNavigator;
|
|
2322
|
+
var init_relativePriority = __esm({
|
|
2323
|
+
"src/core/navigators/relativePriority.ts"() {
|
|
2324
|
+
"use strict";
|
|
2325
|
+
init_navigators();
|
|
2326
|
+
DEFAULT_PRIORITY = 0.5;
|
|
2327
|
+
DEFAULT_PRIORITY_INFLUENCE = 0.5;
|
|
2328
|
+
DEFAULT_COMBINE_MODE = "max";
|
|
2329
|
+
RelativePriorityNavigator = class extends ContentNavigator {
|
|
2330
|
+
config;
|
|
2331
|
+
_strategyData;
|
|
2332
|
+
/** Human-readable name for CardFilter interface */
|
|
2333
|
+
name;
|
|
2334
|
+
constructor(user, course, _strategyData) {
|
|
2335
|
+
super(user, course, _strategyData);
|
|
2336
|
+
this._strategyData = _strategyData;
|
|
2337
|
+
this.config = this.parseConfig(_strategyData.serializedData);
|
|
2338
|
+
this.name = _strategyData.name || "Relative Priority";
|
|
2339
|
+
}
|
|
2340
|
+
parseConfig(serializedData) {
|
|
2341
|
+
try {
|
|
2342
|
+
const parsed = JSON.parse(serializedData);
|
|
2343
|
+
return {
|
|
2344
|
+
tagPriorities: parsed.tagPriorities || {},
|
|
2345
|
+
defaultPriority: parsed.defaultPriority ?? DEFAULT_PRIORITY,
|
|
2346
|
+
combineMode: parsed.combineMode ?? DEFAULT_COMBINE_MODE,
|
|
2347
|
+
priorityInfluence: parsed.priorityInfluence ?? DEFAULT_PRIORITY_INFLUENCE
|
|
2348
|
+
};
|
|
2349
|
+
} catch {
|
|
2350
|
+
return {
|
|
2351
|
+
tagPriorities: {},
|
|
2352
|
+
defaultPriority: DEFAULT_PRIORITY,
|
|
2353
|
+
combineMode: DEFAULT_COMBINE_MODE,
|
|
2354
|
+
priorityInfluence: DEFAULT_PRIORITY_INFLUENCE
|
|
2355
|
+
};
|
|
2356
|
+
}
|
|
2357
|
+
}
|
|
2358
|
+
/**
|
|
2359
|
+
* Look up the priority for a tag.
|
|
2360
|
+
*/
|
|
2361
|
+
getTagPriority(tagId) {
|
|
2362
|
+
return this.config.tagPriorities[tagId] ?? this.config.defaultPriority ?? DEFAULT_PRIORITY;
|
|
2363
|
+
}
|
|
2364
|
+
/**
|
|
2365
|
+
* Compute combined priority for a card based on its tags.
|
|
2366
|
+
*/
|
|
2367
|
+
computeCardPriority(cardTags) {
|
|
2368
|
+
if (cardTags.length === 0) {
|
|
2369
|
+
return this.config.defaultPriority ?? DEFAULT_PRIORITY;
|
|
2370
|
+
}
|
|
2371
|
+
const priorities = cardTags.map((tag) => this.getTagPriority(tag));
|
|
2372
|
+
switch (this.config.combineMode) {
|
|
2373
|
+
case "max":
|
|
2374
|
+
return Math.max(...priorities);
|
|
2375
|
+
case "min":
|
|
2376
|
+
return Math.min(...priorities);
|
|
2377
|
+
case "average":
|
|
2378
|
+
return priorities.reduce((sum, p) => sum + p, 0) / priorities.length;
|
|
2379
|
+
default:
|
|
2380
|
+
return Math.max(...priorities);
|
|
2381
|
+
}
|
|
2382
|
+
}
|
|
2383
|
+
/**
|
|
2384
|
+
* Compute boost factor based on priority.
|
|
2385
|
+
*
|
|
2386
|
+
* The formula: 1 + (priority - 0.5) * priorityInfluence
|
|
2387
|
+
*
|
|
2388
|
+
* This creates a multiplier centered around 1.0:
|
|
2389
|
+
* - Priority 1.0 with influence 0.5 → 1.25 (25% boost)
|
|
2390
|
+
* - Priority 0.5 with any influence → 1.00 (neutral)
|
|
2391
|
+
* - Priority 0.0 with influence 0.5 → 0.75 (25% reduction)
|
|
2392
|
+
*/
|
|
2393
|
+
computeBoostFactor(priority) {
|
|
2394
|
+
const influence = this.config.priorityInfluence ?? DEFAULT_PRIORITY_INFLUENCE;
|
|
2395
|
+
return 1 + (priority - 0.5) * influence;
|
|
2396
|
+
}
|
|
2397
|
+
/**
|
|
2398
|
+
* Build human-readable reason for priority adjustment.
|
|
2399
|
+
*/
|
|
2400
|
+
buildPriorityReason(cardTags, priority, boostFactor, finalScore) {
|
|
2401
|
+
if (cardTags.length === 0) {
|
|
2402
|
+
return `No tags, neutral priority (${priority.toFixed(2)})`;
|
|
2403
|
+
}
|
|
2404
|
+
const tagList = cardTags.slice(0, 3).join(", ");
|
|
2405
|
+
const more = cardTags.length > 3 ? ` (+${cardTags.length - 3} more)` : "";
|
|
2406
|
+
if (boostFactor === 1) {
|
|
2407
|
+
return `Neutral priority (${priority.toFixed(2)}) for tags: ${tagList}${more}`;
|
|
2408
|
+
} else if (boostFactor > 1) {
|
|
2409
|
+
return `High-priority tags: ${tagList}${more} (priority ${priority.toFixed(2)} \u2192 boost ${boostFactor.toFixed(2)}x \u2192 ${finalScore.toFixed(2)})`;
|
|
2410
|
+
} else {
|
|
2411
|
+
return `Low-priority tags: ${tagList}${more} (priority ${priority.toFixed(2)} \u2192 reduce ${boostFactor.toFixed(2)}x \u2192 ${finalScore.toFixed(2)})`;
|
|
2412
|
+
}
|
|
2413
|
+
}
|
|
2414
|
+
/**
|
|
2415
|
+
* CardFilter.transform implementation.
|
|
2416
|
+
*
|
|
2417
|
+
* Apply priority-adjusted scoring. Cards with high-priority tags get boosted,
|
|
2418
|
+
* cards with low-priority tags get reduced scores.
|
|
2419
|
+
*/
|
|
2420
|
+
async transform(cards, _context) {
|
|
2421
|
+
const adjusted = await Promise.all(
|
|
2422
|
+
cards.map(async (card) => {
|
|
2423
|
+
const cardTags = card.tags ?? [];
|
|
2424
|
+
const priority = this.computeCardPriority(cardTags);
|
|
2425
|
+
const boostFactor = this.computeBoostFactor(priority);
|
|
2426
|
+
const finalScore = Math.max(0, Math.min(1, card.score * boostFactor));
|
|
2427
|
+
const action = boostFactor > 1 ? "boosted" : boostFactor < 1 ? "penalized" : "passed";
|
|
2428
|
+
const reason = this.buildPriorityReason(cardTags, priority, boostFactor, finalScore);
|
|
2429
|
+
return {
|
|
2430
|
+
...card,
|
|
2431
|
+
score: finalScore,
|
|
2432
|
+
provenance: [
|
|
2433
|
+
...card.provenance,
|
|
2434
|
+
{
|
|
2435
|
+
strategy: "relativePriority",
|
|
2436
|
+
strategyName: this.strategyName || this.name,
|
|
2437
|
+
strategyId: this.strategyId || "NAVIGATION_STRATEGY-priority",
|
|
2438
|
+
action,
|
|
2439
|
+
score: finalScore,
|
|
2440
|
+
reason
|
|
2441
|
+
}
|
|
2442
|
+
]
|
|
2443
|
+
};
|
|
2444
|
+
})
|
|
2445
|
+
);
|
|
2446
|
+
return adjusted;
|
|
2447
|
+
}
|
|
2448
|
+
/**
|
|
2449
|
+
* Legacy getWeightedCards - now throws as filters should not be used as generators.
|
|
2450
|
+
*
|
|
2451
|
+
* Use transform() via Pipeline instead.
|
|
2452
|
+
*/
|
|
2453
|
+
async getWeightedCards(_limit) {
|
|
2454
|
+
throw new Error(
|
|
2455
|
+
"RelativePriorityNavigator is a filter and should not be used as a generator. Use Pipeline with a generator and this filter via transform()."
|
|
2456
|
+
);
|
|
2457
|
+
}
|
|
2458
|
+
// Legacy methods - stub implementations since filters don't generate cards
|
|
2459
|
+
async getNewCards(_n) {
|
|
2460
|
+
return [];
|
|
2461
|
+
}
|
|
2462
|
+
async getPendingReviews() {
|
|
2463
|
+
return [];
|
|
2464
|
+
}
|
|
2465
|
+
};
|
|
2466
|
+
}
|
|
2467
|
+
});
|
|
2468
|
+
|
|
2469
|
+
// src/core/navigators/srs.ts
|
|
2470
|
+
var srs_exports = {};
|
|
2471
|
+
__export(srs_exports, {
|
|
2472
|
+
default: () => SRSNavigator
|
|
2473
|
+
});
|
|
2474
|
+
var import_moment3, SRSNavigator;
|
|
2475
|
+
var init_srs = __esm({
|
|
2476
|
+
"src/core/navigators/srs.ts"() {
|
|
2477
|
+
"use strict";
|
|
2478
|
+
import_moment3 = __toESM(require("moment"), 1);
|
|
2479
|
+
init_navigators();
|
|
2480
|
+
SRSNavigator = class extends ContentNavigator {
|
|
2481
|
+
/** Human-readable name for CardGenerator interface */
|
|
2482
|
+
name;
|
|
2483
|
+
constructor(user, course, strategyData) {
|
|
2484
|
+
super(user, course, strategyData);
|
|
2485
|
+
this.name = strategyData?.name || "SRS";
|
|
2486
|
+
}
|
|
2487
|
+
/**
|
|
2488
|
+
* Get review cards scored by urgency.
|
|
2489
|
+
*
|
|
2490
|
+
* Score formula combines:
|
|
2491
|
+
* - Relative overdueness: hoursOverdue / intervalHours
|
|
2492
|
+
* - Interval recency: exponential decay favoring shorter intervals
|
|
2493
|
+
*
|
|
2494
|
+
* Cards not yet due are excluded (not scored as 0).
|
|
2495
|
+
*
|
|
2496
|
+
* This method supports both the legacy signature (limit only) and the
|
|
2497
|
+
* CardGenerator interface signature (limit, context).
|
|
2498
|
+
*
|
|
2499
|
+
* @param limit - Maximum number of cards to return
|
|
2500
|
+
* @param _context - Optional GeneratorContext (currently unused, but required for interface)
|
|
2501
|
+
*/
|
|
2502
|
+
async getWeightedCards(limit, _context) {
|
|
2503
|
+
if (!this.user || !this.course) {
|
|
2504
|
+
throw new Error("SRSNavigator requires user and course to be set");
|
|
2505
|
+
}
|
|
2506
|
+
const reviews = await this.user.getPendingReviews(this.course.getCourseID());
|
|
2507
|
+
const now = import_moment3.default.utc();
|
|
2508
|
+
const dueReviews = reviews.filter((r) => now.isAfter(import_moment3.default.utc(r.reviewTime)));
|
|
2509
|
+
const scored = dueReviews.map((review) => {
|
|
2510
|
+
const { score, reason } = this.computeUrgencyScore(review, now);
|
|
2511
|
+
return {
|
|
2512
|
+
cardId: review.cardId,
|
|
2513
|
+
courseId: review.courseId,
|
|
2514
|
+
score,
|
|
2515
|
+
provenance: [
|
|
2516
|
+
{
|
|
2517
|
+
strategy: "srs",
|
|
2518
|
+
strategyName: this.strategyName || this.name,
|
|
2519
|
+
strategyId: this.strategyId || "NAVIGATION_STRATEGY-SRS-default",
|
|
2520
|
+
action: "generated",
|
|
2521
|
+
score,
|
|
2522
|
+
reason
|
|
2523
|
+
}
|
|
2524
|
+
]
|
|
2525
|
+
};
|
|
2526
|
+
});
|
|
2527
|
+
return scored.sort((a, b) => b.score - a.score).slice(0, limit);
|
|
2528
|
+
}
|
|
2529
|
+
/**
|
|
2530
|
+
* Compute urgency score for a review card.
|
|
2531
|
+
*
|
|
2532
|
+
* Two factors:
|
|
2533
|
+
* 1. Relative overdueness = hoursOverdue / intervalHours
|
|
2534
|
+
* - 2 days overdue on 3-day interval = 0.67 (urgent)
|
|
2535
|
+
* - 2 days overdue on 180-day interval = 0.01 (not urgent)
|
|
2536
|
+
*
|
|
2537
|
+
* 2. Interval recency factor = 0.3 + 0.7 * exp(-intervalHours / 720)
|
|
2538
|
+
* - 24h interval → ~1.0 (very recent learning)
|
|
2539
|
+
* - 30 days (720h) → ~0.56
|
|
2540
|
+
* - 180 days → ~0.30
|
|
2541
|
+
*
|
|
2542
|
+
* Combined: base 0.5 + weighted average of factors * 0.45
|
|
2543
|
+
* Result range: approximately 0.5 to 0.95
|
|
2544
|
+
*/
|
|
2545
|
+
computeUrgencyScore(review, now) {
|
|
2546
|
+
const scheduledAt = import_moment3.default.utc(review.scheduledAt);
|
|
2547
|
+
const due = import_moment3.default.utc(review.reviewTime);
|
|
2548
|
+
const intervalHours = Math.max(1, due.diff(scheduledAt, "hours"));
|
|
2549
|
+
const hoursOverdue = now.diff(due, "hours");
|
|
2550
|
+
const relativeOverdue = hoursOverdue / intervalHours;
|
|
2551
|
+
const recencyFactor = 0.3 + 0.7 * Math.exp(-intervalHours / 720);
|
|
2552
|
+
const overdueContribution = Math.min(1, Math.max(0, relativeOverdue));
|
|
2553
|
+
const urgency = overdueContribution * 0.5 + recencyFactor * 0.5;
|
|
2554
|
+
const score = Math.min(0.95, 0.5 + urgency * 0.45);
|
|
2555
|
+
const reason = `${Math.round(hoursOverdue)}h overdue (interval: ${Math.round(intervalHours)}h, relative: ${relativeOverdue.toFixed(2)}), recency: ${recencyFactor.toFixed(2)}, review`;
|
|
2556
|
+
return { score, reason };
|
|
2557
|
+
}
|
|
2558
|
+
/**
|
|
2559
|
+
* Get pending reviews in legacy format.
|
|
2560
|
+
*
|
|
2561
|
+
* Returns all pending reviews for the course, enriched with session item fields.
|
|
2562
|
+
*/
|
|
2563
|
+
async getPendingReviews() {
|
|
2564
|
+
if (!this.user || !this.course) {
|
|
2565
|
+
throw new Error("SRSNavigator requires user and course to be set");
|
|
2566
|
+
}
|
|
2567
|
+
const reviews = await this.user.getPendingReviews(this.course.getCourseID());
|
|
2568
|
+
return reviews.map((r) => ({
|
|
2569
|
+
...r,
|
|
2570
|
+
contentSourceType: "course",
|
|
2571
|
+
contentSourceID: this.course.getCourseID(),
|
|
2572
|
+
cardID: r.cardId,
|
|
2573
|
+
courseID: r.courseId,
|
|
2574
|
+
qualifiedID: `${r.courseId}-${r.cardId}`,
|
|
2575
|
+
reviewID: r._id,
|
|
2576
|
+
status: "review"
|
|
2577
|
+
}));
|
|
2578
|
+
}
|
|
2579
|
+
/**
|
|
2580
|
+
* SRS does not generate new cards.
|
|
2581
|
+
* Use ELONavigator or another generator for new cards.
|
|
2582
|
+
*/
|
|
2583
|
+
async getNewCards(_n) {
|
|
2584
|
+
return [];
|
|
2585
|
+
}
|
|
2586
|
+
};
|
|
2587
|
+
}
|
|
2588
|
+
});
|
|
2589
|
+
|
|
2590
|
+
// src/core/navigators/userGoal.ts
|
|
2591
|
+
var userGoal_exports = {};
|
|
2592
|
+
__export(userGoal_exports, {
|
|
2593
|
+
USER_GOAL_NAVIGATOR_STUB: () => USER_GOAL_NAVIGATOR_STUB
|
|
2594
|
+
});
|
|
2595
|
+
var USER_GOAL_NAVIGATOR_STUB;
|
|
2596
|
+
var init_userGoal = __esm({
|
|
2597
|
+
"src/core/navigators/userGoal.ts"() {
|
|
2598
|
+
"use strict";
|
|
2599
|
+
USER_GOAL_NAVIGATOR_STUB = true;
|
|
2600
|
+
}
|
|
2601
|
+
});
|
|
2602
|
+
|
|
1075
2603
|
// import("./**/*") in src/core/navigators/index.ts
|
|
1076
2604
|
var globImport;
|
|
1077
2605
|
var init_ = __esm({
|
|
1078
2606
|
'import("./**/*") in src/core/navigators/index.ts'() {
|
|
1079
2607
|
globImport = __glob({
|
|
2608
|
+
"./CompositeGenerator.ts": () => Promise.resolve().then(() => (init_CompositeGenerator(), CompositeGenerator_exports)),
|
|
2609
|
+
"./Pipeline.ts": () => Promise.resolve().then(() => (init_Pipeline(), Pipeline_exports)),
|
|
2610
|
+
"./PipelineAssembler.ts": () => Promise.resolve().then(() => (init_PipelineAssembler(), PipelineAssembler_exports)),
|
|
1080
2611
|
"./elo.ts": () => Promise.resolve().then(() => (init_elo(), elo_exports)),
|
|
2612
|
+
"./filters/eloDistance.ts": () => Promise.resolve().then(() => (init_eloDistance(), eloDistance_exports)),
|
|
2613
|
+
"./filters/index.ts": () => Promise.resolve().then(() => (init_filters(), filters_exports)),
|
|
2614
|
+
"./filters/types.ts": () => Promise.resolve().then(() => (init_types(), types_exports)),
|
|
2615
|
+
"./filters/userTagPreference.ts": () => Promise.resolve().then(() => (init_userTagPreference(), userTagPreference_exports)),
|
|
2616
|
+
"./generators/index.ts": () => Promise.resolve().then(() => (init_generators(), generators_exports)),
|
|
2617
|
+
"./generators/types.ts": () => Promise.resolve().then(() => (init_types2(), types_exports2)),
|
|
1081
2618
|
"./hardcodedOrder.ts": () => Promise.resolve().then(() => (init_hardcodedOrder(), hardcodedOrder_exports)),
|
|
1082
|
-
"./
|
|
2619
|
+
"./hierarchyDefinition.ts": () => Promise.resolve().then(() => (init_hierarchyDefinition(), hierarchyDefinition_exports)),
|
|
2620
|
+
"./index.ts": () => Promise.resolve().then(() => (init_navigators(), navigators_exports)),
|
|
2621
|
+
"./inferredPreference.ts": () => Promise.resolve().then(() => (init_inferredPreference(), inferredPreference_exports)),
|
|
2622
|
+
"./interferenceMitigator.ts": () => Promise.resolve().then(() => (init_interferenceMitigator(), interferenceMitigator_exports)),
|
|
2623
|
+
"./relativePriority.ts": () => Promise.resolve().then(() => (init_relativePriority(), relativePriority_exports)),
|
|
2624
|
+
"./srs.ts": () => Promise.resolve().then(() => (init_srs(), srs_exports)),
|
|
2625
|
+
"./userGoal.ts": () => Promise.resolve().then(() => (init_userGoal(), userGoal_exports))
|
|
1083
2626
|
});
|
|
1084
2627
|
}
|
|
1085
2628
|
});
|
|
@@ -1088,9 +2631,34 @@ var init_ = __esm({
|
|
|
1088
2631
|
var navigators_exports = {};
|
|
1089
2632
|
__export(navigators_exports, {
|
|
1090
2633
|
ContentNavigator: () => ContentNavigator,
|
|
1091
|
-
|
|
2634
|
+
NavigatorRole: () => NavigatorRole,
|
|
2635
|
+
NavigatorRoles: () => NavigatorRoles,
|
|
2636
|
+
Navigators: () => Navigators,
|
|
2637
|
+
getCardOrigin: () => getCardOrigin,
|
|
2638
|
+
isFilter: () => isFilter,
|
|
2639
|
+
isGenerator: () => isGenerator
|
|
1092
2640
|
});
|
|
1093
|
-
|
|
2641
|
+
function getCardOrigin(card) {
|
|
2642
|
+
if (card.provenance.length === 0) {
|
|
2643
|
+
throw new Error("Card has no provenance - cannot determine origin");
|
|
2644
|
+
}
|
|
2645
|
+
const firstEntry = card.provenance[0];
|
|
2646
|
+
const reason = firstEntry.reason.toLowerCase();
|
|
2647
|
+
if (reason.includes("failed")) {
|
|
2648
|
+
return "failed";
|
|
2649
|
+
}
|
|
2650
|
+
if (reason.includes("review")) {
|
|
2651
|
+
return "review";
|
|
2652
|
+
}
|
|
2653
|
+
return "new";
|
|
2654
|
+
}
|
|
2655
|
+
function isGenerator(impl) {
|
|
2656
|
+
return NavigatorRoles[impl] === "generator" /* GENERATOR */;
|
|
2657
|
+
}
|
|
2658
|
+
function isFilter(impl) {
|
|
2659
|
+
return NavigatorRoles[impl] === "filter" /* FILTER */;
|
|
2660
|
+
}
|
|
2661
|
+
var Navigators, NavigatorRole, NavigatorRoles, ContentNavigator;
|
|
1094
2662
|
var init_navigators = __esm({
|
|
1095
2663
|
"src/core/navigators/index.ts"() {
|
|
1096
2664
|
"use strict";
|
|
@@ -1098,14 +2666,103 @@ var init_navigators = __esm({
|
|
|
1098
2666
|
init_();
|
|
1099
2667
|
Navigators = /* @__PURE__ */ ((Navigators2) => {
|
|
1100
2668
|
Navigators2["ELO"] = "elo";
|
|
2669
|
+
Navigators2["SRS"] = "srs";
|
|
1101
2670
|
Navigators2["HARDCODED"] = "hardcodedOrder";
|
|
2671
|
+
Navigators2["HIERARCHY"] = "hierarchyDefinition";
|
|
2672
|
+
Navigators2["INTERFERENCE"] = "interferenceMitigator";
|
|
2673
|
+
Navigators2["RELATIVE_PRIORITY"] = "relativePriority";
|
|
2674
|
+
Navigators2["USER_TAG_PREFERENCE"] = "userTagPreference";
|
|
1102
2675
|
return Navigators2;
|
|
1103
2676
|
})(Navigators || {});
|
|
2677
|
+
NavigatorRole = /* @__PURE__ */ ((NavigatorRole2) => {
|
|
2678
|
+
NavigatorRole2["GENERATOR"] = "generator";
|
|
2679
|
+
NavigatorRole2["FILTER"] = "filter";
|
|
2680
|
+
return NavigatorRole2;
|
|
2681
|
+
})(NavigatorRole || {});
|
|
2682
|
+
NavigatorRoles = {
|
|
2683
|
+
["elo" /* ELO */]: "generator" /* GENERATOR */,
|
|
2684
|
+
["srs" /* SRS */]: "generator" /* GENERATOR */,
|
|
2685
|
+
["hardcodedOrder" /* HARDCODED */]: "generator" /* GENERATOR */,
|
|
2686
|
+
["hierarchyDefinition" /* HIERARCHY */]: "filter" /* FILTER */,
|
|
2687
|
+
["interferenceMitigator" /* INTERFERENCE */]: "filter" /* FILTER */,
|
|
2688
|
+
["relativePriority" /* RELATIVE_PRIORITY */]: "filter" /* FILTER */,
|
|
2689
|
+
["userTagPreference" /* USER_TAG_PREFERENCE */]: "filter" /* FILTER */
|
|
2690
|
+
};
|
|
1104
2691
|
ContentNavigator = class {
|
|
2692
|
+
/** User interface for this navigation session */
|
|
2693
|
+
user;
|
|
2694
|
+
/** Course interface for this navigation session */
|
|
2695
|
+
course;
|
|
2696
|
+
/** Human-readable name for this strategy instance (from ContentNavigationStrategyData.name) */
|
|
2697
|
+
strategyName;
|
|
2698
|
+
/** Unique document ID for this strategy instance (from ContentNavigationStrategyData._id) */
|
|
2699
|
+
strategyId;
|
|
2700
|
+
/**
|
|
2701
|
+
* Constructor for standard navigators.
|
|
2702
|
+
* Call this from subclass constructors to initialize common fields.
|
|
2703
|
+
*
|
|
2704
|
+
* Note: CompositeGenerator doesn't use this pattern and should call super() without args.
|
|
2705
|
+
*/
|
|
2706
|
+
constructor(user, course, strategyData) {
|
|
2707
|
+
if (user && course && strategyData) {
|
|
2708
|
+
this.user = user;
|
|
2709
|
+
this.course = course;
|
|
2710
|
+
this.strategyName = strategyData.name;
|
|
2711
|
+
this.strategyId = strategyData._id;
|
|
2712
|
+
}
|
|
2713
|
+
}
|
|
2714
|
+
// ============================================================================
|
|
2715
|
+
// STRATEGY STATE HELPERS
|
|
2716
|
+
// ============================================================================
|
|
2717
|
+
//
|
|
2718
|
+
// These methods allow strategies to persist their own state (user preferences,
|
|
2719
|
+
// learned patterns, temporal tracking) in the user database.
|
|
2720
|
+
//
|
|
2721
|
+
// ============================================================================
|
|
2722
|
+
/**
|
|
2723
|
+
* Unique key identifying this strategy for state storage.
|
|
2724
|
+
*
|
|
2725
|
+
* Defaults to the constructor name (e.g., "UserTagPreferenceFilter").
|
|
2726
|
+
* Override in subclasses if multiple instances of the same strategy type
|
|
2727
|
+
* need separate state storage.
|
|
2728
|
+
*/
|
|
2729
|
+
get strategyKey() {
|
|
2730
|
+
return this.constructor.name;
|
|
2731
|
+
}
|
|
2732
|
+
/**
|
|
2733
|
+
* Get this strategy's persisted state for the current course.
|
|
2734
|
+
*
|
|
2735
|
+
* @returns The strategy's data payload, or null if no state exists
|
|
2736
|
+
* @throws Error if user or course is not initialized
|
|
2737
|
+
*/
|
|
2738
|
+
async getStrategyState() {
|
|
2739
|
+
if (!this.user || !this.course) {
|
|
2740
|
+
throw new Error(
|
|
2741
|
+
`Cannot get strategy state: navigator not properly initialized. Ensure user and course are provided to constructor.`
|
|
2742
|
+
);
|
|
2743
|
+
}
|
|
2744
|
+
return this.user.getStrategyState(this.course.getCourseID(), this.strategyKey);
|
|
2745
|
+
}
|
|
2746
|
+
/**
|
|
2747
|
+
* Persist this strategy's state for the current course.
|
|
2748
|
+
*
|
|
2749
|
+
* @param data - The strategy's data payload to store
|
|
2750
|
+
* @throws Error if user or course is not initialized
|
|
2751
|
+
*/
|
|
2752
|
+
async putStrategyState(data) {
|
|
2753
|
+
if (!this.user || !this.course) {
|
|
2754
|
+
throw new Error(
|
|
2755
|
+
`Cannot put strategy state: navigator not properly initialized. Ensure user and course are provided to constructor.`
|
|
2756
|
+
);
|
|
2757
|
+
}
|
|
2758
|
+
return this.user.putStrategyState(this.course.getCourseID(), this.strategyKey, data);
|
|
2759
|
+
}
|
|
1105
2760
|
/**
|
|
2761
|
+
* Factory method to create navigator instances dynamically.
|
|
1106
2762
|
*
|
|
1107
|
-
* @param user
|
|
1108
|
-
* @param
|
|
2763
|
+
* @param user - User interface
|
|
2764
|
+
* @param course - Course interface
|
|
2765
|
+
* @param strategyData - Strategy configuration document
|
|
1109
2766
|
* @returns the runtime object used to steer a study session.
|
|
1110
2767
|
*/
|
|
1111
2768
|
static async create(user, course, strategyData) {
|
|
@@ -1126,6 +2783,70 @@ var init_navigators = __esm({
|
|
|
1126
2783
|
}
|
|
1127
2784
|
return new NavigatorImpl(user, course, strategyData);
|
|
1128
2785
|
}
|
|
2786
|
+
/**
|
|
2787
|
+
* Get cards with suitability scores and provenance trails.
|
|
2788
|
+
*
|
|
2789
|
+
* **This is the PRIMARY API for navigation strategies.**
|
|
2790
|
+
*
|
|
2791
|
+
* Returns cards ranked by suitability score (0-1). Higher scores indicate
|
|
2792
|
+
* better candidates for presentation. Each card includes a provenance trail
|
|
2793
|
+
* documenting how strategies contributed to the final score.
|
|
2794
|
+
*
|
|
2795
|
+
* ## For Generators
|
|
2796
|
+
* Override this method to generate candidates and compute scores based on
|
|
2797
|
+
* your strategy's logic (e.g., ELO proximity, review urgency). Create the
|
|
2798
|
+
* initial provenance entry with action='generated'.
|
|
2799
|
+
*
|
|
2800
|
+
* ## Default Implementation
|
|
2801
|
+
* The base class provides a backward-compatible default that:
|
|
2802
|
+
* 1. Calls legacy getNewCards() and getPendingReviews()
|
|
2803
|
+
* 2. Assigns score=1.0 to all cards
|
|
2804
|
+
* 3. Creates minimal provenance from legacy methods
|
|
2805
|
+
* 4. Returns combined results up to limit
|
|
2806
|
+
*
|
|
2807
|
+
* This allows existing strategies to work without modification while
|
|
2808
|
+
* new strategies can override with proper scoring and provenance.
|
|
2809
|
+
*
|
|
2810
|
+
* @param limit - Maximum cards to return
|
|
2811
|
+
* @returns Cards sorted by score descending, with provenance trails
|
|
2812
|
+
*/
|
|
2813
|
+
async getWeightedCards(limit) {
|
|
2814
|
+
const newCards = await this.getNewCards(limit);
|
|
2815
|
+
const reviews = await this.getPendingReviews();
|
|
2816
|
+
const weighted = [
|
|
2817
|
+
...newCards.map((c) => ({
|
|
2818
|
+
cardId: c.cardID,
|
|
2819
|
+
courseId: c.courseID,
|
|
2820
|
+
score: 1,
|
|
2821
|
+
provenance: [
|
|
2822
|
+
{
|
|
2823
|
+
strategy: "legacy",
|
|
2824
|
+
strategyName: this.strategyName || "Legacy API",
|
|
2825
|
+
strategyId: this.strategyId || "legacy-fallback",
|
|
2826
|
+
action: "generated",
|
|
2827
|
+
score: 1,
|
|
2828
|
+
reason: "Generated via legacy getNewCards(), new card"
|
|
2829
|
+
}
|
|
2830
|
+
]
|
|
2831
|
+
})),
|
|
2832
|
+
...reviews.map((r) => ({
|
|
2833
|
+
cardId: r.cardID,
|
|
2834
|
+
courseId: r.courseID,
|
|
2835
|
+
score: 1,
|
|
2836
|
+
provenance: [
|
|
2837
|
+
{
|
|
2838
|
+
strategy: "legacy",
|
|
2839
|
+
strategyName: this.strategyName || "Legacy API",
|
|
2840
|
+
strategyId: this.strategyId || "legacy-fallback",
|
|
2841
|
+
action: "generated",
|
|
2842
|
+
score: 1,
|
|
2843
|
+
reason: "Generated via legacy getPendingReviews(), review"
|
|
2844
|
+
}
|
|
2845
|
+
]
|
|
2846
|
+
}))
|
|
2847
|
+
];
|
|
2848
|
+
return weighted.slice(0, limit);
|
|
2849
|
+
}
|
|
1129
2850
|
};
|
|
1130
2851
|
}
|
|
1131
2852
|
});
|
|
@@ -1206,11 +2927,11 @@ ${JSON.stringify(config)}
|
|
|
1206
2927
|
function isSuccessRow(row) {
|
|
1207
2928
|
return "doc" in row && row.doc !== null && row.doc !== void 0;
|
|
1208
2929
|
}
|
|
1209
|
-
var
|
|
2930
|
+
var import_common9, CoursesDB, CourseDB;
|
|
1210
2931
|
var init_courseDB = __esm({
|
|
1211
2932
|
"src/impl/couch/courseDB.ts"() {
|
|
1212
2933
|
"use strict";
|
|
1213
|
-
|
|
2934
|
+
import_common9 = require("@vue-skuilder/common");
|
|
1214
2935
|
init_couch();
|
|
1215
2936
|
init_updateQueue();
|
|
1216
2937
|
init_types_legacy();
|
|
@@ -1219,6 +2940,12 @@ var init_courseDB = __esm({
|
|
|
1219
2940
|
init_courseAPI();
|
|
1220
2941
|
init_courseLookupDB();
|
|
1221
2942
|
init_navigators();
|
|
2943
|
+
init_Pipeline();
|
|
2944
|
+
init_PipelineAssembler();
|
|
2945
|
+
init_CompositeGenerator();
|
|
2946
|
+
init_elo();
|
|
2947
|
+
init_srs();
|
|
2948
|
+
init_eloDistance();
|
|
1222
2949
|
CoursesDB = class {
|
|
1223
2950
|
_courseIDs;
|
|
1224
2951
|
constructor(courseIDs) {
|
|
@@ -1330,14 +3057,14 @@ var init_courseDB = __esm({
|
|
|
1330
3057
|
docs.rows.forEach((r) => {
|
|
1331
3058
|
if (isSuccessRow(r)) {
|
|
1332
3059
|
if (r.doc && r.doc.elo) {
|
|
1333
|
-
ret.push((0,
|
|
3060
|
+
ret.push((0, import_common9.toCourseElo)(r.doc.elo));
|
|
1334
3061
|
} else {
|
|
1335
3062
|
logger.warn("no elo data for card: " + r.id);
|
|
1336
|
-
ret.push((0,
|
|
3063
|
+
ret.push((0, import_common9.blankCourseElo)());
|
|
1337
3064
|
}
|
|
1338
3065
|
} else {
|
|
1339
3066
|
logger.warn("no elo data for card: " + JSON.stringify(r));
|
|
1340
|
-
ret.push((0,
|
|
3067
|
+
ret.push((0, import_common9.blankCourseElo)());
|
|
1341
3068
|
}
|
|
1342
3069
|
});
|
|
1343
3070
|
return ret;
|
|
@@ -1399,15 +3126,6 @@ var init_courseDB = __esm({
|
|
|
1399
3126
|
ret[r.id] = r.doc.id_displayable_data;
|
|
1400
3127
|
}
|
|
1401
3128
|
});
|
|
1402
|
-
await Promise.all(
|
|
1403
|
-
cards.rows.map((r) => {
|
|
1404
|
-
return async () => {
|
|
1405
|
-
if (isSuccessRow(r)) {
|
|
1406
|
-
ret[r.id] = r.doc.id_displayable_data;
|
|
1407
|
-
}
|
|
1408
|
-
};
|
|
1409
|
-
})
|
|
1410
|
-
);
|
|
1411
3129
|
return ret;
|
|
1412
3130
|
}
|
|
1413
3131
|
async getCardsByELO(elo, cardLimit) {
|
|
@@ -1492,6 +3210,28 @@ ${above.rows.map((r) => ` ${r.id}-${r.key}
|
|
|
1492
3210
|
throw new Error(`Failed to find tags for card ${this.id}-${cardId}`);
|
|
1493
3211
|
}
|
|
1494
3212
|
}
|
|
3213
|
+
async getAppliedTagsBatch(cardIds) {
|
|
3214
|
+
if (cardIds.length === 0) {
|
|
3215
|
+
return /* @__PURE__ */ new Map();
|
|
3216
|
+
}
|
|
3217
|
+
const db = getCourseDB2(this.id);
|
|
3218
|
+
const result = await db.query("getTags", {
|
|
3219
|
+
keys: cardIds,
|
|
3220
|
+
include_docs: false
|
|
3221
|
+
});
|
|
3222
|
+
const tagsByCard = /* @__PURE__ */ new Map();
|
|
3223
|
+
for (const cardId of cardIds) {
|
|
3224
|
+
tagsByCard.set(cardId, []);
|
|
3225
|
+
}
|
|
3226
|
+
for (const row of result.rows) {
|
|
3227
|
+
const cardId = row.key;
|
|
3228
|
+
const tagName = row.value?.name;
|
|
3229
|
+
if (tagName && tagsByCard.has(cardId)) {
|
|
3230
|
+
tagsByCard.get(cardId).push(tagName);
|
|
3231
|
+
}
|
|
3232
|
+
}
|
|
3233
|
+
return tagsByCard;
|
|
3234
|
+
}
|
|
1495
3235
|
async addTagToCard(cardId, tagId, updateELO) {
|
|
1496
3236
|
return await addTagToCard(
|
|
1497
3237
|
this.id,
|
|
@@ -1519,7 +3259,7 @@ ${above.rows.map((r) => ` ${r.id}-${r.key}
|
|
|
1519
3259
|
async getCourseTagStubs() {
|
|
1520
3260
|
return getCourseTagStubs(this.id);
|
|
1521
3261
|
}
|
|
1522
|
-
async addNote(codeCourse, shape, data, author, tags, uploads, elo = (0,
|
|
3262
|
+
async addNote(codeCourse, shape, data, author, tags, uploads, elo = (0, import_common9.blankCourseElo)()) {
|
|
1523
3263
|
try {
|
|
1524
3264
|
const resp = await addNote55(this.id, codeCourse, shape, data, author, tags, uploads, elo);
|
|
1525
3265
|
if (resp.ok) {
|
|
@@ -1528,19 +3268,19 @@ ${above.rows.map((r) => ` ${r.id}-${r.key}
|
|
|
1528
3268
|
`[courseDB.addNote] Note added but card creation failed: ${resp.cardCreationError}`
|
|
1529
3269
|
);
|
|
1530
3270
|
return {
|
|
1531
|
-
status:
|
|
3271
|
+
status: import_common9.Status.error,
|
|
1532
3272
|
message: `Note was added but no cards were created: ${resp.cardCreationError}`,
|
|
1533
3273
|
id: resp.id
|
|
1534
3274
|
};
|
|
1535
3275
|
}
|
|
1536
3276
|
return {
|
|
1537
|
-
status:
|
|
3277
|
+
status: import_common9.Status.ok,
|
|
1538
3278
|
message: "",
|
|
1539
3279
|
id: resp.id
|
|
1540
3280
|
};
|
|
1541
3281
|
} else {
|
|
1542
3282
|
return {
|
|
1543
|
-
status:
|
|
3283
|
+
status: import_common9.Status.error,
|
|
1544
3284
|
message: "Unexpected error adding note"
|
|
1545
3285
|
};
|
|
1546
3286
|
}
|
|
@@ -1552,7 +3292,7 @@ ${above.rows.map((r) => ` ${r.id}-${r.key}
|
|
|
1552
3292
|
message: ${err.message}`
|
|
1553
3293
|
);
|
|
1554
3294
|
return {
|
|
1555
|
-
status:
|
|
3295
|
+
status: import_common9.Status.error,
|
|
1556
3296
|
message: `Error adding note to course. ${e.reason || err.message}`
|
|
1557
3297
|
};
|
|
1558
3298
|
}
|
|
@@ -1603,42 +3343,82 @@ ${above.rows.map((r) => ` ${r.id}-${r.key}
|
|
|
1603
3343
|
logger.debug(JSON.stringify(data));
|
|
1604
3344
|
return Promise.resolve();
|
|
1605
3345
|
}
|
|
1606
|
-
|
|
3346
|
+
/**
|
|
3347
|
+
* Creates an instantiated navigator for this course.
|
|
3348
|
+
*
|
|
3349
|
+
* Handles multiple generators by wrapping them in CompositeGenerator.
|
|
3350
|
+
* This is the preferred method for getting a ready-to-use navigator.
|
|
3351
|
+
*
|
|
3352
|
+
* @param user - User database interface
|
|
3353
|
+
* @returns Instantiated ContentNavigator ready for use
|
|
3354
|
+
*/
|
|
3355
|
+
async createNavigator(user) {
|
|
1607
3356
|
try {
|
|
1608
|
-
const
|
|
1609
|
-
if (
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
return strategy;
|
|
1615
|
-
}
|
|
1616
|
-
} catch (e) {
|
|
1617
|
-
logger.warn(
|
|
1618
|
-
// @ts-expect-error tmp: defaultNavigationStrategyId property does not yet exist
|
|
1619
|
-
`Failed to load strategy '${config.defaultNavigationStrategyId}' specified in course config. Falling back to ELO.`,
|
|
1620
|
-
e
|
|
1621
|
-
);
|
|
1622
|
-
}
|
|
3357
|
+
const allStrategies = await this.getAllNavigationStrategies();
|
|
3358
|
+
if (allStrategies.length === 0) {
|
|
3359
|
+
logger.debug(
|
|
3360
|
+
"[courseDB] No strategy documents found, using default Pipeline(Composite(ELO, SRS), [eloDistanceFilter])"
|
|
3361
|
+
);
|
|
3362
|
+
return this.createDefaultPipeline(user);
|
|
1623
3363
|
}
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
3364
|
+
const assembler = new PipelineAssembler();
|
|
3365
|
+
const { pipeline, generatorStrategies, filterStrategies, warnings } = await assembler.assemble({
|
|
3366
|
+
strategies: allStrategies,
|
|
3367
|
+
user,
|
|
3368
|
+
course: this
|
|
3369
|
+
});
|
|
3370
|
+
for (const warning of warnings) {
|
|
3371
|
+
logger.warn(`[PipelineAssembler] ${warning}`);
|
|
3372
|
+
}
|
|
3373
|
+
if (!pipeline) {
|
|
3374
|
+
logger.debug("[courseDB] Pipeline assembly failed, using default pipeline");
|
|
3375
|
+
return this.createDefaultPipeline(user);
|
|
3376
|
+
}
|
|
3377
|
+
logger.debug(
|
|
3378
|
+
`[courseDB] Using assembled pipeline with ${generatorStrategies.length} generator(s) and ${filterStrategies.length} filter(s)`
|
|
1628
3379
|
);
|
|
3380
|
+
return pipeline;
|
|
3381
|
+
} catch (e) {
|
|
3382
|
+
logger.error(`[courseDB] Error creating navigator: ${e}`);
|
|
3383
|
+
throw e;
|
|
1629
3384
|
}
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
3385
|
+
}
|
|
3386
|
+
makeDefaultEloStrategy() {
|
|
3387
|
+
return {
|
|
3388
|
+
_id: "NAVIGATION_STRATEGY-ELO-default",
|
|
1633
3389
|
docType: "NAVIGATION_STRATEGY" /* NAVIGATION_STRATEGY */,
|
|
1634
|
-
name: "ELO",
|
|
1635
|
-
description: "ELO-based navigation strategy",
|
|
3390
|
+
name: "ELO (default)",
|
|
3391
|
+
description: "Default ELO-based navigation strategy for new cards",
|
|
1636
3392
|
implementingClass: "elo" /* ELO */,
|
|
1637
3393
|
course: this.id,
|
|
1638
3394
|
serializedData: ""
|
|
1639
|
-
// serde is a noop for ELO navigator.
|
|
1640
3395
|
};
|
|
1641
|
-
|
|
3396
|
+
}
|
|
3397
|
+
makeDefaultSrsStrategy() {
|
|
3398
|
+
return {
|
|
3399
|
+
_id: "NAVIGATION_STRATEGY-SRS-default",
|
|
3400
|
+
docType: "NAVIGATION_STRATEGY" /* NAVIGATION_STRATEGY */,
|
|
3401
|
+
name: "SRS (default)",
|
|
3402
|
+
description: "Default SRS-based navigation strategy for reviews",
|
|
3403
|
+
implementingClass: "srs" /* SRS */,
|
|
3404
|
+
course: this.id,
|
|
3405
|
+
serializedData: ""
|
|
3406
|
+
};
|
|
3407
|
+
}
|
|
3408
|
+
/**
|
|
3409
|
+
* Creates the default navigation pipeline for courses with no configured strategies.
|
|
3410
|
+
*
|
|
3411
|
+
* Default: Pipeline(Composite(ELO, SRS), [eloDistanceFilter])
|
|
3412
|
+
* - ELO generator: scores new cards by skill proximity
|
|
3413
|
+
* - SRS generator: scores reviews by overdueness and interval recency
|
|
3414
|
+
* - ELO distance filter: penalizes cards far from user's current level
|
|
3415
|
+
*/
|
|
3416
|
+
createDefaultPipeline(user) {
|
|
3417
|
+
const eloNavigator = new ELONavigator(user, this, this.makeDefaultEloStrategy());
|
|
3418
|
+
const srsNavigator = new SRSNavigator(user, this, this.makeDefaultSrsStrategy());
|
|
3419
|
+
const compositeGenerator = new CompositeGenerator([eloNavigator, srsNavigator]);
|
|
3420
|
+
const eloDistanceFilter = createEloDistanceFilter();
|
|
3421
|
+
return new Pipeline(compositeGenerator, [eloDistanceFilter], user, this);
|
|
1642
3422
|
}
|
|
1643
3423
|
////////////////////////////////////
|
|
1644
3424
|
// END NavigationStrategyManager implementation
|
|
@@ -1649,22 +3429,39 @@ ${above.rows.map((r) => ` ${r.id}-${r.key}
|
|
|
1649
3429
|
async getNewCards(limit = 99) {
|
|
1650
3430
|
const u = await this._getCurrentUser();
|
|
1651
3431
|
try {
|
|
1652
|
-
const
|
|
1653
|
-
const navigator = await ContentNavigator.create(u, this, strategy);
|
|
3432
|
+
const navigator = await this.createNavigator(u);
|
|
1654
3433
|
return navigator.getNewCards(limit);
|
|
1655
3434
|
} catch (e) {
|
|
1656
|
-
logger.error(`[courseDB] Error
|
|
3435
|
+
logger.error(`[courseDB] Error in getNewCards: ${e}`);
|
|
1657
3436
|
throw e;
|
|
1658
3437
|
}
|
|
1659
3438
|
}
|
|
1660
3439
|
async getPendingReviews() {
|
|
1661
3440
|
const u = await this._getCurrentUser();
|
|
1662
3441
|
try {
|
|
1663
|
-
const
|
|
1664
|
-
const navigator = await ContentNavigator.create(u, this, strategy);
|
|
3442
|
+
const navigator = await this.createNavigator(u);
|
|
1665
3443
|
return navigator.getPendingReviews();
|
|
1666
3444
|
} catch (e) {
|
|
1667
|
-
logger.error(`[courseDB] Error
|
|
3445
|
+
logger.error(`[courseDB] Error in getPendingReviews: ${e}`);
|
|
3446
|
+
throw e;
|
|
3447
|
+
}
|
|
3448
|
+
}
|
|
3449
|
+
/**
|
|
3450
|
+
* Get cards with suitability scores for presentation.
|
|
3451
|
+
*
|
|
3452
|
+
* This is the PRIMARY API for content sources going forward. Delegates to the
|
|
3453
|
+
* course's configured NavigationStrategy to get scored candidates.
|
|
3454
|
+
*
|
|
3455
|
+
* @param limit - Maximum number of cards to return
|
|
3456
|
+
* @returns Cards sorted by score descending
|
|
3457
|
+
*/
|
|
3458
|
+
async getWeightedCards(limit) {
|
|
3459
|
+
const u = await this._getCurrentUser();
|
|
3460
|
+
try {
|
|
3461
|
+
const navigator = await this.createNavigator(u);
|
|
3462
|
+
return navigator.getWeightedCards(limit);
|
|
3463
|
+
} catch (e) {
|
|
3464
|
+
logger.error(`[courseDB] Error getting weighted cards: ${e}`);
|
|
1668
3465
|
throw e;
|
|
1669
3466
|
}
|
|
1670
3467
|
}
|
|
@@ -1680,7 +3477,7 @@ ${above.rows.map((r) => ` ${r.id}-${r.key}
|
|
|
1680
3477
|
const courseDoc = (await u.getCourseRegistrationsDoc()).courses.find((c) => {
|
|
1681
3478
|
return c.courseID === this.id;
|
|
1682
3479
|
});
|
|
1683
|
-
targetElo = (0,
|
|
3480
|
+
targetElo = (0, import_common9.EloToNumber)(courseDoc.elo);
|
|
1684
3481
|
} catch {
|
|
1685
3482
|
targetElo = 1e3;
|
|
1686
3483
|
}
|
|
@@ -1804,13 +3601,13 @@ ${above.rows.map((r) => ` ${r.id}-${r.key}
|
|
|
1804
3601
|
});
|
|
1805
3602
|
|
|
1806
3603
|
// src/impl/couch/classroomDB.ts
|
|
1807
|
-
var
|
|
3604
|
+
var import_moment4, classroomLookupDBTitle, CLASSROOM_CONFIG, ClassroomDBBase, StudentClassroomDB, TeacherClassroomDB, ClassroomLookupDB;
|
|
1808
3605
|
var init_classroomDB2 = __esm({
|
|
1809
3606
|
"src/impl/couch/classroomDB.ts"() {
|
|
1810
3607
|
"use strict";
|
|
1811
3608
|
init_factory();
|
|
1812
3609
|
init_logger();
|
|
1813
|
-
|
|
3610
|
+
import_moment4 = __toESM(require("moment"), 1);
|
|
1814
3611
|
init_pouchdb_setup();
|
|
1815
3612
|
init_couch();
|
|
1816
3613
|
init_courseDB();
|
|
@@ -1905,9 +3702,9 @@ var init_classroomDB2 = __esm({
|
|
|
1905
3702
|
}
|
|
1906
3703
|
async getNewCards() {
|
|
1907
3704
|
const activeCards = await this._user.getActiveCards();
|
|
1908
|
-
const now =
|
|
3705
|
+
const now = import_moment4.default.utc();
|
|
1909
3706
|
const assigned = await this.getAssignedContent();
|
|
1910
|
-
const due = assigned.filter((c) => now.isAfter(
|
|
3707
|
+
const due = assigned.filter((c) => now.isAfter(import_moment4.default.utc(c.activeOn, REVIEW_TIME_FORMAT2)));
|
|
1911
3708
|
logger.info(`Due content: ${JSON.stringify(due)}`);
|
|
1912
3709
|
let ret = [];
|
|
1913
3710
|
for (let i = 0; i < due.length; i++) {
|
|
@@ -1944,6 +3741,52 @@ var init_classroomDB2 = __esm({
|
|
|
1944
3741
|
}
|
|
1945
3742
|
});
|
|
1946
3743
|
}
|
|
3744
|
+
/**
|
|
3745
|
+
* Get cards with suitability scores for presentation.
|
|
3746
|
+
*
|
|
3747
|
+
* This implementation wraps the legacy getNewCards/getPendingReviews methods,
|
|
3748
|
+
* assigning score=1.0 to all cards. StudentClassroomDB does not currently
|
|
3749
|
+
* support pluggable navigation strategies.
|
|
3750
|
+
*
|
|
3751
|
+
* @param limit - Maximum number of cards to return
|
|
3752
|
+
* @returns Cards sorted by score descending (all scores = 1.0)
|
|
3753
|
+
*/
|
|
3754
|
+
async getWeightedCards(limit) {
|
|
3755
|
+
const [newCards, reviews] = await Promise.all([this.getNewCards(), this.getPendingReviews()]);
|
|
3756
|
+
const weighted = [
|
|
3757
|
+
...newCards.map((c) => ({
|
|
3758
|
+
cardId: c.cardID,
|
|
3759
|
+
courseId: c.courseID,
|
|
3760
|
+
score: 1,
|
|
3761
|
+
provenance: [
|
|
3762
|
+
{
|
|
3763
|
+
strategy: "classroom",
|
|
3764
|
+
strategyName: "Classroom",
|
|
3765
|
+
strategyId: "CLASSROOM",
|
|
3766
|
+
action: "generated",
|
|
3767
|
+
score: 1,
|
|
3768
|
+
reason: "Classroom legacy getNewCards(), new card"
|
|
3769
|
+
}
|
|
3770
|
+
]
|
|
3771
|
+
})),
|
|
3772
|
+
...reviews.map((r) => ({
|
|
3773
|
+
cardId: r.cardID,
|
|
3774
|
+
courseId: r.courseID,
|
|
3775
|
+
score: 1,
|
|
3776
|
+
provenance: [
|
|
3777
|
+
{
|
|
3778
|
+
strategy: "classroom",
|
|
3779
|
+
strategyName: "Classroom",
|
|
3780
|
+
strategyId: "CLASSROOM",
|
|
3781
|
+
action: "generated",
|
|
3782
|
+
score: 1,
|
|
3783
|
+
reason: "Classroom legacy getPendingReviews(), review"
|
|
3784
|
+
}
|
|
3785
|
+
]
|
|
3786
|
+
}))
|
|
3787
|
+
];
|
|
3788
|
+
return weighted.slice(0, limit);
|
|
3789
|
+
}
|
|
1947
3790
|
};
|
|
1948
3791
|
TeacherClassroomDB = class _TeacherClassroomDB extends ClassroomDBBase {
|
|
1949
3792
|
_stuDb;
|
|
@@ -2000,8 +3843,8 @@ var init_classroomDB2 = __esm({
|
|
|
2000
3843
|
type: "tag",
|
|
2001
3844
|
_id: id,
|
|
2002
3845
|
assignedBy: content.assignedBy,
|
|
2003
|
-
assignedOn:
|
|
2004
|
-
activeOn: content.activeOn ||
|
|
3846
|
+
assignedOn: import_moment4.default.utc(),
|
|
3847
|
+
activeOn: content.activeOn || import_moment4.default.utc()
|
|
2005
3848
|
});
|
|
2006
3849
|
} else {
|
|
2007
3850
|
put = await this._db.put({
|
|
@@ -2009,8 +3852,8 @@ var init_classroomDB2 = __esm({
|
|
|
2009
3852
|
type: "course",
|
|
2010
3853
|
_id: id,
|
|
2011
3854
|
assignedBy: content.assignedBy,
|
|
2012
|
-
assignedOn:
|
|
2013
|
-
activeOn: content.activeOn ||
|
|
3855
|
+
assignedOn: import_moment4.default.utc(),
|
|
3856
|
+
activeOn: content.activeOn || import_moment4.default.utc()
|
|
2014
3857
|
});
|
|
2015
3858
|
}
|
|
2016
3859
|
if (put.ok) {
|
|
@@ -2090,8 +3933,7 @@ var init_adminDB2 = __esm({
|
|
|
2090
3933
|
}
|
|
2091
3934
|
}
|
|
2092
3935
|
}
|
|
2093
|
-
|
|
2094
|
-
return dbs.map((db) => {
|
|
3936
|
+
return promisedCRDbs.map((db) => {
|
|
2095
3937
|
return {
|
|
2096
3938
|
...db.getConfig(),
|
|
2097
3939
|
_id: db._id
|
|
@@ -2140,7 +3982,7 @@ var init_auth = __esm({
|
|
|
2140
3982
|
"use strict";
|
|
2141
3983
|
init_factory();
|
|
2142
3984
|
init_logger();
|
|
2143
|
-
import_cross_fetch = __toESM(require("cross-fetch"));
|
|
3985
|
+
import_cross_fetch = __toESM(require("cross-fetch"), 1);
|
|
2144
3986
|
}
|
|
2145
3987
|
});
|
|
2146
3988
|
|
|
@@ -2149,14 +3991,14 @@ var CouchDBSyncStrategy_exports = {};
|
|
|
2149
3991
|
__export(CouchDBSyncStrategy_exports, {
|
|
2150
3992
|
CouchDBSyncStrategy: () => CouchDBSyncStrategy
|
|
2151
3993
|
});
|
|
2152
|
-
var
|
|
3994
|
+
var import_common10, log3, CouchDBSyncStrategy;
|
|
2153
3995
|
var init_CouchDBSyncStrategy = __esm({
|
|
2154
3996
|
"src/impl/couch/CouchDBSyncStrategy.ts"() {
|
|
2155
3997
|
"use strict";
|
|
2156
3998
|
init_factory();
|
|
2157
3999
|
init_types_legacy();
|
|
2158
4000
|
init_logger();
|
|
2159
|
-
|
|
4001
|
+
import_common10 = require("@vue-skuilder/common");
|
|
2160
4002
|
init_common();
|
|
2161
4003
|
init_pouchdb_setup();
|
|
2162
4004
|
init_couch();
|
|
@@ -2227,32 +4069,32 @@ var init_CouchDBSyncStrategy = __esm({
|
|
|
2227
4069
|
}
|
|
2228
4070
|
}
|
|
2229
4071
|
return {
|
|
2230
|
-
status:
|
|
4072
|
+
status: import_common10.Status.ok,
|
|
2231
4073
|
error: void 0
|
|
2232
4074
|
};
|
|
2233
4075
|
} else {
|
|
2234
4076
|
return {
|
|
2235
|
-
status:
|
|
4077
|
+
status: import_common10.Status.error,
|
|
2236
4078
|
error: "Failed to log in after account creation"
|
|
2237
4079
|
};
|
|
2238
4080
|
}
|
|
2239
4081
|
} else {
|
|
2240
4082
|
logger.warn(`Signup not OK: ${JSON.stringify(signupRequest)}`);
|
|
2241
4083
|
return {
|
|
2242
|
-
status:
|
|
4084
|
+
status: import_common10.Status.error,
|
|
2243
4085
|
error: "Account creation failed"
|
|
2244
4086
|
};
|
|
2245
4087
|
}
|
|
2246
4088
|
} catch (e) {
|
|
2247
4089
|
if (e.reason === "Document update conflict.") {
|
|
2248
4090
|
return {
|
|
2249
|
-
status:
|
|
4091
|
+
status: import_common10.Status.error,
|
|
2250
4092
|
error: "This username is taken!"
|
|
2251
4093
|
};
|
|
2252
4094
|
}
|
|
2253
4095
|
logger.error(`Error on signup: ${JSON.stringify(e)}`);
|
|
2254
4096
|
return {
|
|
2255
|
-
status:
|
|
4097
|
+
status: import_common10.Status.error,
|
|
2256
4098
|
error: e.message || "Unknown error during account creation"
|
|
2257
4099
|
};
|
|
2258
4100
|
}
|
|
@@ -2426,17 +4268,17 @@ function getStartAndEndKeys2(key) {
|
|
|
2426
4268
|
endkey: key + "\uFFF0"
|
|
2427
4269
|
};
|
|
2428
4270
|
}
|
|
2429
|
-
var import_cross_fetch2,
|
|
4271
|
+
var import_cross_fetch2, import_moment5, import_process, isBrowser, GUEST_LOCAL_DB, localUserDB, pouchDBincludeCredentialsConfig, REVIEW_TIME_FORMAT2;
|
|
2430
4272
|
var init_couch = __esm({
|
|
2431
4273
|
"src/impl/couch/index.ts"() {
|
|
2432
4274
|
"use strict";
|
|
2433
4275
|
init_factory();
|
|
2434
4276
|
init_types_legacy();
|
|
2435
|
-
import_cross_fetch2 = __toESM(require("cross-fetch"));
|
|
2436
|
-
|
|
4277
|
+
import_cross_fetch2 = __toESM(require("cross-fetch"), 1);
|
|
4278
|
+
import_moment5 = __toESM(require("moment"), 1);
|
|
2437
4279
|
init_logger();
|
|
2438
4280
|
init_pouchdb_setup();
|
|
2439
|
-
import_process = __toESM(require("process"));
|
|
4281
|
+
import_process = __toESM(require("process"), 1);
|
|
2440
4282
|
init_contentSource();
|
|
2441
4283
|
init_adminDB2();
|
|
2442
4284
|
init_classroomDB2();
|
|
@@ -2463,7 +4305,9 @@ var init_couch = __esm({
|
|
|
2463
4305
|
function accomodateGuest() {
|
|
2464
4306
|
logger.log("[funnel] accomodateGuest() called");
|
|
2465
4307
|
if (typeof localStorage === "undefined") {
|
|
2466
|
-
logger.log(
|
|
4308
|
+
logger.log(
|
|
4309
|
+
"[funnel] localStorage not available (Node.js environment), returning default guest"
|
|
4310
|
+
);
|
|
2467
4311
|
return {
|
|
2468
4312
|
username: GuestUsername + "nodejs-test",
|
|
2469
4313
|
firstVisit: true
|
|
@@ -2631,14 +4475,14 @@ async function dropUserFromClassroom(user, classID) {
|
|
|
2631
4475
|
async function getUserClassrooms(user) {
|
|
2632
4476
|
return getOrCreateClassroomRegistrationsDoc(user);
|
|
2633
4477
|
}
|
|
2634
|
-
var
|
|
4478
|
+
var import_common12, import_moment6, log4, BaseUser, userCoursesDoc, userClassroomsDoc;
|
|
2635
4479
|
var init_BaseUserDB = __esm({
|
|
2636
4480
|
"src/impl/common/BaseUserDB.ts"() {
|
|
2637
4481
|
"use strict";
|
|
2638
4482
|
init_core();
|
|
2639
4483
|
init_util();
|
|
2640
|
-
|
|
2641
|
-
|
|
4484
|
+
import_common12 = require("@vue-skuilder/common");
|
|
4485
|
+
import_moment6 = __toESM(require("moment"), 1);
|
|
2642
4486
|
init_types_legacy();
|
|
2643
4487
|
init_logger();
|
|
2644
4488
|
init_userDBHelpers();
|
|
@@ -2687,7 +4531,7 @@ Currently logged-in as ${this._username}.`
|
|
|
2687
4531
|
);
|
|
2688
4532
|
}
|
|
2689
4533
|
const result = await this.syncStrategy.createAccount(username, password);
|
|
2690
|
-
if (result.status ===
|
|
4534
|
+
if (result.status === import_common12.Status.ok) {
|
|
2691
4535
|
log4(`Account created successfully, updating username to ${username}`);
|
|
2692
4536
|
this._username = username;
|
|
2693
4537
|
try {
|
|
@@ -2729,7 +4573,7 @@ Currently logged-in as ${this._username}.`
|
|
|
2729
4573
|
async resetUserData() {
|
|
2730
4574
|
if (this.syncStrategy.canAuthenticate()) {
|
|
2731
4575
|
return {
|
|
2732
|
-
status:
|
|
4576
|
+
status: import_common12.Status.error,
|
|
2733
4577
|
error: "Reset user data is only available for local-only mode. Use logout instead for remote sync."
|
|
2734
4578
|
};
|
|
2735
4579
|
}
|
|
@@ -2748,11 +4592,11 @@ Currently logged-in as ${this._username}.`
|
|
|
2748
4592
|
await localDB.bulkDocs(docsToDelete);
|
|
2749
4593
|
}
|
|
2750
4594
|
await this.init();
|
|
2751
|
-
return { status:
|
|
4595
|
+
return { status: import_common12.Status.ok };
|
|
2752
4596
|
} catch (error) {
|
|
2753
4597
|
logger.error("Failed to reset user data:", error);
|
|
2754
4598
|
return {
|
|
2755
|
-
status:
|
|
4599
|
+
status: import_common12.Status.error,
|
|
2756
4600
|
error: error instanceof Error ? error.message : "Unknown error during reset"
|
|
2757
4601
|
};
|
|
2758
4602
|
}
|
|
@@ -2899,7 +4743,7 @@ Currently logged-in as ${this._username}.`
|
|
|
2899
4743
|
);
|
|
2900
4744
|
return reviews.rows.filter((r) => {
|
|
2901
4745
|
if (r.id.startsWith(DocTypePrefixes["SCHEDULED_CARD" /* SCHEDULED_CARD */])) {
|
|
2902
|
-
const date =
|
|
4746
|
+
const date = import_moment6.default.utc(
|
|
2903
4747
|
r.id.substr(DocTypePrefixes["SCHEDULED_CARD" /* SCHEDULED_CARD */].length),
|
|
2904
4748
|
REVIEW_TIME_FORMAT
|
|
2905
4749
|
);
|
|
@@ -2912,11 +4756,11 @@ Currently logged-in as ${this._username}.`
|
|
|
2912
4756
|
}).map((r) => r.doc);
|
|
2913
4757
|
}
|
|
2914
4758
|
async getReviewsForcast(daysCount) {
|
|
2915
|
-
const time =
|
|
4759
|
+
const time = import_moment6.default.utc().add(daysCount, "days");
|
|
2916
4760
|
return this.getReviewstoDate(time);
|
|
2917
4761
|
}
|
|
2918
4762
|
async getPendingReviews(course_id) {
|
|
2919
|
-
const now =
|
|
4763
|
+
const now = import_moment6.default.utc();
|
|
2920
4764
|
return this.getReviewstoDate(now, course_id);
|
|
2921
4765
|
}
|
|
2922
4766
|
async getScheduledReviewCount(course_id) {
|
|
@@ -3203,7 +5047,7 @@ Currently logged-in as ${this._username}.`
|
|
|
3203
5047
|
*/
|
|
3204
5048
|
async putCardRecord(record) {
|
|
3205
5049
|
const cardHistoryID = getCardHistoryID(record.courseID, record.cardID);
|
|
3206
|
-
record.timeStamp =
|
|
5050
|
+
record.timeStamp = import_moment6.default.utc(record.timeStamp).toString();
|
|
3207
5051
|
try {
|
|
3208
5052
|
const cardHistory = await this.update(
|
|
3209
5053
|
cardHistoryID,
|
|
@@ -3219,7 +5063,7 @@ Currently logged-in as ${this._username}.`
|
|
|
3219
5063
|
const ret = {
|
|
3220
5064
|
...record2
|
|
3221
5065
|
};
|
|
3222
|
-
ret.timeStamp =
|
|
5066
|
+
ret.timeStamp = import_moment6.default.utc(record2.timeStamp);
|
|
3223
5067
|
return ret;
|
|
3224
5068
|
});
|
|
3225
5069
|
return cardHistory;
|
|
@@ -3443,6 +5287,55 @@ Currently logged-in as ${this._username}.`
|
|
|
3443
5287
|
async updateUserElo(courseId, elo) {
|
|
3444
5288
|
return updateUserElo(this._username, courseId, elo);
|
|
3445
5289
|
}
|
|
5290
|
+
async getStrategyState(courseId, strategyKey) {
|
|
5291
|
+
const docId = buildStrategyStateId(courseId, strategyKey);
|
|
5292
|
+
try {
|
|
5293
|
+
const doc = await this.localDB.get(docId);
|
|
5294
|
+
return doc.data;
|
|
5295
|
+
} catch (e) {
|
|
5296
|
+
const err = e;
|
|
5297
|
+
if (err.status === 404) {
|
|
5298
|
+
return null;
|
|
5299
|
+
}
|
|
5300
|
+
throw e;
|
|
5301
|
+
}
|
|
5302
|
+
}
|
|
5303
|
+
async putStrategyState(courseId, strategyKey, data) {
|
|
5304
|
+
const docId = buildStrategyStateId(courseId, strategyKey);
|
|
5305
|
+
let existingRev;
|
|
5306
|
+
try {
|
|
5307
|
+
const existing = await this.localDB.get(docId);
|
|
5308
|
+
existingRev = existing._rev;
|
|
5309
|
+
} catch (e) {
|
|
5310
|
+
const err = e;
|
|
5311
|
+
if (err.status !== 404) {
|
|
5312
|
+
throw e;
|
|
5313
|
+
}
|
|
5314
|
+
}
|
|
5315
|
+
const doc = {
|
|
5316
|
+
_id: docId,
|
|
5317
|
+
_rev: existingRev,
|
|
5318
|
+
docType: "STRATEGY_STATE" /* STRATEGY_STATE */,
|
|
5319
|
+
courseId,
|
|
5320
|
+
strategyKey,
|
|
5321
|
+
data,
|
|
5322
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
5323
|
+
};
|
|
5324
|
+
await this.localDB.put(doc);
|
|
5325
|
+
}
|
|
5326
|
+
async deleteStrategyState(courseId, strategyKey) {
|
|
5327
|
+
const docId = buildStrategyStateId(courseId, strategyKey);
|
|
5328
|
+
try {
|
|
5329
|
+
const doc = await this.localDB.get(docId);
|
|
5330
|
+
await this.localDB.remove(doc);
|
|
5331
|
+
} catch (e) {
|
|
5332
|
+
const err = e;
|
|
5333
|
+
if (err.status === 404) {
|
|
5334
|
+
return;
|
|
5335
|
+
}
|
|
5336
|
+
throw e;
|
|
5337
|
+
}
|
|
5338
|
+
}
|
|
3446
5339
|
};
|
|
3447
5340
|
userCoursesDoc = "CourseRegistrations";
|
|
3448
5341
|
userClassroomsDoc = "ClassroomRegistrations";
|
|
@@ -3925,11 +5818,11 @@ var init_StaticDataUnpacker = __esm({
|
|
|
3925
5818
|
});
|
|
3926
5819
|
|
|
3927
5820
|
// src/impl/static/courseDB.ts
|
|
3928
|
-
var
|
|
5821
|
+
var import_common14, StaticCourseDB;
|
|
3929
5822
|
var init_courseDB2 = __esm({
|
|
3930
5823
|
"src/impl/static/courseDB.ts"() {
|
|
3931
5824
|
"use strict";
|
|
3932
|
-
|
|
5825
|
+
import_common14 = require("@vue-skuilder/common");
|
|
3933
5826
|
init_types_legacy();
|
|
3934
5827
|
init_navigators();
|
|
3935
5828
|
init_logger();
|
|
@@ -4110,6 +6003,14 @@ var init_courseDB2 = __esm({
|
|
|
4110
6003
|
};
|
|
4111
6004
|
}
|
|
4112
6005
|
}
|
|
6006
|
+
async getAppliedTagsBatch(cardIds) {
|
|
6007
|
+
const tagsIndex = await this.unpacker.getTagsIndex();
|
|
6008
|
+
const tagsByCard = /* @__PURE__ */ new Map();
|
|
6009
|
+
for (const cardId of cardIds) {
|
|
6010
|
+
tagsByCard.set(cardId, tagsIndex.byCard[cardId] || []);
|
|
6011
|
+
}
|
|
6012
|
+
return tagsByCard;
|
|
6013
|
+
}
|
|
4113
6014
|
async addTagToCard(_cardId, _tagId) {
|
|
4114
6015
|
throw new Error("Cannot modify tags in static mode");
|
|
4115
6016
|
}
|
|
@@ -4192,7 +6093,7 @@ var init_courseDB2 = __esm({
|
|
|
4192
6093
|
}
|
|
4193
6094
|
async addNote(_codeCourse, _shape, _data, _author, _tags, _uploads, _elo) {
|
|
4194
6095
|
return {
|
|
4195
|
-
status:
|
|
6096
|
+
status: import_common14.Status.error,
|
|
4196
6097
|
message: "Cannot add notes in static mode"
|
|
4197
6098
|
};
|
|
4198
6099
|
}
|
|
@@ -4223,9 +6124,6 @@ var init_courseDB2 = __esm({
|
|
|
4223
6124
|
async updateNavigationStrategy(_id, _data) {
|
|
4224
6125
|
throw new Error("Cannot update navigation strategies in static mode");
|
|
4225
6126
|
}
|
|
4226
|
-
async surfaceNavigationStrategy() {
|
|
4227
|
-
return this.getNavigationStrategy("ELO");
|
|
4228
|
-
}
|
|
4229
6127
|
// Study Content Source implementation
|
|
4230
6128
|
async getPendingReviews() {
|
|
4231
6129
|
return [];
|
|
@@ -4546,6 +6444,213 @@ var init_factory = __esm({
|
|
|
4546
6444
|
}
|
|
4547
6445
|
});
|
|
4548
6446
|
|
|
6447
|
+
// src/study/TagFilteredContentSource.ts
|
|
6448
|
+
var import_common18, TagFilteredContentSource;
|
|
6449
|
+
var init_TagFilteredContentSource = __esm({
|
|
6450
|
+
"src/study/TagFilteredContentSource.ts"() {
|
|
6451
|
+
"use strict";
|
|
6452
|
+
import_common18 = require("@vue-skuilder/common");
|
|
6453
|
+
init_courseDB();
|
|
6454
|
+
init_logger();
|
|
6455
|
+
TagFilteredContentSource = class {
|
|
6456
|
+
courseId;
|
|
6457
|
+
filter;
|
|
6458
|
+
user;
|
|
6459
|
+
// Cache resolved card IDs to avoid repeated lookups within a session
|
|
6460
|
+
resolvedCardIds = null;
|
|
6461
|
+
constructor(courseId, filter, user) {
|
|
6462
|
+
this.courseId = courseId;
|
|
6463
|
+
this.filter = filter;
|
|
6464
|
+
this.user = user;
|
|
6465
|
+
logger.info(
|
|
6466
|
+
`[TagFilteredContentSource] Created for course "${courseId}" with filter:`,
|
|
6467
|
+
JSON.stringify(filter)
|
|
6468
|
+
);
|
|
6469
|
+
}
|
|
6470
|
+
/**
|
|
6471
|
+
* Resolves the TagFilter to a set of eligible card IDs.
|
|
6472
|
+
*
|
|
6473
|
+
* - Cards in `include` tags are OR'd together (card needs at least one)
|
|
6474
|
+
* - Cards in `exclude` tags are removed from the result
|
|
6475
|
+
*/
|
|
6476
|
+
async resolveFilteredCardIds() {
|
|
6477
|
+
if (this.resolvedCardIds !== null) {
|
|
6478
|
+
return this.resolvedCardIds;
|
|
6479
|
+
}
|
|
6480
|
+
const includedCardIds = /* @__PURE__ */ new Set();
|
|
6481
|
+
if (this.filter.include.length > 0) {
|
|
6482
|
+
for (const tagName of this.filter.include) {
|
|
6483
|
+
try {
|
|
6484
|
+
const tagDoc = await getTag(this.courseId, tagName);
|
|
6485
|
+
tagDoc.taggedCards.forEach((cardId) => includedCardIds.add(cardId));
|
|
6486
|
+
} catch (error) {
|
|
6487
|
+
logger.warn(
|
|
6488
|
+
`[TagFilteredContentSource] Could not resolve tag "${tagName}" for inclusion:`,
|
|
6489
|
+
error
|
|
6490
|
+
);
|
|
6491
|
+
}
|
|
6492
|
+
}
|
|
6493
|
+
}
|
|
6494
|
+
if (includedCardIds.size === 0 && this.filter.include.length > 0) {
|
|
6495
|
+
logger.warn(
|
|
6496
|
+
`[TagFilteredContentSource] No cards found for include tags: ${this.filter.include.join(", ")}`
|
|
6497
|
+
);
|
|
6498
|
+
this.resolvedCardIds = /* @__PURE__ */ new Set();
|
|
6499
|
+
return this.resolvedCardIds;
|
|
6500
|
+
}
|
|
6501
|
+
const excludedCardIds = /* @__PURE__ */ new Set();
|
|
6502
|
+
if (this.filter.exclude.length > 0) {
|
|
6503
|
+
for (const tagName of this.filter.exclude) {
|
|
6504
|
+
try {
|
|
6505
|
+
const tagDoc = await getTag(this.courseId, tagName);
|
|
6506
|
+
tagDoc.taggedCards.forEach((cardId) => excludedCardIds.add(cardId));
|
|
6507
|
+
} catch (error) {
|
|
6508
|
+
logger.warn(
|
|
6509
|
+
`[TagFilteredContentSource] Could not resolve tag "${tagName}" for exclusion:`,
|
|
6510
|
+
error
|
|
6511
|
+
);
|
|
6512
|
+
}
|
|
6513
|
+
}
|
|
6514
|
+
}
|
|
6515
|
+
const finalCardIds = /* @__PURE__ */ new Set();
|
|
6516
|
+
for (const cardId of includedCardIds) {
|
|
6517
|
+
if (!excludedCardIds.has(cardId)) {
|
|
6518
|
+
finalCardIds.add(cardId);
|
|
6519
|
+
}
|
|
6520
|
+
}
|
|
6521
|
+
logger.info(
|
|
6522
|
+
`[TagFilteredContentSource] Resolved ${finalCardIds.size} cards (included: ${includedCardIds.size}, excluded: ${excludedCardIds.size})`
|
|
6523
|
+
);
|
|
6524
|
+
this.resolvedCardIds = finalCardIds;
|
|
6525
|
+
return finalCardIds;
|
|
6526
|
+
}
|
|
6527
|
+
/**
|
|
6528
|
+
* Gets new cards that match the tag filter and are not already active for the user.
|
|
6529
|
+
*/
|
|
6530
|
+
async getNewCards(limit) {
|
|
6531
|
+
if (!(0, import_common18.hasActiveFilter)(this.filter)) {
|
|
6532
|
+
logger.warn("[TagFilteredContentSource] getNewCards called with no active filter");
|
|
6533
|
+
return [];
|
|
6534
|
+
}
|
|
6535
|
+
const eligibleCardIds = await this.resolveFilteredCardIds();
|
|
6536
|
+
const activeCards = await this.user.getActiveCards();
|
|
6537
|
+
const activeCardIds = new Set(activeCards.map((c) => c.cardID));
|
|
6538
|
+
const newItems = [];
|
|
6539
|
+
for (const cardId of eligibleCardIds) {
|
|
6540
|
+
if (!activeCardIds.has(cardId)) {
|
|
6541
|
+
newItems.push({
|
|
6542
|
+
courseID: this.courseId,
|
|
6543
|
+
cardID: cardId,
|
|
6544
|
+
contentSourceType: "course",
|
|
6545
|
+
contentSourceID: this.courseId,
|
|
6546
|
+
status: "new"
|
|
6547
|
+
});
|
|
6548
|
+
}
|
|
6549
|
+
if (limit !== void 0 && newItems.length >= limit) {
|
|
6550
|
+
break;
|
|
6551
|
+
}
|
|
6552
|
+
}
|
|
6553
|
+
logger.info(`[TagFilteredContentSource] Found ${newItems.length} new cards matching filter`);
|
|
6554
|
+
return newItems;
|
|
6555
|
+
}
|
|
6556
|
+
/**
|
|
6557
|
+
* Gets pending reviews, filtered to only include cards that match the tag filter.
|
|
6558
|
+
*/
|
|
6559
|
+
async getPendingReviews() {
|
|
6560
|
+
if (!(0, import_common18.hasActiveFilter)(this.filter)) {
|
|
6561
|
+
logger.warn("[TagFilteredContentSource] getPendingReviews called with no active filter");
|
|
6562
|
+
return [];
|
|
6563
|
+
}
|
|
6564
|
+
const eligibleCardIds = await this.resolveFilteredCardIds();
|
|
6565
|
+
const allReviews = await this.user.getPendingReviews(this.courseId);
|
|
6566
|
+
const filteredReviews = allReviews.filter((review) => {
|
|
6567
|
+
return eligibleCardIds.has(review.cardId);
|
|
6568
|
+
});
|
|
6569
|
+
logger.info(
|
|
6570
|
+
`[TagFilteredContentSource] Found ${filteredReviews.length} pending reviews matching filter (of ${allReviews.length} total)`
|
|
6571
|
+
);
|
|
6572
|
+
return filteredReviews.map((r) => ({
|
|
6573
|
+
...r,
|
|
6574
|
+
courseID: r.courseId,
|
|
6575
|
+
cardID: r.cardId,
|
|
6576
|
+
contentSourceType: "course",
|
|
6577
|
+
contentSourceID: this.courseId,
|
|
6578
|
+
reviewID: r._id,
|
|
6579
|
+
status: "review"
|
|
6580
|
+
}));
|
|
6581
|
+
}
|
|
6582
|
+
/**
|
|
6583
|
+
* Get cards with suitability scores for presentation.
|
|
6584
|
+
*
|
|
6585
|
+
* This implementation wraps the legacy getNewCards/getPendingReviews methods,
|
|
6586
|
+
* assigning score=1.0 to all cards. TagFilteredContentSource does not currently
|
|
6587
|
+
* support pluggable navigation strategies - it returns flat-scored candidates.
|
|
6588
|
+
*
|
|
6589
|
+
* @param limit - Maximum number of cards to return
|
|
6590
|
+
* @returns Cards sorted by score descending (all scores = 1.0)
|
|
6591
|
+
*/
|
|
6592
|
+
async getWeightedCards(limit) {
|
|
6593
|
+
const [newCards, reviews] = await Promise.all([
|
|
6594
|
+
this.getNewCards(limit),
|
|
6595
|
+
this.getPendingReviews()
|
|
6596
|
+
]);
|
|
6597
|
+
const weighted = [
|
|
6598
|
+
...reviews.map((r) => ({
|
|
6599
|
+
cardId: r.cardID,
|
|
6600
|
+
courseId: r.courseID,
|
|
6601
|
+
score: 1,
|
|
6602
|
+
provenance: [
|
|
6603
|
+
{
|
|
6604
|
+
strategy: "tagFilter",
|
|
6605
|
+
strategyName: "Tag Filter",
|
|
6606
|
+
strategyId: "TAG_FILTER",
|
|
6607
|
+
action: "generated",
|
|
6608
|
+
score: 1,
|
|
6609
|
+
reason: `Tag-filtered review (tags: ${this.filter.include.join(", ")})`
|
|
6610
|
+
}
|
|
6611
|
+
]
|
|
6612
|
+
})),
|
|
6613
|
+
...newCards.map((c) => ({
|
|
6614
|
+
cardId: c.cardID,
|
|
6615
|
+
courseId: c.courseID,
|
|
6616
|
+
score: 1,
|
|
6617
|
+
provenance: [
|
|
6618
|
+
{
|
|
6619
|
+
strategy: "tagFilter",
|
|
6620
|
+
strategyName: "Tag Filter",
|
|
6621
|
+
strategyId: "TAG_FILTER",
|
|
6622
|
+
action: "generated",
|
|
6623
|
+
score: 1,
|
|
6624
|
+
reason: `Tag-filtered new card (tags: ${this.filter.include.join(", ")})`
|
|
6625
|
+
}
|
|
6626
|
+
]
|
|
6627
|
+
}))
|
|
6628
|
+
];
|
|
6629
|
+
return weighted.slice(0, limit);
|
|
6630
|
+
}
|
|
6631
|
+
/**
|
|
6632
|
+
* Clears the cached resolved card IDs.
|
|
6633
|
+
* Call this if the underlying tag data may have changed during a session.
|
|
6634
|
+
*/
|
|
6635
|
+
clearCache() {
|
|
6636
|
+
this.resolvedCardIds = null;
|
|
6637
|
+
}
|
|
6638
|
+
/**
|
|
6639
|
+
* Returns the course ID this source is filtering.
|
|
6640
|
+
*/
|
|
6641
|
+
getCourseId() {
|
|
6642
|
+
return this.courseId;
|
|
6643
|
+
}
|
|
6644
|
+
/**
|
|
6645
|
+
* Returns the active tag filter.
|
|
6646
|
+
*/
|
|
6647
|
+
getFilter() {
|
|
6648
|
+
return this.filter;
|
|
6649
|
+
}
|
|
6650
|
+
};
|
|
6651
|
+
}
|
|
6652
|
+
});
|
|
6653
|
+
|
|
4549
6654
|
// src/core/interfaces/contentSource.ts
|
|
4550
6655
|
function isReview(item) {
|
|
4551
6656
|
const ret = item.status === "review" || item.status === "failed-review" || "reviewID" in item;
|
|
@@ -4555,14 +6660,20 @@ async function getStudySource(source, user) {
|
|
|
4555
6660
|
if (source.type === "classroom") {
|
|
4556
6661
|
return await StudentClassroomDB.factory(source.id, user);
|
|
4557
6662
|
} else {
|
|
6663
|
+
if ((0, import_common19.hasActiveFilter)(source.tagFilter)) {
|
|
6664
|
+
return new TagFilteredContentSource(source.id, source.tagFilter, user);
|
|
6665
|
+
}
|
|
4558
6666
|
return getDataLayer().getCourseDB(source.id);
|
|
4559
6667
|
}
|
|
4560
6668
|
}
|
|
6669
|
+
var import_common19;
|
|
4561
6670
|
var init_contentSource = __esm({
|
|
4562
6671
|
"src/core/interfaces/contentSource.ts"() {
|
|
4563
6672
|
"use strict";
|
|
4564
6673
|
init_factory();
|
|
4565
6674
|
init_classroomDB2();
|
|
6675
|
+
import_common19 = require("@vue-skuilder/common");
|
|
6676
|
+
init_TagFilteredContentSource();
|
|
4566
6677
|
}
|
|
4567
6678
|
});
|
|
4568
6679
|
|
|
@@ -4607,6 +6718,16 @@ var init_user = __esm({
|
|
|
4607
6718
|
}
|
|
4608
6719
|
});
|
|
4609
6720
|
|
|
6721
|
+
// src/core/types/strategyState.ts
|
|
6722
|
+
function buildStrategyStateId(courseId, strategyKey) {
|
|
6723
|
+
return `STRATEGY_STATE::${courseId}::${strategyKey}`;
|
|
6724
|
+
}
|
|
6725
|
+
var init_strategyState = __esm({
|
|
6726
|
+
"src/core/types/strategyState.ts"() {
|
|
6727
|
+
"use strict";
|
|
6728
|
+
}
|
|
6729
|
+
});
|
|
6730
|
+
|
|
4610
6731
|
// src/core/bulkImport/cardProcessor.ts
|
|
4611
6732
|
async function importParsedCards(parsedCards, courseDB, config) {
|
|
4612
6733
|
const results = [];
|
|
@@ -4675,7 +6796,7 @@ elo: ${elo}`;
|
|
|
4675
6796
|
misc: {}
|
|
4676
6797
|
} : void 0
|
|
4677
6798
|
);
|
|
4678
|
-
if (result.status ===
|
|
6799
|
+
if (result.status === import_common20.Status.ok) {
|
|
4679
6800
|
return {
|
|
4680
6801
|
originalText,
|
|
4681
6802
|
status: "success",
|
|
@@ -4719,17 +6840,17 @@ function validateProcessorConfig(config) {
|
|
|
4719
6840
|
}
|
|
4720
6841
|
return { isValid: true };
|
|
4721
6842
|
}
|
|
4722
|
-
var
|
|
6843
|
+
var import_common20;
|
|
4723
6844
|
var init_cardProcessor = __esm({
|
|
4724
6845
|
"src/core/bulkImport/cardProcessor.ts"() {
|
|
4725
6846
|
"use strict";
|
|
4726
|
-
|
|
6847
|
+
import_common20 = require("@vue-skuilder/common");
|
|
4727
6848
|
init_logger();
|
|
4728
6849
|
}
|
|
4729
6850
|
});
|
|
4730
6851
|
|
|
4731
6852
|
// src/core/bulkImport/types.ts
|
|
4732
|
-
var
|
|
6853
|
+
var init_types3 = __esm({
|
|
4733
6854
|
"src/core/bulkImport/types.ts"() {
|
|
4734
6855
|
"use strict";
|
|
4735
6856
|
}
|
|
@@ -4740,7 +6861,7 @@ var init_bulkImport = __esm({
|
|
|
4740
6861
|
"src/core/bulkImport/index.ts"() {
|
|
4741
6862
|
"use strict";
|
|
4742
6863
|
init_cardProcessor();
|
|
4743
|
-
|
|
6864
|
+
init_types3();
|
|
4744
6865
|
}
|
|
4745
6866
|
});
|
|
4746
6867
|
|
|
@@ -4751,6 +6872,7 @@ var init_core = __esm({
|
|
|
4751
6872
|
init_interfaces();
|
|
4752
6873
|
init_types_legacy();
|
|
4753
6874
|
init_user();
|
|
6875
|
+
init_strategyState();
|
|
4754
6876
|
init_Loggable();
|
|
4755
6877
|
init_util();
|
|
4756
6878
|
init_navigators();
|
|
@@ -4771,15 +6893,20 @@ __export(index_exports, {
|
|
|
4771
6893
|
GuestUsername: () => GuestUsername,
|
|
4772
6894
|
Loggable: () => Loggable,
|
|
4773
6895
|
NOT_SET: () => NOT_SET,
|
|
6896
|
+
NavigatorRole: () => NavigatorRole,
|
|
6897
|
+
NavigatorRoles: () => NavigatorRoles,
|
|
4774
6898
|
Navigators: () => Navigators,
|
|
4775
6899
|
SessionController: () => SessionController,
|
|
4776
6900
|
StaticToCouchDBMigrator: () => StaticToCouchDBMigrator,
|
|
6901
|
+
TagFilteredContentSource: () => TagFilteredContentSource,
|
|
4777
6902
|
_resetDataLayer: () => _resetDataLayer,
|
|
4778
6903
|
areQuestionRecords: () => areQuestionRecords,
|
|
6904
|
+
buildStrategyStateId: () => buildStrategyStateId,
|
|
4779
6905
|
docIsDeleted: () => docIsDeleted,
|
|
4780
6906
|
ensureAppDataDirectory: () => ensureAppDataDirectory,
|
|
4781
6907
|
getAppDataDirectory: () => getAppDataDirectory,
|
|
4782
6908
|
getCardHistoryID: () => getCardHistoryID,
|
|
6909
|
+
getCardOrigin: () => getCardOrigin,
|
|
4783
6910
|
getDataLayer: () => getDataLayer,
|
|
4784
6911
|
getDbPath: () => getDbPath,
|
|
4785
6912
|
getLogFilePath: () => getLogFilePath,
|
|
@@ -4788,6 +6915,8 @@ __export(index_exports, {
|
|
|
4788
6915
|
initializeDataDirectory: () => initializeDataDirectory,
|
|
4789
6916
|
initializeDataLayer: () => initializeDataLayer,
|
|
4790
6917
|
initializeTuiLogging: () => initializeTuiLogging,
|
|
6918
|
+
isFilter: () => isFilter,
|
|
6919
|
+
isGenerator: () => isGenerator,
|
|
4791
6920
|
isQuestionRecord: () => isQuestionRecord,
|
|
4792
6921
|
isReview: () => isReview,
|
|
4793
6922
|
log: () => log,
|
|
@@ -4805,14 +6934,14 @@ init_core();
|
|
|
4805
6934
|
init_courseLookupDB();
|
|
4806
6935
|
|
|
4807
6936
|
// src/study/services/SrsService.ts
|
|
4808
|
-
var
|
|
6937
|
+
var import_moment8 = __toESM(require("moment"), 1);
|
|
4809
6938
|
init_couch();
|
|
4810
6939
|
|
|
4811
6940
|
// src/study/SpacedRepetition.ts
|
|
4812
6941
|
init_util();
|
|
4813
|
-
var
|
|
6942
|
+
var import_moment7 = __toESM(require("moment"), 1);
|
|
4814
6943
|
init_logger();
|
|
4815
|
-
var duration =
|
|
6944
|
+
var duration = import_moment7.default.duration;
|
|
4816
6945
|
function newInterval(user, cardHistory) {
|
|
4817
6946
|
if (areQuestionRecords(cardHistory)) {
|
|
4818
6947
|
return newQuestionInterval(user, cardHistory);
|
|
@@ -4876,8 +7005,8 @@ function getInitialInterval(cardHistory) {
|
|
|
4876
7005
|
return 60 * 60 * 24 * 3;
|
|
4877
7006
|
}
|
|
4878
7007
|
function secondsBetween(start, end) {
|
|
4879
|
-
start = (0,
|
|
4880
|
-
end = (0,
|
|
7008
|
+
start = (0, import_moment7.default)(start);
|
|
7009
|
+
end = (0, import_moment7.default)(end);
|
|
4881
7010
|
const ret = duration(end.diff(start)).asSeconds();
|
|
4882
7011
|
return ret;
|
|
4883
7012
|
}
|
|
@@ -4897,7 +7026,7 @@ var SrsService = class {
|
|
|
4897
7026
|
*/
|
|
4898
7027
|
async scheduleReview(history, item) {
|
|
4899
7028
|
const nextInterval = newInterval(this.user, history);
|
|
4900
|
-
const nextReviewTime =
|
|
7029
|
+
const nextReviewTime = import_moment8.default.utc().add(nextInterval, "seconds");
|
|
4901
7030
|
if (isReview(item)) {
|
|
4902
7031
|
logger.info(`[SrsService] Removing previously scheduled review for: ${item.cardID}`);
|
|
4903
7032
|
void this.user.removeScheduledCardReview(item.reviewID);
|
|
@@ -4914,7 +7043,7 @@ var SrsService = class {
|
|
|
4914
7043
|
};
|
|
4915
7044
|
|
|
4916
7045
|
// src/study/services/EloService.ts
|
|
4917
|
-
var
|
|
7046
|
+
var import_common21 = require("@vue-skuilder/common");
|
|
4918
7047
|
init_logger();
|
|
4919
7048
|
var EloService = class {
|
|
4920
7049
|
dataLayer;
|
|
@@ -4937,10 +7066,10 @@ var EloService = class {
|
|
|
4937
7066
|
logger.warn(`k value interpretation not currently implemented`);
|
|
4938
7067
|
}
|
|
4939
7068
|
const courseDB = this.dataLayer.getCourseDB(currentCard.card.course_id);
|
|
4940
|
-
const userElo = (0,
|
|
7069
|
+
const userElo = (0, import_common21.toCourseElo)(userCourseRegDoc.courses.find((c) => c.courseID === course_id).elo);
|
|
4941
7070
|
const cardElo = (await courseDB.getCardEloData([currentCard.card.card_id]))[0];
|
|
4942
7071
|
if (cardElo && userElo) {
|
|
4943
|
-
const eloUpdate = (0,
|
|
7072
|
+
const eloUpdate = (0, import_common21.adjustCourseScores)(userElo, cardElo, userScore);
|
|
4944
7073
|
userCourseRegDoc.courses.find((c) => c.courseID === course_id).elo = eloUpdate.userElo;
|
|
4945
7074
|
const results = await Promise.allSettled([
|
|
4946
7075
|
this.user.updateUserElo(course_id, eloUpdate.userElo),
|
|
@@ -5142,7 +7271,7 @@ var ResponseProcessor = class {
|
|
|
5142
7271
|
};
|
|
5143
7272
|
|
|
5144
7273
|
// src/study/services/CardHydrationService.ts
|
|
5145
|
-
var
|
|
7274
|
+
var import_common22 = require("@vue-skuilder/common");
|
|
5146
7275
|
init_logger();
|
|
5147
7276
|
|
|
5148
7277
|
// src/study/ItemQueue.ts
|
|
@@ -5266,8 +7395,8 @@ var CardHydrationService = class {
|
|
|
5266
7395
|
} else {
|
|
5267
7396
|
const courseDB = this.getCourseDB(nextItem.courseID);
|
|
5268
7397
|
const cardData = await courseDB.getCourseDoc(nextItem.cardID);
|
|
5269
|
-
if (!(0,
|
|
5270
|
-
cardData.elo = (0,
|
|
7398
|
+
if (!(0, import_common22.isCourseElo)(cardData.elo)) {
|
|
7399
|
+
cardData.elo = (0, import_common22.toCourseElo)(cardData.elo);
|
|
5271
7400
|
}
|
|
5272
7401
|
const view = this.getViewComponent(cardData.id_view);
|
|
5273
7402
|
const dataDocs = await Promise.all(
|
|
@@ -5278,7 +7407,7 @@ var CardHydrationService = class {
|
|
|
5278
7407
|
})
|
|
5279
7408
|
)
|
|
5280
7409
|
);
|
|
5281
|
-
const data = dataDocs.map(
|
|
7410
|
+
const data = dataDocs.map(import_common22.displayableDataToViewData).reverse();
|
|
5282
7411
|
this.hydratedQ.add(
|
|
5283
7412
|
{
|
|
5284
7413
|
item: nextItem,
|
|
@@ -6733,6 +8862,7 @@ init_dataDirectory();
|
|
|
6733
8862
|
init_tuiLogger();
|
|
6734
8863
|
|
|
6735
8864
|
// src/study/SessionController.ts
|
|
8865
|
+
init_navigators();
|
|
6736
8866
|
function randomInt(min, max) {
|
|
6737
8867
|
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
6738
8868
|
}
|
|
@@ -6835,7 +8965,12 @@ var SessionController = class extends Loggable {
|
|
|
6835
8965
|
}
|
|
6836
8966
|
async prepareSession() {
|
|
6837
8967
|
try {
|
|
6838
|
-
|
|
8968
|
+
const hasWeightedCards = this.sources.some((s) => typeof s.getWeightedCards === "function");
|
|
8969
|
+
if (hasWeightedCards) {
|
|
8970
|
+
await this.getWeightedContent();
|
|
8971
|
+
} else {
|
|
8972
|
+
await Promise.all([this.getScheduledReviews(), this.getNewCards()]);
|
|
8973
|
+
}
|
|
6839
8974
|
} catch (e) {
|
|
6840
8975
|
this.error("Error preparing study session:", e);
|
|
6841
8976
|
}
|
|
@@ -6861,6 +8996,9 @@ var SessionController = class extends Loggable {
|
|
|
6861
8996
|
* Used by SessionControllerDebug component for runtime inspection.
|
|
6862
8997
|
*/
|
|
6863
8998
|
getDebugInfo() {
|
|
8999
|
+
const supportsWeightedCards = this.sources.some(
|
|
9000
|
+
(s) => typeof s.getWeightedCards === "function"
|
|
9001
|
+
);
|
|
6864
9002
|
const extractQueueItems = (queue, limit = 10) => {
|
|
6865
9003
|
const items = [];
|
|
6866
9004
|
for (let i = 0; i < Math.min(queue.length, limit); i++) {
|
|
@@ -6878,6 +9016,10 @@ var SessionController = class extends Loggable {
|
|
|
6878
9016
|
return items;
|
|
6879
9017
|
};
|
|
6880
9018
|
return {
|
|
9019
|
+
api: {
|
|
9020
|
+
mode: supportsWeightedCards ? "weighted" : "legacy",
|
|
9021
|
+
description: supportsWeightedCards ? "Using getWeightedCards() API with scored candidates" : "Using legacy getNewCards()/getPendingReviews() API"
|
|
9022
|
+
},
|
|
6881
9023
|
reviewQueue: {
|
|
6882
9024
|
length: this.reviewQ.length,
|
|
6883
9025
|
dequeueCount: this.reviewQ.dequeueCount,
|
|
@@ -6900,6 +9042,109 @@ var SessionController = class extends Loggable {
|
|
|
6900
9042
|
}
|
|
6901
9043
|
};
|
|
6902
9044
|
}
|
|
9045
|
+
/**
|
|
9046
|
+
* Fetch content using the new getWeightedCards API.
|
|
9047
|
+
*
|
|
9048
|
+
* This method uses getWeightedCards() to get scored candidates, then uses the
|
|
9049
|
+
* scores to determine ordering. For reviews, we still need the full ScheduledCard
|
|
9050
|
+
* data from getPendingReviews(), so we fetch both and use scores for ordering.
|
|
9051
|
+
*
|
|
9052
|
+
* The hybrid approach:
|
|
9053
|
+
* 1. Fetch weighted cards to get scoring/ordering information
|
|
9054
|
+
* 2. Fetch full review data via legacy getPendingReviews()
|
|
9055
|
+
* 3. Order reviews by their weighted scores
|
|
9056
|
+
* 4. Add new cards ordered by their weighted scores
|
|
9057
|
+
*/
|
|
9058
|
+
async getWeightedContent() {
|
|
9059
|
+
const limit = 20;
|
|
9060
|
+
const allWeighted = [];
|
|
9061
|
+
const allReviews = [];
|
|
9062
|
+
const allNewCards = [];
|
|
9063
|
+
for (const source of this.sources) {
|
|
9064
|
+
try {
|
|
9065
|
+
const reviews = await source.getPendingReviews().catch((error) => {
|
|
9066
|
+
this.error(`Failed to get reviews for source:`, error);
|
|
9067
|
+
return [];
|
|
9068
|
+
});
|
|
9069
|
+
allReviews.push(...reviews);
|
|
9070
|
+
if (typeof source.getWeightedCards === "function") {
|
|
9071
|
+
const weighted = await source.getWeightedCards(limit);
|
|
9072
|
+
allWeighted.push(...weighted);
|
|
9073
|
+
} else {
|
|
9074
|
+
const newCards = await source.getNewCards(limit);
|
|
9075
|
+
allNewCards.push(...newCards);
|
|
9076
|
+
allWeighted.push(
|
|
9077
|
+
...newCards.map((c) => ({
|
|
9078
|
+
cardId: c.cardID,
|
|
9079
|
+
courseId: c.courseID,
|
|
9080
|
+
score: 1,
|
|
9081
|
+
provenance: [
|
|
9082
|
+
{
|
|
9083
|
+
strategy: "legacy",
|
|
9084
|
+
strategyName: "Legacy Fallback",
|
|
9085
|
+
strategyId: "legacy-fallback",
|
|
9086
|
+
action: "generated",
|
|
9087
|
+
score: 1,
|
|
9088
|
+
reason: "Fallback to legacy getNewCards(), new card"
|
|
9089
|
+
}
|
|
9090
|
+
]
|
|
9091
|
+
})),
|
|
9092
|
+
...reviews.map((r) => ({
|
|
9093
|
+
cardId: r.cardID,
|
|
9094
|
+
courseId: r.courseID,
|
|
9095
|
+
score: 1,
|
|
9096
|
+
provenance: [
|
|
9097
|
+
{
|
|
9098
|
+
strategy: "legacy",
|
|
9099
|
+
strategyName: "Legacy Fallback",
|
|
9100
|
+
strategyId: "legacy-fallback",
|
|
9101
|
+
action: "generated",
|
|
9102
|
+
score: 1,
|
|
9103
|
+
reason: "Fallback to legacy getPendingReviews(), review"
|
|
9104
|
+
}
|
|
9105
|
+
]
|
|
9106
|
+
}))
|
|
9107
|
+
);
|
|
9108
|
+
}
|
|
9109
|
+
} catch (error) {
|
|
9110
|
+
this.error(`Failed to get content from source:`, error);
|
|
9111
|
+
}
|
|
9112
|
+
}
|
|
9113
|
+
const scoreMap = /* @__PURE__ */ new Map();
|
|
9114
|
+
for (const w of allWeighted) {
|
|
9115
|
+
const key = `${w.courseId}::${w.cardId}`;
|
|
9116
|
+
scoreMap.set(key, w.score);
|
|
9117
|
+
}
|
|
9118
|
+
const scoredReviews = allReviews.map((r) => ({
|
|
9119
|
+
review: r,
|
|
9120
|
+
score: scoreMap.get(`${r.courseID}::${r.cardID}`) ?? 1
|
|
9121
|
+
}));
|
|
9122
|
+
scoredReviews.sort((a, b) => b.score - a.score);
|
|
9123
|
+
let report = "Weighted content session created with:\n";
|
|
9124
|
+
for (const { review, score } of scoredReviews) {
|
|
9125
|
+
this.reviewQ.add(review, review.cardID);
|
|
9126
|
+
report += `Review: ${review.courseID}::${review.cardID} (score: ${score.toFixed(2)})
|
|
9127
|
+
`;
|
|
9128
|
+
}
|
|
9129
|
+
const newCardWeighted = allWeighted.filter((w) => getCardOrigin(w) === "new").sort((a, b) => b.score - a.score);
|
|
9130
|
+
for (const card of newCardWeighted) {
|
|
9131
|
+
const newItem = {
|
|
9132
|
+
cardID: card.cardId,
|
|
9133
|
+
courseID: card.courseId,
|
|
9134
|
+
contentSourceType: "course",
|
|
9135
|
+
contentSourceID: card.courseId,
|
|
9136
|
+
status: "new"
|
|
9137
|
+
};
|
|
9138
|
+
this.newQ.add(newItem, card.cardId);
|
|
9139
|
+
report += `New: ${card.courseId}::${card.cardId} (score: ${card.score.toFixed(2)})
|
|
9140
|
+
`;
|
|
9141
|
+
}
|
|
9142
|
+
this.log(report);
|
|
9143
|
+
}
|
|
9144
|
+
/**
|
|
9145
|
+
* @deprecated Use getWeightedContent() instead. This method is kept for backward
|
|
9146
|
+
* compatibility with sources that don't support getWeightedCards().
|
|
9147
|
+
*/
|
|
6903
9148
|
async getScheduledReviews() {
|
|
6904
9149
|
const reviews = await Promise.all(
|
|
6905
9150
|
this.sources.map(
|
|
@@ -6925,6 +9170,10 @@ var SessionController = class extends Loggable {
|
|
|
6925
9170
|
report += dueCards.map((card) => `Card ${card.courseID}::${card.cardID} `).join("\n");
|
|
6926
9171
|
this.log(report);
|
|
6927
9172
|
}
|
|
9173
|
+
/**
|
|
9174
|
+
* @deprecated Use getWeightedContent() instead. This method is kept for backward
|
|
9175
|
+
* compatibility with sources that don't support getWeightedCards().
|
|
9176
|
+
*/
|
|
6928
9177
|
async getNewCards(n = 10) {
|
|
6929
9178
|
const perCourse = Math.ceil(n / this.sources.length);
|
|
6930
9179
|
const newContent = await Promise.all(this.sources.map((c) => c.getNewCards(perCourse)));
|
|
@@ -7089,6 +9338,9 @@ var SessionController = class extends Loggable {
|
|
|
7089
9338
|
}
|
|
7090
9339
|
};
|
|
7091
9340
|
|
|
9341
|
+
// src/study/index.ts
|
|
9342
|
+
init_TagFilteredContentSource();
|
|
9343
|
+
|
|
7092
9344
|
// src/index.ts
|
|
7093
9345
|
init_factory();
|
|
7094
9346
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -7103,15 +9355,20 @@ init_factory();
|
|
|
7103
9355
|
GuestUsername,
|
|
7104
9356
|
Loggable,
|
|
7105
9357
|
NOT_SET,
|
|
9358
|
+
NavigatorRole,
|
|
9359
|
+
NavigatorRoles,
|
|
7106
9360
|
Navigators,
|
|
7107
9361
|
SessionController,
|
|
7108
9362
|
StaticToCouchDBMigrator,
|
|
9363
|
+
TagFilteredContentSource,
|
|
7109
9364
|
_resetDataLayer,
|
|
7110
9365
|
areQuestionRecords,
|
|
9366
|
+
buildStrategyStateId,
|
|
7111
9367
|
docIsDeleted,
|
|
7112
9368
|
ensureAppDataDirectory,
|
|
7113
9369
|
getAppDataDirectory,
|
|
7114
9370
|
getCardHistoryID,
|
|
9371
|
+
getCardOrigin,
|
|
7115
9372
|
getDataLayer,
|
|
7116
9373
|
getDbPath,
|
|
7117
9374
|
getLogFilePath,
|
|
@@ -7120,6 +9377,8 @@ init_factory();
|
|
|
7120
9377
|
initializeDataDirectory,
|
|
7121
9378
|
initializeDataLayer,
|
|
7122
9379
|
initializeTuiLogging,
|
|
9380
|
+
isFilter,
|
|
9381
|
+
isGenerator,
|
|
7123
9382
|
isQuestionRecord,
|
|
7124
9383
|
isReview,
|
|
7125
9384
|
log,
|