@vue-skuilder/db 0.3.3 → 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -3340,6 +3340,115 @@ var init_eloDistance = __esm({
3340
3340
  }
3341
3341
  });
3342
3342
 
3343
+ // src/core/navigators/filters/skillPressure.ts
3344
+ var skillPressure_exports = {};
3345
+ __export(skillPressure_exports, {
3346
+ default: () => SkillPressureFilter,
3347
+ skillPressures: () => skillPressures
3348
+ });
3349
+ function skillPressures(elo, config = {}) {
3350
+ const out = /* @__PURE__ */ new Map();
3351
+ const raise = (tag, pressure, why) => {
3352
+ if (pressure <= 0) return;
3353
+ const prev = out.get(tag);
3354
+ if (!prev || pressure > prev.pressure) out.set(tag, { pressure, why });
3355
+ };
3356
+ for (const s of (0, import_common6.skillNeed)(elo, config).skills) {
3357
+ raise(s.tag, s.need, `need ${s.need.toFixed(2)} (${Math.round(s.deficit)} below the skill median)`);
3358
+ }
3359
+ if (config.security !== false) {
3360
+ const weights = { ...DEFAULT_SECURITY_WEIGHTS, ...config.security ?? {} };
3361
+ const { include, exclude, roles } = config;
3362
+ const security = (0, import_common6.courseSecurity)(elo, {
3363
+ selector: { include, exclude, roles },
3364
+ config: config.security ? config.security.config : void 0
3365
+ });
3366
+ for (const s of security.tags) {
3367
+ if (s.status === "secure") continue;
3368
+ const n = Math.min(s.attempts, 12);
3369
+ raise(
3370
+ s.tag,
3371
+ weights[s.status],
3372
+ s.status === "shaky" ? `shaky (${s.right}/${n} right)` : `unproven (${s.attempts} recent attempts)`
3373
+ );
3374
+ }
3375
+ }
3376
+ return out;
3377
+ }
3378
+ async function applySkillPressure(cards, context, config, source) {
3379
+ if (!context.userCourseElo) return cards;
3380
+ const pressures = skillPressures(context.userCourseElo, config);
3381
+ if (pressures.size === 0) return cards;
3382
+ const gain = config.gain ?? DEFAULT_GAIN;
3383
+ return cards.map((card) => {
3384
+ let top = null;
3385
+ for (const tag of card.tags ?? []) {
3386
+ const entry = pressures.get(tag);
3387
+ if (entry && (!top || entry.pressure > top.entry.pressure)) top = { tag, entry };
3388
+ }
3389
+ if (!top) return card;
3390
+ const multiplier = 1 + gain * top.entry.pressure;
3391
+ const score = card.score * multiplier;
3392
+ return {
3393
+ ...card,
3394
+ score,
3395
+ provenance: [
3396
+ ...card.provenance,
3397
+ {
3398
+ strategy: "skillPressure",
3399
+ strategyName: source.name,
3400
+ strategyId: source.strategyId,
3401
+ action: "boosted",
3402
+ score,
3403
+ reason: `skill pressure: ${top.tag} ${top.entry.why} \u2192 \xD7${multiplier.toFixed(2)}`
3404
+ }
3405
+ ]
3406
+ };
3407
+ });
3408
+ }
3409
+ var import_common6, DEFAULT_GAIN, DEFAULT_SECURITY_WEIGHTS, SkillPressureFilter;
3410
+ var init_skillPressure = __esm({
3411
+ "src/core/navigators/filters/skillPressure.ts"() {
3412
+ "use strict";
3413
+ import_common6 = require("@vue-skuilder/common");
3414
+ init_navigators();
3415
+ DEFAULT_GAIN = 0.5;
3416
+ DEFAULT_SECURITY_WEIGHTS = {
3417
+ shaky: 0.8,
3418
+ unproven: 0.5
3419
+ };
3420
+ SkillPressureFilter = class _SkillPressureFilter extends ContentNavigator {
3421
+ name;
3422
+ /** See CardFilter.kind. Static, so the pipeline plan can read it without an instance. */
3423
+ static kind = "signal";
3424
+ kind = _SkillPressureFilter.kind;
3425
+ config;
3426
+ constructor(user, course, strategyData) {
3427
+ super(user, course, strategyData);
3428
+ this.name = strategyData.name || "Skill Pressure";
3429
+ let parsed = {};
3430
+ try {
3431
+ parsed = strategyData.serializedData ? JSON.parse(strategyData.serializedData) : {};
3432
+ } catch {
3433
+ parsed = {};
3434
+ }
3435
+ this.config = parsed;
3436
+ }
3437
+ transform(cards, context) {
3438
+ return applySkillPressure(cards, context, this.config, {
3439
+ name: this.name,
3440
+ strategyId: this.strategyId || "NAVIGATION_STRATEGY-skillPressure"
3441
+ });
3442
+ }
3443
+ async getWeightedCards(_limit) {
3444
+ throw new Error(
3445
+ "SkillPressureFilter is a filter and should not be used as a generator. Use Pipeline with a generator and this filter via transform()."
3446
+ );
3447
+ }
3448
+ };
3449
+ }
3450
+ });
3451
+
3343
3452
  // src/core/navigators/index.ts
