@vue-skuilder/db 0.1.16 → 0.1.18
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-DNa0XPtn.d.ts → classroomDB-BgfrVb8d.d.ts} +357 -103
- package/dist/{userDB-BqwxtJ_7.d.mts → classroomDB-CTOenngH.d.cts} +358 -104
- package/dist/core/index.d.cts +230 -0
- package/dist/core/index.d.ts +161 -23
- package/dist/core/index.js +1964 -154
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.mjs +1925 -121
- package/dist/core/index.mjs.map +1 -1
- package/dist/{dataLayerProvider-BV5iZqt_.d.ts → dataLayerProvider-CZxC9GtB.d.ts} +1 -1
- package/dist/{dataLayerProvider-VlngD19_.d.mts → dataLayerProvider-D6PoCwS6.d.cts} +1 -1
- package/dist/impl/couch/{index.d.mts → index.d.cts} +46 -5
- package/dist/impl/couch/index.d.ts +44 -3
- package/dist/impl/couch/index.js +1971 -171
- package/dist/impl/couch/index.js.map +1 -1
- package/dist/impl/couch/index.mjs +1933 -134
- package/dist/impl/couch/index.mjs.map +1 -1
- package/dist/impl/static/{index.d.mts → index.d.cts} +5 -6
- package/dist/impl/static/index.d.ts +2 -3
- package/dist/impl/static/index.js +1614 -119
- package/dist/impl/static/index.js.map +1 -1
- package/dist/impl/static/index.mjs +1585 -92
- package/dist/impl/static/index.mjs.map +1 -1
- package/dist/{index-Bmll7Xse.d.mts → index-D-Fa4Smt.d.cts} +1 -1
- package/dist/{index.d.mts → index.d.cts} +97 -13
- package/dist/index.d.ts +90 -6
- package/dist/index.js +2085 -153
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2031 -106
- package/dist/index.mjs.map +1 -1
- package/dist/pouch/index.js +3 -3
- package/dist/{types-Dbp5DaRR.d.mts → types-CzPDLAK6.d.cts} +1 -1
- package/dist/util/packer/{index.d.mts → index.d.cts} +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 +265 -0
- package/docs/todo-evolutionary-orchestration.md +310 -0
- package/docs/todo-nominal-tag-types.md +121 -0
- package/docs/todo-pipeline-optimization.md +117 -0
- package/docs/todo-strategy-authoring.md +401 -0
- package/docs/todo-strategy-state-storage.md +278 -0
- package/eslint.config.mjs +1 -1
- package/package.json +9 -4
- package/src/core/interfaces/contentSource.ts +88 -4
- package/src/core/interfaces/navigationStrategyManager.ts +0 -5
- package/src/core/navigators/CompositeGenerator.ts +268 -0
- package/src/core/navigators/Pipeline.ts +205 -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 +6 -0
- package/src/core/navigators/filters/types.ts +115 -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 +345 -3
- package/src/core/navigators/interferenceMitigator.ts +367 -0
- package/src/core/navigators/relativePriority.ts +267 -0
- package/src/core/navigators/srs.ts +195 -0
- package/src/impl/couch/classroomDB.ts +51 -0
- package/src/impl/couch/courseDB.ts +117 -39
- package/src/impl/static/courseDB.ts +0 -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 +405 -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/{types-legacy-6ettoclI.d.mts → types-legacy-6ettoclI.d.cts} +0 -0
package/dist/core/index.js
CHANGED
|
@@ -181,9 +181,9 @@ var import_pouchdb, import_pouchdb_find, import_pouchdb_authentication, pouchdb_
|
|
|
181
181
|
var init_pouchdb_setup = __esm({
|
|
182
182
|
"src/impl/couch/pouchdb-setup.ts"() {
|
|
183
183
|
"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"));
|
|
184
|
+
import_pouchdb = __toESM(require("pouchdb"), 1);
|
|
185
|
+
import_pouchdb_find = __toESM(require("pouchdb-find"), 1);
|
|
186
|
+
import_pouchdb_authentication = __toESM(require("@nilock2/pouchdb-authentication"), 1);
|
|
187
187
|
import_pouchdb.default.plugin(import_pouchdb_find.default);
|
|
188
188
|
import_pouchdb.default.plugin(import_pouchdb_authentication.default);
|
|
189
189
|
import_pouchdb.default.defaults({
|
|
@@ -218,8 +218,8 @@ var path, os;
|
|
|
218
218
|
var init_dataDirectory = __esm({
|
|
219
219
|
"src/util/dataDirectory.ts"() {
|
|
220
220
|
"use strict";
|
|
221
|
-
path = __toESM(require("path"));
|
|
222
|
-
os = __toESM(require("os"));
|
|
221
|
+
path = __toESM(require("path"), 1);
|
|
222
|
+
os = __toESM(require("os"), 1);
|
|
223
223
|
init_tuiLogger();
|
|
224
224
|
init_factory();
|
|
225
225
|
}
|
|
@@ -279,7 +279,7 @@ var import_moment, REVIEW_TIME_FORMAT, log2;
|
|
|
279
279
|
var init_userDBHelpers = __esm({
|
|
280
280
|
"src/impl/common/userDBHelpers.ts"() {
|
|
281
281
|
"use strict";
|
|
282
|
-
import_moment = __toESM(require("moment"));
|
|
282
|
+
import_moment = __toESM(require("moment"), 1);
|
|
283
283
|
init_core();
|
|
284
284
|
init_logger();
|
|
285
285
|
init_pouchdb_setup();
|
|
@@ -435,7 +435,7 @@ var import_moment2, UsrCrsData;
|
|
|
435
435
|
var init_user_course_relDB = __esm({
|
|
436
436
|
"src/impl/couch/user-course-relDB.ts"() {
|
|
437
437
|
"use strict";
|
|
438
|
-
import_moment2 = __toESM(require("moment"));
|
|
438
|
+
import_moment2 = __toESM(require("moment"), 1);
|
|
439
439
|
init_logger();
|
|
440
440
|
UsrCrsData = class {
|
|
441
441
|
user;
|
|
@@ -709,23 +709,460 @@ var init_courseLookupDB = __esm({
|
|
|
709
709
|
}
|
|
710
710
|
});
|
|
711
711
|
|
|
712
|
+
// src/core/navigators/CompositeGenerator.ts
|
|
713
|
+
var CompositeGenerator_exports = {};
|
|
714
|
+
__export(CompositeGenerator_exports, {
|
|
715
|
+
AggregationMode: () => AggregationMode,
|
|
716
|
+
default: () => CompositeGenerator
|
|
717
|
+
});
|
|
718
|
+
var AggregationMode, DEFAULT_AGGREGATION_MODE, FREQUENCY_BOOST_FACTOR, CompositeGenerator;
|
|
719
|
+
var init_CompositeGenerator = __esm({
|
|
720
|
+
"src/core/navigators/CompositeGenerator.ts"() {
|
|
721
|
+
"use strict";
|
|
722
|
+
init_navigators();
|
|
723
|
+
init_logger();
|
|
724
|
+
AggregationMode = /* @__PURE__ */ ((AggregationMode2) => {
|
|
725
|
+
AggregationMode2["MAX"] = "max";
|
|
726
|
+
AggregationMode2["AVERAGE"] = "average";
|
|
727
|
+
AggregationMode2["FREQUENCY_BOOST"] = "frequencyBoost";
|
|
728
|
+
return AggregationMode2;
|
|
729
|
+
})(AggregationMode || {});
|
|
730
|
+
DEFAULT_AGGREGATION_MODE = "frequencyBoost" /* FREQUENCY_BOOST */;
|
|
731
|
+
FREQUENCY_BOOST_FACTOR = 0.1;
|
|
732
|
+
CompositeGenerator = class _CompositeGenerator extends ContentNavigator {
|
|
733
|
+
/** Human-readable name for CardGenerator interface */
|
|
734
|
+
name = "Composite Generator";
|
|
735
|
+
generators;
|
|
736
|
+
aggregationMode;
|
|
737
|
+
constructor(generators, aggregationMode = DEFAULT_AGGREGATION_MODE) {
|
|
738
|
+
super();
|
|
739
|
+
this.generators = generators;
|
|
740
|
+
this.aggregationMode = aggregationMode;
|
|
741
|
+
if (generators.length === 0) {
|
|
742
|
+
throw new Error("CompositeGenerator requires at least one generator");
|
|
743
|
+
}
|
|
744
|
+
logger.debug(
|
|
745
|
+
`[CompositeGenerator] Created with ${generators.length} generators, mode: ${aggregationMode}`
|
|
746
|
+
);
|
|
747
|
+
}
|
|
748
|
+
/**
|
|
749
|
+
* Creates a CompositeGenerator from strategy data.
|
|
750
|
+
*
|
|
751
|
+
* This is a convenience factory for use by PipelineAssembler.
|
|
752
|
+
*/
|
|
753
|
+
static async fromStrategies(user, course, strategies, aggregationMode = DEFAULT_AGGREGATION_MODE) {
|
|
754
|
+
const generators = await Promise.all(
|
|
755
|
+
strategies.map((s) => ContentNavigator.create(user, course, s))
|
|
756
|
+
);
|
|
757
|
+
return new _CompositeGenerator(generators, aggregationMode);
|
|
758
|
+
}
|
|
759
|
+
/**
|
|
760
|
+
* Get weighted cards from all generators, merge and deduplicate.
|
|
761
|
+
*
|
|
762
|
+
* Cards appearing in multiple generators receive a score boost.
|
|
763
|
+
* Provenance tracks which generators produced each card and how scores were aggregated.
|
|
764
|
+
*
|
|
765
|
+
* This method supports both the legacy signature (limit only) and the
|
|
766
|
+
* CardGenerator interface signature (limit, context).
|
|
767
|
+
*
|
|
768
|
+
* @param limit - Maximum number of cards to return
|
|
769
|
+
* @param context - Optional GeneratorContext passed to child generators
|
|
770
|
+
*/
|
|
771
|
+
async getWeightedCards(limit, context) {
|
|
772
|
+
const results = await Promise.all(
|
|
773
|
+
this.generators.map((g) => g.getWeightedCards(limit, context))
|
|
774
|
+
);
|
|
775
|
+
const byCardId = /* @__PURE__ */ new Map();
|
|
776
|
+
for (const cards of results) {
|
|
777
|
+
for (const card of cards) {
|
|
778
|
+
const existing = byCardId.get(card.cardId) || [];
|
|
779
|
+
existing.push(card);
|
|
780
|
+
byCardId.set(card.cardId, existing);
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
const merged = [];
|
|
784
|
+
for (const [, cards] of byCardId) {
|
|
785
|
+
const aggregatedScore = this.aggregateScores(cards);
|
|
786
|
+
const finalScore = Math.min(1, aggregatedScore);
|
|
787
|
+
const mergedProvenance = cards.flatMap((c) => c.provenance);
|
|
788
|
+
const initialScore = cards[0].score;
|
|
789
|
+
const action = finalScore > initialScore ? "boosted" : finalScore < initialScore ? "penalized" : "passed";
|
|
790
|
+
const reason = this.buildAggregationReason(cards, finalScore);
|
|
791
|
+
merged.push({
|
|
792
|
+
...cards[0],
|
|
793
|
+
score: finalScore,
|
|
794
|
+
provenance: [
|
|
795
|
+
...mergedProvenance,
|
|
796
|
+
{
|
|
797
|
+
strategy: "composite",
|
|
798
|
+
strategyName: "Composite Generator",
|
|
799
|
+
strategyId: "COMPOSITE_GENERATOR",
|
|
800
|
+
action,
|
|
801
|
+
score: finalScore,
|
|
802
|
+
reason
|
|
803
|
+
}
|
|
804
|
+
]
|
|
805
|
+
});
|
|
806
|
+
}
|
|
807
|
+
return merged.sort((a, b) => b.score - a.score).slice(0, limit);
|
|
808
|
+
}
|
|
809
|
+
/**
|
|
810
|
+
* Build human-readable reason for score aggregation.
|
|
811
|
+
*/
|
|
812
|
+
buildAggregationReason(cards, finalScore) {
|
|
813
|
+
const count = cards.length;
|
|
814
|
+
const scores = cards.map((c) => c.score.toFixed(2)).join(", ");
|
|
815
|
+
if (count === 1) {
|
|
816
|
+
return `Single generator, score ${finalScore.toFixed(2)}`;
|
|
817
|
+
}
|
|
818
|
+
const strategies = cards.map((c) => c.provenance[0]?.strategy || "unknown").join(", ");
|
|
819
|
+
switch (this.aggregationMode) {
|
|
820
|
+
case "max" /* MAX */:
|
|
821
|
+
return `Max of ${count} generators (${strategies}): scores [${scores}] \u2192 ${finalScore.toFixed(2)}`;
|
|
822
|
+
case "average" /* AVERAGE */:
|
|
823
|
+
return `Average of ${count} generators (${strategies}): scores [${scores}] \u2192 ${finalScore.toFixed(2)}`;
|
|
824
|
+
case "frequencyBoost" /* FREQUENCY_BOOST */: {
|
|
825
|
+
const avg = cards.reduce((sum, c) => sum + c.score, 0) / count;
|
|
826
|
+
const boost = 1 + FREQUENCY_BOOST_FACTOR * (count - 1);
|
|
827
|
+
return `Frequency boost from ${count} generators (${strategies}): avg ${avg.toFixed(2)} \xD7 ${boost.toFixed(2)} \u2192 ${finalScore.toFixed(2)}`;
|
|
828
|
+
}
|
|
829
|
+
default:
|
|
830
|
+
return `Aggregated from ${count} generators: ${finalScore.toFixed(2)}`;
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
/**
|
|
834
|
+
* Aggregate scores from multiple generators for the same card.
|
|
835
|
+
*/
|
|
836
|
+
aggregateScores(cards) {
|
|
837
|
+
const scores = cards.map((c) => c.score);
|
|
838
|
+
switch (this.aggregationMode) {
|
|
839
|
+
case "max" /* MAX */:
|
|
840
|
+
return Math.max(...scores);
|
|
841
|
+
case "average" /* AVERAGE */:
|
|
842
|
+
return scores.reduce((sum, s) => sum + s, 0) / scores.length;
|
|
843
|
+
case "frequencyBoost" /* FREQUENCY_BOOST */: {
|
|
844
|
+
const avg = scores.reduce((sum, s) => sum + s, 0) / scores.length;
|
|
845
|
+
const frequencyBoost = 1 + FREQUENCY_BOOST_FACTOR * (cards.length - 1);
|
|
846
|
+
return avg * frequencyBoost;
|
|
847
|
+
}
|
|
848
|
+
default:
|
|
849
|
+
return scores[0];
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
/**
|
|
853
|
+
* Get new cards from all generators, merged and deduplicated.
|
|
854
|
+
*/
|
|
855
|
+
async getNewCards(n) {
|
|
856
|
+
const legacyGenerators = this.generators.filter(
|
|
857
|
+
(g) => g instanceof ContentNavigator
|
|
858
|
+
);
|
|
859
|
+
const results = await Promise.all(legacyGenerators.map((g) => g.getNewCards(n)));
|
|
860
|
+
const seen = /* @__PURE__ */ new Set();
|
|
861
|
+
const merged = [];
|
|
862
|
+
for (const cards of results) {
|
|
863
|
+
for (const card of cards) {
|
|
864
|
+
if (!seen.has(card.cardID)) {
|
|
865
|
+
seen.add(card.cardID);
|
|
866
|
+
merged.push(card);
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
return n ? merged.slice(0, n) : merged;
|
|
871
|
+
}
|
|
872
|
+
/**
|
|
873
|
+
* Get pending reviews from all generators, merged and deduplicated.
|
|
874
|
+
*/
|
|
875
|
+
async getPendingReviews() {
|
|
876
|
+
const legacyGenerators = this.generators.filter(
|
|
877
|
+
(g) => g instanceof ContentNavigator
|
|
878
|
+
);
|
|
879
|
+
const results = await Promise.all(legacyGenerators.map((g) => g.getPendingReviews()));
|
|
880
|
+
const seen = /* @__PURE__ */ new Set();
|
|
881
|
+
const merged = [];
|
|
882
|
+
for (const reviews of results) {
|
|
883
|
+
for (const review of reviews) {
|
|
884
|
+
if (!seen.has(review.cardID)) {
|
|
885
|
+
seen.add(review.cardID);
|
|
886
|
+
merged.push(review);
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
return merged;
|
|
891
|
+
}
|
|
892
|
+
};
|
|
893
|
+
}
|
|
894
|
+
});
|
|
895
|
+
|
|
896
|
+
// src/core/navigators/Pipeline.ts
|
|
897
|
+
var Pipeline_exports = {};
|
|
898
|
+
__export(Pipeline_exports, {
|
|
899
|
+
Pipeline: () => Pipeline
|
|
900
|
+
});
|
|
901
|
+
var import_common5, Pipeline;
|
|
902
|
+
var init_Pipeline = __esm({
|
|
903
|
+
"src/core/navigators/Pipeline.ts"() {
|
|
904
|
+
"use strict";
|
|
905
|
+
import_common5 = require("@vue-skuilder/common");
|
|
906
|
+
init_navigators();
|
|
907
|
+
init_logger();
|
|
908
|
+
Pipeline = class extends ContentNavigator {
|
|
909
|
+
generator;
|
|
910
|
+
filters;
|
|
911
|
+
/**
|
|
912
|
+
* Create a new pipeline.
|
|
913
|
+
*
|
|
914
|
+
* @param generator - The generator (or CompositeGenerator) that produces candidates
|
|
915
|
+
* @param filters - Filters to apply sequentially (order doesn't matter for multipliers)
|
|
916
|
+
* @param user - User database interface
|
|
917
|
+
* @param course - Course database interface
|
|
918
|
+
*/
|
|
919
|
+
constructor(generator, filters, user, course) {
|
|
920
|
+
super();
|
|
921
|
+
this.generator = generator;
|
|
922
|
+
this.filters = filters;
|
|
923
|
+
this.user = user;
|
|
924
|
+
this.course = course;
|
|
925
|
+
logger.debug(
|
|
926
|
+
`[Pipeline] Created with generator '${generator.name}' and ${filters.length} filters: ${filters.map((f) => f.name).join(", ")}`
|
|
927
|
+
);
|
|
928
|
+
}
|
|
929
|
+
/**
|
|
930
|
+
* Get weighted cards by running generator and applying filters.
|
|
931
|
+
*
|
|
932
|
+
* 1. Build shared context (user ELO, etc.)
|
|
933
|
+
* 2. Get candidates from generator (passing context)
|
|
934
|
+
* 3. Apply each filter sequentially
|
|
935
|
+
* 4. Remove zero-score cards
|
|
936
|
+
* 5. Sort by score descending
|
|
937
|
+
* 6. Return top N
|
|
938
|
+
*
|
|
939
|
+
* @param limit - Maximum number of cards to return
|
|
940
|
+
* @returns Cards sorted by score descending
|
|
941
|
+
*/
|
|
942
|
+
async getWeightedCards(limit) {
|
|
943
|
+
const context = await this.buildContext();
|
|
944
|
+
const overFetchMultiplier = 2 + this.filters.length * 0.5;
|
|
945
|
+
const fetchLimit = Math.ceil(limit * overFetchMultiplier);
|
|
946
|
+
logger.debug(
|
|
947
|
+
`[Pipeline] Fetching ${fetchLimit} candidates from generator '${this.generator.name}'`
|
|
948
|
+
);
|
|
949
|
+
let cards = await this.generator.getWeightedCards(fetchLimit, context);
|
|
950
|
+
logger.debug(`[Pipeline] Generator returned ${cards.length} candidates`);
|
|
951
|
+
for (const filter of this.filters) {
|
|
952
|
+
const beforeCount = cards.length;
|
|
953
|
+
cards = await filter.transform(cards, context);
|
|
954
|
+
logger.debug(`[Pipeline] Filter '${filter.name}': ${beforeCount} \u2192 ${cards.length} cards`);
|
|
955
|
+
}
|
|
956
|
+
cards = cards.filter((c) => c.score > 0);
|
|
957
|
+
cards.sort((a, b) => b.score - a.score);
|
|
958
|
+
const result = cards.slice(0, limit);
|
|
959
|
+
logger.debug(
|
|
960
|
+
`[Pipeline] Returning ${result.length} cards (top scores: ${result.slice(0, 3).map((c) => c.score.toFixed(2)).join(", ")}...)`
|
|
961
|
+
);
|
|
962
|
+
return result;
|
|
963
|
+
}
|
|
964
|
+
/**
|
|
965
|
+
* Build shared context for generator and filters.
|
|
966
|
+
*
|
|
967
|
+
* Called once per getWeightedCards() invocation.
|
|
968
|
+
* Contains data that the generator and multiple filters might need.
|
|
969
|
+
*
|
|
970
|
+
* The context satisfies both GeneratorContext and FilterContext interfaces.
|
|
971
|
+
*/
|
|
972
|
+
async buildContext() {
|
|
973
|
+
let userElo = 1e3;
|
|
974
|
+
try {
|
|
975
|
+
const courseReg = await this.user.getCourseRegDoc(this.course.getCourseID());
|
|
976
|
+
const courseElo = (0, import_common5.toCourseElo)(courseReg.elo);
|
|
977
|
+
userElo = courseElo.global.score;
|
|
978
|
+
} catch (e) {
|
|
979
|
+
logger.debug(`[Pipeline] Could not get user ELO, using default: ${e}`);
|
|
980
|
+
}
|
|
981
|
+
return {
|
|
982
|
+
user: this.user,
|
|
983
|
+
course: this.course,
|
|
984
|
+
userElo
|
|
985
|
+
};
|
|
986
|
+
}
|
|
987
|
+
// ===========================================================================
|
|
988
|
+
// Legacy StudyContentSource methods
|
|
989
|
+
// ===========================================================================
|
|
990
|
+
//
|
|
991
|
+
// These delegate to the generator for backward compatibility.
|
|
992
|
+
// Eventually SessionController will use getWeightedCards() exclusively.
|
|
993
|
+
//
|
|
994
|
+
/**
|
|
995
|
+
* Get new cards via legacy API.
|
|
996
|
+
* Delegates to the generator if it supports the legacy interface.
|
|
997
|
+
*/
|
|
998
|
+
async getNewCards(n) {
|
|
999
|
+
if ("getNewCards" in this.generator && typeof this.generator.getNewCards === "function") {
|
|
1000
|
+
return this.generator.getNewCards(n);
|
|
1001
|
+
}
|
|
1002
|
+
return [];
|
|
1003
|
+
}
|
|
1004
|
+
/**
|
|
1005
|
+
* Get pending reviews via legacy API.
|
|
1006
|
+
* Delegates to the generator if it supports the legacy interface.
|
|
1007
|
+
*/
|
|
1008
|
+
async getPendingReviews() {
|
|
1009
|
+
if ("getPendingReviews" in this.generator && typeof this.generator.getPendingReviews === "function") {
|
|
1010
|
+
return this.generator.getPendingReviews();
|
|
1011
|
+
}
|
|
1012
|
+
return [];
|
|
1013
|
+
}
|
|
1014
|
+
/**
|
|
1015
|
+
* Get the course ID for this pipeline.
|
|
1016
|
+
*/
|
|
1017
|
+
getCourseID() {
|
|
1018
|
+
return this.course.getCourseID();
|
|
1019
|
+
}
|
|
1020
|
+
};
|
|
1021
|
+
}
|
|
1022
|
+
});
|
|
1023
|
+
|
|
1024
|
+
// src/core/navigators/PipelineAssembler.ts
|
|
1025
|
+
var PipelineAssembler_exports = {};
|
|
1026
|
+
__export(PipelineAssembler_exports, {
|
|
1027
|
+
PipelineAssembler: () => PipelineAssembler
|
|
1028
|
+
});
|
|
1029
|
+
var PipelineAssembler;
|
|
1030
|
+
var init_PipelineAssembler = __esm({
|
|
1031
|
+
"src/core/navigators/PipelineAssembler.ts"() {
|
|
1032
|
+
"use strict";
|
|
1033
|
+
init_navigators();
|
|
1034
|
+
init_Pipeline();
|
|
1035
|
+
init_types_legacy();
|
|
1036
|
+
init_logger();
|
|
1037
|
+
init_CompositeGenerator();
|
|
1038
|
+
PipelineAssembler = class {
|
|
1039
|
+
/**
|
|
1040
|
+
* Assembles a navigation pipeline from strategy documents.
|
|
1041
|
+
*
|
|
1042
|
+
* 1. Separates into generators and filters by role
|
|
1043
|
+
* 2. Validates at least one generator exists (or creates default ELO)
|
|
1044
|
+
* 3. Instantiates generators - wraps multiple in CompositeGenerator
|
|
1045
|
+
* 4. Instantiates filters
|
|
1046
|
+
* 5. Returns Pipeline(generator, filters)
|
|
1047
|
+
*
|
|
1048
|
+
* @param input - Strategy documents plus user/course interfaces
|
|
1049
|
+
* @returns Assembled pipeline and any warnings
|
|
1050
|
+
*/
|
|
1051
|
+
async assemble(input) {
|
|
1052
|
+
const { strategies, user, course } = input;
|
|
1053
|
+
const warnings = [];
|
|
1054
|
+
if (strategies.length === 0) {
|
|
1055
|
+
return {
|
|
1056
|
+
pipeline: null,
|
|
1057
|
+
generatorStrategies: [],
|
|
1058
|
+
filterStrategies: [],
|
|
1059
|
+
warnings
|
|
1060
|
+
};
|
|
1061
|
+
}
|
|
1062
|
+
const generatorStrategies = [];
|
|
1063
|
+
const filterStrategies = [];
|
|
1064
|
+
for (const s of strategies) {
|
|
1065
|
+
if (isGenerator(s.implementingClass)) {
|
|
1066
|
+
generatorStrategies.push(s);
|
|
1067
|
+
} else if (isFilter(s.implementingClass)) {
|
|
1068
|
+
filterStrategies.push(s);
|
|
1069
|
+
} else {
|
|
1070
|
+
warnings.push(`Unknown strategy type '${s.implementingClass}', skipping: ${s.name}`);
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
if (generatorStrategies.length === 0) {
|
|
1074
|
+
if (filterStrategies.length > 0) {
|
|
1075
|
+
logger.debug(
|
|
1076
|
+
"[PipelineAssembler] No generator found, using default ELO with configured filters"
|
|
1077
|
+
);
|
|
1078
|
+
generatorStrategies.push(this.makeDefaultEloStrategy(course.getCourseID()));
|
|
1079
|
+
} else {
|
|
1080
|
+
warnings.push("No generator strategy found");
|
|
1081
|
+
return {
|
|
1082
|
+
pipeline: null,
|
|
1083
|
+
generatorStrategies: [],
|
|
1084
|
+
filterStrategies: [],
|
|
1085
|
+
warnings
|
|
1086
|
+
};
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
let generator;
|
|
1090
|
+
if (generatorStrategies.length === 1) {
|
|
1091
|
+
const nav = await ContentNavigator.create(user, course, generatorStrategies[0]);
|
|
1092
|
+
generator = nav;
|
|
1093
|
+
logger.debug(`[PipelineAssembler] Using single generator: ${generatorStrategies[0].name}`);
|
|
1094
|
+
} else {
|
|
1095
|
+
logger.debug(
|
|
1096
|
+
`[PipelineAssembler] Using CompositeGenerator for ${generatorStrategies.length} generators: ${generatorStrategies.map((g) => g.name).join(", ")}`
|
|
1097
|
+
);
|
|
1098
|
+
generator = await CompositeGenerator.fromStrategies(user, course, generatorStrategies);
|
|
1099
|
+
}
|
|
1100
|
+
const filters = [];
|
|
1101
|
+
const sortedFilterStrategies = [...filterStrategies].sort(
|
|
1102
|
+
(a, b) => a.name.localeCompare(b.name)
|
|
1103
|
+
);
|
|
1104
|
+
for (const filterStrategy of sortedFilterStrategies) {
|
|
1105
|
+
try {
|
|
1106
|
+
const nav = await ContentNavigator.create(user, course, filterStrategy);
|
|
1107
|
+
if ("transform" in nav && typeof nav.transform === "function") {
|
|
1108
|
+
filters.push(nav);
|
|
1109
|
+
logger.debug(`[PipelineAssembler] Added filter: ${filterStrategy.name}`);
|
|
1110
|
+
} else {
|
|
1111
|
+
warnings.push(
|
|
1112
|
+
`Filter '${filterStrategy.name}' does not implement CardFilter.transform(), skipping`
|
|
1113
|
+
);
|
|
1114
|
+
}
|
|
1115
|
+
} catch (e) {
|
|
1116
|
+
warnings.push(`Failed to instantiate filter '${filterStrategy.name}': ${e}`);
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
const pipeline = new Pipeline(generator, filters, user, course);
|
|
1120
|
+
logger.debug(
|
|
1121
|
+
`[PipelineAssembler] Assembled pipeline with ${generatorStrategies.length} generator(s) and ${filters.length} filter(s)`
|
|
1122
|
+
);
|
|
1123
|
+
return {
|
|
1124
|
+
pipeline,
|
|
1125
|
+
generatorStrategies,
|
|
1126
|
+
filterStrategies: sortedFilterStrategies,
|
|
1127
|
+
warnings
|
|
1128
|
+
};
|
|
1129
|
+
}
|
|
1130
|
+
/**
|
|
1131
|
+
* Creates a default ELO generator strategy.
|
|
1132
|
+
* Used when filters are configured but no generator is specified.
|
|
1133
|
+
*/
|
|
1134
|
+
makeDefaultEloStrategy(courseId) {
|
|
1135
|
+
return {
|
|
1136
|
+
_id: "NAVIGATION_STRATEGY-ELO-default",
|
|
1137
|
+
course: courseId,
|
|
1138
|
+
docType: "NAVIGATION_STRATEGY" /* NAVIGATION_STRATEGY */,
|
|
1139
|
+
name: "ELO (default)",
|
|
1140
|
+
description: "Default ELO-based generator",
|
|
1141
|
+
implementingClass: "elo" /* ELO */,
|
|
1142
|
+
serializedData: ""
|
|
1143
|
+
};
|
|
1144
|
+
}
|
|
1145
|
+
};
|
|
1146
|
+
}
|
|
1147
|
+
});
|
|
1148
|
+
|
|
712
1149
|
// src/core/navigators/elo.ts
|
|
713
1150
|
var elo_exports = {};
|
|
714
1151
|
__export(elo_exports, {
|
|
715
1152
|
default: () => ELONavigator
|
|
716
1153
|
});
|
|
717
|
-
var ELONavigator;
|
|
1154
|
+
var import_common6, ELONavigator;
|
|
718
1155
|
var init_elo = __esm({
|
|
719
1156
|
"src/core/navigators/elo.ts"() {
|
|
720
1157
|
"use strict";
|
|
721
1158
|
init_navigators();
|
|
1159
|
+
import_common6 = require("@vue-skuilder/common");
|
|
722
1160
|
ELONavigator = class extends ContentNavigator {
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
constructor(user, course) {
|
|
726
|
-
super();
|
|
727
|
-
this.
|
|
728
|
-
this.course = course;
|
|
1161
|
+
/** Human-readable name for CardGenerator interface */
|
|
1162
|
+
name;
|
|
1163
|
+
constructor(user, course, strategyData) {
|
|
1164
|
+
super(user, course, strategyData);
|
|
1165
|
+
this.name = strategyData?.name || "ELO";
|
|
729
1166
|
}
|
|
730
1167
|
async getPendingReviews() {
|
|
731
1168
|
const reviews = await this.user.getPendingReviews(this.course.getCourseID());
|
|
@@ -753,84 +1190,983 @@ var init_elo = __esm({
|
|
|
753
1190
|
};
|
|
754
1191
|
});
|
|
755
1192
|
}
|
|
756
|
-
async getNewCards(limit = 99) {
|
|
757
|
-
const activeCards = await this.user.getActiveCards();
|
|
758
|
-
return (await this.course.getCardsCenteredAtELO(
|
|
759
|
-
{ limit, elo: "user" },
|
|
760
|
-
(c) => {
|
|
761
|
-
if (activeCards.some((ac) => c.cardID === ac.cardID)) {
|
|
762
|
-
return false;
|
|
763
|
-
} else {
|
|
764
|
-
return true;
|
|
765
|
-
}
|
|
766
|
-
}
|
|
767
|
-
)).map((c) => {
|
|
768
|
-
return {
|
|
769
|
-
...c,
|
|
770
|
-
status: "new"
|
|
771
|
-
};
|
|
772
|
-
});
|
|
1193
|
+
async getNewCards(limit = 99) {
|
|
1194
|
+
const activeCards = await this.user.getActiveCards();
|
|
1195
|
+
return (await this.course.getCardsCenteredAtELO(
|
|
1196
|
+
{ limit, elo: "user" },
|
|
1197
|
+
(c) => {
|
|
1198
|
+
if (activeCards.some((ac) => c.cardID === ac.cardID)) {
|
|
1199
|
+
return false;
|
|
1200
|
+
} else {
|
|
1201
|
+
return true;
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
)).map((c) => {
|
|
1205
|
+
return {
|
|
1206
|
+
...c,
|
|
1207
|
+
status: "new"
|
|
1208
|
+
};
|
|
1209
|
+
});
|
|
1210
|
+
}
|
|
1211
|
+
/**
|
|
1212
|
+
* Get new cards with suitability scores based on ELO distance.
|
|
1213
|
+
*
|
|
1214
|
+
* Cards closer to user's ELO get higher scores.
|
|
1215
|
+
* Score formula: max(0, 1 - distance / 500)
|
|
1216
|
+
*
|
|
1217
|
+
* NOTE: This generator only handles NEW cards. Reviews are handled by
|
|
1218
|
+
* SRSNavigator. Use CompositeGenerator to combine both.
|
|
1219
|
+
*
|
|
1220
|
+
* This method supports both the legacy signature (limit only) and the
|
|
1221
|
+
* CardGenerator interface signature (limit, context).
|
|
1222
|
+
*
|
|
1223
|
+
* @param limit - Maximum number of cards to return
|
|
1224
|
+
* @param context - Optional GeneratorContext (used when called via Pipeline)
|
|
1225
|
+
*/
|
|
1226
|
+
async getWeightedCards(limit, context) {
|
|
1227
|
+
let userGlobalElo;
|
|
1228
|
+
if (context?.userElo !== void 0) {
|
|
1229
|
+
userGlobalElo = context.userElo;
|
|
1230
|
+
} else {
|
|
1231
|
+
const courseReg = await this.user.getCourseRegDoc(this.course.getCourseID());
|
|
1232
|
+
const userElo = (0, import_common6.toCourseElo)(courseReg.elo);
|
|
1233
|
+
userGlobalElo = userElo.global.score;
|
|
1234
|
+
}
|
|
1235
|
+
const newCards = await this.getNewCards(limit);
|
|
1236
|
+
const cardIds = newCards.map((c) => c.cardID);
|
|
1237
|
+
const cardEloData = await this.course.getCardEloData(cardIds);
|
|
1238
|
+
const scored = newCards.map((c, i) => {
|
|
1239
|
+
const cardElo = cardEloData[i]?.global?.score ?? 1e3;
|
|
1240
|
+
const distance = Math.abs(cardElo - userGlobalElo);
|
|
1241
|
+
const score = Math.max(0, 1 - distance / 500);
|
|
1242
|
+
return {
|
|
1243
|
+
cardId: c.cardID,
|
|
1244
|
+
courseId: c.courseID,
|
|
1245
|
+
score,
|
|
1246
|
+
provenance: [
|
|
1247
|
+
{
|
|
1248
|
+
strategy: "elo",
|
|
1249
|
+
strategyName: this.strategyName || this.name,
|
|
1250
|
+
strategyId: this.strategyId || "NAVIGATION_STRATEGY-ELO-default",
|
|
1251
|
+
action: "generated",
|
|
1252
|
+
score,
|
|
1253
|
+
reason: `ELO distance ${Math.round(distance)} (card: ${Math.round(cardElo)}, user: ${Math.round(userGlobalElo)}), new card`
|
|
1254
|
+
}
|
|
1255
|
+
]
|
|
1256
|
+
};
|
|
1257
|
+
});
|
|
1258
|
+
scored.sort((a, b) => b.score - a.score);
|
|
1259
|
+
return scored.slice(0, limit);
|
|
1260
|
+
}
|
|
1261
|
+
};
|
|
1262
|
+
}
|
|
1263
|
+
});
|
|
1264
|
+
|
|
1265
|
+
// src/core/navigators/filters/eloDistance.ts
|
|
1266
|
+
var eloDistance_exports = {};
|
|
1267
|
+
__export(eloDistance_exports, {
|
|
1268
|
+
DEFAULT_HALF_LIFE: () => DEFAULT_HALF_LIFE,
|
|
1269
|
+
DEFAULT_MAX_MULTIPLIER: () => DEFAULT_MAX_MULTIPLIER,
|
|
1270
|
+
DEFAULT_MIN_MULTIPLIER: () => DEFAULT_MIN_MULTIPLIER,
|
|
1271
|
+
createEloDistanceFilter: () => createEloDistanceFilter
|
|
1272
|
+
});
|
|
1273
|
+
function computeMultiplier(distance, halfLife, minMultiplier, maxMultiplier) {
|
|
1274
|
+
const normalizedDistance = distance / halfLife;
|
|
1275
|
+
const decay = Math.exp(-(normalizedDistance * normalizedDistance));
|
|
1276
|
+
return minMultiplier + (maxMultiplier - minMultiplier) * decay;
|
|
1277
|
+
}
|
|
1278
|
+
function createEloDistanceFilter(config) {
|
|
1279
|
+
const halfLife = config?.halfLife ?? DEFAULT_HALF_LIFE;
|
|
1280
|
+
const minMultiplier = config?.minMultiplier ?? DEFAULT_MIN_MULTIPLIER;
|
|
1281
|
+
const maxMultiplier = config?.maxMultiplier ?? DEFAULT_MAX_MULTIPLIER;
|
|
1282
|
+
return {
|
|
1283
|
+
name: "ELO Distance Filter",
|
|
1284
|
+
async transform(cards, context) {
|
|
1285
|
+
const { course, userElo } = context;
|
|
1286
|
+
const cardIds = cards.map((c) => c.cardId);
|
|
1287
|
+
const cardElos = await course.getCardEloData(cardIds);
|
|
1288
|
+
return cards.map((card, i) => {
|
|
1289
|
+
const cardElo = cardElos[i]?.global?.score ?? 1e3;
|
|
1290
|
+
const distance = Math.abs(cardElo - userElo);
|
|
1291
|
+
const multiplier = computeMultiplier(distance, halfLife, minMultiplier, maxMultiplier);
|
|
1292
|
+
const newScore = card.score * multiplier;
|
|
1293
|
+
const action = multiplier < maxMultiplier - 0.01 ? "penalized" : "passed";
|
|
1294
|
+
return {
|
|
1295
|
+
...card,
|
|
1296
|
+
score: newScore,
|
|
1297
|
+
provenance: [
|
|
1298
|
+
...card.provenance,
|
|
1299
|
+
{
|
|
1300
|
+
strategy: "eloDistance",
|
|
1301
|
+
strategyName: "ELO Distance Filter",
|
|
1302
|
+
strategyId: "ELO_DISTANCE_FILTER",
|
|
1303
|
+
action,
|
|
1304
|
+
score: newScore,
|
|
1305
|
+
reason: `ELO distance ${Math.round(distance)} (card: ${Math.round(cardElo)}, user: ${Math.round(userElo)}) \u2192 ${multiplier.toFixed(2)}x`
|
|
1306
|
+
}
|
|
1307
|
+
]
|
|
1308
|
+
};
|
|
1309
|
+
});
|
|
1310
|
+
}
|
|
1311
|
+
};
|
|
1312
|
+
}
|
|
1313
|
+
var DEFAULT_HALF_LIFE, DEFAULT_MIN_MULTIPLIER, DEFAULT_MAX_MULTIPLIER;
|
|
1314
|
+
var init_eloDistance = __esm({
|
|
1315
|
+
"src/core/navigators/filters/eloDistance.ts"() {
|
|
1316
|
+
"use strict";
|
|
1317
|
+
DEFAULT_HALF_LIFE = 200;
|
|
1318
|
+
DEFAULT_MIN_MULTIPLIER = 0.3;
|
|
1319
|
+
DEFAULT_MAX_MULTIPLIER = 1;
|
|
1320
|
+
}
|
|
1321
|
+
});
|
|
1322
|
+
|
|
1323
|
+
// src/core/navigators/filters/index.ts
|
|
1324
|
+
var filters_exports = {};
|
|
1325
|
+
__export(filters_exports, {
|
|
1326
|
+
createEloDistanceFilter: () => createEloDistanceFilter
|
|
1327
|
+
});
|
|
1328
|
+
var init_filters = __esm({
|
|
1329
|
+
"src/core/navigators/filters/index.ts"() {
|
|
1330
|
+
"use strict";
|
|
1331
|
+
init_eloDistance();
|
|
1332
|
+
}
|
|
1333
|
+
});
|
|
1334
|
+
|
|
1335
|
+
// src/core/navigators/filters/types.ts
|
|
1336
|
+
var types_exports = {};
|
|
1337
|
+
var init_types = __esm({
|
|
1338
|
+
"src/core/navigators/filters/types.ts"() {
|
|
1339
|
+
"use strict";
|
|
1340
|
+
}
|
|
1341
|
+
});
|
|
1342
|
+
|
|
1343
|
+
// src/core/navigators/generators/index.ts
|
|
1344
|
+
var generators_exports = {};
|
|
1345
|
+
var init_generators = __esm({
|
|
1346
|
+
"src/core/navigators/generators/index.ts"() {
|
|
1347
|
+
"use strict";
|
|
1348
|
+
}
|
|
1349
|
+
});
|
|
1350
|
+
|
|
1351
|
+
// src/core/navigators/generators/types.ts
|
|
1352
|
+
var types_exports2 = {};
|
|
1353
|
+
var init_types2 = __esm({
|
|
1354
|
+
"src/core/navigators/generators/types.ts"() {
|
|
1355
|
+
"use strict";
|
|
1356
|
+
}
|
|
1357
|
+
});
|
|
1358
|
+
|
|
1359
|
+
// src/core/navigators/hardcodedOrder.ts
|
|
1360
|
+
var hardcodedOrder_exports = {};
|
|
1361
|
+
__export(hardcodedOrder_exports, {
|
|
1362
|
+
default: () => HardcodedOrderNavigator
|
|
1363
|
+
});
|
|
1364
|
+
var HardcodedOrderNavigator;
|
|
1365
|
+
var init_hardcodedOrder = __esm({
|
|
1366
|
+
"src/core/navigators/hardcodedOrder.ts"() {
|
|
1367
|
+
"use strict";
|
|
1368
|
+
init_navigators();
|
|
1369
|
+
init_logger();
|
|
1370
|
+
HardcodedOrderNavigator = class extends ContentNavigator {
|
|
1371
|
+
/** Human-readable name for CardGenerator interface */
|
|
1372
|
+
name;
|
|
1373
|
+
orderedCardIds = [];
|
|
1374
|
+
constructor(user, course, strategyData) {
|
|
1375
|
+
super(user, course, strategyData);
|
|
1376
|
+
this.name = strategyData.name || "Hardcoded Order";
|
|
1377
|
+
if (strategyData.serializedData) {
|
|
1378
|
+
try {
|
|
1379
|
+
this.orderedCardIds = JSON.parse(strategyData.serializedData);
|
|
1380
|
+
} catch (e) {
|
|
1381
|
+
logger.error("Failed to parse serializedData for HardcodedOrderNavigator", e);
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
async getPendingReviews() {
|
|
1386
|
+
const reviews = await this.user.getPendingReviews(this.course.getCourseID());
|
|
1387
|
+
return reviews.map((r) => {
|
|
1388
|
+
return {
|
|
1389
|
+
...r,
|
|
1390
|
+
contentSourceType: "course",
|
|
1391
|
+
contentSourceID: this.course.getCourseID(),
|
|
1392
|
+
cardID: r.cardId,
|
|
1393
|
+
courseID: r.courseId,
|
|
1394
|
+
reviewID: r._id,
|
|
1395
|
+
status: "review"
|
|
1396
|
+
};
|
|
1397
|
+
});
|
|
1398
|
+
}
|
|
1399
|
+
async getNewCards(limit = 99) {
|
|
1400
|
+
const activeCardIds = (await this.user.getActiveCards()).map((c) => c.cardID);
|
|
1401
|
+
const newCardIds = this.orderedCardIds.filter((cardId) => !activeCardIds.includes(cardId));
|
|
1402
|
+
const cardsToReturn = newCardIds.slice(0, limit);
|
|
1403
|
+
return cardsToReturn.map((cardId) => {
|
|
1404
|
+
return {
|
|
1405
|
+
cardID: cardId,
|
|
1406
|
+
courseID: this.course.getCourseID(),
|
|
1407
|
+
contentSourceType: "course",
|
|
1408
|
+
contentSourceID: this.course.getCourseID(),
|
|
1409
|
+
status: "new"
|
|
1410
|
+
};
|
|
1411
|
+
});
|
|
1412
|
+
}
|
|
1413
|
+
/**
|
|
1414
|
+
* Get cards in hardcoded order with scores based on position.
|
|
1415
|
+
*
|
|
1416
|
+
* Earlier cards in the sequence get higher scores.
|
|
1417
|
+
* Score formula: 1.0 - (position / totalCards) * 0.5
|
|
1418
|
+
* This ensures scores range from 1.0 (first card) to 0.5+ (last card).
|
|
1419
|
+
*
|
|
1420
|
+
* This method supports both the legacy signature (limit only) and the
|
|
1421
|
+
* CardGenerator interface signature (limit, context).
|
|
1422
|
+
*
|
|
1423
|
+
* @param limit - Maximum number of cards to return
|
|
1424
|
+
* @param _context - Optional GeneratorContext (currently unused, but required for interface)
|
|
1425
|
+
*/
|
|
1426
|
+
async getWeightedCards(limit, _context) {
|
|
1427
|
+
const activeCardIds = (await this.user.getActiveCards()).map((c) => c.cardID);
|
|
1428
|
+
const reviews = await this.getPendingReviews();
|
|
1429
|
+
const newCardIds = this.orderedCardIds.filter((cardId) => !activeCardIds.includes(cardId));
|
|
1430
|
+
const totalCards = newCardIds.length;
|
|
1431
|
+
const scoredNew = newCardIds.slice(0, limit).map((cardId, index) => {
|
|
1432
|
+
const position = index + 1;
|
|
1433
|
+
const score = Math.max(0.5, 1 - index / totalCards * 0.5);
|
|
1434
|
+
return {
|
|
1435
|
+
cardId,
|
|
1436
|
+
courseId: this.course.getCourseID(),
|
|
1437
|
+
score,
|
|
1438
|
+
provenance: [
|
|
1439
|
+
{
|
|
1440
|
+
strategy: "hardcodedOrder",
|
|
1441
|
+
strategyName: this.strategyName || this.name,
|
|
1442
|
+
strategyId: this.strategyId || "NAVIGATION_STRATEGY-hardcoded",
|
|
1443
|
+
action: "generated",
|
|
1444
|
+
score,
|
|
1445
|
+
reason: `Position ${position} of ${totalCards} in fixed sequence, new card`
|
|
1446
|
+
}
|
|
1447
|
+
]
|
|
1448
|
+
};
|
|
1449
|
+
});
|
|
1450
|
+
const scoredReviews = reviews.map((r) => ({
|
|
1451
|
+
cardId: r.cardID,
|
|
1452
|
+
courseId: r.courseID,
|
|
1453
|
+
score: 1,
|
|
1454
|
+
provenance: [
|
|
1455
|
+
{
|
|
1456
|
+
strategy: "hardcodedOrder",
|
|
1457
|
+
strategyName: this.strategyName || this.name,
|
|
1458
|
+
strategyId: this.strategyId || "NAVIGATION_STRATEGY-hardcoded",
|
|
1459
|
+
action: "generated",
|
|
1460
|
+
score: 1,
|
|
1461
|
+
reason: "Scheduled review, highest priority"
|
|
1462
|
+
}
|
|
1463
|
+
]
|
|
1464
|
+
}));
|
|
1465
|
+
const all = [...scoredReviews, ...scoredNew];
|
|
1466
|
+
all.sort((a, b) => b.score - a.score);
|
|
1467
|
+
return all.slice(0, limit);
|
|
1468
|
+
}
|
|
1469
|
+
};
|
|
1470
|
+
}
|
|
1471
|
+
});
|
|
1472
|
+
|
|
1473
|
+
// src/core/navigators/hierarchyDefinition.ts
|
|
1474
|
+
var hierarchyDefinition_exports = {};
|
|
1475
|
+
__export(hierarchyDefinition_exports, {
|
|
1476
|
+
default: () => HierarchyDefinitionNavigator
|
|
1477
|
+
});
|
|
1478
|
+
var import_common7, DEFAULT_MIN_COUNT, HierarchyDefinitionNavigator;
|
|
1479
|
+
var init_hierarchyDefinition = __esm({
|
|
1480
|
+
"src/core/navigators/hierarchyDefinition.ts"() {
|
|
1481
|
+
"use strict";
|
|
1482
|
+
init_navigators();
|
|
1483
|
+
import_common7 = require("@vue-skuilder/common");
|
|
1484
|
+
DEFAULT_MIN_COUNT = 3;
|
|
1485
|
+
HierarchyDefinitionNavigator = class extends ContentNavigator {
|
|
1486
|
+
config;
|
|
1487
|
+
_strategyData;
|
|
1488
|
+
/** Human-readable name for CardFilter interface */
|
|
1489
|
+
name;
|
|
1490
|
+
constructor(user, course, _strategyData) {
|
|
1491
|
+
super(user, course, _strategyData);
|
|
1492
|
+
this._strategyData = _strategyData;
|
|
1493
|
+
this.config = this.parseConfig(_strategyData.serializedData);
|
|
1494
|
+
this.name = _strategyData.name || "Hierarchy Definition";
|
|
1495
|
+
}
|
|
1496
|
+
parseConfig(serializedData) {
|
|
1497
|
+
try {
|
|
1498
|
+
const parsed = JSON.parse(serializedData);
|
|
1499
|
+
return {
|
|
1500
|
+
prerequisites: parsed.prerequisites || {}
|
|
1501
|
+
};
|
|
1502
|
+
} catch {
|
|
1503
|
+
return {
|
|
1504
|
+
prerequisites: {}
|
|
1505
|
+
};
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1508
|
+
/**
|
|
1509
|
+
* Check if a specific prerequisite is satisfied
|
|
1510
|
+
*/
|
|
1511
|
+
isPrerequisiteMet(prereq, userTagElo, userGlobalElo) {
|
|
1512
|
+
if (!userTagElo) return false;
|
|
1513
|
+
const minCount = prereq.masteryThreshold?.minCount ?? DEFAULT_MIN_COUNT;
|
|
1514
|
+
if (userTagElo.count < minCount) return false;
|
|
1515
|
+
if (prereq.masteryThreshold?.minElo !== void 0) {
|
|
1516
|
+
return userTagElo.score >= prereq.masteryThreshold.minElo;
|
|
1517
|
+
} else {
|
|
1518
|
+
return userTagElo.score >= userGlobalElo;
|
|
1519
|
+
}
|
|
1520
|
+
}
|
|
1521
|
+
/**
|
|
1522
|
+
* Get the set of tags the user has mastered.
|
|
1523
|
+
* A tag is "mastered" if it appears as a prerequisite somewhere and meets its threshold.
|
|
1524
|
+
*/
|
|
1525
|
+
async getMasteredTags(context) {
|
|
1526
|
+
const mastered = /* @__PURE__ */ new Set();
|
|
1527
|
+
try {
|
|
1528
|
+
const courseReg = await context.user.getCourseRegDoc(context.course.getCourseID());
|
|
1529
|
+
const userElo = (0, import_common7.toCourseElo)(courseReg.elo);
|
|
1530
|
+
for (const prereqs of Object.values(this.config.prerequisites)) {
|
|
1531
|
+
for (const prereq of prereqs) {
|
|
1532
|
+
const tagElo = userElo.tags[prereq.tag];
|
|
1533
|
+
if (this.isPrerequisiteMet(prereq, tagElo, userElo.global.score)) {
|
|
1534
|
+
mastered.add(prereq.tag);
|
|
1535
|
+
}
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
1538
|
+
} catch {
|
|
1539
|
+
}
|
|
1540
|
+
return mastered;
|
|
1541
|
+
}
|
|
1542
|
+
/**
|
|
1543
|
+
* Get the set of tags that are unlocked (prerequisites met)
|
|
1544
|
+
*/
|
|
1545
|
+
getUnlockedTags(masteredTags) {
|
|
1546
|
+
const unlocked = /* @__PURE__ */ new Set();
|
|
1547
|
+
for (const [tagId, prereqs] of Object.entries(this.config.prerequisites)) {
|
|
1548
|
+
const allPrereqsMet = prereqs.every((prereq) => masteredTags.has(prereq.tag));
|
|
1549
|
+
if (allPrereqsMet) {
|
|
1550
|
+
unlocked.add(tagId);
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1553
|
+
return unlocked;
|
|
1554
|
+
}
|
|
1555
|
+
/**
|
|
1556
|
+
* Check if a tag has prerequisites defined in config
|
|
1557
|
+
*/
|
|
1558
|
+
hasPrerequisites(tagId) {
|
|
1559
|
+
return tagId in this.config.prerequisites;
|
|
1560
|
+
}
|
|
1561
|
+
/**
|
|
1562
|
+
* Check if a card is unlocked and generate reason.
|
|
1563
|
+
*/
|
|
1564
|
+
async checkCardUnlock(cardId, course, unlockedTags, masteredTags) {
|
|
1565
|
+
try {
|
|
1566
|
+
const tagResponse = await course.getAppliedTags(cardId);
|
|
1567
|
+
const cardTags = tagResponse.rows.map((row) => row.value?.name || row.key);
|
|
1568
|
+
const lockedTags = cardTags.filter(
|
|
1569
|
+
(tag) => this.hasPrerequisites(tag) && !unlockedTags.has(tag)
|
|
1570
|
+
);
|
|
1571
|
+
if (lockedTags.length === 0) {
|
|
1572
|
+
const tagList = cardTags.length > 0 ? cardTags.join(", ") : "none";
|
|
1573
|
+
return {
|
|
1574
|
+
isUnlocked: true,
|
|
1575
|
+
reason: `Prerequisites met, tags: ${tagList}`
|
|
1576
|
+
};
|
|
1577
|
+
}
|
|
1578
|
+
const missingPrereqs = lockedTags.flatMap((tag) => {
|
|
1579
|
+
const prereqs = this.config.prerequisites[tag] || [];
|
|
1580
|
+
return prereqs.filter((p) => !masteredTags.has(p.tag)).map((p) => p.tag);
|
|
1581
|
+
});
|
|
1582
|
+
return {
|
|
1583
|
+
isUnlocked: false,
|
|
1584
|
+
reason: `Blocked: missing prerequisites ${missingPrereqs.join(", ")} for tags ${lockedTags.join(", ")}`
|
|
1585
|
+
};
|
|
1586
|
+
} catch {
|
|
1587
|
+
return {
|
|
1588
|
+
isUnlocked: true,
|
|
1589
|
+
reason: "Prerequisites check skipped (tag lookup failed)"
|
|
1590
|
+
};
|
|
1591
|
+
}
|
|
1592
|
+
}
|
|
1593
|
+
/**
|
|
1594
|
+
* CardFilter.transform implementation.
|
|
1595
|
+
*
|
|
1596
|
+
* Apply prerequisite gating to cards. Cards with locked tags receive score: 0.
|
|
1597
|
+
*/
|
|
1598
|
+
async transform(cards, context) {
|
|
1599
|
+
const masteredTags = await this.getMasteredTags(context);
|
|
1600
|
+
const unlockedTags = this.getUnlockedTags(masteredTags);
|
|
1601
|
+
const gated = [];
|
|
1602
|
+
for (const card of cards) {
|
|
1603
|
+
const { isUnlocked, reason } = await this.checkCardUnlock(
|
|
1604
|
+
card.cardId,
|
|
1605
|
+
context.course,
|
|
1606
|
+
unlockedTags,
|
|
1607
|
+
masteredTags
|
|
1608
|
+
);
|
|
1609
|
+
const finalScore = isUnlocked ? card.score : 0;
|
|
1610
|
+
const action = isUnlocked ? "passed" : "penalized";
|
|
1611
|
+
gated.push({
|
|
1612
|
+
...card,
|
|
1613
|
+
score: finalScore,
|
|
1614
|
+
provenance: [
|
|
1615
|
+
...card.provenance,
|
|
1616
|
+
{
|
|
1617
|
+
strategy: "hierarchyDefinition",
|
|
1618
|
+
strategyName: this.strategyName || this.name,
|
|
1619
|
+
strategyId: this.strategyId || "NAVIGATION_STRATEGY-hierarchy",
|
|
1620
|
+
action,
|
|
1621
|
+
score: finalScore,
|
|
1622
|
+
reason
|
|
1623
|
+
}
|
|
1624
|
+
]
|
|
1625
|
+
});
|
|
1626
|
+
}
|
|
1627
|
+
return gated;
|
|
1628
|
+
}
|
|
1629
|
+
/**
|
|
1630
|
+
* Legacy getWeightedCards - now throws as filters should not be used as generators.
|
|
1631
|
+
*
|
|
1632
|
+
* Use transform() via Pipeline instead.
|
|
1633
|
+
*/
|
|
1634
|
+
async getWeightedCards(_limit) {
|
|
1635
|
+
throw new Error(
|
|
1636
|
+
"HierarchyDefinitionNavigator is a filter and should not be used as a generator. Use Pipeline with a generator and this filter via transform()."
|
|
1637
|
+
);
|
|
1638
|
+
}
|
|
1639
|
+
// Legacy methods - stub implementations since filters don't generate cards
|
|
1640
|
+
async getNewCards(_n) {
|
|
1641
|
+
return [];
|
|
1642
|
+
}
|
|
1643
|
+
async getPendingReviews() {
|
|
1644
|
+
return [];
|
|
1645
|
+
}
|
|
1646
|
+
};
|
|
1647
|
+
}
|
|
1648
|
+
});
|
|
1649
|
+
|
|
1650
|
+
// src/core/navigators/interferenceMitigator.ts
|
|
1651
|
+
var interferenceMitigator_exports = {};
|
|
1652
|
+
__export(interferenceMitigator_exports, {
|
|
1653
|
+
default: () => InterferenceMitigatorNavigator
|
|
1654
|
+
});
|
|
1655
|
+
var import_common8, DEFAULT_MIN_COUNT2, DEFAULT_MIN_ELAPSED_DAYS, DEFAULT_INTERFERENCE_DECAY, InterferenceMitigatorNavigator;
|
|
1656
|
+
var init_interferenceMitigator = __esm({
|
|
1657
|
+
"src/core/navigators/interferenceMitigator.ts"() {
|
|
1658
|
+
"use strict";
|
|
1659
|
+
init_navigators();
|
|
1660
|
+
import_common8 = require("@vue-skuilder/common");
|
|
1661
|
+
DEFAULT_MIN_COUNT2 = 10;
|
|
1662
|
+
DEFAULT_MIN_ELAPSED_DAYS = 3;
|
|
1663
|
+
DEFAULT_INTERFERENCE_DECAY = 0.8;
|
|
1664
|
+
InterferenceMitigatorNavigator = class extends ContentNavigator {
|
|
1665
|
+
config;
|
|
1666
|
+
_strategyData;
|
|
1667
|
+
/** Human-readable name for CardFilter interface */
|
|
1668
|
+
name;
|
|
1669
|
+
/** Precomputed map: tag -> set of { partner, decay } it interferes with */
|
|
1670
|
+
interferenceMap;
|
|
1671
|
+
constructor(user, course, _strategyData) {
|
|
1672
|
+
super(user, course, _strategyData);
|
|
1673
|
+
this._strategyData = _strategyData;
|
|
1674
|
+
this.config = this.parseConfig(_strategyData.serializedData);
|
|
1675
|
+
this.interferenceMap = this.buildInterferenceMap();
|
|
1676
|
+
this.name = _strategyData.name || "Interference Mitigator";
|
|
1677
|
+
}
|
|
1678
|
+
parseConfig(serializedData) {
|
|
1679
|
+
try {
|
|
1680
|
+
const parsed = JSON.parse(serializedData);
|
|
1681
|
+
let sets = parsed.interferenceSets || [];
|
|
1682
|
+
if (sets.length > 0 && Array.isArray(sets[0])) {
|
|
1683
|
+
sets = sets.map((tags) => ({ tags }));
|
|
1684
|
+
}
|
|
1685
|
+
return {
|
|
1686
|
+
interferenceSets: sets,
|
|
1687
|
+
maturityThreshold: {
|
|
1688
|
+
minCount: parsed.maturityThreshold?.minCount ?? DEFAULT_MIN_COUNT2,
|
|
1689
|
+
minElo: parsed.maturityThreshold?.minElo,
|
|
1690
|
+
minElapsedDays: parsed.maturityThreshold?.minElapsedDays ?? DEFAULT_MIN_ELAPSED_DAYS
|
|
1691
|
+
},
|
|
1692
|
+
defaultDecay: parsed.defaultDecay ?? DEFAULT_INTERFERENCE_DECAY
|
|
1693
|
+
};
|
|
1694
|
+
} catch {
|
|
1695
|
+
return {
|
|
1696
|
+
interferenceSets: [],
|
|
1697
|
+
maturityThreshold: {
|
|
1698
|
+
minCount: DEFAULT_MIN_COUNT2,
|
|
1699
|
+
minElapsedDays: DEFAULT_MIN_ELAPSED_DAYS
|
|
1700
|
+
},
|
|
1701
|
+
defaultDecay: DEFAULT_INTERFERENCE_DECAY
|
|
1702
|
+
};
|
|
1703
|
+
}
|
|
1704
|
+
}
|
|
1705
|
+
/**
|
|
1706
|
+
* Build a map from each tag to its interference partners with decay coefficients.
|
|
1707
|
+
* If tags A, B, C are in an interference group with decay 0.8, then:
|
|
1708
|
+
* - A interferes with B (decay 0.8) and C (decay 0.8)
|
|
1709
|
+
* - B interferes with A (decay 0.8) and C (decay 0.8)
|
|
1710
|
+
* - etc.
|
|
1711
|
+
*/
|
|
1712
|
+
buildInterferenceMap() {
|
|
1713
|
+
const map = /* @__PURE__ */ new Map();
|
|
1714
|
+
for (const group of this.config.interferenceSets) {
|
|
1715
|
+
const decay = group.decay ?? this.config.defaultDecay ?? DEFAULT_INTERFERENCE_DECAY;
|
|
1716
|
+
for (const tag of group.tags) {
|
|
1717
|
+
if (!map.has(tag)) {
|
|
1718
|
+
map.set(tag, []);
|
|
1719
|
+
}
|
|
1720
|
+
const partners = map.get(tag);
|
|
1721
|
+
for (const other of group.tags) {
|
|
1722
|
+
if (other !== tag) {
|
|
1723
|
+
const existing = partners.find((p) => p.partner === other);
|
|
1724
|
+
if (existing) {
|
|
1725
|
+
existing.decay = Math.max(existing.decay, decay);
|
|
1726
|
+
} else {
|
|
1727
|
+
partners.push({ partner: other, decay });
|
|
1728
|
+
}
|
|
1729
|
+
}
|
|
1730
|
+
}
|
|
1731
|
+
}
|
|
1732
|
+
}
|
|
1733
|
+
return map;
|
|
1734
|
+
}
|
|
1735
|
+
/**
|
|
1736
|
+
* Get the set of tags that are currently immature for this user.
|
|
1737
|
+
* A tag is immature if the user has interacted with it but hasn't
|
|
1738
|
+
* reached the maturity threshold.
|
|
1739
|
+
*/
|
|
1740
|
+
async getImmatureTags(context) {
|
|
1741
|
+
const immature = /* @__PURE__ */ new Set();
|
|
1742
|
+
try {
|
|
1743
|
+
const courseReg = await context.user.getCourseRegDoc(context.course.getCourseID());
|
|
1744
|
+
const userElo = (0, import_common8.toCourseElo)(courseReg.elo);
|
|
1745
|
+
const minCount = this.config.maturityThreshold?.minCount ?? DEFAULT_MIN_COUNT2;
|
|
1746
|
+
const minElo = this.config.maturityThreshold?.minElo;
|
|
1747
|
+
const minElapsedDays = this.config.maturityThreshold?.minElapsedDays ?? DEFAULT_MIN_ELAPSED_DAYS;
|
|
1748
|
+
const minCountForElapsed = minElapsedDays * 2;
|
|
1749
|
+
for (const [tagId, tagElo] of Object.entries(userElo.tags)) {
|
|
1750
|
+
if (tagElo.count === 0) continue;
|
|
1751
|
+
const belowCount = tagElo.count < minCount;
|
|
1752
|
+
const belowElo = minElo !== void 0 && tagElo.score < minElo;
|
|
1753
|
+
const belowElapsed = tagElo.count < minCountForElapsed;
|
|
1754
|
+
if (belowCount || belowElo || belowElapsed) {
|
|
1755
|
+
immature.add(tagId);
|
|
1756
|
+
}
|
|
1757
|
+
}
|
|
1758
|
+
} catch {
|
|
1759
|
+
}
|
|
1760
|
+
return immature;
|
|
1761
|
+
}
|
|
1762
|
+
/**
|
|
1763
|
+
* Get all tags that interfere with any immature tag, along with their decay coefficients.
|
|
1764
|
+
* These are the tags we want to avoid introducing.
|
|
1765
|
+
*/
|
|
1766
|
+
getTagsToAvoid(immatureTags) {
|
|
1767
|
+
const avoid = /* @__PURE__ */ new Map();
|
|
1768
|
+
for (const immatureTag of immatureTags) {
|
|
1769
|
+
const partners = this.interferenceMap.get(immatureTag);
|
|
1770
|
+
if (partners) {
|
|
1771
|
+
for (const { partner, decay } of partners) {
|
|
1772
|
+
if (!immatureTags.has(partner)) {
|
|
1773
|
+
const existing = avoid.get(partner) ?? 0;
|
|
1774
|
+
avoid.set(partner, Math.max(existing, decay));
|
|
1775
|
+
}
|
|
1776
|
+
}
|
|
1777
|
+
}
|
|
1778
|
+
}
|
|
1779
|
+
return avoid;
|
|
1780
|
+
}
|
|
1781
|
+
/**
|
|
1782
|
+
* Get tags for a single card
|
|
1783
|
+
*/
|
|
1784
|
+
async getCardTags(cardId, course) {
|
|
1785
|
+
try {
|
|
1786
|
+
const tagResponse = await course.getAppliedTags(cardId);
|
|
1787
|
+
return tagResponse.rows.map((row) => row.value?.name || row.key).filter(Boolean);
|
|
1788
|
+
} catch {
|
|
1789
|
+
return [];
|
|
1790
|
+
}
|
|
1791
|
+
}
|
|
1792
|
+
/**
|
|
1793
|
+
* Compute interference score reduction for a card.
|
|
1794
|
+
* Returns: { multiplier, interfering tags, reason }
|
|
1795
|
+
*/
|
|
1796
|
+
computeInterferenceEffect(cardTags, tagsToAvoid, immatureTags) {
|
|
1797
|
+
if (tagsToAvoid.size === 0) {
|
|
1798
|
+
return {
|
|
1799
|
+
multiplier: 1,
|
|
1800
|
+
interferingTags: [],
|
|
1801
|
+
reason: "No interference detected"
|
|
1802
|
+
};
|
|
1803
|
+
}
|
|
1804
|
+
let multiplier = 1;
|
|
1805
|
+
const interferingTags = [];
|
|
1806
|
+
for (const tag of cardTags) {
|
|
1807
|
+
const decay = tagsToAvoid.get(tag);
|
|
1808
|
+
if (decay !== void 0) {
|
|
1809
|
+
interferingTags.push(tag);
|
|
1810
|
+
multiplier *= 1 - decay;
|
|
1811
|
+
}
|
|
1812
|
+
}
|
|
1813
|
+
if (interferingTags.length === 0) {
|
|
1814
|
+
return {
|
|
1815
|
+
multiplier: 1,
|
|
1816
|
+
interferingTags: [],
|
|
1817
|
+
reason: "No interference detected"
|
|
1818
|
+
};
|
|
1819
|
+
}
|
|
1820
|
+
const causingTags = /* @__PURE__ */ new Set();
|
|
1821
|
+
for (const tag of interferingTags) {
|
|
1822
|
+
for (const immatureTag of immatureTags) {
|
|
1823
|
+
const partners = this.interferenceMap.get(immatureTag);
|
|
1824
|
+
if (partners?.some((p) => p.partner === tag)) {
|
|
1825
|
+
causingTags.add(immatureTag);
|
|
1826
|
+
}
|
|
1827
|
+
}
|
|
1828
|
+
}
|
|
1829
|
+
const reason = `Interferes with immature tags ${Array.from(causingTags).join(", ")} (tags: ${interferingTags.join(", ")}, multiplier: ${multiplier.toFixed(2)})`;
|
|
1830
|
+
return { multiplier, interferingTags, reason };
|
|
1831
|
+
}
|
|
1832
|
+
/**
|
|
1833
|
+
* CardFilter.transform implementation.
|
|
1834
|
+
*
|
|
1835
|
+
* Apply interference-aware scoring. Cards with tags that interfere with
|
|
1836
|
+
* immature learnings get reduced scores.
|
|
1837
|
+
*/
|
|
1838
|
+
async transform(cards, context) {
|
|
1839
|
+
const immatureTags = await this.getImmatureTags(context);
|
|
1840
|
+
const tagsToAvoid = this.getTagsToAvoid(immatureTags);
|
|
1841
|
+
const adjusted = [];
|
|
1842
|
+
for (const card of cards) {
|
|
1843
|
+
const cardTags = await this.getCardTags(card.cardId, context.course);
|
|
1844
|
+
const { multiplier, reason } = this.computeInterferenceEffect(
|
|
1845
|
+
cardTags,
|
|
1846
|
+
tagsToAvoid,
|
|
1847
|
+
immatureTags
|
|
1848
|
+
);
|
|
1849
|
+
const finalScore = card.score * multiplier;
|
|
1850
|
+
const action = multiplier < 1 ? "penalized" : multiplier > 1 ? "boosted" : "passed";
|
|
1851
|
+
adjusted.push({
|
|
1852
|
+
...card,
|
|
1853
|
+
score: finalScore,
|
|
1854
|
+
provenance: [
|
|
1855
|
+
...card.provenance,
|
|
1856
|
+
{
|
|
1857
|
+
strategy: "interferenceMitigator",
|
|
1858
|
+
strategyName: this.strategyName || this.name,
|
|
1859
|
+
strategyId: this.strategyId || "NAVIGATION_STRATEGY-interference",
|
|
1860
|
+
action,
|
|
1861
|
+
score: finalScore,
|
|
1862
|
+
reason
|
|
1863
|
+
}
|
|
1864
|
+
]
|
|
1865
|
+
});
|
|
1866
|
+
}
|
|
1867
|
+
return adjusted;
|
|
1868
|
+
}
|
|
1869
|
+
/**
|
|
1870
|
+
* Legacy getWeightedCards - now throws as filters should not be used as generators.
|
|
1871
|
+
*
|
|
1872
|
+
* Use transform() via Pipeline instead.
|
|
1873
|
+
*/
|
|
1874
|
+
async getWeightedCards(_limit) {
|
|
1875
|
+
throw new Error(
|
|
1876
|
+
"InterferenceMitigatorNavigator is a filter and should not be used as a generator. Use Pipeline with a generator and this filter via transform()."
|
|
1877
|
+
);
|
|
1878
|
+
}
|
|
1879
|
+
// Legacy methods - stub implementations since filters don't generate cards
|
|
1880
|
+
async getNewCards(_n) {
|
|
1881
|
+
return [];
|
|
1882
|
+
}
|
|
1883
|
+
async getPendingReviews() {
|
|
1884
|
+
return [];
|
|
1885
|
+
}
|
|
1886
|
+
};
|
|
1887
|
+
}
|
|
1888
|
+
});
|
|
1889
|
+
|
|
1890
|
+
// src/core/navigators/relativePriority.ts
|
|
1891
|
+
var relativePriority_exports = {};
|
|
1892
|
+
__export(relativePriority_exports, {
|
|
1893
|
+
default: () => RelativePriorityNavigator
|
|
1894
|
+
});
|
|
1895
|
+
var DEFAULT_PRIORITY, DEFAULT_PRIORITY_INFLUENCE, DEFAULT_COMBINE_MODE, RelativePriorityNavigator;
|
|
1896
|
+
var init_relativePriority = __esm({
|
|
1897
|
+
"src/core/navigators/relativePriority.ts"() {
|
|
1898
|
+
"use strict";
|
|
1899
|
+
init_navigators();
|
|
1900
|
+
DEFAULT_PRIORITY = 0.5;
|
|
1901
|
+
DEFAULT_PRIORITY_INFLUENCE = 0.5;
|
|
1902
|
+
DEFAULT_COMBINE_MODE = "max";
|
|
1903
|
+
RelativePriorityNavigator = class extends ContentNavigator {
|
|
1904
|
+
config;
|
|
1905
|
+
_strategyData;
|
|
1906
|
+
/** Human-readable name for CardFilter interface */
|
|
1907
|
+
name;
|
|
1908
|
+
constructor(user, course, _strategyData) {
|
|
1909
|
+
super(user, course, _strategyData);
|
|
1910
|
+
this._strategyData = _strategyData;
|
|
1911
|
+
this.config = this.parseConfig(_strategyData.serializedData);
|
|
1912
|
+
this.name = _strategyData.name || "Relative Priority";
|
|
1913
|
+
}
|
|
1914
|
+
parseConfig(serializedData) {
|
|
1915
|
+
try {
|
|
1916
|
+
const parsed = JSON.parse(serializedData);
|
|
1917
|
+
return {
|
|
1918
|
+
tagPriorities: parsed.tagPriorities || {},
|
|
1919
|
+
defaultPriority: parsed.defaultPriority ?? DEFAULT_PRIORITY,
|
|
1920
|
+
combineMode: parsed.combineMode ?? DEFAULT_COMBINE_MODE,
|
|
1921
|
+
priorityInfluence: parsed.priorityInfluence ?? DEFAULT_PRIORITY_INFLUENCE
|
|
1922
|
+
};
|
|
1923
|
+
} catch {
|
|
1924
|
+
return {
|
|
1925
|
+
tagPriorities: {},
|
|
1926
|
+
defaultPriority: DEFAULT_PRIORITY,
|
|
1927
|
+
combineMode: DEFAULT_COMBINE_MODE,
|
|
1928
|
+
priorityInfluence: DEFAULT_PRIORITY_INFLUENCE
|
|
1929
|
+
};
|
|
1930
|
+
}
|
|
1931
|
+
}
|
|
1932
|
+
/**
|
|
1933
|
+
* Look up the priority for a tag.
|
|
1934
|
+
*/
|
|
1935
|
+
getTagPriority(tagId) {
|
|
1936
|
+
return this.config.tagPriorities[tagId] ?? this.config.defaultPriority ?? DEFAULT_PRIORITY;
|
|
1937
|
+
}
|
|
1938
|
+
/**
|
|
1939
|
+
* Compute combined priority for a card based on its tags.
|
|
1940
|
+
*/
|
|
1941
|
+
computeCardPriority(cardTags) {
|
|
1942
|
+
if (cardTags.length === 0) {
|
|
1943
|
+
return this.config.defaultPriority ?? DEFAULT_PRIORITY;
|
|
1944
|
+
}
|
|
1945
|
+
const priorities = cardTags.map((tag) => this.getTagPriority(tag));
|
|
1946
|
+
switch (this.config.combineMode) {
|
|
1947
|
+
case "max":
|
|
1948
|
+
return Math.max(...priorities);
|
|
1949
|
+
case "min":
|
|
1950
|
+
return Math.min(...priorities);
|
|
1951
|
+
case "average":
|
|
1952
|
+
return priorities.reduce((sum, p) => sum + p, 0) / priorities.length;
|
|
1953
|
+
default:
|
|
1954
|
+
return Math.max(...priorities);
|
|
1955
|
+
}
|
|
1956
|
+
}
|
|
1957
|
+
/**
|
|
1958
|
+
* Compute boost factor based on priority.
|
|
1959
|
+
*
|
|
1960
|
+
* The formula: 1 + (priority - 0.5) * priorityInfluence
|
|
1961
|
+
*
|
|
1962
|
+
* This creates a multiplier centered around 1.0:
|
|
1963
|
+
* - Priority 1.0 with influence 0.5 → 1.25 (25% boost)
|
|
1964
|
+
* - Priority 0.5 with any influence → 1.00 (neutral)
|
|
1965
|
+
* - Priority 0.0 with influence 0.5 → 0.75 (25% reduction)
|
|
1966
|
+
*/
|
|
1967
|
+
computeBoostFactor(priority) {
|
|
1968
|
+
const influence = this.config.priorityInfluence ?? DEFAULT_PRIORITY_INFLUENCE;
|
|
1969
|
+
return 1 + (priority - 0.5) * influence;
|
|
1970
|
+
}
|
|
1971
|
+
/**
|
|
1972
|
+
* Build human-readable reason for priority adjustment.
|
|
1973
|
+
*/
|
|
1974
|
+
buildPriorityReason(cardTags, priority, boostFactor, finalScore) {
|
|
1975
|
+
if (cardTags.length === 0) {
|
|
1976
|
+
return `No tags, neutral priority (${priority.toFixed(2)})`;
|
|
1977
|
+
}
|
|
1978
|
+
const tagList = cardTags.slice(0, 3).join(", ");
|
|
1979
|
+
const more = cardTags.length > 3 ? ` (+${cardTags.length - 3} more)` : "";
|
|
1980
|
+
if (boostFactor === 1) {
|
|
1981
|
+
return `Neutral priority (${priority.toFixed(2)}) for tags: ${tagList}${more}`;
|
|
1982
|
+
} else if (boostFactor > 1) {
|
|
1983
|
+
return `High-priority tags: ${tagList}${more} (priority ${priority.toFixed(2)} \u2192 boost ${boostFactor.toFixed(2)}x \u2192 ${finalScore.toFixed(2)})`;
|
|
1984
|
+
} else {
|
|
1985
|
+
return `Low-priority tags: ${tagList}${more} (priority ${priority.toFixed(2)} \u2192 reduce ${boostFactor.toFixed(2)}x \u2192 ${finalScore.toFixed(2)})`;
|
|
1986
|
+
}
|
|
1987
|
+
}
|
|
1988
|
+
/**
|
|
1989
|
+
* Get tags for a single card.
|
|
1990
|
+
*/
|
|
1991
|
+
async getCardTags(cardId, course) {
|
|
1992
|
+
try {
|
|
1993
|
+
const tagResponse = await course.getAppliedTags(cardId);
|
|
1994
|
+
return tagResponse.rows.map((r) => r.doc?.name).filter((x) => !!x);
|
|
1995
|
+
} catch {
|
|
1996
|
+
return [];
|
|
1997
|
+
}
|
|
1998
|
+
}
|
|
1999
|
+
/**
|
|
2000
|
+
* CardFilter.transform implementation.
|
|
2001
|
+
*
|
|
2002
|
+
* Apply priority-adjusted scoring. Cards with high-priority tags get boosted,
|
|
2003
|
+
* cards with low-priority tags get reduced scores.
|
|
2004
|
+
*/
|
|
2005
|
+
async transform(cards, context) {
|
|
2006
|
+
const adjusted = await Promise.all(
|
|
2007
|
+
cards.map(async (card) => {
|
|
2008
|
+
const cardTags = await this.getCardTags(card.cardId, context.course);
|
|
2009
|
+
const priority = this.computeCardPriority(cardTags);
|
|
2010
|
+
const boostFactor = this.computeBoostFactor(priority);
|
|
2011
|
+
const finalScore = Math.max(0, Math.min(1, card.score * boostFactor));
|
|
2012
|
+
const action = boostFactor > 1 ? "boosted" : boostFactor < 1 ? "penalized" : "passed";
|
|
2013
|
+
const reason = this.buildPriorityReason(cardTags, priority, boostFactor, finalScore);
|
|
2014
|
+
return {
|
|
2015
|
+
...card,
|
|
2016
|
+
score: finalScore,
|
|
2017
|
+
provenance: [
|
|
2018
|
+
...card.provenance,
|
|
2019
|
+
{
|
|
2020
|
+
strategy: "relativePriority",
|
|
2021
|
+
strategyName: this.strategyName || this.name,
|
|
2022
|
+
strategyId: this.strategyId || "NAVIGATION_STRATEGY-priority",
|
|
2023
|
+
action,
|
|
2024
|
+
score: finalScore,
|
|
2025
|
+
reason
|
|
2026
|
+
}
|
|
2027
|
+
]
|
|
2028
|
+
};
|
|
2029
|
+
})
|
|
2030
|
+
);
|
|
2031
|
+
return adjusted;
|
|
2032
|
+
}
|
|
2033
|
+
/**
|
|
2034
|
+
* Legacy getWeightedCards - now throws as filters should not be used as generators.
|
|
2035
|
+
*
|
|
2036
|
+
* Use transform() via Pipeline instead.
|
|
2037
|
+
*/
|
|
2038
|
+
async getWeightedCards(_limit) {
|
|
2039
|
+
throw new Error(
|
|
2040
|
+
"RelativePriorityNavigator is a filter and should not be used as a generator. Use Pipeline with a generator and this filter via transform()."
|
|
2041
|
+
);
|
|
2042
|
+
}
|
|
2043
|
+
// Legacy methods - stub implementations since filters don't generate cards
|
|
2044
|
+
async getNewCards(_n) {
|
|
2045
|
+
return [];
|
|
2046
|
+
}
|
|
2047
|
+
async getPendingReviews() {
|
|
2048
|
+
return [];
|
|
773
2049
|
}
|
|
774
2050
|
};
|
|
775
2051
|
}
|
|
776
2052
|
});
|
|
777
2053
|
|
|
778
|
-
// src/core/navigators/
|
|
779
|
-
var
|
|
780
|
-
__export(
|
|
781
|
-
default: () =>
|
|
2054
|
+
// src/core/navigators/srs.ts
|
|
2055
|
+
var srs_exports = {};
|
|
2056
|
+
__export(srs_exports, {
|
|
2057
|
+
default: () => SRSNavigator
|
|
782
2058
|
});
|
|
783
|
-
var
|
|
784
|
-
var
|
|
785
|
-
"src/core/navigators/
|
|
2059
|
+
var import_moment3, SRSNavigator;
|
|
2060
|
+
var init_srs = __esm({
|
|
2061
|
+
"src/core/navigators/srs.ts"() {
|
|
786
2062
|
"use strict";
|
|
2063
|
+
import_moment3 = __toESM(require("moment"), 1);
|
|
787
2064
|
init_navigators();
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
user;
|
|
792
|
-
course;
|
|
2065
|
+
SRSNavigator = class extends ContentNavigator {
|
|
2066
|
+
/** Human-readable name for CardGenerator interface */
|
|
2067
|
+
name;
|
|
793
2068
|
constructor(user, course, strategyData) {
|
|
794
|
-
super();
|
|
795
|
-
this.
|
|
796
|
-
this.course = course;
|
|
797
|
-
if (strategyData.serializedData) {
|
|
798
|
-
try {
|
|
799
|
-
this.orderedCardIds = JSON.parse(strategyData.serializedData);
|
|
800
|
-
} catch (e) {
|
|
801
|
-
logger.error("Failed to parse serializedData for HardcodedOrderNavigator", e);
|
|
802
|
-
}
|
|
803
|
-
}
|
|
2069
|
+
super(user, course, strategyData);
|
|
2070
|
+
this.name = strategyData?.name || "SRS";
|
|
804
2071
|
}
|
|
805
|
-
|
|
2072
|
+
/**
|
|
2073
|
+
* Get review cards scored by urgency.
|
|
2074
|
+
*
|
|
2075
|
+
* Score formula combines:
|
|
2076
|
+
* - Relative overdueness: hoursOverdue / intervalHours
|
|
2077
|
+
* - Interval recency: exponential decay favoring shorter intervals
|
|
2078
|
+
*
|
|
2079
|
+
* Cards not yet due are excluded (not scored as 0).
|
|
2080
|
+
*
|
|
2081
|
+
* This method supports both the legacy signature (limit only) and the
|
|
2082
|
+
* CardGenerator interface signature (limit, context).
|
|
2083
|
+
*
|
|
2084
|
+
* @param limit - Maximum number of cards to return
|
|
2085
|
+
* @param _context - Optional GeneratorContext (currently unused, but required for interface)
|
|
2086
|
+
*/
|
|
2087
|
+
async getWeightedCards(limit, _context) {
|
|
2088
|
+
if (!this.user || !this.course) {
|
|
2089
|
+
throw new Error("SRSNavigator requires user and course to be set");
|
|
2090
|
+
}
|
|
806
2091
|
const reviews = await this.user.getPendingReviews(this.course.getCourseID());
|
|
807
|
-
|
|
2092
|
+
const now = import_moment3.default.utc();
|
|
2093
|
+
const dueReviews = reviews.filter((r) => now.isAfter(import_moment3.default.utc(r.reviewTime)));
|
|
2094
|
+
const scored = dueReviews.map((review) => {
|
|
2095
|
+
const { score, reason } = this.computeUrgencyScore(review, now);
|
|
808
2096
|
return {
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
2097
|
+
cardId: review.cardId,
|
|
2098
|
+
courseId: review.courseId,
|
|
2099
|
+
score,
|
|
2100
|
+
provenance: [
|
|
2101
|
+
{
|
|
2102
|
+
strategy: "srs",
|
|
2103
|
+
strategyName: this.strategyName || this.name,
|
|
2104
|
+
strategyId: this.strategyId || "NAVIGATION_STRATEGY-SRS-default",
|
|
2105
|
+
action: "generated",
|
|
2106
|
+
score,
|
|
2107
|
+
reason
|
|
2108
|
+
}
|
|
2109
|
+
]
|
|
816
2110
|
};
|
|
817
2111
|
});
|
|
2112
|
+
return scored.sort((a, b) => b.score - a.score).slice(0, limit);
|
|
818
2113
|
}
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
2114
|
+
/**
|
|
2115
|
+
* Compute urgency score for a review card.
|
|
2116
|
+
*
|
|
2117
|
+
* Two factors:
|
|
2118
|
+
* 1. Relative overdueness = hoursOverdue / intervalHours
|
|
2119
|
+
* - 2 days overdue on 3-day interval = 0.67 (urgent)
|
|
2120
|
+
* - 2 days overdue on 180-day interval = 0.01 (not urgent)
|
|
2121
|
+
*
|
|
2122
|
+
* 2. Interval recency factor = 0.3 + 0.7 * exp(-intervalHours / 720)
|
|
2123
|
+
* - 24h interval → ~1.0 (very recent learning)
|
|
2124
|
+
* - 30 days (720h) → ~0.56
|
|
2125
|
+
* - 180 days → ~0.30
|
|
2126
|
+
*
|
|
2127
|
+
* Combined: base 0.5 + weighted average of factors * 0.45
|
|
2128
|
+
* Result range: approximately 0.5 to 0.95
|
|
2129
|
+
*/
|
|
2130
|
+
computeUrgencyScore(review, now) {
|
|
2131
|
+
const scheduledAt = import_moment3.default.utc(review.scheduledAt);
|
|
2132
|
+
const due = import_moment3.default.utc(review.reviewTime);
|
|
2133
|
+
const intervalHours = Math.max(1, due.diff(scheduledAt, "hours"));
|
|
2134
|
+
const hoursOverdue = now.diff(due, "hours");
|
|
2135
|
+
const relativeOverdue = hoursOverdue / intervalHours;
|
|
2136
|
+
const recencyFactor = 0.3 + 0.7 * Math.exp(-intervalHours / 720);
|
|
2137
|
+
const overdueContribution = Math.min(1, Math.max(0, relativeOverdue));
|
|
2138
|
+
const urgency = overdueContribution * 0.5 + recencyFactor * 0.5;
|
|
2139
|
+
const score = Math.min(0.95, 0.5 + urgency * 0.45);
|
|
2140
|
+
const reason = `${Math.round(hoursOverdue)}h overdue (interval: ${Math.round(intervalHours)}h, relative: ${relativeOverdue.toFixed(2)}), recency: ${recencyFactor.toFixed(2)}, review`;
|
|
2141
|
+
return { score, reason };
|
|
2142
|
+
}
|
|
2143
|
+
/**
|
|
2144
|
+
* Get pending reviews in legacy format.
|
|
2145
|
+
*
|
|
2146
|
+
* Returns all pending reviews for the course, enriched with session item fields.
|
|
2147
|
+
*/
|
|
2148
|
+
async getPendingReviews() {
|
|
2149
|
+
if (!this.user || !this.course) {
|
|
2150
|
+
throw new Error("SRSNavigator requires user and course to be set");
|
|
2151
|
+
}
|
|
2152
|
+
const reviews = await this.user.getPendingReviews(this.course.getCourseID());
|
|
2153
|
+
return reviews.map((r) => ({
|
|
2154
|
+
...r,
|
|
2155
|
+
contentSourceType: "course",
|
|
2156
|
+
contentSourceID: this.course.getCourseID(),
|
|
2157
|
+
cardID: r.cardId,
|
|
2158
|
+
courseID: r.courseId,
|
|
2159
|
+
qualifiedID: `${r.courseId}-${r.cardId}`,
|
|
2160
|
+
reviewID: r._id,
|
|
2161
|
+
status: "review"
|
|
2162
|
+
}));
|
|
2163
|
+
}
|
|
2164
|
+
/**
|
|
2165
|
+
* SRS does not generate new cards.
|
|
2166
|
+
* Use ELONavigator or another generator for new cards.
|
|
2167
|
+
*/
|
|
2168
|
+
async getNewCards(_n) {
|
|
2169
|
+
return [];
|
|
834
2170
|
}
|
|
835
2171
|
};
|
|
836
2172
|
}
|
|
@@ -841,9 +2177,21 @@ var globImport;
|
|
|
841
2177
|
var init_ = __esm({
|
|
842
2178
|
'import("./**/*") in src/core/navigators/index.ts'() {
|
|
843
2179
|
globImport = __glob({
|
|
2180
|
+
"./CompositeGenerator.ts": () => Promise.resolve().then(() => (init_CompositeGenerator(), CompositeGenerator_exports)),
|
|
2181
|
+
"./Pipeline.ts": () => Promise.resolve().then(() => (init_Pipeline(), Pipeline_exports)),
|
|
2182
|
+
"./PipelineAssembler.ts": () => Promise.resolve().then(() => (init_PipelineAssembler(), PipelineAssembler_exports)),
|
|
844
2183
|
"./elo.ts": () => Promise.resolve().then(() => (init_elo(), elo_exports)),
|
|
2184
|
+
"./filters/eloDistance.ts": () => Promise.resolve().then(() => (init_eloDistance(), eloDistance_exports)),
|
|
2185
|
+
"./filters/index.ts": () => Promise.resolve().then(() => (init_filters(), filters_exports)),
|
|
2186
|
+
"./filters/types.ts": () => Promise.resolve().then(() => (init_types(), types_exports)),
|
|
2187
|
+
"./generators/index.ts": () => Promise.resolve().then(() => (init_generators(), generators_exports)),
|
|
2188
|
+
"./generators/types.ts": () => Promise.resolve().then(() => (init_types2(), types_exports2)),
|
|
845
2189
|
"./hardcodedOrder.ts": () => Promise.resolve().then(() => (init_hardcodedOrder(), hardcodedOrder_exports)),
|
|
846
|
-
"./
|
|
2190
|
+
"./hierarchyDefinition.ts": () => Promise.resolve().then(() => (init_hierarchyDefinition(), hierarchyDefinition_exports)),
|
|
2191
|
+
"./index.ts": () => Promise.resolve().then(() => (init_navigators(), navigators_exports)),
|
|
2192
|
+
"./interferenceMitigator.ts": () => Promise.resolve().then(() => (init_interferenceMitigator(), interferenceMitigator_exports)),
|
|
2193
|
+
"./relativePriority.ts": () => Promise.resolve().then(() => (init_relativePriority(), relativePriority_exports)),
|
|
2194
|
+
"./srs.ts": () => Promise.resolve().then(() => (init_srs(), srs_exports))
|
|
847
2195
|
});
|
|
848
2196
|
}
|
|
849
2197
|
});
|
|
@@ -852,9 +2200,34 @@ var init_ = __esm({
|
|
|
852
2200
|
var navigators_exports = {};
|
|
853
2201
|
__export(navigators_exports, {
|
|
854
2202
|
ContentNavigator: () => ContentNavigator,
|
|
855
|
-
|
|
2203
|
+
NavigatorRole: () => NavigatorRole,
|
|
2204
|
+
NavigatorRoles: () => NavigatorRoles,
|
|
2205
|
+
Navigators: () => Navigators,
|
|
2206
|
+
getCardOrigin: () => getCardOrigin,
|
|
2207
|
+
isFilter: () => isFilter,
|
|
2208
|
+
isGenerator: () => isGenerator
|
|
856
2209
|
});
|
|
857
|
-
|
|
2210
|
+
function getCardOrigin(card) {
|
|
2211
|
+
if (card.provenance.length === 0) {
|
|
2212
|
+
throw new Error("Card has no provenance - cannot determine origin");
|
|
2213
|
+
}
|
|
2214
|
+
const firstEntry = card.provenance[0];
|
|
2215
|
+
const reason = firstEntry.reason.toLowerCase();
|
|
2216
|
+
if (reason.includes("failed")) {
|
|
2217
|
+
return "failed";
|
|
2218
|
+
}
|
|
2219
|
+
if (reason.includes("review")) {
|
|
2220
|
+
return "review";
|
|
2221
|
+
}
|
|
2222
|
+
return "new";
|
|
2223
|
+
}
|
|
2224
|
+
function isGenerator(impl) {
|
|
2225
|
+
return NavigatorRoles[impl] === "generator" /* GENERATOR */;
|
|
2226
|
+
}
|
|
2227
|
+
function isFilter(impl) {
|
|
2228
|
+
return NavigatorRoles[impl] === "filter" /* FILTER */;
|
|
2229
|
+
}
|
|
2230
|
+
var Navigators, NavigatorRole, NavigatorRoles, ContentNavigator;
|
|
858
2231
|
var init_navigators = __esm({
|
|
859
2232
|
"src/core/navigators/index.ts"() {
|
|
860
2233
|
"use strict";
|
|
@@ -862,14 +2235,55 @@ var init_navigators = __esm({
|
|
|
862
2235
|
init_();
|
|
863
2236
|
Navigators = /* @__PURE__ */ ((Navigators2) => {
|
|
864
2237
|
Navigators2["ELO"] = "elo";
|
|
2238
|
+
Navigators2["SRS"] = "srs";
|
|
865
2239
|
Navigators2["HARDCODED"] = "hardcodedOrder";
|
|
2240
|
+
Navigators2["HIERARCHY"] = "hierarchyDefinition";
|
|
2241
|
+
Navigators2["INTERFERENCE"] = "interferenceMitigator";
|
|
2242
|
+
Navigators2["RELATIVE_PRIORITY"] = "relativePriority";
|
|
866
2243
|
return Navigators2;
|
|
867
2244
|
})(Navigators || {});
|
|
2245
|
+
NavigatorRole = /* @__PURE__ */ ((NavigatorRole2) => {
|
|
2246
|
+
NavigatorRole2["GENERATOR"] = "generator";
|
|
2247
|
+
NavigatorRole2["FILTER"] = "filter";
|
|
2248
|
+
return NavigatorRole2;
|
|
2249
|
+
})(NavigatorRole || {});
|
|
2250
|
+
NavigatorRoles = {
|
|
2251
|
+
["elo" /* ELO */]: "generator" /* GENERATOR */,
|
|
2252
|
+
["srs" /* SRS */]: "generator" /* GENERATOR */,
|
|
2253
|
+
["hardcodedOrder" /* HARDCODED */]: "generator" /* GENERATOR */,
|
|
2254
|
+
["hierarchyDefinition" /* HIERARCHY */]: "filter" /* FILTER */,
|
|
2255
|
+
["interferenceMitigator" /* INTERFERENCE */]: "filter" /* FILTER */,
|
|
2256
|
+
["relativePriority" /* RELATIVE_PRIORITY */]: "filter" /* FILTER */
|
|
2257
|
+
};
|
|
868
2258
|
ContentNavigator = class {
|
|
2259
|
+
/** User interface for this navigation session */
|
|
2260
|
+
user;
|
|
2261
|
+
/** Course interface for this navigation session */
|
|
2262
|
+
course;
|
|
2263
|
+
/** Human-readable name for this strategy instance (from ContentNavigationStrategyData.name) */
|
|
2264
|
+
strategyName;
|
|
2265
|
+
/** Unique document ID for this strategy instance (from ContentNavigationStrategyData._id) */
|
|
2266
|
+
strategyId;
|
|
2267
|
+
/**
|
|
2268
|
+
* Constructor for standard navigators.
|
|
2269
|
+
* Call this from subclass constructors to initialize common fields.
|
|
2270
|
+
*
|
|
2271
|
+
* Note: CompositeGenerator doesn't use this pattern and should call super() without args.
|
|
2272
|
+
*/
|
|
2273
|
+
constructor(user, course, strategyData) {
|
|
2274
|
+
if (user && course && strategyData) {
|
|
2275
|
+
this.user = user;
|
|
2276
|
+
this.course = course;
|
|
2277
|
+
this.strategyName = strategyData.name;
|
|
2278
|
+
this.strategyId = strategyData._id;
|
|
2279
|
+
}
|
|
2280
|
+
}
|
|
869
2281
|
/**
|
|
2282
|
+
* Factory method to create navigator instances dynamically.
|
|
870
2283
|
*
|
|
871
|
-
* @param user
|
|
872
|
-
* @param
|
|
2284
|
+
* @param user - User interface
|
|
2285
|
+
* @param course - Course interface
|
|
2286
|
+
* @param strategyData - Strategy configuration document
|
|
873
2287
|
* @returns the runtime object used to steer a study session.
|
|
874
2288
|
*/
|
|
875
2289
|
static async create(user, course, strategyData) {
|
|
@@ -890,6 +2304,70 @@ var init_navigators = __esm({
|
|
|
890
2304
|
}
|
|
891
2305
|
return new NavigatorImpl(user, course, strategyData);
|
|
892
2306
|
}
|
|
2307
|
+
/**
|
|
2308
|
+
* Get cards with suitability scores and provenance trails.
|
|
2309
|
+
*
|
|
2310
|
+
* **This is the PRIMARY API for navigation strategies.**
|
|
2311
|
+
*
|
|
2312
|
+
* Returns cards ranked by suitability score (0-1). Higher scores indicate
|
|
2313
|
+
* better candidates for presentation. Each card includes a provenance trail
|
|
2314
|
+
* documenting how strategies contributed to the final score.
|
|
2315
|
+
*
|
|
2316
|
+
* ## For Generators
|
|
2317
|
+
* Override this method to generate candidates and compute scores based on
|
|
2318
|
+
* your strategy's logic (e.g., ELO proximity, review urgency). Create the
|
|
2319
|
+
* initial provenance entry with action='generated'.
|
|
2320
|
+
*
|
|
2321
|
+
* ## Default Implementation
|
|
2322
|
+
* The base class provides a backward-compatible default that:
|
|
2323
|
+
* 1. Calls legacy getNewCards() and getPendingReviews()
|
|
2324
|
+
* 2. Assigns score=1.0 to all cards
|
|
2325
|
+
* 3. Creates minimal provenance from legacy methods
|
|
2326
|
+
* 4. Returns combined results up to limit
|
|
2327
|
+
*
|
|
2328
|
+
* This allows existing strategies to work without modification while
|
|
2329
|
+
* new strategies can override with proper scoring and provenance.
|
|
2330
|
+
*
|
|
2331
|
+
* @param limit - Maximum cards to return
|
|
2332
|
+
* @returns Cards sorted by score descending, with provenance trails
|
|
2333
|
+
*/
|
|
2334
|
+
async getWeightedCards(limit) {
|
|
2335
|
+
const newCards = await this.getNewCards(limit);
|
|
2336
|
+
const reviews = await this.getPendingReviews();
|
|
2337
|
+
const weighted = [
|
|
2338
|
+
...newCards.map((c) => ({
|
|
2339
|
+
cardId: c.cardID,
|
|
2340
|
+
courseId: c.courseID,
|
|
2341
|
+
score: 1,
|
|
2342
|
+
provenance: [
|
|
2343
|
+
{
|
|
2344
|
+
strategy: "legacy",
|
|
2345
|
+
strategyName: this.strategyName || "Legacy API",
|
|
2346
|
+
strategyId: this.strategyId || "legacy-fallback",
|
|
2347
|
+
action: "generated",
|
|
2348
|
+
score: 1,
|
|
2349
|
+
reason: "Generated via legacy getNewCards(), new card"
|
|
2350
|
+
}
|
|
2351
|
+
]
|
|
2352
|
+
})),
|
|
2353
|
+
...reviews.map((r) => ({
|
|
2354
|
+
cardId: r.cardID,
|
|
2355
|
+
courseId: r.courseID,
|
|
2356
|
+
score: 1,
|
|
2357
|
+
provenance: [
|
|
2358
|
+
{
|
|
2359
|
+
strategy: "legacy",
|
|
2360
|
+
strategyName: this.strategyName || "Legacy API",
|
|
2361
|
+
strategyId: this.strategyId || "legacy-fallback",
|
|
2362
|
+
action: "generated",
|
|
2363
|
+
score: 1,
|
|
2364
|
+
reason: "Generated via legacy getPendingReviews(), review"
|
|
2365
|
+
}
|
|
2366
|
+
]
|
|
2367
|
+
}))
|
|
2368
|
+
];
|
|
2369
|
+
return weighted.slice(0, limit);
|
|
2370
|
+
}
|
|
893
2371
|
};
|
|
894
2372
|
}
|
|
895
2373
|
});
|
|
@@ -970,11 +2448,11 @@ ${JSON.stringify(config)}
|
|
|
970
2448
|
function isSuccessRow(row) {
|
|
971
2449
|
return "doc" in row && row.doc !== null && row.doc !== void 0;
|
|
972
2450
|
}
|
|
973
|
-
var
|
|
2451
|
+
var import_common9, CourseDB;
|
|
974
2452
|
var init_courseDB = __esm({
|
|
975
2453
|
"src/impl/couch/courseDB.ts"() {
|
|
976
2454
|
"use strict";
|
|
977
|
-
|
|
2455
|
+
import_common9 = require("@vue-skuilder/common");
|
|
978
2456
|
init_couch();
|
|
979
2457
|
init_updateQueue();
|
|
980
2458
|
init_types_legacy();
|
|
@@ -983,6 +2461,12 @@ var init_courseDB = __esm({
|
|
|
983
2461
|
init_courseAPI();
|
|
984
2462
|
init_courseLookupDB();
|
|
985
2463
|
init_navigators();
|
|
2464
|
+
init_Pipeline();
|
|
2465
|
+
init_PipelineAssembler();
|
|
2466
|
+
init_CompositeGenerator();
|
|
2467
|
+
init_elo();
|
|
2468
|
+
init_srs();
|
|
2469
|
+
init_eloDistance();
|
|
986
2470
|
CourseDB = class {
|
|
987
2471
|
// private log(msg: string): void {
|
|
988
2472
|
// log(`CourseLog: ${this.id}\n ${msg}`);
|
|
@@ -1049,14 +2533,14 @@ var init_courseDB = __esm({
|
|
|
1049
2533
|
docs.rows.forEach((r) => {
|
|
1050
2534
|
if (isSuccessRow(r)) {
|
|
1051
2535
|
if (r.doc && r.doc.elo) {
|
|
1052
|
-
ret.push((0,
|
|
2536
|
+
ret.push((0, import_common9.toCourseElo)(r.doc.elo));
|
|
1053
2537
|
} else {
|
|
1054
2538
|
logger.warn("no elo data for card: " + r.id);
|
|
1055
|
-
ret.push((0,
|
|
2539
|
+
ret.push((0, import_common9.blankCourseElo)());
|
|
1056
2540
|
}
|
|
1057
2541
|
} else {
|
|
1058
2542
|
logger.warn("no elo data for card: " + JSON.stringify(r));
|
|
1059
|
-
ret.push((0,
|
|
2543
|
+
ret.push((0, import_common9.blankCourseElo)());
|
|
1060
2544
|
}
|
|
1061
2545
|
});
|
|
1062
2546
|
return ret;
|
|
@@ -1238,7 +2722,7 @@ ${above.rows.map((r) => ` ${r.id}-${r.key}
|
|
|
1238
2722
|
async getCourseTagStubs() {
|
|
1239
2723
|
return getCourseTagStubs(this.id);
|
|
1240
2724
|
}
|
|
1241
|
-
async addNote(codeCourse, shape, data, author, tags, uploads, elo = (0,
|
|
2725
|
+
async addNote(codeCourse, shape, data, author, tags, uploads, elo = (0, import_common9.blankCourseElo)()) {
|
|
1242
2726
|
try {
|
|
1243
2727
|
const resp = await addNote55(this.id, codeCourse, shape, data, author, tags, uploads, elo);
|
|
1244
2728
|
if (resp.ok) {
|
|
@@ -1247,19 +2731,19 @@ ${above.rows.map((r) => ` ${r.id}-${r.key}
|
|
|
1247
2731
|
`[courseDB.addNote] Note added but card creation failed: ${resp.cardCreationError}`
|
|
1248
2732
|
);
|
|
1249
2733
|
return {
|
|
1250
|
-
status:
|
|
2734
|
+
status: import_common9.Status.error,
|
|
1251
2735
|
message: `Note was added but no cards were created: ${resp.cardCreationError}`,
|
|
1252
2736
|
id: resp.id
|
|
1253
2737
|
};
|
|
1254
2738
|
}
|
|
1255
2739
|
return {
|
|
1256
|
-
status:
|
|
2740
|
+
status: import_common9.Status.ok,
|
|
1257
2741
|
message: "",
|
|
1258
2742
|
id: resp.id
|
|
1259
2743
|
};
|
|
1260
2744
|
} else {
|
|
1261
2745
|
return {
|
|
1262
|
-
status:
|
|
2746
|
+
status: import_common9.Status.error,
|
|
1263
2747
|
message: "Unexpected error adding note"
|
|
1264
2748
|
};
|
|
1265
2749
|
}
|
|
@@ -1271,7 +2755,7 @@ ${above.rows.map((r) => ` ${r.id}-${r.key}
|
|
|
1271
2755
|
message: ${err.message}`
|
|
1272
2756
|
);
|
|
1273
2757
|
return {
|
|
1274
|
-
status:
|
|
2758
|
+
status: import_common9.Status.error,
|
|
1275
2759
|
message: `Error adding note to course. ${e.reason || err.message}`
|
|
1276
2760
|
};
|
|
1277
2761
|
}
|
|
@@ -1322,42 +2806,82 @@ ${above.rows.map((r) => ` ${r.id}-${r.key}
|
|
|
1322
2806
|
logger.debug(JSON.stringify(data));
|
|
1323
2807
|
return Promise.resolve();
|
|
1324
2808
|
}
|
|
1325
|
-
|
|
2809
|
+
/**
|
|
2810
|
+
* Creates an instantiated navigator for this course.
|
|
2811
|
+
*
|
|
2812
|
+
* Handles multiple generators by wrapping them in CompositeGenerator.
|
|
2813
|
+
* This is the preferred method for getting a ready-to-use navigator.
|
|
2814
|
+
*
|
|
2815
|
+
* @param user - User database interface
|
|
2816
|
+
* @returns Instantiated ContentNavigator ready for use
|
|
2817
|
+
*/
|
|
2818
|
+
async createNavigator(user) {
|
|
1326
2819
|
try {
|
|
1327
|
-
const
|
|
1328
|
-
if (
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
return strategy;
|
|
1334
|
-
}
|
|
1335
|
-
} catch (e) {
|
|
1336
|
-
logger.warn(
|
|
1337
|
-
// @ts-expect-error tmp: defaultNavigationStrategyId property does not yet exist
|
|
1338
|
-
`Failed to load strategy '${config.defaultNavigationStrategyId}' specified in course config. Falling back to ELO.`,
|
|
1339
|
-
e
|
|
1340
|
-
);
|
|
1341
|
-
}
|
|
2820
|
+
const allStrategies = await this.getAllNavigationStrategies();
|
|
2821
|
+
if (allStrategies.length === 0) {
|
|
2822
|
+
logger.debug(
|
|
2823
|
+
"[courseDB] No strategy documents found, using default Pipeline(Composite(ELO, SRS), [eloDistanceFilter])"
|
|
2824
|
+
);
|
|
2825
|
+
return this.createDefaultPipeline(user);
|
|
1342
2826
|
}
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
2827
|
+
const assembler = new PipelineAssembler();
|
|
2828
|
+
const { pipeline, generatorStrategies, filterStrategies, warnings } = await assembler.assemble({
|
|
2829
|
+
strategies: allStrategies,
|
|
2830
|
+
user,
|
|
2831
|
+
course: this
|
|
2832
|
+
});
|
|
2833
|
+
for (const warning of warnings) {
|
|
2834
|
+
logger.warn(`[PipelineAssembler] ${warning}`);
|
|
2835
|
+
}
|
|
2836
|
+
if (!pipeline) {
|
|
2837
|
+
logger.debug("[courseDB] Pipeline assembly failed, using default pipeline");
|
|
2838
|
+
return this.createDefaultPipeline(user);
|
|
2839
|
+
}
|
|
2840
|
+
logger.debug(
|
|
2841
|
+
`[courseDB] Using assembled pipeline with ${generatorStrategies.length} generator(s) and ${filterStrategies.length} filter(s)`
|
|
1347
2842
|
);
|
|
2843
|
+
return pipeline;
|
|
2844
|
+
} catch (e) {
|
|
2845
|
+
logger.error(`[courseDB] Error creating navigator: ${e}`);
|
|
2846
|
+
throw e;
|
|
1348
2847
|
}
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
2848
|
+
}
|
|
2849
|
+
makeDefaultEloStrategy() {
|
|
2850
|
+
return {
|
|
2851
|
+
_id: "NAVIGATION_STRATEGY-ELO-default",
|
|
1352
2852
|
docType: "NAVIGATION_STRATEGY" /* NAVIGATION_STRATEGY */,
|
|
1353
|
-
name: "ELO",
|
|
1354
|
-
description: "ELO-based navigation strategy",
|
|
2853
|
+
name: "ELO (default)",
|
|
2854
|
+
description: "Default ELO-based navigation strategy for new cards",
|
|
1355
2855
|
implementingClass: "elo" /* ELO */,
|
|
1356
2856
|
course: this.id,
|
|
1357
2857
|
serializedData: ""
|
|
1358
|
-
// serde is a noop for ELO navigator.
|
|
1359
2858
|
};
|
|
1360
|
-
|
|
2859
|
+
}
|
|
2860
|
+
makeDefaultSrsStrategy() {
|
|
2861
|
+
return {
|
|
2862
|
+
_id: "NAVIGATION_STRATEGY-SRS-default",
|
|
2863
|
+
docType: "NAVIGATION_STRATEGY" /* NAVIGATION_STRATEGY */,
|
|
2864
|
+
name: "SRS (default)",
|
|
2865
|
+
description: "Default SRS-based navigation strategy for reviews",
|
|
2866
|
+
implementingClass: "srs" /* SRS */,
|
|
2867
|
+
course: this.id,
|
|
2868
|
+
serializedData: ""
|
|
2869
|
+
};
|
|
2870
|
+
}
|
|
2871
|
+
/**
|
|
2872
|
+
* Creates the default navigation pipeline for courses with no configured strategies.
|
|
2873
|
+
*
|
|
2874
|
+
* Default: Pipeline(Composite(ELO, SRS), [eloDistanceFilter])
|
|
2875
|
+
* - ELO generator: scores new cards by skill proximity
|
|
2876
|
+
* - SRS generator: scores reviews by overdueness and interval recency
|
|
2877
|
+
* - ELO distance filter: penalizes cards far from user's current level
|
|
2878
|
+
*/
|
|
2879
|
+
createDefaultPipeline(user) {
|
|
2880
|
+
const eloNavigator = new ELONavigator(user, this, this.makeDefaultEloStrategy());
|
|
2881
|
+
const srsNavigator = new SRSNavigator(user, this, this.makeDefaultSrsStrategy());
|
|
2882
|
+
const compositeGenerator = new CompositeGenerator([eloNavigator, srsNavigator]);
|
|
2883
|
+
const eloDistanceFilter = createEloDistanceFilter();
|
|
2884
|
+
return new Pipeline(compositeGenerator, [eloDistanceFilter], user, this);
|
|
1361
2885
|
}
|
|
1362
2886
|
////////////////////////////////////
|
|
1363
2887
|
// END NavigationStrategyManager implementation
|
|
@@ -1368,22 +2892,39 @@ ${above.rows.map((r) => ` ${r.id}-${r.key}
|
|
|
1368
2892
|
async getNewCards(limit = 99) {
|
|
1369
2893
|
const u = await this._getCurrentUser();
|
|
1370
2894
|
try {
|
|
1371
|
-
const
|
|
1372
|
-
const navigator = await ContentNavigator.create(u, this, strategy);
|
|
2895
|
+
const navigator = await this.createNavigator(u);
|
|
1373
2896
|
return navigator.getNewCards(limit);
|
|
1374
2897
|
} catch (e) {
|
|
1375
|
-
logger.error(`[courseDB] Error
|
|
2898
|
+
logger.error(`[courseDB] Error in getNewCards: ${e}`);
|
|
1376
2899
|
throw e;
|
|
1377
2900
|
}
|
|
1378
2901
|
}
|
|
1379
2902
|
async getPendingReviews() {
|
|
1380
2903
|
const u = await this._getCurrentUser();
|
|
1381
2904
|
try {
|
|
1382
|
-
const
|
|
1383
|
-
const navigator = await ContentNavigator.create(u, this, strategy);
|
|
2905
|
+
const navigator = await this.createNavigator(u);
|
|
1384
2906
|
return navigator.getPendingReviews();
|
|
1385
2907
|
} catch (e) {
|
|
1386
|
-
logger.error(`[courseDB] Error
|
|
2908
|
+
logger.error(`[courseDB] Error in getPendingReviews: ${e}`);
|
|
2909
|
+
throw e;
|
|
2910
|
+
}
|
|
2911
|
+
}
|
|
2912
|
+
/**
|
|
2913
|
+
* Get cards with suitability scores for presentation.
|
|
2914
|
+
*
|
|
2915
|
+
* This is the PRIMARY API for content sources going forward. Delegates to the
|
|
2916
|
+
* course's configured NavigationStrategy to get scored candidates.
|
|
2917
|
+
*
|
|
2918
|
+
* @param limit - Maximum number of cards to return
|
|
2919
|
+
* @returns Cards sorted by score descending
|
|
2920
|
+
*/
|
|
2921
|
+
async getWeightedCards(limit) {
|
|
2922
|
+
const u = await this._getCurrentUser();
|
|
2923
|
+
try {
|
|
2924
|
+
const navigator = await this.createNavigator(u);
|
|
2925
|
+
return navigator.getWeightedCards(limit);
|
|
2926
|
+
} catch (e) {
|
|
2927
|
+
logger.error(`[courseDB] Error getting weighted cards: ${e}`);
|
|
1387
2928
|
throw e;
|
|
1388
2929
|
}
|
|
1389
2930
|
}
|
|
@@ -1399,7 +2940,7 @@ ${above.rows.map((r) => ` ${r.id}-${r.key}
|
|
|
1399
2940
|
const courseDoc = (await u.getCourseRegistrationsDoc()).courses.find((c) => {
|
|
1400
2941
|
return c.courseID === this.id;
|
|
1401
2942
|
});
|
|
1402
|
-
targetElo = (0,
|
|
2943
|
+
targetElo = (0, import_common9.EloToNumber)(courseDoc.elo);
|
|
1403
2944
|
} catch {
|
|
1404
2945
|
targetElo = 1e3;
|
|
1405
2946
|
}
|
|
@@ -1523,13 +3064,13 @@ ${above.rows.map((r) => ` ${r.id}-${r.key}
|
|
|
1523
3064
|
});
|
|
1524
3065
|
|
|
1525
3066
|
// src/impl/couch/classroomDB.ts
|
|
1526
|
-
var
|
|
3067
|
+
var import_moment4, CLASSROOM_CONFIG, ClassroomDBBase, StudentClassroomDB;
|
|
1527
3068
|
var init_classroomDB2 = __esm({
|
|
1528
3069
|
"src/impl/couch/classroomDB.ts"() {
|
|
1529
3070
|
"use strict";
|
|
1530
3071
|
init_factory();
|
|
1531
3072
|
init_logger();
|
|
1532
|
-
|
|
3073
|
+
import_moment4 = __toESM(require("moment"), 1);
|
|
1533
3074
|
init_pouchdb_setup();
|
|
1534
3075
|
init_couch();
|
|
1535
3076
|
init_courseDB();
|
|
@@ -1623,9 +3164,9 @@ var init_classroomDB2 = __esm({
|
|
|
1623
3164
|
}
|
|
1624
3165
|
async getNewCards() {
|
|
1625
3166
|
const activeCards = await this._user.getActiveCards();
|
|
1626
|
-
const now =
|
|
3167
|
+
const now = import_moment4.default.utc();
|
|
1627
3168
|
const assigned = await this.getAssignedContent();
|
|
1628
|
-
const due = assigned.filter((c) => now.isAfter(
|
|
3169
|
+
const due = assigned.filter((c) => now.isAfter(import_moment4.default.utc(c.activeOn, REVIEW_TIME_FORMAT2)));
|
|
1629
3170
|
logger.info(`Due content: ${JSON.stringify(due)}`);
|
|
1630
3171
|
let ret = [];
|
|
1631
3172
|
for (let i = 0; i < due.length; i++) {
|
|
@@ -1662,6 +3203,52 @@ var init_classroomDB2 = __esm({
|
|
|
1662
3203
|
}
|
|
1663
3204
|
});
|
|
1664
3205
|
}
|
|
3206
|
+
/**
|
|
3207
|
+
* Get cards with suitability scores for presentation.
|
|
3208
|
+
*
|
|
3209
|
+
* This implementation wraps the legacy getNewCards/getPendingReviews methods,
|
|
3210
|
+
* assigning score=1.0 to all cards. StudentClassroomDB does not currently
|
|
3211
|
+
* support pluggable navigation strategies.
|
|
3212
|
+
*
|
|
3213
|
+
* @param limit - Maximum number of cards to return
|
|
3214
|
+
* @returns Cards sorted by score descending (all scores = 1.0)
|
|
3215
|
+
*/
|
|
3216
|
+
async getWeightedCards(limit) {
|
|
3217
|
+
const [newCards, reviews] = await Promise.all([this.getNewCards(), this.getPendingReviews()]);
|
|
3218
|
+
const weighted = [
|
|
3219
|
+
...newCards.map((c) => ({
|
|
3220
|
+
cardId: c.cardID,
|
|
3221
|
+
courseId: c.courseID,
|
|
3222
|
+
score: 1,
|
|
3223
|
+
provenance: [
|
|
3224
|
+
{
|
|
3225
|
+
strategy: "classroom",
|
|
3226
|
+
strategyName: "Classroom",
|
|
3227
|
+
strategyId: "CLASSROOM",
|
|
3228
|
+
action: "generated",
|
|
3229
|
+
score: 1,
|
|
3230
|
+
reason: "Classroom legacy getNewCards(), new card"
|
|
3231
|
+
}
|
|
3232
|
+
]
|
|
3233
|
+
})),
|
|
3234
|
+
...reviews.map((r) => ({
|
|
3235
|
+
cardId: r.cardID,
|
|
3236
|
+
courseId: r.courseID,
|
|
3237
|
+
score: 1,
|
|
3238
|
+
provenance: [
|
|
3239
|
+
{
|
|
3240
|
+
strategy: "classroom",
|
|
3241
|
+
strategyName: "Classroom",
|
|
3242
|
+
strategyId: "CLASSROOM",
|
|
3243
|
+
action: "generated",
|
|
3244
|
+
score: 1,
|
|
3245
|
+
reason: "Classroom legacy getPendingReviews(), review"
|
|
3246
|
+
}
|
|
3247
|
+
]
|
|
3248
|
+
}))
|
|
3249
|
+
];
|
|
3250
|
+
return weighted.slice(0, limit);
|
|
3251
|
+
}
|
|
1665
3252
|
};
|
|
1666
3253
|
}
|
|
1667
3254
|
});
|
|
@@ -1686,19 +3273,19 @@ var init_auth = __esm({
|
|
|
1686
3273
|
"use strict";
|
|
1687
3274
|
init_factory();
|
|
1688
3275
|
init_logger();
|
|
1689
|
-
import_cross_fetch = __toESM(require("cross-fetch"));
|
|
3276
|
+
import_cross_fetch = __toESM(require("cross-fetch"), 1);
|
|
1690
3277
|
}
|
|
1691
3278
|
});
|
|
1692
3279
|
|
|
1693
3280
|
// src/impl/couch/CouchDBSyncStrategy.ts
|
|
1694
|
-
var
|
|
3281
|
+
var import_common10;
|
|
1695
3282
|
var init_CouchDBSyncStrategy = __esm({
|
|
1696
3283
|
"src/impl/couch/CouchDBSyncStrategy.ts"() {
|
|
1697
3284
|
"use strict";
|
|
1698
3285
|
init_factory();
|
|
1699
3286
|
init_types_legacy();
|
|
1700
3287
|
init_logger();
|
|
1701
|
-
|
|
3288
|
+
import_common10 = require("@vue-skuilder/common");
|
|
1702
3289
|
init_common();
|
|
1703
3290
|
init_pouchdb_setup();
|
|
1704
3291
|
init_couch();
|
|
@@ -1758,17 +3345,17 @@ function getStartAndEndKeys2(key) {
|
|
|
1758
3345
|
endkey: key + "\uFFF0"
|
|
1759
3346
|
};
|
|
1760
3347
|
}
|
|
1761
|
-
var import_cross_fetch2,
|
|
3348
|
+
var import_cross_fetch2, import_moment5, import_process, isBrowser, GUEST_LOCAL_DB, localUserDB, pouchDBincludeCredentialsConfig, REVIEW_TIME_FORMAT2;
|
|
1762
3349
|
var init_couch = __esm({
|
|
1763
3350
|
"src/impl/couch/index.ts"() {
|
|
1764
3351
|
"use strict";
|
|
1765
3352
|
init_factory();
|
|
1766
3353
|
init_types_legacy();
|
|
1767
|
-
import_cross_fetch2 = __toESM(require("cross-fetch"));
|
|
1768
|
-
|
|
3354
|
+
import_cross_fetch2 = __toESM(require("cross-fetch"), 1);
|
|
3355
|
+
import_moment5 = __toESM(require("moment"), 1);
|
|
1769
3356
|
init_logger();
|
|
1770
3357
|
init_pouchdb_setup();
|
|
1771
|
-
import_process = __toESM(require("process"));
|
|
3358
|
+
import_process = __toESM(require("process"), 1);
|
|
1772
3359
|
init_contentSource();
|
|
1773
3360
|
init_adminDB2();
|
|
1774
3361
|
init_classroomDB2();
|
|
@@ -1884,14 +3471,14 @@ async function dropUserFromClassroom(user, classID) {
|
|
|
1884
3471
|
async function getUserClassrooms(user) {
|
|
1885
3472
|
return getOrCreateClassroomRegistrationsDoc(user);
|
|
1886
3473
|
}
|
|
1887
|
-
var
|
|
3474
|
+
var import_common12, import_moment6, log3, BaseUser, userCoursesDoc, userClassroomsDoc;
|
|
1888
3475
|
var init_BaseUserDB = __esm({
|
|
1889
3476
|
"src/impl/common/BaseUserDB.ts"() {
|
|
1890
3477
|
"use strict";
|
|
1891
3478
|
init_core();
|
|
1892
3479
|
init_util();
|
|
1893
|
-
|
|
1894
|
-
|
|
3480
|
+
import_common12 = require("@vue-skuilder/common");
|
|
3481
|
+
import_moment6 = __toESM(require("moment"), 1);
|
|
1895
3482
|
init_types_legacy();
|
|
1896
3483
|
init_logger();
|
|
1897
3484
|
init_userDBHelpers();
|
|
@@ -1940,7 +3527,7 @@ Currently logged-in as ${this._username}.`
|
|
|
1940
3527
|
);
|
|
1941
3528
|
}
|
|
1942
3529
|
const result = await this.syncStrategy.createAccount(username, password);
|
|
1943
|
-
if (result.status ===
|
|
3530
|
+
if (result.status === import_common12.Status.ok) {
|
|
1944
3531
|
log3(`Account created successfully, updating username to ${username}`);
|
|
1945
3532
|
this._username = username;
|
|
1946
3533
|
try {
|
|
@@ -1982,7 +3569,7 @@ Currently logged-in as ${this._username}.`
|
|
|
1982
3569
|
async resetUserData() {
|
|
1983
3570
|
if (this.syncStrategy.canAuthenticate()) {
|
|
1984
3571
|
return {
|
|
1985
|
-
status:
|
|
3572
|
+
status: import_common12.Status.error,
|
|
1986
3573
|
error: "Reset user data is only available for local-only mode. Use logout instead for remote sync."
|
|
1987
3574
|
};
|
|
1988
3575
|
}
|
|
@@ -2001,11 +3588,11 @@ Currently logged-in as ${this._username}.`
|
|
|
2001
3588
|
await localDB.bulkDocs(docsToDelete);
|
|
2002
3589
|
}
|
|
2003
3590
|
await this.init();
|
|
2004
|
-
return { status:
|
|
3591
|
+
return { status: import_common12.Status.ok };
|
|
2005
3592
|
} catch (error) {
|
|
2006
3593
|
logger.error("Failed to reset user data:", error);
|
|
2007
3594
|
return {
|
|
2008
|
-
status:
|
|
3595
|
+
status: import_common12.Status.error,
|
|
2009
3596
|
error: error instanceof Error ? error.message : "Unknown error during reset"
|
|
2010
3597
|
};
|
|
2011
3598
|
}
|
|
@@ -2152,7 +3739,7 @@ Currently logged-in as ${this._username}.`
|
|
|
2152
3739
|
);
|
|
2153
3740
|
return reviews.rows.filter((r) => {
|
|
2154
3741
|
if (r.id.startsWith(DocTypePrefixes["SCHEDULED_CARD" /* SCHEDULED_CARD */])) {
|
|
2155
|
-
const date =
|
|
3742
|
+
const date = import_moment6.default.utc(
|
|
2156
3743
|
r.id.substr(DocTypePrefixes["SCHEDULED_CARD" /* SCHEDULED_CARD */].length),
|
|
2157
3744
|
REVIEW_TIME_FORMAT
|
|
2158
3745
|
);
|
|
@@ -2165,11 +3752,11 @@ Currently logged-in as ${this._username}.`
|
|
|
2165
3752
|
}).map((r) => r.doc);
|
|
2166
3753
|
}
|
|
2167
3754
|
async getReviewsForcast(daysCount) {
|
|
2168
|
-
const time =
|
|
3755
|
+
const time = import_moment6.default.utc().add(daysCount, "days");
|
|
2169
3756
|
return this.getReviewstoDate(time);
|
|
2170
3757
|
}
|
|
2171
3758
|
async getPendingReviews(course_id) {
|
|
2172
|
-
const now =
|
|
3759
|
+
const now = import_moment6.default.utc();
|
|
2173
3760
|
return this.getReviewstoDate(now, course_id);
|
|
2174
3761
|
}
|
|
2175
3762
|
async getScheduledReviewCount(course_id) {
|
|
@@ -2456,7 +4043,7 @@ Currently logged-in as ${this._username}.`
|
|
|
2456
4043
|
*/
|
|
2457
4044
|
async putCardRecord(record) {
|
|
2458
4045
|
const cardHistoryID = getCardHistoryID(record.courseID, record.cardID);
|
|
2459
|
-
record.timeStamp =
|
|
4046
|
+
record.timeStamp = import_moment6.default.utc(record.timeStamp).toString();
|
|
2460
4047
|
try {
|
|
2461
4048
|
const cardHistory = await this.update(
|
|
2462
4049
|
cardHistoryID,
|
|
@@ -2472,7 +4059,7 @@ Currently logged-in as ${this._username}.`
|
|
|
2472
4059
|
const ret = {
|
|
2473
4060
|
...record2
|
|
2474
4061
|
};
|
|
2475
|
-
ret.timeStamp =
|
|
4062
|
+
ret.timeStamp = import_moment6.default.utc(record2.timeStamp);
|
|
2476
4063
|
return ret;
|
|
2477
4064
|
});
|
|
2478
4065
|
return cardHistory;
|
|
@@ -2735,6 +4322,213 @@ var init_factory = __esm({
|
|
|
2735
4322
|
}
|
|
2736
4323
|
});
|
|
2737
4324
|
|
|
4325
|
+
// src/study/TagFilteredContentSource.ts
|
|
4326
|
+
var import_common14, TagFilteredContentSource;
|
|
4327
|
+
var init_TagFilteredContentSource = __esm({
|
|
4328
|
+
"src/study/TagFilteredContentSource.ts"() {
|
|
4329
|
+
"use strict";
|
|
4330
|
+
import_common14 = require("@vue-skuilder/common");
|
|
4331
|
+
init_courseDB();
|
|
4332
|
+
init_logger();
|
|
4333
|
+
TagFilteredContentSource = class {
|
|
4334
|
+
courseId;
|
|
4335
|
+
filter;
|
|
4336
|
+
user;
|
|
4337
|
+
// Cache resolved card IDs to avoid repeated lookups within a session
|
|
4338
|
+
resolvedCardIds = null;
|
|
4339
|
+
constructor(courseId, filter, user) {
|
|
4340
|
+
this.courseId = courseId;
|
|
4341
|
+
this.filter = filter;
|
|
4342
|
+
this.user = user;
|
|
4343
|
+
logger.info(
|
|
4344
|
+
`[TagFilteredContentSource] Created for course "${courseId}" with filter:`,
|
|
4345
|
+
JSON.stringify(filter)
|
|
4346
|
+
);
|
|
4347
|
+
}
|
|
4348
|
+
/**
|
|
4349
|
+
* Resolves the TagFilter to a set of eligible card IDs.
|
|
4350
|
+
*
|
|
4351
|
+
* - Cards in `include` tags are OR'd together (card needs at least one)
|
|
4352
|
+
* - Cards in `exclude` tags are removed from the result
|
|
4353
|
+
*/
|
|
4354
|
+
async resolveFilteredCardIds() {
|
|
4355
|
+
if (this.resolvedCardIds !== null) {
|
|
4356
|
+
return this.resolvedCardIds;
|
|
4357
|
+
}
|
|
4358
|
+
const includedCardIds = /* @__PURE__ */ new Set();
|
|
4359
|
+
if (this.filter.include.length > 0) {
|
|
4360
|
+
for (const tagName of this.filter.include) {
|
|
4361
|
+
try {
|
|
4362
|
+
const tagDoc = await getTag(this.courseId, tagName);
|
|
4363
|
+
tagDoc.taggedCards.forEach((cardId) => includedCardIds.add(cardId));
|
|
4364
|
+
} catch (error) {
|
|
4365
|
+
logger.warn(
|
|
4366
|
+
`[TagFilteredContentSource] Could not resolve tag "${tagName}" for inclusion:`,
|
|
4367
|
+
error
|
|
4368
|
+
);
|
|
4369
|
+
}
|
|
4370
|
+
}
|
|
4371
|
+
}
|
|
4372
|
+
if (includedCardIds.size === 0 && this.filter.include.length > 0) {
|
|
4373
|
+
logger.warn(
|
|
4374
|
+
`[TagFilteredContentSource] No cards found for include tags: ${this.filter.include.join(", ")}`
|
|
4375
|
+
);
|
|
4376
|
+
this.resolvedCardIds = /* @__PURE__ */ new Set();
|
|
4377
|
+
return this.resolvedCardIds;
|
|
4378
|
+
}
|
|
4379
|
+
const excludedCardIds = /* @__PURE__ */ new Set();
|
|
4380
|
+
if (this.filter.exclude.length > 0) {
|
|
4381
|
+
for (const tagName of this.filter.exclude) {
|
|
4382
|
+
try {
|
|
4383
|
+
const tagDoc = await getTag(this.courseId, tagName);
|
|
4384
|
+
tagDoc.taggedCards.forEach((cardId) => excludedCardIds.add(cardId));
|
|
4385
|
+
} catch (error) {
|
|
4386
|
+
logger.warn(
|
|
4387
|
+
`[TagFilteredContentSource] Could not resolve tag "${tagName}" for exclusion:`,
|
|
4388
|
+
error
|
|
4389
|
+
);
|
|
4390
|
+
}
|
|
4391
|
+
}
|
|
4392
|
+
}
|
|
4393
|
+
const finalCardIds = /* @__PURE__ */ new Set();
|
|
4394
|
+
for (const cardId of includedCardIds) {
|
|
4395
|
+
if (!excludedCardIds.has(cardId)) {
|
|
4396
|
+
finalCardIds.add(cardId);
|
|
4397
|
+
}
|
|
4398
|
+
}
|
|
4399
|
+
logger.info(
|
|
4400
|
+
`[TagFilteredContentSource] Resolved ${finalCardIds.size} cards (included: ${includedCardIds.size}, excluded: ${excludedCardIds.size})`
|
|
4401
|
+
);
|
|
4402
|
+
this.resolvedCardIds = finalCardIds;
|
|
4403
|
+
return finalCardIds;
|
|
4404
|
+
}
|
|
4405
|
+
/**
|
|
4406
|
+
* Gets new cards that match the tag filter and are not already active for the user.
|
|
4407
|
+
*/
|
|
4408
|
+
async getNewCards(limit) {
|
|
4409
|
+
if (!(0, import_common14.hasActiveFilter)(this.filter)) {
|
|
4410
|
+
logger.warn("[TagFilteredContentSource] getNewCards called with no active filter");
|
|
4411
|
+
return [];
|
|
4412
|
+
}
|
|
4413
|
+
const eligibleCardIds = await this.resolveFilteredCardIds();
|
|
4414
|
+
const activeCards = await this.user.getActiveCards();
|
|
4415
|
+
const activeCardIds = new Set(activeCards.map((c) => c.cardID));
|
|
4416
|
+
const newItems = [];
|
|
4417
|
+
for (const cardId of eligibleCardIds) {
|
|
4418
|
+
if (!activeCardIds.has(cardId)) {
|
|
4419
|
+
newItems.push({
|
|
4420
|
+
courseID: this.courseId,
|
|
4421
|
+
cardID: cardId,
|
|
4422
|
+
contentSourceType: "course",
|
|
4423
|
+
contentSourceID: this.courseId,
|
|
4424
|
+
status: "new"
|
|
4425
|
+
});
|
|
4426
|
+
}
|
|
4427
|
+
if (limit !== void 0 && newItems.length >= limit) {
|
|
4428
|
+
break;
|
|
4429
|
+
}
|
|
4430
|
+
}
|
|
4431
|
+
logger.info(`[TagFilteredContentSource] Found ${newItems.length} new cards matching filter`);
|
|
4432
|
+
return newItems;
|
|
4433
|
+
}
|
|
4434
|
+
/**
|
|
4435
|
+
* Gets pending reviews, filtered to only include cards that match the tag filter.
|
|
4436
|
+
*/
|
|
4437
|
+
async getPendingReviews() {
|
|
4438
|
+
if (!(0, import_common14.hasActiveFilter)(this.filter)) {
|
|
4439
|
+
logger.warn("[TagFilteredContentSource] getPendingReviews called with no active filter");
|
|
4440
|
+
return [];
|
|
4441
|
+
}
|
|
4442
|
+
const eligibleCardIds = await this.resolveFilteredCardIds();
|
|
4443
|
+
const allReviews = await this.user.getPendingReviews(this.courseId);
|
|
4444
|
+
const filteredReviews = allReviews.filter((review) => {
|
|
4445
|
+
return eligibleCardIds.has(review.cardId);
|
|
4446
|
+
});
|
|
4447
|
+
logger.info(
|
|
4448
|
+
`[TagFilteredContentSource] Found ${filteredReviews.length} pending reviews matching filter (of ${allReviews.length} total)`
|
|
4449
|
+
);
|
|
4450
|
+
return filteredReviews.map((r) => ({
|
|
4451
|
+
...r,
|
|
4452
|
+
courseID: r.courseId,
|
|
4453
|
+
cardID: r.cardId,
|
|
4454
|
+
contentSourceType: "course",
|
|
4455
|
+
contentSourceID: this.courseId,
|
|
4456
|
+
reviewID: r._id,
|
|
4457
|
+
status: "review"
|
|
4458
|
+
}));
|
|
4459
|
+
}
|
|
4460
|
+
/**
|
|
4461
|
+
* Get cards with suitability scores for presentation.
|
|
4462
|
+
*
|
|
4463
|
+
* This implementation wraps the legacy getNewCards/getPendingReviews methods,
|
|
4464
|
+
* assigning score=1.0 to all cards. TagFilteredContentSource does not currently
|
|
4465
|
+
* support pluggable navigation strategies - it returns flat-scored candidates.
|
|
4466
|
+
*
|
|
4467
|
+
* @param limit - Maximum number of cards to return
|
|
4468
|
+
* @returns Cards sorted by score descending (all scores = 1.0)
|
|
4469
|
+
*/
|
|
4470
|
+
async getWeightedCards(limit) {
|
|
4471
|
+
const [newCards, reviews] = await Promise.all([
|
|
4472
|
+
this.getNewCards(limit),
|
|
4473
|
+
this.getPendingReviews()
|
|
4474
|
+
]);
|
|
4475
|
+
const weighted = [
|
|
4476
|
+
...reviews.map((r) => ({
|
|
4477
|
+
cardId: r.cardID,
|
|
4478
|
+
courseId: r.courseID,
|
|
4479
|
+
score: 1,
|
|
4480
|
+
provenance: [
|
|
4481
|
+
{
|
|
4482
|
+
strategy: "tagFilter",
|
|
4483
|
+
strategyName: "Tag Filter",
|
|
4484
|
+
strategyId: "TAG_FILTER",
|
|
4485
|
+
action: "generated",
|
|
4486
|
+
score: 1,
|
|
4487
|
+
reason: `Tag-filtered review (tags: ${this.filter.include.join(", ")})`
|
|
4488
|
+
}
|
|
4489
|
+
]
|
|
4490
|
+
})),
|
|
4491
|
+
...newCards.map((c) => ({
|
|
4492
|
+
cardId: c.cardID,
|
|
4493
|
+
courseId: c.courseID,
|
|
4494
|
+
score: 1,
|
|
4495
|
+
provenance: [
|
|
4496
|
+
{
|
|
4497
|
+
strategy: "tagFilter",
|
|
4498
|
+
strategyName: "Tag Filter",
|
|
4499
|
+
strategyId: "TAG_FILTER",
|
|
4500
|
+
action: "generated",
|
|
4501
|
+
score: 1,
|
|
4502
|
+
reason: `Tag-filtered new card (tags: ${this.filter.include.join(", ")})`
|
|
4503
|
+
}
|
|
4504
|
+
]
|
|
4505
|
+
}))
|
|
4506
|
+
];
|
|
4507
|
+
return weighted.slice(0, limit);
|
|
4508
|
+
}
|
|
4509
|
+
/**
|
|
4510
|
+
* Clears the cached resolved card IDs.
|
|
4511
|
+
* Call this if the underlying tag data may have changed during a session.
|
|
4512
|
+
*/
|
|
4513
|
+
clearCache() {
|
|
4514
|
+
this.resolvedCardIds = null;
|
|
4515
|
+
}
|
|
4516
|
+
/**
|
|
4517
|
+
* Returns the course ID this source is filtering.
|
|
4518
|
+
*/
|
|
4519
|
+
getCourseId() {
|
|
4520
|
+
return this.courseId;
|
|
4521
|
+
}
|
|
4522
|
+
/**
|
|
4523
|
+
* Returns the active tag filter.
|
|
4524
|
+
*/
|
|
4525
|
+
getFilter() {
|
|
4526
|
+
return this.filter;
|
|
4527
|
+
}
|
|
4528
|
+
};
|
|
4529
|
+
}
|
|
4530
|
+
});
|
|
4531
|
+
|
|
2738
4532
|
// src/core/interfaces/contentSource.ts
|
|
2739
4533
|
function isReview(item) {
|
|
2740
4534
|
const ret = item.status === "review" || item.status === "failed-review" || "reviewID" in item;
|
|
@@ -2744,14 +4538,20 @@ async function getStudySource(source, user) {
|
|
|
2744
4538
|
if (source.type === "classroom") {
|
|
2745
4539
|
return await StudentClassroomDB.factory(source.id, user);
|
|
2746
4540
|
} else {
|
|
4541
|
+
if ((0, import_common15.hasActiveFilter)(source.tagFilter)) {
|
|
4542
|
+
return new TagFilteredContentSource(source.id, source.tagFilter, user);
|
|
4543
|
+
}
|
|
2747
4544
|
return getDataLayer().getCourseDB(source.id);
|
|
2748
4545
|
}
|
|
2749
4546
|
}
|
|
4547
|
+
var import_common15;
|
|
2750
4548
|
var init_contentSource = __esm({
|
|
2751
4549
|
"src/core/interfaces/contentSource.ts"() {
|
|
2752
4550
|
"use strict";
|
|
2753
4551
|
init_factory();
|
|
2754
4552
|
init_classroomDB2();
|
|
4553
|
+
import_common15 = require("@vue-skuilder/common");
|
|
4554
|
+
init_TagFilteredContentSource();
|
|
2755
4555
|
}
|
|
2756
4556
|
});
|
|
2757
4557
|
|
|
@@ -2864,7 +4664,7 @@ elo: ${elo}`;
|
|
|
2864
4664
|
misc: {}
|
|
2865
4665
|
} : void 0
|
|
2866
4666
|
);
|
|
2867
|
-
if (result.status ===
|
|
4667
|
+
if (result.status === import_common16.Status.ok) {
|
|
2868
4668
|
return {
|
|
2869
4669
|
originalText,
|
|
2870
4670
|
status: "success",
|
|
@@ -2908,17 +4708,17 @@ function validateProcessorConfig(config) {
|
|
|
2908
4708
|
}
|
|
2909
4709
|
return { isValid: true };
|
|
2910
4710
|
}
|
|
2911
|
-
var
|
|
4711
|
+
var import_common16;
|
|
2912
4712
|
var init_cardProcessor = __esm({
|
|
2913
4713
|
"src/core/bulkImport/cardProcessor.ts"() {
|
|
2914
4714
|
"use strict";
|
|
2915
|
-
|
|
4715
|
+
import_common16 = require("@vue-skuilder/common");
|
|
2916
4716
|
init_logger();
|
|
2917
4717
|
}
|
|
2918
4718
|
});
|
|
2919
4719
|
|
|
2920
4720
|
// src/core/bulkImport/types.ts
|
|
2921
|
-
var
|
|
4721
|
+
var init_types3 = __esm({
|
|
2922
4722
|
"src/core/bulkImport/types.ts"() {
|
|
2923
4723
|
"use strict";
|
|
2924
4724
|
}
|
|
@@ -2929,7 +4729,7 @@ var init_bulkImport = __esm({
|
|
|
2929
4729
|
"src/core/bulkImport/index.ts"() {
|
|
2930
4730
|
"use strict";
|
|
2931
4731
|
init_cardProcessor();
|
|
2932
|
-
|
|
4732
|
+
init_types3();
|
|
2933
4733
|
}
|
|
2934
4734
|
});
|
|
2935
4735
|
|
|
@@ -2941,12 +4741,17 @@ __export(core_exports, {
|
|
|
2941
4741
|
DocTypePrefixes: () => DocTypePrefixes,
|
|
2942
4742
|
GuestUsername: () => GuestUsername,
|
|
2943
4743
|
Loggable: () => Loggable,
|
|
4744
|
+
NavigatorRole: () => NavigatorRole,
|
|
4745
|
+
NavigatorRoles: () => NavigatorRoles,
|
|
2944
4746
|
Navigators: () => Navigators,
|
|
2945
4747
|
areQuestionRecords: () => areQuestionRecords,
|
|
2946
4748
|
docIsDeleted: () => docIsDeleted,
|
|
2947
4749
|
getCardHistoryID: () => getCardHistoryID,
|
|
4750
|
+
getCardOrigin: () => getCardOrigin,
|
|
2948
4751
|
getStudySource: () => getStudySource,
|
|
2949
4752
|
importParsedCards: () => importParsedCards,
|
|
4753
|
+
isFilter: () => isFilter,
|
|
4754
|
+
isGenerator: () => isGenerator,
|
|
2950
4755
|
isQuestionRecord: () => isQuestionRecord,
|
|
2951
4756
|
isReview: () => isReview,
|
|
2952
4757
|
log: () => log,
|
|
@@ -2973,12 +4778,17 @@ init_core();
|
|
|
2973
4778
|
DocTypePrefixes,
|
|
2974
4779
|
GuestUsername,
|
|
2975
4780
|
Loggable,
|
|
4781
|
+
NavigatorRole,
|
|
4782
|
+
NavigatorRoles,
|
|
2976
4783
|
Navigators,
|
|
2977
4784
|
areQuestionRecords,
|
|
2978
4785
|
docIsDeleted,
|
|
2979
4786
|
getCardHistoryID,
|
|
4787
|
+
getCardOrigin,
|
|
2980
4788
|
getStudySource,
|
|
2981
4789
|
importParsedCards,
|
|
4790
|
+
isFilter,
|
|
4791
|
+
isGenerator,
|
|
2982
4792
|
isQuestionRecord,
|
|
2983
4793
|
isReview,
|
|
2984
4794
|
log,
|