@vue-skuilder/db 0.2.30 → 0.2.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/{contentSource-CqJmbOZN.d.ts → contentSource-DMduBjDC.d.ts} +19 -4
  2. package/dist/{contentSource-B6FrSihy.d.cts → contentSource-Doh1aVBJ.d.cts} +19 -4
  3. package/dist/core/index.d.cts +3 -3
  4. package/dist/core/index.d.ts +3 -3
  5. package/dist/core/index.js +88 -76
  6. package/dist/core/index.js.map +1 -1
  7. package/dist/core/index.mjs +40 -27
  8. package/dist/core/index.mjs.map +1 -1
  9. package/dist/{dataLayerProvider-DUxDqMtZ.d.cts → dataLayerProvider-BW1CBAbb.d.cts} +1 -1
  10. package/dist/{dataLayerProvider-B9_UCvkR.d.ts → dataLayerProvider-Cxfe4nSK.d.ts} +1 -1
  11. package/dist/diagnostics/index.d.cts +18 -3
  12. package/dist/diagnostics/index.d.ts +18 -3
  13. package/dist/diagnostics/index.js +159 -135
  14. package/dist/diagnostics/index.js.map +1 -1
  15. package/dist/diagnostics/index.mjs +156 -135
  16. package/dist/diagnostics/index.mjs.map +1 -1
  17. package/dist/impl/couch/index.d.cts +2 -2
  18. package/dist/impl/couch/index.d.ts +2 -2
  19. package/dist/impl/couch/index.js +92 -80
  20. package/dist/impl/couch/index.js.map +1 -1
  21. package/dist/impl/couch/index.mjs +40 -27
  22. package/dist/impl/couch/index.mjs.map +1 -1
  23. package/dist/impl/static/index.d.cts +2 -2
  24. package/dist/impl/static/index.d.ts +2 -2
  25. package/dist/impl/static/index.js +79 -67
  26. package/dist/impl/static/index.js.map +1 -1
  27. package/dist/impl/static/index.mjs +40 -27
  28. package/dist/impl/static/index.mjs.map +1 -1
  29. package/dist/index.d.cts +3 -3
  30. package/dist/index.d.ts +3 -3
  31. package/dist/index.js +141 -110
  32. package/dist/index.js.map +1 -1
  33. package/dist/index.mjs +65 -33
  34. package/dist/index.mjs.map +1 -1
  35. package/package.json +3 -3
  36. package/src/core/navigators/PipelineDebugger.ts +42 -23
  37. package/src/core/navigators/filters/eloDistance.ts +7 -8
  38. package/src/core/navigators/generators/elo.ts +8 -2
  39. package/src/core/navigators/generators/prescribed.ts +7 -5
  40. package/src/core/types/studySession.ts +12 -1
  41. package/src/diagnostics/derive.ts +5 -2
  42. package/src/diagnostics/pipeline.ts +28 -0
  43. package/src/diagnostics/text.ts +11 -4
  44. package/src/study/SessionController.ts +3 -1
  45. package/src/study/services/EloService.ts +33 -6
package/dist/index.js CHANGED
@@ -806,13 +806,12 @@ function clearRunHistory() {
806
806
  _pendingRuns = [];
807
807
  }
808
808
  function getOrigin(card) {
809
- const firstEntry = card.provenance[0];
810
- if (!firstEntry) return "unknown";
811
- const reason = firstEntry.reason?.toLowerCase() || "";
812
- const strategy = firstEntry.strategy?.toLowerCase() || "";
813
- if (reason.includes("new card") || strategy.includes("elo")) return "new";
814
- if (reason.includes("review") || strategy.includes("srs")) return "review";
815
- return "unknown";
809
+ return card.reviewID ? "review" : "new";
810
+ }
811
+ function requiredBy(card) {
812
+ return card.provenance.find(
813
+ (p) => p.strategy === "ephemeralHint" && p.score === Number.POSITIVE_INFINITY
814
+ )?.strategyName;
816
815
  }