3344
3453
  function registerNavigator(implementingClass, constructor, role) {
3345
3454
  navigatorRegistry.set(implementingClass, { constructor, role });
@@ -3376,19 +3485,22 @@ async function initializeNavigatorRegistry() {
3376
3485
  interferenceModule,
3377
3486
  relativePriorityModule,
3378
3487
  userTagPreferenceModule,
3379
- eloDistanceModule
3488
+ eloDistanceModule,
3489
+ skillPressureModule
3380
3490
  ] = await Promise.all([
3381
3491
  Promise.resolve().then(() => (init_hierarchyDefinition(), hierarchyDefinition_exports)),
3382
3492
  Promise.resolve().then(() => (init_interferenceMitigator(), interferenceMitigator_exports)),
3383
3493
  Promise.resolve().then(() => (init_relativePriority(), relativePriority_exports)),
3384
3494
  Promise.resolve().then(() => (init_userTagPreference(), userTagPreference_exports)),
3385
- Promise.resolve().then(() => (init_eloDistance(), eloDistance_exports))
3495
+ Promise.resolve().then(() => (init_eloDistance(), eloDistance_exports)),
3496
+ Promise.resolve().then(() => (init_skillPressure(), skillPressure_exports))
3386
3497
  ]);
3387
3498
  registerNavigator("hierarchyDefinition", hierarchyModule.default);
3388
3499
  registerNavigator("interferenceMitigator", interferenceModule.default);
3389
3500
  registerNavigator("relativePriority", relativePriorityModule.default);
3390
3501
  registerNavigator("userTagPreference", userTagPreferenceModule.default);
3391
3502
  registerNavigator("eloDistance", eloDistanceModule.default);
3503
+ registerNavigator("skillPressure", skillPressureModule.default);
3392
3504
  logger.debug(
3393
3505
  `[NavigatorRegistry] Initialized ${navigatorRegistry.size} navigators: ${getRegisteredNavigatorNames().join(", ")}`
3394
3506
  );
@@ -3434,6 +3546,7 @@ var init_navigators = __esm({
3434
3546
  Navigators2["RELATIVE_PRIORITY"] = "relativePriority";
3435
3547
  Navigators2["USER_TAG_PREFERENCE"] = "userTagPreference";
3436
3548
  Navigators2["ELO_DISTANCE"] = "eloDistance";
3549
+ Navigators2["SKILL_PRESSURE"] = "skillPressure";
3437
3550
  return Navigators2;
3438
3551
  })(Navigators || {});
3439
3552
  NavigatorRole = /* @__PURE__ */ ((NavigatorRole2) => {
@@ -3449,7 +3562,8 @@ var init_navigators = __esm({
3449
3562
  ["interferenceMitigator" /* INTERFERENCE */]: "filter" /* FILTER */,
3450
3563
  ["relativePriority" /* RELATIVE_PRIORITY */]: "filter" /* FILTER */,
3451
3564
  ["userTagPreference" /* USER_TAG_PREFERENCE */]: "filter" /* FILTER */,
3452
- ["eloDistance" /* ELO_DISTANCE */]: "filter" /* FILTER */
3565
+ ["eloDistance" /* ELO_DISTANCE */]: "filter" /* FILTER */,
3566
+ ["skillPressure" /* SKILL_PRESSURE */]: "filter" /* FILTER */
3453
3567
  };
3454
3568
  ContentNavigator = class {
3455
3569
  /** User interface for this navigation session */
@@ -3659,7 +3773,7 @@ var FRAMEWORK_VERSION, hostAppVersion, DEFAULT_STRATEGY_HASH;
3659
3773
  var init_versionStamps = __esm({
3660
3774
  "src/core/versionStamps.ts"() {
3661
3775
  "use strict";
3662
- FRAMEWORK_VERSION = true ? "0.3.3" : "dev";
3776
+ FRAMEWORK_VERSION = true ? "0.3.5" : "dev";
3663
3777
  DEFAULT_STRATEGY_HASH = "default";
3664
3778
  }
3665
3779
  });
@@ -3994,7 +4108,7 @@ function newQuestionInterval(user, cardHistory) {
3994
4108
  }
3995
4109
  if (currentAttempt.isCorrect) {
3996
4110
  const rawPerf = currentAttempt.performance;
3997
- const numericPerf = (0, import_common6.isTaggedPerformance)(rawPerf) ? rawPerf._global : rawPerf;
4111
+ const numericPerf = (0, import_common7.isTaggedPerformance)(rawPerf) ? rawPerf._global : rawPerf;
3998
4112
  const skill = Math.min(1, Math.max(0, numericPerf));
3999
4113
  logger.debug(`Demontrated skill: ${skill}`);
4000
4114
  const interval = lastInterval * (0.75 + skill);
@@ -4050,13 +4164,13 @@ function secondsBetween(start, end) {
4050
4164
  const ret = duration(end.diff(start)).asSeconds();
4051
4165
  return ret;
4052
4166
  }
4053
- var import_moment3, import_common6, duration, SLOW_CORRECT_MAX_INTERVAL;
4167
+ var import_moment3, import_common7, duration, SLOW_CORRECT_MAX_INTERVAL;
4054
4168
  var init_SpacedRepetition = __esm({
4055
4169
  "src/study/SpacedRepetition.ts"() {
4056
4170
  "use strict";
4057
4171
  init_util();
4058
4172
  import_moment3 = __toESM(require("moment"), 1);
4059
- import_common6 = require("@vue-skuilder/common");
4173
+ import_common7 = require("@vue-skuilder/common");
4060
4174
  init_logger();
4061
4175
  duration = import_moment3.default.duration;
4062
4176
  SLOW_CORRECT_MAX_INTERVAL = 20 * 60 * 60;
@@ -4134,20 +4248,20 @@ function recordTagPresentations(userElo, perf, records, cardId, at) {
4134
4248
  const entry = {
4135
4249
  at,
4136
4250
  ok,
4137
- tagOk: score > import_common7.TAG_OK_MIN_PERF,
4251
+ tagOk: score > import_common8.TAG_OK_MIN_PERF,
4138
4252
  perf: score,
4139
4253
  card: cardId
4140
4254
  };
4141
- userElo.tags[tag] = (0, import_common7.pushTagPresentation)(rank, entry);
4255
+ userElo.tags[tag] = (0, import_common8.pushTagPresentation)(rank, entry);
4142
4256
  written.push(tag);
4143
4257
  }
4144
4258
  return written;
4145
4259
  }
4146
- var import_common7;
4260
+ var import_common8;
4147
4261
  var init_tagRecent = __esm({
4148
4262
  "src/study/services/tagRecent.ts"() {
4149
4263
  "use strict";
4150
- import_common7 = require("@vue-skuilder/common");
4264
+ import_common8 = require("@vue-skuilder/common");
4151
4265
  }
4152
4266
  });
4153
4267
 
@@ -4156,7 +4270,7 @@ function withCountOnlyRoles(perf, cardId) {
4156
4270
  const out = { ...perf };
4157
4271
  const counted = [];
4158
4272
  for (const [tag, score] of Object.entries(perf)) {
4159
- if (tag === "_global" || score === null || !(0, import_common8.isCountOnlyTag)(tag)) continue;
4273
+ if (tag === "_global" || score === null || !(0, import_common9.isCountOnlyTag)(tag)) continue;
4160
4274
  out[tag] = null;
4161
4275
  counted.push(tag);
4162
4276
  }
@@ -4167,11 +4281,11 @@ function withCountOnlyRoles(perf, cardId) {
4167
4281
  }
4168
4282
  return out;
4169
4283
  }
4170
- var import_common8, EloService;
4284
+ var import_common9, EloService;
4171
4285
  var init_EloService = __esm({
4172
4286
  "src/study/services/EloService.ts"() {
4173
4287
  "use strict";
4174
- import_common8 = require("@vue-skuilder/common");
4288
+ import_common9 = require("@vue-skuilder/common");
4175
4289
  init_logger();
4176
4290
  init_tagRecent();
4177
4291
  EloService = class {
@@ -4224,7 +4338,7 @@ var init_EloService = __esm({
4224
4338
  );
4225
4339
  return null;
4226
4340
  }
4227
- const userElo = (0, import_common8.toCourseElo)(courseReg.elo);
4341
+ const userElo = (0, import_common9.toCourseElo)(courseReg.elo);
4228
4342
  const cardElo = (await courseDB.getCardEloData([currentCard.card.card_id]))[0];
4229
4343
  if (cardElo && userElo) {
4230
4344
  const writeCard = !await this.isQaUser(courseDB);
@@ -4235,11 +4349,11 @@ var init_EloService = __esm({
4235
4349
  for (const tag of cardTagKeys) {
4236
4350
  beforeUserTag[tag] = userElo.tags[tag]?.score ?? userElo.global.score;
4237
4351
  }
4238
- const eloUpdate = (0, import_common8.adjustCourseScores)(userElo, cardElo, userScore);
4352
+ const eloUpdate = (0, import_common9.adjustCourseScores)(userElo, cardElo, userScore);
4239
4353
  courseReg.elo = eloUpdate.userElo;
4240
4354
  const tags = {};
4241
4355
  for (const tag of cardTagKeys) {
4242
- const countOnly = (0, import_common8.isCountOnlyTag)(tag);
4356
+ const countOnly = (0, import_common9.isCountOnlyTag)(tag);
4243
4357
  tags[tag] = {
4244
4358
  before: beforeUserTag[tag],
4245
4359
  after: countOnly ? beforeUserTag[tag] : eloUpdate.userElo.tags[tag].score,
@@ -4313,7 +4427,7 @@ var init_EloService = __esm({
4313
4427
  );
4314
4428
  return null;
4315
4429
  }
4316
- const userElo = (0, import_common8.toCourseElo)(courseReg.elo);
4430
+ const userElo = (0, import_common9.toCourseElo)(courseReg.elo);
4317
4431
  const [cardEloResults, cardTagsMap] = await Promise.all([
4318
4432
  courseDB.getCardEloData([currentCard.card.card_id]),
4319
4433
  courseDB.getAppliedTagsBatch([card_id])
@@ -4325,7 +4439,7 @@ var init_EloService = __esm({
4325
4439
  const globalScore = taggedPerformance._global;
4326
4440
  for (const tag of cardTags) {
4327
4441
  if (!(tag in enriched)) {
4328
- enriched[tag] = (0, import_common8.isCountOnlyTag)(tag) ? null : globalScore;
4442
+ enriched[tag] = (0, import_common9.isCountOnlyTag)(tag) ? null : globalScore;
4329
4443
  }
4330
4444
  }
4331
4445
  if (cardElo && userElo) {
@@ -4337,7 +4451,7 @@ var init_EloService = __esm({
4337
4451
  for (const tag of touchedTags) {
4338
4452
  beforeUserTag[tag] = userElo.tags[tag]?.score ?? userElo.global.score;
4339
4453
  }
4340
- const eloUpdate = (0, import_common8.adjustCourseScoresPerTag)(userElo, cardElo, enriched);
4454
+ const eloUpdate = (0, import_common9.adjustCourseScoresPerTag)(userElo, cardElo, enriched);
4341
4455
  const at = (/* @__PURE__ */ new Date()).toISOString();
4342
4456
  const recorded = recordTagPresentations(
4343
4457
  eloUpdate.userElo,
@@ -4410,13 +4524,13 @@ var init_EloService = __esm({
4410
4524
  });
4411
4525
 
4412
4526
  // src/study/services/ResponseProcessor.ts
4413
- var import_common9, ResponseProcessor;
4527
+ var import_common10, ResponseProcessor;
4414
4528
  var init_ResponseProcessor = __esm({
4415
4529
  "src/study/services/ResponseProcessor.ts"() {
4416
4530
  "use strict";
4417
4531
  init_core();
4418
4532
  init_logger();
4419
- import_common9 = require("@vue-skuilder/common");
4533
+ import_common10 = require("@vue-skuilder/common");
4420
4534
  ResponseProcessor = class {
4421
4535
  srsService;
4422
4536
  eloService;
@@ -4459,7 +4573,7 @@ var init_ResponseProcessor = __esm({
4459
4573
  taggedPerformance: null
4460
4574
  };
4461
4575
  }
4462
- if ((0, import_common9.isTaggedPerformance)(performance2)) {
4576
+ if ((0, import_common10.isTaggedPerformance)(performance2)) {
4463
4577
  return {
4464
4578
  globalScore: performance2._global,
4465
4579
  taggedPerformance: performance2
@@ -4762,11 +4876,11 @@ function prefetchAudio(url) {
4762
4876
  audio.src = url;
4763
4877
  });
4764
4878
  }
4765
- var import_common10, CardHydrationService;
4879
+ var import_common11, CardHydrationService;
4766
4880
  var init_CardHydrationService = __esm({
4767
4881
  "src/study/services/CardHydrationService.ts"() {
4768
4882
  "use strict";
4769
- import_common10 = require("@vue-skuilder/common");
4883
+ import_common11 = require("@vue-skuilder/common");
4770
4884
  init_logger();
4771
4885
  CardHydrationService = class {
4772
4886
  constructor(getViewComponent, getCourseDB2, getItemsToHydrate) {
@@ -4879,8 +4993,8 @@ var init_CardHydrationService = __esm({
4879
4993
  courseDB.getCourseDoc(item.cardID),
4880
4994
  courseDB.getAppliedTagsBatch([item.cardID])
4881
4995
  ]);
4882
- if (!(0, import_common10.isCourseElo)(cardData.elo)) {
4883
- cardData.elo = (0, import_common10.toCourseElo)(cardData.elo);
4996
+ if (!(0, import_common11.isCourseElo)(cardData.elo)) {
4997
+ cardData.elo = (0, import_common11.toCourseElo)(cardData.elo);
4884
4998
  }
4885
4999
  const view = this.getViewComponent(cardData.id_view);
4886
5000
  const dataDocs = await Promise.all(
@@ -4904,9 +5018,9 @@ var init_CardHydrationService = __esm({
4904
5018
  );
4905
5019
  await Promise.allSettled(uniqueAudioUrls.map(prefetchAudio));
4906
5020
  }
4907
- const data = dataDocs.map(import_common10.displayableDataToViewData).reverse();
5021
+ const data = dataDocs.map(import_common11.displayableDataToViewData).reverse();
4908
5022
  this.hydratedCards.set(item.cardID, {
4909
- item: { ...item, elo: (0, import_common10.toCourseElo)(cardData.elo).global.score },
5023
+ item: { ...item, elo: (0, import_common11.toCourseElo)(cardData.elo).global.score },
4910
5024
  view,
4911
5025
  data,
4912
5026
  tags: tagsByCard.get(item.cardID) ?? []
@@ -7067,11 +7181,11 @@ function logCardProvenance(cards, maxCards = 3) {
7067
7181
  }
7068
7182
  }
7069
7183
  }
7070
- var import_common11, VERBOSE_RESULTS, Pipeline;
7184
+ var import_common12, VERBOSE_RESULTS, Pipeline;
7071
7185
  var init_Pipeline = __esm({
7072
7186
  "src/core/navigators/Pipeline.ts"() {
7073
7187
  "use strict";
7074
- import_common11 = require("@vue-skuilder/common");
7188
+ import_common12 = require("@vue-skuilder/common");
7075
7189
  init_navigators();
7076
7190
  init_logger();
7077
7191
  init_perfMarks();
@@ -7583,7 +7697,7 @@ var init_Pipeline = __esm({
7583
7697
  let userCourseElo;
7584
7698
  try {
7585
7699
  const courseReg = await this.user.getCourseRegDoc(this.course.getCourseID());
7586
- userCourseElo = (0, import_common11.toCourseElo)(courseReg.elo);
7700
+ userCourseElo = (0, import_common12.toCourseElo)(courseReg.elo);
7587
7701
  userElo = userCourseElo.global.score;
7588
7702
  } catch (e) {
7589
7703
  logger.debug(`[Pipeline] Could not get user ELO, using default: ${e}`);
@@ -7646,7 +7760,7 @@ var init_Pipeline = __esm({
7646
7760
  */
7647
7761
  async getTagEloStatus(tagFilter) {
7648
7762
  const courseReg = await this.user.getCourseRegDoc(this.course.getCourseID());
7649
- const courseElo = (0, import_common11.toCourseElo)(courseReg.elo);
7763
+ const courseElo = (0, import_common12.toCourseElo)(courseReg.elo);
7650
7764
  const result = {};
7651
7765
  if (!tagFilter) {
7652
7766
  for (const [tag, data] of Object.entries(courseElo.tags)) {
@@ -10232,11 +10346,11 @@ var init_SessionController = __esm({
10232
10346
  });
10233
10347
 
10234
10348
  // src/study/TagFilteredContentSource.ts
10235
- var import_common12, TagFilteredContentSource;
10349
+ var import_common13, TagFilteredContentSource;
10236
10350
  var init_TagFilteredContentSource = __esm({
10237
10351
  "src/study/TagFilteredContentSource.ts"() {
10238
10352
  "use strict";
10239
- import_common12 = require("@vue-skuilder/common");
10353
+ import_common13 = require("@vue-skuilder/common");
10240
10354
  init_courseDB();
10241
10355
  init_logger();
10242
10356
  TagFilteredContentSource = class {
@@ -10322,7 +10436,7 @@ var init_TagFilteredContentSource = __esm({
10322
10436
  * @returns Cards sorted by score descending (all scores = 1.0)
10323
10437
  */
10324
10438
  async getWeightedCards(limit) {
10325
- if (!(0, import_common12.hasActiveFilter)(this.filter)) {
10439
+ if (!(0, import_common13.hasActiveFilter)(this.filter)) {
10326
10440
  logger.warn("[TagFilteredContentSource] getWeightedCards called with no active filter");
10327
10441
  return { cards: [] };
10328
10442
  }
@@ -10739,13 +10853,13 @@ async function dropUserFromClassroom(user, classID) {
10739
10853
  async function getUserClassrooms(user) {
10740
10854
  return getOrCreateClassroomRegistrationsDoc(user);
10741
10855
  }
10742
- var import_common13, import_moment7, log3, HYDRATION_TIMEOUT_MS, BaseUser, userCoursesDoc, userClassroomsDoc;
10856
+ var import_common14, import_moment7, log3, HYDRATION_TIMEOUT_MS, BaseUser, userCoursesDoc, userClassroomsDoc;
10743
10857
  var init_BaseUserDB = __esm({
10744
10858
  "src/impl/common/BaseUserDB.ts"() {
10745
10859
  "use strict";
10746
10860
  init_core();
10747
10861
  init_util();
10748
- import_common13 = require("@vue-skuilder/common");
10862
+ import_common14 = require("@vue-skuilder/common");
10749
10863
  import_moment7 = __toESM(require("moment"), 1);
10750
10864
  init_types_legacy();
10751
10865
  init_logger();
@@ -10852,7 +10966,7 @@ Currently logged-in as ${this._username}.`
10852
10966
  );
10853
10967
  }
10854
10968
  const result = await this.syncStrategy.createAccount(username, password);
10855
- if (result.status === import_common13.Status.ok) {
10969
+ if (result.status === import_common14.Status.ok) {
10856
10970
  log3(`Account created successfully, updating username to ${username}`);
10857
10971
  this._username = username;
10858
10972
  try {
@@ -10928,7 +11042,7 @@ Currently logged-in as ${this._username}.`
10928
11042
  async resetUserData() {
10929
11043
  if (this.syncStrategy.canAuthenticate()) {
10930
11044
  return {
10931
- status: import_common13.Status.error,
11045
+ status: import_common14.Status.error,
10932
11046
  error: "Reset user data is only available for local-only mode. Use logout instead for remote sync."
10933
11047
  };
10934
11048
  }
@@ -10950,11 +11064,11 @@ Currently logged-in as ${this._username}.`
10950
11064
  await localDB.bulkDocs(docsToDelete);
10951
11065
  }
10952
11066
  await this.init();
10953
- return { status: import_common13.Status.ok };
11067
+ return { status: import_common14.Status.ok };
10954
11068
  } catch (error) {
10955
11069
  logger.error("Failed to reset user data:", error);
10956
11070
  return {
10957
- status: import_common13.Status.error,
11071
+ status: import_common14.Status.error,
10958
11072
  error: error instanceof Error ? error.message : "Unknown error during reset"
10959
11073
  };
10960
11074
  }
@@ -11894,12 +12008,12 @@ var init_common = __esm({
11894
12008
  });
11895
12009
 
11896
12010
  // src/impl/couch/courseAPI.ts
11897
- async function addNote55(courseID, codeCourse, shape, data, author, tags, uploads, elo = (0, import_common15.blankCourseElo)()) {
12011
+ async function addNote55(courseID, codeCourse, shape, data, author, tags, uploads, elo = (0, import_common16.blankCourseElo)()) {
11898
12012
  const db = getCourseDB(courseID);
11899
- const payload = (0, import_common16.prepareNote55)(courseID, codeCourse, shape, data, author, tags, uploads);
12013
+ const payload = (0, import_common17.prepareNote55)(courseID, codeCourse, shape, data, author, tags, uploads);
11900
12014
  const _id = `${DocTypePrefixes["DISPLAYABLE_DATA" /* DISPLAYABLE_DATA */]}-${(0, import_uuid.v4)()}`;
11901
12015
  const result = await db.put({ ...payload, _id });
11902
- const dataShapeId = import_common14.NameSpacer.getDataShapeString({
12016
+ const dataShapeId = import_common15.NameSpacer.getDataShapeString({
11903
12017
  course: codeCourse,
11904
12018
  dataShape: shape.name
11905
12019
  });
@@ -11926,9 +12040,9 @@ async function addNote55(courseID, codeCourse, shape, data, author, tags, upload
11926
12040
  }
11927
12041
  return result;
11928
12042
  }
11929
- async function createCards(courseID, datashapeID, noteID, tags, elo = (0, import_common15.blankCourseElo)(), author) {
12043
+ async function createCards(courseID, datashapeID, noteID, tags, elo = (0, import_common16.blankCourseElo)(), author) {
11930
12044
  const cfg = await getCredentialledCourseConfig(courseID);
11931
- const dsDescriptor = import_common14.NameSpacer.getDataShapeDescriptor(datashapeID);
12045
+ const dsDescriptor = import_common15.NameSpacer.getDataShapeDescriptor(datashapeID);
11932
12046
  let questionViewTypes = [];
11933
12047
  for (const ds of cfg.dataShapes) {
11934
12048
  if (ds.name === datashapeID) {
@@ -11944,8 +12058,8 @@ async function createCards(courseID, datashapeID, noteID, tags, elo = (0, import
11944
12058
  await createCard(questionView, courseID, dsDescriptor, noteID, tags, elo, author);
11945
12059
  }
11946
12060
  }
11947
- async function createCard(questionViewName, courseID, dsDescriptor, noteID, tags, elo = (0, import_common15.blankCourseElo)(), author) {
11948
- const qDescriptor = import_common14.NameSpacer.getQuestionDescriptor(questionViewName);
12061
+ async function createCard(questionViewName, courseID, dsDescriptor, noteID, tags, elo = (0, import_common16.blankCourseElo)(), author) {
12062
+ const qDescriptor = import_common15.NameSpacer.getQuestionDescriptor(questionViewName);
11949
12063
  const cfg = await getCredentialledCourseConfig(courseID);
11950
12064
  for (const rQ of cfg.questionTypes) {
11951
12065
  if (rQ.name === questionViewName) {
@@ -11954,7 +12068,7 @@ async function createCard(questionViewName, courseID, dsDescriptor, noteID, tags
11954
12068
  courseID,
11955
12069
  dsDescriptor.course,
11956
12070
  [noteID],
11957
- import_common14.NameSpacer.getViewString({
12071
+ import_common15.NameSpacer.getViewString({
11958
12072
  course: qDescriptor.course,
11959
12073
  questionType: qDescriptor.questionType,
11960
12074
  view
@@ -11976,7 +12090,7 @@ async function addCard(courseID, course, id_displayable_data, id_view, elo, tags
11976
12090
  id_displayable_data,
11977
12091
  id_view,
11978
12092
  docType: "CARD" /* CARD */,
11979
- elo: elo || (0, import_common15.toCourseElo)(990 + Math.round(20 * Math.random())),
12093
+ elo: elo || (0, import_common16.toCourseElo)(990 + Math.round(20 * Math.random())),
11980
12094
  author
11981
12095
  });
11982
12096
  for (const tag of tags) {
@@ -12069,16 +12183,16 @@ function getTagID(tagName) {
12069
12183
  return tagPrefix + tagName;
12070
12184
  }
12071
12185
  }
12072
- var import_common14, import_common15, import_common16, import_uuid, COURSE_CONFIG_TTL_MS, courseConfigCache, AlreadyTaggedErr;
12186
+ var import_common15, import_common16, import_common17, import_uuid, COURSE_CONFIG_TTL_MS, courseConfigCache, AlreadyTaggedErr;
12073
12187
  var init_courseAPI = __esm({
12074
12188
  "src/impl/couch/courseAPI.ts"() {
12075
12189
  "use strict";
12076
12190
  init_couch();
12077
- import_common14 = require("@vue-skuilder/common");
12078
12191
  import_common15 = require("@vue-skuilder/common");
12192
+ import_common16 = require("@vue-skuilder/common");
12079
12193
  init_courseDB();
12080
12194
  init_types_legacy();
12081
- import_common16 = require("@vue-skuilder/common");
12195
+ import_common17 = require("@vue-skuilder/common");
12082
12196
  init_common();
12083
12197
  init_logger();
12084
12198
  import_uuid = require("uuid");
@@ -12868,11 +12982,11 @@ ${JSON.stringify(config)}
12868
12982
  function isSuccessRow(row) {
12869
12983
  return "doc" in row && row.doc !== null && row.doc !== void 0;
12870
12984
  }
12871
- var import_common18, CoursesDB, CourseDB;
12985
+ var import_common19, CoursesDB, CourseDB;
12872
12986
  var init_courseDB = __esm({
12873
12987
  "src/impl/couch/courseDB.ts"() {
12874
12988
  "use strict";
12875
- import_common18 = require("@vue-skuilder/common");
12989
+ import_common19 = require("@vue-skuilder/common");
12876
12990
  init_couch();
12877
12991
  init_updateQueue();
12878
12992
  init_types_legacy();
@@ -13024,14 +13138,14 @@ var init_courseDB = __esm({
13024
13138
  docs.rows.forEach((r) => {
13025
13139
  if (isSuccessRow(r)) {
13026
13140
  if (r.doc && r.doc.elo) {
13027
- ret.push((0, import_common18.toCourseElo)(r.doc.elo));
13141
+ ret.push((0, import_common19.toCourseElo)(r.doc.elo));
13028
13142
  } else {
13029
13143
  logger.warn("no elo data for card: " + r.id);
13030
- ret.push((0, import_common18.blankCourseElo)());
13144
+ ret.push((0, import_common19.blankCourseElo)());
13031
13145
  }
13032
13146
  } else {
13033
13147
  logger.warn("no elo data for card: " + JSON.stringify(r));
13034
- ret.push((0, import_common18.blankCourseElo)());
13148
+ ret.push((0, import_common19.blankCourseElo)());
13035
13149
  }
13036
13150
  });
13037
13151
  return ret;
@@ -13229,7 +13343,7 @@ ${above.rows.map((r) => ` ${r.id}-${r.key}
13229
13343
  async getCourseTagStubs() {
13230
13344
  return filterAllDocsByPrefix2(this.db, "TAG" /* TAG */.valueOf() + "-");
13231
13345
  }
13232
- async addNote(codeCourse, shape, data, author, tags, uploads, elo = (0, import_common18.blankCourseElo)()) {
13346
+ async addNote(codeCourse, shape, data, author, tags, uploads, elo = (0, import_common19.blankCourseElo)()) {
13233
13347
  try {
13234
13348
  const resp = await addNote55(this.id, codeCourse, shape, data, author, tags, uploads, elo);
13235
13349
  if (resp.ok) {
@@ -13238,19 +13352,19 @@ ${above.rows.map((r) => ` ${r.id}-${r.key}
13238
13352
  `[courseDB.addNote] Note added but card creation failed: ${resp.cardCreationError}`
13239
13353
  );
13240
13354
  return {
13241
- status: import_common18.Status.error,
13355
+ status: import_common19.Status.error,
13242
13356
  message: `Note was added but no cards were created: ${resp.cardCreationError}`,
13243
13357
  id: resp.id
13244
13358
  };
13245
13359
  }
13246
13360
  return {
13247
- status: import_common18.Status.ok,
13361
+ status: import_common19.Status.ok,
13248
13362
  message: "",
13249
13363
  id: resp.id
13250
13364
  };
13251
13365
  } else {
13252
13366
  return {
13253
- status: import_common18.Status.error,
13367
+ status: import_common19.Status.error,
13254
13368
  message: "Unexpected error adding note"
13255
13369
  };
13256
13370
  }
@@ -13262,7 +13376,7 @@ ${above.rows.map((r) => ` ${r.id}-${r.key}
13262
13376
  message: ${err.message}`
13263
13377
  );
13264
13378
  return {
13265
- status: import_common18.Status.error,
13379
+ status: import_common19.Status.error,
13266
13380
  message: `Error adding note to course. ${e.reason || err.message}`
13267
13381
  };
13268
13382
  }
@@ -13469,7 +13583,7 @@ ${e.stack}` : JSON.stringify(e);
13469
13583
  const courseDoc = (await u.getCourseRegistrationsDoc()).courses.find((c) => {
13470
13584
  return c.courseID === this.id;
13471
13585
  });
13472
- targetElo = (0, import_common18.EloToNumber)(courseDoc.elo);
13586
+ targetElo = (0, import_common19.EloToNumber)(courseDoc.elo);
13473
13587
  } catch {
13474
13588
  targetElo = 1e3;
13475
13589
  }
@@ -13999,14 +14113,14 @@ var CouchDBSyncStrategy_exports = {};
13999
14113
  __export(CouchDBSyncStrategy_exports, {
14000
14114
  CouchDBSyncStrategy: () => CouchDBSyncStrategy
14001
14115
  });
14002
- var import_common19, log4, CouchDBSyncStrategy;
14116
+ var import_common20, log4, CouchDBSyncStrategy;
14003
14117
  var init_CouchDBSyncStrategy = __esm({
14004
14118
  "src/impl/couch/CouchDBSyncStrategy.ts"() {
14005
14119
  "use strict";
14006
14120
  init_factory();
14007
14121
  init_types_legacy();
14008
14122
  init_logger();
14009
- import_common19 = require("@vue-skuilder/common");
14123
+ import_common20 = require("@vue-skuilder/common");
14010
14124
  init_common();
14011
14125
  init_pouchdb_setup();
14012
14126
  init_couch();
@@ -14147,32 +14261,32 @@ var init_CouchDBSyncStrategy = __esm({
14147
14261
  }
14148
14262
  }
14149
14263
  return {
14150
- status: import_common19.Status.ok,
14264
+ status: import_common20.Status.ok,
14151
14265
  error: void 0
14152
14266
  };
14153
14267
  } else {
14154
14268
  return {
14155
- status: import_common19.Status.error,
14269
+ status: import_common20.Status.error,
14156
14270
  error: "Failed to log in after account creation"
14157
14271
  };
14158
14272
  }
14159
14273
  } else {
14160
14274
  logger.warn(`Signup not OK: ${JSON.stringify(signupRequest)}`);
14161
14275
  return {
14162
- status: import_common19.Status.error,
14276
+ status: import_common20.Status.error,
14163
14277
  error: "Account creation failed"
14164
14278
  };
14165
14279
  }
14166
14280
  } catch (e) {
14167
14281
  if (e.reason === "Document update conflict.") {
14168
14282
  return {
14169
- status: import_common19.Status.error,
14283
+ status: import_common20.Status.error,
14170
14284
  error: "This username is taken!"
14171
14285
  };
14172
14286
  }
14173
14287
  logger.error(`Error on signup: ${JSON.stringify(e)}`);
14174
14288
  return {
14175
- status: import_common19.Status.error,
14289
+ status: import_common20.Status.error,
14176
14290
  error: e.message || "Unknown error during account creation"
14177
14291
  };
14178
14292
  }
@@ -15306,11 +15420,11 @@ var init_StaticDataUnpacker = __esm({
15306
15420
  });
15307
15421
 
15308
15422
  // src/impl/static/courseDB.ts
15309
- var import_common22, StaticCourseDB;
15423
+ var import_common23, StaticCourseDB;
15310
15424
  var init_courseDB2 = __esm({
15311
15425
  "src/impl/static/courseDB.ts"() {
15312
15426
  "use strict";
15313
- import_common22 = require("@vue-skuilder/common");
15427
+ import_common23 = require("@vue-skuilder/common");
15314
15428
  init_types_legacy();
15315
15429
  init_logger();
15316
15430
  init_defaults();
@@ -15571,7 +15685,7 @@ var init_courseDB2 = __esm({
15571
15685
  }
15572
15686
  async addNote(_codeCourse, _shape, _data, _author, _tags, _uploads, _elo) {
15573
15687
  return {
15574
- status: import_common22.Status.error,
15688
+ status: import_common23.Status.error,
15575
15689
  message: "Cannot add notes in static mode"
15576
15690
  };
15577
15691
  }
@@ -16343,19 +16457,19 @@ async function getStudySource(source, user) {
16343
16457
  if (source.type === "classroom") {
16344
16458
  return await StudentClassroomDB.factory(source.id, user);
16345
16459
  } else {
16346
- if ((0, import_common25.hasActiveFilter)(source.tagFilter)) {
16460
+ if ((0, import_common26.hasActiveFilter)(source.tagFilter)) {
16347
16461
  return new TagFilteredContentSource(source.id, source.tagFilter, user);
16348
16462
  }
16349
16463
  return getDataLayer().getCourseDB(source.id);
16350
16464
  }
16351
16465
  }
16352
- var import_common25;
16466
+ var import_common26;
16353
16467
  var init_contentSource = __esm({
16354
16468
  "src/core/interfaces/contentSource.ts"() {
16355
16469
  "use strict";
16356
16470
  init_factory();
16357
16471
  init_classroomDB2();
16358
- import_common25 = require("@vue-skuilder/common");
16472
+ import_common26 = require("@vue-skuilder/common");
16359
16473
  init_TagFilteredContentSource();
16360
16474
  }
16361
16475
  });
@@ -16495,7 +16609,7 @@ elo: ${elo}`;
16495
16609
  misc: {}
16496
16610
  } : void 0
16497
16611
  );
16498
- if (result.status === import_common26.Status.ok) {
16612
+ if (result.status === import_common27.Status.ok) {
16499
16613
  return {
16500
16614
  originalText,
16501
16615
  status: "success",
@@ -16539,11 +16653,11 @@ function validateProcessorConfig(config) {
16539
16653
  }
16540
16654
  return { isValid: true };
16541
16655
  }
16542
- var import_common26;
16656
+ var import_common27;
16543
16657
  var init_cardProcessor = __esm({
16544
16658
  "src/core/bulkImport/cardProcessor.ts"() {
16545
16659
  "use strict";
16546
- import_common26 = require("@vue-skuilder/common");
16660
+ import_common27 = require("@vue-skuilder/common");
16547
16661
  init_logger();
16548
16662
  }
16549
16663
  });
@@ -16718,10 +16832,10 @@ init_regulators();
16718
16832
  init_courseLookupDB();
16719
16833
 
16720
16834
  // src/courseConfigRegistration.ts
16721
- var import_common27 = require("@vue-skuilder/common");
16835
+ var import_common28 = require("@vue-skuilder/common");
16722
16836
  init_logger();
16723
16837
  function isDataShapeRegistered(dataShape, courseConfig) {
16724
- const namespacedName = import_common27.NameSpacer.getDataShapeString({
16838
+ const namespacedName = import_common28.NameSpacer.getDataShapeString({
16725
16839
  dataShape: dataShape.name,
16726
16840
  course: dataShape.course
16727
16841
  });
@@ -16729,7 +16843,7 @@ function isDataShapeRegistered(dataShape, courseConfig) {
16729
16843
  return existingDataShape !== void 0;
16730
16844
  }
16731
16845
  function isDataShapeSchemaAvailable(dataShape, courseConfig) {
16732
- const namespacedName = import_common27.NameSpacer.getDataShapeString({
16846
+ const namespacedName = import_common28.NameSpacer.getDataShapeString({
16733
16847
  dataShape: dataShape.name,
16734
16848
  course: dataShape.course
16735
16849
  });
@@ -16737,7 +16851,7 @@ function isDataShapeSchemaAvailable(dataShape, courseConfig) {
16737
16851
  return existingDataShape !== void 0 && existingDataShape.serializedZodSchema !== void 0;
16738
16852
  }
16739
16853
  function isQuestionTypeRegistered(question, courseConfig) {
16740
- const namespacedName = import_common27.NameSpacer.getQuestionString({
16854
+ const namespacedName = import_common28.NameSpacer.getQuestionString({
16741
16855
  course: question.course,
16742
16856
  questionType: question.name
16743
16857
  });
@@ -16769,13 +16883,13 @@ function processCustomQuestionsData(customQuestions) {
16769
16883
  return { dataShapes: processedDataShapes, questions: processedQuestions };
16770
16884
  }
16771
16885
  function registerDataShape(dataShape, courseConfig) {
16772
- const namespacedName = import_common27.NameSpacer.getDataShapeString({
16886
+ const namespacedName = import_common28.NameSpacer.getDataShapeString({
16773
16887
  dataShape: dataShape.name,
16774
16888
  course: dataShape.course
16775
16889
  });
16776
16890
  let serializedZodSchema;
16777
16891
  try {
16778
- serializedZodSchema = (0, import_common27.toZodJSON)(dataShape.dataShape);
16892
+ serializedZodSchema = (0, import_common28.toZodJSON)(dataShape.dataShape);
16779
16893
  } catch (error) {
16780
16894
  logger.warn(`Failed to generate schema for ${namespacedName}:`, error);
16781
16895
  serializedZodSchema = void 0;
@@ -16820,7 +16934,7 @@ function registerQuestionType(question, courseConfig) {
16820
16934
  logger.info(`QuestionType '${question.name}' from '${question.course}' already registered`);
16821
16935
  return false;
16822
16936
  }
16823
- const namespacedQuestionName = import_common27.NameSpacer.getQuestionString({
16937
+ const namespacedQuestionName = import_common28.NameSpacer.getQuestionString({
16824
16938
  course: question.course,
16825
16939
  questionType: question.name
16826
16940
  });
@@ -16832,7 +16946,7 @@ function registerQuestionType(question, courseConfig) {
16832
16946
  }
16833
16947
  });
16834
16948
  const dataShapeList = question.dataShapes.map(
16835
- (dataShape) => import_common27.NameSpacer.getDataShapeString({
16949
+ (dataShape) => import_common28.NameSpacer.getDataShapeString({
16836
16950
  course: question.course,
16837
16951
  dataShape: dataShape.name
16838
16952
  })
@@ -16843,7 +16957,7 @@ function registerQuestionType(question, courseConfig) {
16843
16957
  dataShapeList
16844
16958
  });
16845
16959
  question.dataShapes.forEach((dataShape) => {
16846
- const namespacedDataShapeName = import_common27.NameSpacer.getDataShapeString({
16960
+ const namespacedDataShapeName = import_common28.NameSpacer.getDataShapeString({
16847
16961
  course: question.course,
16848
16962
  dataShape: dataShape.name
16849
16963
  });
@@ -16930,7 +17044,7 @@ async function registerSeedData(question, courseDB, username) {
16930
17044
  username,
16931
17045
  meta.tags ?? [],
16932
17046
  void 0,
16933
- meta.elo !== void 0 ? (0, import_common27.toCourseElo)(meta.elo) : void 0
17047
+ meta.elo !== void 0 ? (0, import_common28.toCourseElo)(meta.elo) : void 0
16934
17048
  );
16935
17049
  }
16936
17050
  }