817
816
  function captureRun(report) {
818
817
  const fullReport = {
@@ -836,17 +835,23 @@ function parseCardElo(provenance) {
836
835
  }
837
836
  function buildRunReport(courseId, courseName, generatorName, generators, generatedCount, filters, allCards, selectedCards, userElo, hints, scoredCards, regulators) {
838
837
  const selectedIds = new Set(selectedCards.map((c) => c.cardId));
839
- const toReport = (card) => ({
840
- cardId: card.cardId,
841
- courseId: card.courseId,
842
- origin: getOrigin(card),
843
- generator: card.provenance[0]?.strategyName || card.provenance[0]?.strategy,
844
- finalScore: card.score,
845
- cardElo: card.cardElo ?? parseCardElo(card.provenance),
846
- provenance: card.provenance,
847
- tags: card.tags,
848
- selected: selectedIds.has(card.cardId)
849
- });
838
+ const toReport = (card) => {
839
+ const required = requiredBy(card);
840
+ const first = card.provenance[0];
841
+ const generator = first && first.strategy !== "ephemeralHint" ? first.strategyName || first.strategy : void 0;
842
+ return {
843
+ cardId: card.cardId,
844
+ courseId: card.courseId,
845
+ origin: getOrigin(card),
846
+ ...generator ? { generator } : {},
847
+ ...required ? { required } : {},
848
+ finalScore: card.score,
849
+ cardElo: card.cardElo ?? parseCardElo(card.provenance),
850
+ provenance: card.provenance,
851
+ tags: card.tags,
852
+ selected: selectedIds.has(card.cardId)
853
+ };
854
+ };
850
855
  const selectedReported = [];
851
856
  const nearMissReported = [];
852
857
  const discardedTailCards = [];
@@ -1975,10 +1980,14 @@ var init_elo = __esm({
1975
1980
  const userElo = (0, import_common5.toCourseElo)(courseReg.elo);
1976
1981
  userGlobalElo = userElo.global.score;
1977
1982
  }
1978
- const activeCards = await this.user.getActiveCards();
1983
+ const [activeCards, seenCards] = await Promise.all([
1984
+ this.user.getActiveCards(),
1985
+ this.user.getSeenCards(this.course.getCourseID()).catch(() => [])
1986
+ ]);
1987
+ const notNew = /* @__PURE__ */ new Set([...activeCards.map((ac) => ac.cardID), ...seenCards]);
1979
1988
  const newCards = (await this.course.getCardsCenteredAtELO(
1980
1989
  { limit, elo: "user" },
1981
- (c) => !activeCards.some((ac) => c.cardID === ac.cardID)
1990
+ (c) => !notNew.has(c.cardID)
1982
1991
  )).map((c) => ({ ...c, status: "new" }));
1983
1992
  const scored = newCards.map((c) => {
1984
1993
  const cardElo = c.elo ?? 1e3;
@@ -2071,11 +2080,11 @@ function formatAge(ms) {
2071
2080
  }
2072
2081
  function unmetIntroExposeTags(tags, userTagElo, minCount) {
2073
2082
  if (minCount <= 0) return [];
2074
- const exposeTags = new Set(tags.filter((tag) => tag.startsWith("gpc:expose:")));
2083
+ const exposeTags = new Set(tags.filter((tag) => (0, import_common6.tagRole)(tag) === "expose"));
2075
2084
  for (const tag of tags) {
2076
- if (!tag.startsWith("gpc:intro:")) continue;
2077
- const suffix = tag.slice("gpc:intro:".length);
2078
- if (suffix) exposeTags.add(`gpc:expose:${suffix}`);
2085
+ if ((0, import_common6.tagRole)(tag) !== "intro") continue;
2086
+ const expose = (0, import_common6.withTagRole)(tag, "expose");
2087
+ if (expose) exposeTags.add(expose);
2079
2088
  }
2080
2089
  return [...exposeTags].filter((tag) => {
2081
2090
  const tagElo = userTagElo[tag];
@@ -2085,10 +2094,11 @@ function unmetIntroExposeTags(tags, userTagElo, minCount) {
2085
2094
  function pickTopByScore(cards, limit) {
2086
2095
  return [...cards].sort((a, b) => b.score - a.score || a.cardId.localeCompare(b.cardId)).slice(0, limit);
2087
2096
  }
2088
- var DEFAULT_FRESHNESS_WINDOW, DEFAULT_MAX_DIRECT_PER_RUN, DEFAULT_MAX_SUPPORT_PER_RUN, DEFAULT_HIERARCHY_DEPTH, DEFAULT_MIN_COUNT, DEFAULT_PRACTICE_MIN_COUNT, DEFAULT_MAX_PRACTICE_PER_RUN, BASE_TARGET_SCORE, BASE_SUPPORT_SCORE, DISCOVERED_SUPPORT_SCORE, BASE_PRACTICE_SCORE, PRACTICE_BASE_MULT, MAX_PRACTICE_MULTIPLIER, PRACTICE_STALENESS_BUMP_PER_DAY, MAX_TARGET_MULTIPLIER, MAX_SUPPORT_MULTIPLIER, PRESCRIBED_DEBUG_VERSION, PrescribedCardsGenerator;
2097
+ var import_common6, DEFAULT_FRESHNESS_WINDOW, DEFAULT_MAX_DIRECT_PER_RUN, DEFAULT_MAX_SUPPORT_PER_RUN, DEFAULT_HIERARCHY_DEPTH, DEFAULT_MIN_COUNT, DEFAULT_PRACTICE_MIN_COUNT, DEFAULT_MAX_PRACTICE_PER_RUN, BASE_TARGET_SCORE, BASE_SUPPORT_SCORE, DISCOVERED_SUPPORT_SCORE, BASE_PRACTICE_SCORE, PRACTICE_BASE_MULT, MAX_PRACTICE_MULTIPLIER, PRACTICE_STALENESS_BUMP_PER_DAY, MAX_TARGET_MULTIPLIER, MAX_SUPPORT_MULTIPLIER, PRESCRIBED_DEBUG_VERSION, PrescribedCardsGenerator;
2089
2098
  var init_prescribed = __esm({
2090
2099
  "src/core/navigators/generators/prescribed.ts"() {
2091
2100
  "use strict";
2101
+ import_common6 = require("@vue-skuilder/common");
2092
2102
  init_navigators();
2093
2103
  init_StrategyPressureDebugger();
2094
2104
  init_logger();
@@ -3319,7 +3329,9 @@ function tagAwareGap(cardTags, cardElo, userElo, minTagCount) {
3319
3329
  const tags = [];
3320
3330
  for (const tag of cardTags) {
3321
3331
  const user = userElo.tags[tag];
3322
- if (!user || user.score === COUNT_ONLY_SENTINEL || user.count < minTagCount) continue;
3332
+ if ((0, import_common7.isCountOnlyTag)(tag) || !user || user.score === import_common7.COUNT_ONLY_SCORE || user.count < minTagCount) {
3333
+ continue;
3334
+ }
3323
3335
  const card = cardElo.tags[tag]?.score ?? cardElo.global.score;
3324
3336
  tags.push({
3325
3337
  tag,
@@ -3391,11 +3403,12 @@ function createEloDistanceFilter(config) {
3391
3403
  transform: (cards, context) => applyEloDistance(cards, context, resolved, source)
3392
3404
  };
3393
3405
  }
3394
- var DEFAULT_ELO_DISTANCE_CONFIG, TAG_CONFIDENCE_HALF, COUNT_ONLY_SENTINEL, DEFAULT_CARD_ELO, MULTI_DIM_ELO_KEY, multiDimElo, EloDistanceFilter;
3406
+ var import_common7, DEFAULT_ELO_DISTANCE_CONFIG, TAG_CONFIDENCE_HALF, DEFAULT_CARD_ELO, MULTI_DIM_ELO_KEY, multiDimElo, EloDistanceFilter;
3395
3407
  var init_eloDistance = __esm({
3396
3408
  "src/core/navigators/filters/eloDistance.ts"() {
3397
3409
  "use strict";
3398
3410
  init_navigators();
3411
+ import_common7 = require("@vue-skuilder/common");
3399
3412
  init_logger();
3400
3413
  DEFAULT_ELO_DISTANCE_CONFIG = {
3401
3414
  halfLife: 300,
@@ -3405,7 +3418,6 @@ var init_eloDistance = __esm({
3405
3418
  minTagCount: 3
3406
3419
  };
3407
3420
  TAG_CONFIDENCE_HALF = 10;
3408
- COUNT_ONLY_SENTINEL = -1;
3409
3421
  DEFAULT_CARD_ELO = 1e3;
3410
3422
  MULTI_DIM_ELO_KEY = "skuilder:multiDimElo";
3411
3423
  multiDimElo = readMultiDimElo();
@@ -3448,12 +3460,12 @@ var hierarchyDefinition_exports = {};
3448
3460
  __export(hierarchyDefinition_exports, {
3449
3461
  default: () => HierarchyDefinitionNavigator
3450
3462
  });
3451
- var import_common6, DEFAULT_MIN_COUNT2, HierarchyDefinitionNavigator;
3463
+ var import_common8, DEFAULT_MIN_COUNT2, HierarchyDefinitionNavigator;
3452
3464
  var init_hierarchyDefinition = __esm({
3453
3465
  "src/core/navigators/filters/hierarchyDefinition.ts"() {
3454
3466
  "use strict";
3455
3467
  init_navigators();
3456
- import_common6 = require("@vue-skuilder/common");
3468
+ import_common8 = require("@vue-skuilder/common");
3457
3469
  init_logger();
3458
3470
  DEFAULT_MIN_COUNT2 = 3;
3459
3471
  HierarchyDefinitionNavigator = class _HierarchyDefinitionNavigator extends ContentNavigator {
@@ -3503,7 +3515,7 @@ var init_hierarchyDefinition = __esm({
3503
3515
  const mastered = /* @__PURE__ */ new Set();
3504
3516
  try {
3505
3517
  const courseReg = await context.user.getCourseRegDoc(context.course.getCourseID());
3506
- const userElo = (0, import_common6.toCourseElo)(courseReg.elo);
3518
+ const userElo = (0, import_common8.toCourseElo)(courseReg.elo);
3507
3519
  for (const prereqs of Object.values(this.config.prerequisites)) {
3508
3520
  for (const prereq of prereqs) {
3509
3521
  const tagElo = userElo.tags[prereq.tag];
@@ -3875,12 +3887,12 @@ var interferenceMitigator_exports = {};
3875
3887
  __export(interferenceMitigator_exports, {
3876
3888
  default: () => InterferenceMitigatorNavigator
3877
3889
  });
3878
- var import_common7, DEFAULT_MIN_COUNT3, DEFAULT_MIN_ELAPSED_DAYS, DEFAULT_INTERFERENCE_DECAY, InterferenceMitigatorNavigator;
3890
+ var import_common9, DEFAULT_MIN_COUNT3, DEFAULT_MIN_ELAPSED_DAYS, DEFAULT_INTERFERENCE_DECAY, InterferenceMitigatorNavigator;
3879
3891
  var init_interferenceMitigator = __esm({
3880
3892
  "src/core/navigators/filters/interferenceMitigator.ts"() {
3881
3893
  "use strict";
3882
3894
  init_navigators();
3883
- import_common7 = require("@vue-skuilder/common");
3895
+ import_common9 = require("@vue-skuilder/common");
3884
3896
  DEFAULT_MIN_COUNT3 = 10;
3885
3897
  DEFAULT_MIN_ELAPSED_DAYS = 3;
3886
3898
  DEFAULT_INTERFERENCE_DECAY = 0.8;
@@ -3965,7 +3977,7 @@ var init_interferenceMitigator = __esm({
3965
3977
  const immature = /* @__PURE__ */ new Set();
3966
3978
  try {
3967
3979
  const courseReg = await context.user.getCourseRegDoc(context.course.getCourseID());
3968
- const userElo = (0, import_common7.toCourseElo)(courseReg.elo);
3980
+ const userElo = (0, import_common9.toCourseElo)(courseReg.elo);
3969
3981
  const minCount = this.config.maturityThreshold?.minCount ?? DEFAULT_MIN_COUNT3;
3970
3982
  const minElo = this.config.maturityThreshold?.minElo;
3971
3983
  const minElapsedDays = this.config.maturityThreshold?.minElapsedDays ?? DEFAULT_MIN_ELAPSED_DAYS;
@@ -4756,11 +4768,11 @@ function logCardProvenance(cards, maxCards = 3) {
4756
4768
  }
4757
4769
  }
4758
4770
  }
4759
- var import_common8, VERBOSE_RESULTS, Pipeline;
4771
+ var import_common10, VERBOSE_RESULTS, Pipeline;
4760
4772
  var init_Pipeline = __esm({
4761
4773
  "src/core/navigators/Pipeline.ts"() {
4762
4774
  "use strict";
4763
- import_common8 = require("@vue-skuilder/common");
4775
+ import_common10 = require("@vue-skuilder/common");
4764
4776
  init_navigators();
4765
4777
  init_logger();
4766
4778
  init_orchestration();
@@ -5249,7 +5261,7 @@ var init_Pipeline = __esm({
5249
5261
  let userCourseElo;
5250
5262
  try {
5251
5263
  const courseReg = await this.user.getCourseRegDoc(this.course.getCourseID());
5252
- userCourseElo = (0, import_common8.toCourseElo)(courseReg.elo);
5264
+ userCourseElo = (0, import_common10.toCourseElo)(courseReg.elo);
5253
5265
  userElo = userCourseElo.global.score;
5254
5266
  } catch (e) {
5255
5267
  logger.debug(`[Pipeline] Could not get user ELO, using default: ${e}`);
@@ -5311,7 +5323,7 @@ var init_Pipeline = __esm({
5311
5323
  */
5312
5324
  async getTagEloStatus(tagFilter) {
5313
5325
  const courseReg = await this.user.getCourseRegDoc(this.course.getCourseID());
5314
- const courseElo = (0, import_common8.toCourseElo)(courseReg.elo);
5326
+ const courseElo = (0, import_common10.toCourseElo)(courseReg.elo);
5315
5327
  const result = {};
5316
5328
  if (!tagFilter) {
5317
5329
  for (const [tag, data] of Object.entries(courseElo.tags)) {
@@ -6212,11 +6224,11 @@ ${JSON.stringify(config)}
6212
6224
  function isSuccessRow(row) {
6213
6225
  return "doc" in row && row.doc !== null && row.doc !== void 0;
6214
6226
  }
6215
- var import_common9, CoursesDB, CourseDB;
6227
+ var import_common11, CoursesDB, CourseDB;
6216
6228
  var init_courseDB = __esm({
6217
6229
  "src/impl/couch/courseDB.ts"() {
6218
6230
  "use strict";
6219
- import_common9 = require("@vue-skuilder/common");
6231
+ import_common11 = require("@vue-skuilder/common");
6220
6232
  init_couch();
6221
6233
  init_updateQueue();
6222
6234
  init_types_legacy();
@@ -6365,14 +6377,14 @@ var init_courseDB = __esm({
6365
6377
  docs.rows.forEach((r) => {
6366
6378
  if (isSuccessRow(r)) {
6367
6379
  if (r.doc && r.doc.elo) {
6368
- ret.push((0, import_common9.toCourseElo)(r.doc.elo));
6380
+ ret.push((0, import_common11.toCourseElo)(r.doc.elo));
6369
6381
  } else {
6370
6382
  logger.warn("no elo data for card: " + r.id);
6371
- ret.push((0, import_common9.blankCourseElo)());
6383
+ ret.push((0, import_common11.blankCourseElo)());
6372
6384
  }
6373
6385
  } else {
6374
6386
  logger.warn("no elo data for card: " + JSON.stringify(r));
6375
- ret.push((0, import_common9.blankCourseElo)());
6387
+ ret.push((0, import_common11.blankCourseElo)());
6376
6388
  }
6377
6389
  });
6378
6390
  return ret;
@@ -6575,7 +6587,7 @@ ${above.rows.map((r) => ` ${r.id}-${r.key}
6575
6587
  async getCourseTagStubs() {
6576
6588
  return getCourseTagStubs(this.id);
6577
6589
  }
6578
- async addNote(codeCourse, shape, data, author, tags, uploads, elo = (0, import_common9.blankCourseElo)()) {
6590
+ async addNote(codeCourse, shape, data, author, tags, uploads, elo = (0, import_common11.blankCourseElo)()) {
6579
6591
  try {
6580
6592
  const resp = await addNote55(this.id, codeCourse, shape, data, author, tags, uploads, elo);
6581
6593
  if (resp.ok) {
@@ -6584,19 +6596,19 @@ ${above.rows.map((r) => ` ${r.id}-${r.key}
6584
6596
  `[courseDB.addNote] Note added but card creation failed: ${resp.cardCreationError}`
6585
6597
  );
6586
6598
  return {
6587
- status: import_common9.Status.error,
6599
+ status: import_common11.Status.error,
6588
6600
  message: `Note was added but no cards were created: ${resp.cardCreationError}`,
6589
6601
  id: resp.id
6590
6602
  };
6591
6603
  }
6592
6604
  return {
6593
- status: import_common9.Status.ok,
6605
+ status: import_common11.Status.ok,
6594
6606
  message: "",
6595
6607
  id: resp.id
6596
6608
  };
6597
6609
  } else {
6598
6610
  return {
6599
- status: import_common9.Status.error,
6611
+ status: import_common11.Status.error,
6600
6612
  message: "Unexpected error adding note"
6601
6613
  };
6602
6614
  }
@@ -6608,7 +6620,7 @@ ${above.rows.map((r) => ` ${r.id}-${r.key}
6608
6620
  message: ${err.message}`
6609
6621
  );
6610
6622
  return {
6611
- status: import_common9.Status.error,
6623
+ status: import_common11.Status.error,
6612
6624
  message: `Error adding note to course. ${e.reason || err.message}`
6613
6625
  };
6614
6626
  }
@@ -6802,7 +6814,7 @@ ${e.stack}` : JSON.stringify(e);
6802
6814
  const courseDoc = (await u.getCourseRegistrationsDoc()).courses.find((c) => {
6803
6815
  return c.courseID === this.id;
6804
6816
  });
6805
- targetElo = (0, import_common9.EloToNumber)(courseDoc.elo);
6817
+ targetElo = (0, import_common11.EloToNumber)(courseDoc.elo);
6806
6818
  } catch {
6807
6819
  targetElo = 1e3;
6808
6820
  }
@@ -7633,14 +7645,14 @@ var CouchDBSyncStrategy_exports = {};
7633
7645
  __export(CouchDBSyncStrategy_exports, {
7634
7646
  CouchDBSyncStrategy: () => CouchDBSyncStrategy
7635
7647
  });
7636
- var import_common10, log2, CouchDBSyncStrategy;
7648
+ var import_common12, log2, CouchDBSyncStrategy;
7637
7649
  var init_CouchDBSyncStrategy = __esm({
7638
7650
  "src/impl/couch/CouchDBSyncStrategy.ts"() {
7639
7651
  "use strict";
7640
7652
  init_factory();
7641
7653
  init_types_legacy();
7642
7654
  init_logger();
7643
- import_common10 = require("@vue-skuilder/common");
7655
+ import_common12 = require("@vue-skuilder/common");
7644
7656
  init_common();
7645
7657
  init_pouchdb_setup();
7646
7658
  init_couch();
@@ -7781,32 +7793,32 @@ var init_CouchDBSyncStrategy = __esm({
7781
7793
  }
7782
7794
  }
7783
7795
  return {
7784
- status: import_common10.Status.ok,
7796
+ status: import_common12.Status.ok,
7785
7797
  error: void 0
7786
7798
  };
7787
7799
  } else {
7788
7800
  return {
7789
- status: import_common10.Status.error,
7801
+ status: import_common12.Status.error,
7790
7802
  error: "Failed to log in after account creation"
7791
7803
  };
7792
7804
  }
7793
7805
  } else {
7794
7806
  logger.warn(`Signup not OK: ${JSON.stringify(signupRequest)}`);
7795
7807
  return {
7796
- status: import_common10.Status.error,
7808
+ status: import_common12.Status.error,
7797
7809
  error: "Account creation failed"
7798
7810
  };
7799
7811
  }
7800
7812
  } catch (e) {
7801
7813
  if (e.reason === "Document update conflict.") {
7802
7814
  return {
7803
- status: import_common10.Status.error,
7815
+ status: import_common12.Status.error,
7804
7816
  error: "This username is taken!"
7805
7817
  };
7806
7818
  }
7807
7819
  logger.error(`Error on signup: ${JSON.stringify(e)}`);
7808
7820
  return {
7809
- status: import_common10.Status.error,
7821
+ status: import_common12.Status.error,
7810
7822
  error: e.message || "Unknown error during account creation"
7811
7823
  };
7812
7824
  }
@@ -8051,7 +8063,7 @@ function newQuestionInterval(user, cardHistory) {
8051
8063
  }
8052
8064
  if (currentAttempt.isCorrect) {
8053
8065
  const rawPerf = currentAttempt.performance;
8054
- const numericPerf = (0, import_common12.isTaggedPerformance)(rawPerf) ? rawPerf._global : rawPerf;
8066
+ const numericPerf = (0, import_common14.isTaggedPerformance)(rawPerf) ? rawPerf._global : rawPerf;
8055
8067
  const skill = Math.min(1, Math.max(0, numericPerf));
8056
8068
  logger.debug(`Demontrated skill: ${skill}`);
8057
8069
  const interval = lastInterval * (0.75 + skill);
@@ -8102,13 +8114,13 @@ function secondsBetween(start, end) {
8102
8114
  const ret = duration(end.diff(start)).asSeconds();
8103
8115
  return ret;
8104
8116
  }
8105
- var import_moment4, import_common12, duration;
8117
+ var import_moment4, import_common14, duration;
8106
8118
  var init_SpacedRepetition = __esm({
8107
8119
  "src/study/SpacedRepetition.ts"() {
8108
8120
  "use strict";
8109
8121
  init_util();
8110
8122
  import_moment4 = __toESM(require("moment"), 1);
8111
- import_common12 = require("@vue-skuilder/common");
8123
+ import_common14 = require("@vue-skuilder/common");
8112
8124
  init_logger();
8113
8125
  duration = import_moment4.default.duration;
8114
8126
  }
@@ -8183,25 +8195,40 @@ function recordTagPresentations(userElo, perf, records, cardId, at) {
8183
8195
  if (typeof score !== "number") continue;
8184
8196
  const rank = userElo.tags[tag] ?? { score: userElo.global.score, count: 0 };
8185
8197
  const entry = { at, ok, perf: score, card: cardId };
8186
- userElo.tags[tag] = (0, import_common13.pushTagPresentation)(rank, entry);
8198
+ userElo.tags[tag] = (0, import_common15.pushTagPresentation)(rank, entry);
8187
8199
  written.push(tag);
8188
8200
  }
8189
8201
  return written;
8190
8202
  }
8191
- var import_common13;
8203
+ var import_common15;
8192
8204
  var init_tagRecent = __esm({
8193
8205
  "src/study/services/tagRecent.ts"() {
8194
8206
  "use strict";
8195
- import_common13 = require("@vue-skuilder/common");
8207
+ import_common15 = require("@vue-skuilder/common");
8196
8208
  }
8197
8209
  });
8198
8210
 
8199
8211
  // src/study/services/EloService.ts
8200
- var import_common14, EloService;
8212
+ function withCountOnlyRoles(perf, cardId) {
8213
+ const out = { ...perf };
8214
+ const counted = [];
8215
+ for (const [tag, score] of Object.entries(perf)) {
8216
+ if (tag === "_global" || score === null || !(0, import_common16.isCountOnlyTag)(tag)) continue;
8217
+ out[tag] = null;
8218
+ counted.push(tag);
8219
+ }
8220
+ if (counted.length) {
8221
+ logger.warn(
8222
+ `[EloService] ${cardId} sent scores for bookkeeping tags [${counted.join(", ")}]; counted, not graded`
8223
+ );
8224
+ }
8225
+ return out;
8226
+ }
8227
+ var import_common16, EloService;
8201
8228
  var init_EloService = __esm({
8202
8229
  "src/study/services/EloService.ts"() {
8203
8230
  "use strict";
8204
- import_common14 = require("@vue-skuilder/common");
8231
+ import_common16 = require("@vue-skuilder/common");
8205
8232
  init_logger();
8206
8233
  init_tagRecent();
8207
8234
  EloService = class {
@@ -8234,7 +8261,7 @@ var init_EloService = __esm({
8234
8261
  );
8235
8262
  return null;
8236
8263
  }
8237
- const userElo = (0, import_common14.toCourseElo)(courseReg.elo);
8264
+ const userElo = (0, import_common16.toCourseElo)(courseReg.elo);
8238
8265
  const cardElo = (await courseDB.getCardEloData([currentCard.card.card_id]))[0];
8239
8266
  if (cardElo && userElo) {
8240
8267
  const beforeUserGlobal = userElo.global.score;
@@ -8244,14 +8271,15 @@ var init_EloService = __esm({
8244
8271
  for (const tag of cardTagKeys) {
8245
8272
  beforeUserTag[tag] = userElo.tags[tag]?.score ?? userElo.global.score;
8246
8273
  }
8247
- const eloUpdate = (0, import_common14.adjustCourseScores)(userElo, cardElo, userScore);
8274
+ const eloUpdate = (0, import_common16.adjustCourseScores)(userElo, cardElo, userScore);
8248
8275
  courseReg.elo = eloUpdate.userElo;
8249
8276
  const tags = {};
8250
8277
  for (const tag of cardTagKeys) {
8278
+ const countOnly = (0, import_common16.isCountOnlyTag)(tag);
8251
8279
  tags[tag] = {
8252
8280
  before: beforeUserTag[tag],
8253
- after: eloUpdate.userElo.tags[tag].score,
8254
- score: userScore
8281
+ after: countOnly ? beforeUserTag[tag] : eloUpdate.userElo.tags[tag].score,
8282
+ score: countOnly ? null : userScore
8255
8283
  };
8256
8284
  }
8257
8285
  const event = {
@@ -8315,18 +8343,19 @@ var init_EloService = __esm({
8315
8343
  );
8316
8344
  return null;
8317
8345
  }
8318
- const userElo = (0, import_common14.toCourseElo)(courseReg.elo);
8346
+ const userElo = (0, import_common16.toCourseElo)(courseReg.elo);
8319
8347
  const [cardEloResults, cardTagsMap] = await Promise.all([
8320
8348
  courseDB.getCardEloData([currentCard.card.card_id]),
8321
8349
  courseDB.getAppliedTagsBatch([card_id])
8322
8350
  ]);
8323
8351
  const cardElo = cardEloResults[0];
8324
8352
  const cardTags = cardTagsMap.get(card_id) ?? [];
8325
- const enriched = { ...taggedPerformance };
8353
+ const graded = withCountOnlyRoles(taggedPerformance, card_id);
8354
+ const enriched = { ...graded };
8326
8355
  const globalScore = taggedPerformance._global;
8327
8356
  for (const tag of cardTags) {
8328
8357
  if (!(tag in enriched)) {
8329
- enriched[tag] = globalScore;
8358
+ enriched[tag] = (0, import_common16.isCountOnlyTag)(tag) ? null : globalScore;
8330
8359
  }
8331
8360
  }
8332
8361
  if (cardElo && userElo) {
@@ -8337,11 +8366,11 @@ var init_EloService = __esm({
8337
8366
  for (const tag of touchedTags) {
8338
8367
  beforeUserTag[tag] = userElo.tags[tag]?.score ?? userElo.global.score;
8339
8368
  }
8340
- const eloUpdate = (0, import_common14.adjustCourseScoresPerTag)(userElo, cardElo, enriched);
8369
+ const eloUpdate = (0, import_common16.adjustCourseScoresPerTag)(userElo, cardElo, enriched);
8341
8370
  const at = (/* @__PURE__ */ new Date()).toISOString();
8342
8371
  const recorded = recordTagPresentations(
8343
8372
  eloUpdate.userElo,
8344
- taggedPerformance,
8373
+ graded,
8345
8374
  currentCard.records,
8346
8375
  card_id,
8347
8376
  at
@@ -8404,13 +8433,13 @@ var init_EloService = __esm({
8404
8433
  });
8405
8434
 
8406
8435
  // src/study/services/ResponseProcessor.ts
8407
- var import_common15, ResponseProcessor;
8436
+ var import_common17, ResponseProcessor;
8408
8437
  var init_ResponseProcessor = __esm({
8409
8438
  "src/study/services/ResponseProcessor.ts"() {
8410
8439
  "use strict";
8411
8440
  init_core();
8412
8441
  init_logger();
8413
- import_common15 = require("@vue-skuilder/common");
8442
+ import_common17 = require("@vue-skuilder/common");
8414
8443
  ResponseProcessor = class {
8415
8444
  srsService;
8416
8445
  eloService;
@@ -8453,7 +8482,7 @@ var init_ResponseProcessor = __esm({
8453
8482
  taggedPerformance: null
8454
8483
  };
8455
8484
  }
8456
- if ((0, import_common15.isTaggedPerformance)(performance2)) {
8485
+ if ((0, import_common17.isTaggedPerformance)(performance2)) {
8457
8486
  return {
8458
8487
  globalScore: performance2._global,
8459
8488
  taggedPerformance: performance2
@@ -8756,11 +8785,11 @@ function prefetchAudio(url) {
8756
8785
  audio.src = url;
8757
8786
  });
8758
8787
  }
8759
- var import_common16, CardHydrationService;
8788
+ var import_common18, CardHydrationService;
8760
8789
  var init_CardHydrationService = __esm({
8761
8790
  "src/study/services/CardHydrationService.ts"() {
8762
8791
  "use strict";
8763
- import_common16 = require("@vue-skuilder/common");
8792
+ import_common18 = require("@vue-skuilder/common");
8764
8793
  init_logger();
8765
8794
  CardHydrationService = class {
8766
8795
  constructor(getViewComponent, getCourseDB3, getItemsToHydrate) {
@@ -8873,8 +8902,8 @@ var init_CardHydrationService = __esm({
8873
8902
  courseDB.getCourseDoc(item.cardID),
8874
8903
  courseDB.getAppliedTagsBatch([item.cardID])
8875
8904
  ]);
8876
- if (!(0, import_common16.isCourseElo)(cardData.elo)) {
8877
- cardData.elo = (0, import_common16.toCourseElo)(cardData.elo);
8905
+ if (!(0, import_common18.isCourseElo)(cardData.elo)) {
8906
+ cardData.elo = (0, import_common18.toCourseElo)(cardData.elo);
8878
8907
  }
8879
8908
  const view = this.getViewComponent(cardData.id_view);
8880
8909
  const dataDocs = await Promise.all(
@@ -8898,9 +8927,9 @@ var init_CardHydrationService = __esm({
8898
8927
  );
8899
8928
  await Promise.allSettled(uniqueAudioUrls.map(prefetchAudio));
8900
8929
  }
8901
- const data = dataDocs.map(import_common16.displayableDataToViewData).reverse();
8930
+ const data = dataDocs.map(import_common18.displayableDataToViewData).reverse();
8902
8931
  this.hydratedCards.set(item.cardID, {
8903
- item: { ...item, elo: (0, import_common16.toCourseElo)(cardData.elo).global.score },
8932
+ item: { ...item, elo: (0, import_common18.toCourseElo)(cardData.elo).global.score },
8904
8933
  view,
8905
8934
  data,
8906
8935
  tags: tagsByCard.get(item.cardID) ?? []
@@ -11626,7 +11655,9 @@ function toRunCard(c) {
11626
11655
  cardId: c.cardId,
11627
11656
  origin: c.origin,
11628
11657
  ...c.generator ? { generator: c.generator } : {},
11629
- score: sig4(c.finalScore),
11658
+ ...c.required ? { required: c.required } : {},
11659
+ // A required card's score is infinite, which JSON can't hold: say so with null.
11660
+ score: Number.isFinite(c.finalScore) ? sig4(c.finalScore) : null,
11630
11661
  selected: c.selected
11631
11662
  };
11632
11663
  }
@@ -12956,11 +12987,11 @@ var init_SessionController = __esm({
12956
12987
  });
12957
12988
 
12958
12989
  // src/study/TagFilteredContentSource.ts
12959
- var import_common17, TagFilteredContentSource;
12990
+ var import_common19, TagFilteredContentSource;
12960
12991
  var init_TagFilteredContentSource = __esm({
12961
12992
  "src/study/TagFilteredContentSource.ts"() {
12962
12993
  "use strict";
12963
- import_common17 = require("@vue-skuilder/common");
12994
+ import_common19 = require("@vue-skuilder/common");
12964
12995
  init_courseDB();
12965
12996
  init_logger();
12966
12997
  TagFilteredContentSource = class {
@@ -13046,7 +13077,7 @@ var init_TagFilteredContentSource = __esm({
13046
13077
  * @returns Cards sorted by score descending (all scores = 1.0)
13047
13078
  */
13048
13079
  async getWeightedCards(limit) {
13049
- if (!(0, import_common17.hasActiveFilter)(this.filter)) {
13080
+ if (!(0, import_common19.hasActiveFilter)(this.filter)) {
13050
13081
  logger.warn("[TagFilteredContentSource] getWeightedCards called with no active filter");
13051
13082
  return { cards: [] };
13052
13083
  }
@@ -13484,13 +13515,13 @@ async function dropUserFromClassroom(user, classID) {
13484
13515
  async function getUserClassrooms(user) {
13485
13516
  return getOrCreateClassroomRegistrationsDoc(user);
13486
13517
  }
13487
- var import_common18, import_moment8, log4, HYDRATION_TIMEOUT_MS, BaseUser, userCoursesDoc, userClassroomsDoc;
13518
+ var import_common20, import_moment8, log4, HYDRATION_TIMEOUT_MS, BaseUser, userCoursesDoc, userClassroomsDoc;
13488
13519
  var init_BaseUserDB = __esm({
13489
13520
  "src/impl/common/BaseUserDB.ts"() {
13490
13521
  "use strict";
13491
13522
  init_core();
13492
13523
  init_util();
13493
- import_common18 = require("@vue-skuilder/common");
13524
+ import_common20 = require("@vue-skuilder/common");
13494
13525
  import_moment8 = __toESM(require("moment"), 1);
13495
13526
  init_types_legacy();
13496
13527
  init_logger();
@@ -13593,7 +13624,7 @@ Currently logged-in as ${this._username}.`
13593
13624
  );
13594
13625
  }
13595
13626
  const result = await this.syncStrategy.createAccount(username, password);
13596
- if (result.status === import_common18.Status.ok) {
13627
+ if (result.status === import_common20.Status.ok) {
13597
13628
  log4(`Account created successfully, updating username to ${username}`);
13598
13629
  this._username = username;
13599
13630
  try {
@@ -13669,7 +13700,7 @@ Currently logged-in as ${this._username}.`
13669
13700
  async resetUserData() {
13670
13701
  if (this.syncStrategy.canAuthenticate()) {
13671
13702
  return {
13672
- status: import_common18.Status.error,
13703
+ status: import_common20.Status.error,
13673
13704
  error: "Reset user data is only available for local-only mode. Use logout instead for remote sync."
13674
13705
  };
13675
13706
  }
@@ -13691,11 +13722,11 @@ Currently logged-in as ${this._username}.`
13691
13722
  await localDB.bulkDocs(docsToDelete);
13692
13723
  }
13693
13724
  await this.init();
13694
- return { status: import_common18.Status.ok };
13725
+ return { status: import_common20.Status.ok };
13695
13726
  } catch (error) {
13696
13727
  logger.error("Failed to reset user data:", error);
13697
13728
  return {
13698
- status: import_common18.Status.error,
13729
+ status: import_common20.Status.error,
13699
13730
  error: error instanceof Error ? error.message : "Unknown error during reset"
13700
13731
  };
13701
13732
  }
@@ -15108,11 +15139,11 @@ var init_StaticDataUnpacker = __esm({
15108
15139
  });
15109
15140
 
15110
15141
  // src/impl/static/courseDB.ts
15111
- var import_common20, StaticCourseDB;
15142
+ var import_common22, StaticCourseDB;
15112
15143
  var init_courseDB2 = __esm({
15113
15144
  "src/impl/static/courseDB.ts"() {
15114
15145
  "use strict";
15115
- import_common20 = require("@vue-skuilder/common");
15146
+ import_common22 = require("@vue-skuilder/common");
15116
15147
  init_types_legacy();
15117
15148
  init_logger();
15118
15149
  init_defaults();
@@ -15373,7 +15404,7 @@ var init_courseDB2 = __esm({
15373
15404
  }
15374
15405
  async addNote(_codeCourse, _shape, _data, _author, _tags, _uploads, _elo) {
15375
15406
  return {
15376
- status: import_common20.Status.error,
15407
+ status: import_common22.Status.error,
15377
15408
  message: "Cannot add notes in static mode"
15378
15409
  };
15379
15410
  }
@@ -15793,19 +15824,19 @@ async function getStudySource(source, user) {
15793
15824
  if (source.type === "classroom") {
15794
15825
  return await StudentClassroomDB.factory(source.id, user);
15795
15826
  } else {
15796
- if ((0, import_common24.hasActiveFilter)(source.tagFilter)) {
15827
+ if ((0, import_common26.hasActiveFilter)(source.tagFilter)) {
15797
15828
  return new TagFilteredContentSource(source.id, source.tagFilter, user);
15798
15829
  }
15799
15830
  return getDataLayer().getCourseDB(source.id);
15800
15831
  }
15801
15832
  }
15802
- var import_common24;
15833
+ var import_common26;
15803
15834
  var init_contentSource = __esm({
15804
15835
  "src/core/interfaces/contentSource.ts"() {
15805
15836
  "use strict";
15806
15837
  init_factory();
15807
15838
  init_classroomDB2();
15808
- import_common24 = require("@vue-skuilder/common");
15839
+ import_common26 = require("@vue-skuilder/common");
15809
15840
  init_TagFilteredContentSource();
15810
15841
  }
15811
15842
  });
@@ -15945,7 +15976,7 @@ elo: ${elo}`;
15945
15976
  misc: {}
15946
15977
  } : void 0
15947
15978
  );
15948
- if (result.status === import_common25.Status.ok) {
15979
+ if (result.status === import_common27.Status.ok) {
15949
15980
  return {
15950
15981
  originalText,
15951
15982
  status: "success",
@@ -15989,11 +16020,11 @@ function validateProcessorConfig(config) {
15989
16020
  }
15990
16021
  return { isValid: true };
15991
16022
  }
15992
- var import_common25;
16023
+ var import_common27;
15993
16024
  var init_cardProcessor = __esm({
15994
16025
  "src/core/bulkImport/cardProcessor.ts"() {
15995
16026
  "use strict";
15996
- import_common25 = require("@vue-skuilder/common");
16027
+ import_common27 = require("@vue-skuilder/common");
15997
16028
  init_logger();
15998
16029
  }
15999
16030
  });
@@ -16500,10 +16531,10 @@ init_regulators();
16500
16531
  init_courseLookupDB();
16501
16532
 
16502
16533
  // src/courseConfigRegistration.ts
16503
- var import_common26 = require("@vue-skuilder/common");
16534
+ var import_common28 = require("@vue-skuilder/common");
16504
16535
  init_logger();
16505
16536
  function isDataShapeRegistered(dataShape, courseConfig) {
16506
- const namespacedName = import_common26.NameSpacer.getDataShapeString({
16537
+ const namespacedName = import_common28.NameSpacer.getDataShapeString({
16507
16538
  dataShape: dataShape.name,
16508
16539
  course: dataShape.course
16509
16540
  });
@@ -16511,7 +16542,7 @@ function isDataShapeRegistered(dataShape, courseConfig) {
16511
16542
  return existingDataShape !== void 0;
16512
16543
  }
16513
16544
  function isDataShapeSchemaAvailable(dataShape, courseConfig) {
16514
- const namespacedName = import_common26.NameSpacer.getDataShapeString({
16545
+ const namespacedName = import_common28.NameSpacer.getDataShapeString({
16515
16546
  dataShape: dataShape.name,
16516
16547
  course: dataShape.course
16517
16548
  });
@@ -16519,7 +16550,7 @@ function isDataShapeSchemaAvailable(dataShape, courseConfig) {
16519
16550
  return existingDataShape !== void 0 && existingDataShape.serializedZodSchema !== void 0;
16520
16551
  }
16521
16552
  function isQuestionTypeRegistered(question, courseConfig) {
16522
- const namespacedName = import_common26.NameSpacer.getQuestionString({
16553
+ const namespacedName = import_common28.NameSpacer.getQuestionString({
16523
16554
  course: question.course,
16524
16555
  questionType: question.name
16525
16556
  });
@@ -16551,13 +16582,13 @@ function processCustomQuestionsData(customQuestions) {
16551
16582
  return { dataShapes: processedDataShapes, questions: processedQuestions };
16552
16583
  }
16553
16584
  function registerDataShape(dataShape, courseConfig) {
16554
- const namespacedName = import_common26.NameSpacer.getDataShapeString({
16585
+ const namespacedName = import_common28.NameSpacer.getDataShapeString({
16555
16586
  dataShape: dataShape.name,
16556
16587
  course: dataShape.course
16557
16588
  });
16558
16589
  let serializedZodSchema;
16559
16590
  try {
16560
- serializedZodSchema = (0, import_common26.toZodJSON)(dataShape.dataShape);
16591
+ serializedZodSchema = (0, import_common28.toZodJSON)(dataShape.dataShape);
16561
16592
  } catch (error) {
16562
16593
  logger.warn(`Failed to generate schema for ${namespacedName}:`, error);
16563
16594
  serializedZodSchema = void 0;
@@ -16602,7 +16633,7 @@ function registerQuestionType(question, courseConfig) {
16602
16633
  logger.info(`QuestionType '${question.name}' from '${question.course}' already registered`);
16603
16634
  return false;
16604
16635
  }
16605
- const namespacedQuestionName = import_common26.NameSpacer.getQuestionString({
16636
+ const namespacedQuestionName = import_common28.NameSpacer.getQuestionString({
16606
16637
  course: question.course,
16607
16638
  questionType: question.name
16608
16639
  });
@@ -16614,7 +16645,7 @@ function registerQuestionType(question, courseConfig) {
16614
16645
  }
16615
16646
  });
16616
16647
  const dataShapeList = question.dataShapes.map(
16617
- (dataShape) => import_common26.NameSpacer.getDataShapeString({
16648
+ (dataShape) => import_common28.NameSpacer.getDataShapeString({
16618
16649
  course: question.course,
16619
16650
  dataShape: dataShape.name
16620
16651
  })
@@ -16625,7 +16656,7 @@ function registerQuestionType(question, courseConfig) {
16625
16656
  dataShapeList
16626
16657
  });
16627
16658
  question.dataShapes.forEach((dataShape) => {
16628
- const namespacedDataShapeName = import_common26.NameSpacer.getDataShapeString({
16659
+ const namespacedDataShapeName = import_common28.NameSpacer.getDataShapeString({
16629
16660
  course: question.course,
16630
16661
  dataShape: dataShape.name
16631
16662
  });