@vue-skuilder/standalone-ui 0.2.23 → 0.2.24

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.
@@ -31380,59 +31380,107 @@ ${c.id}:`), logger.info(JSON.stringify(c.doc, null, 2));
31380
31380
  async updateUserAndCardElo(t, c, u, d, m, g) {
31381
31381
  g && logger.warn("k value interpretation not currently implemented");
31382
31382
  let b = this.dataLayer.getCourseDB(m.card.course_id), S = d.courses.find((t) => t.courseID === c);
31383
- if (!S) {
31384
- logger.error(`[EloService] No registration for course ${c} on user's registration doc \u2014 skipping ELO update for card ${u}. (Is the user registered for this course?)`);
31385
- return;
31386
- }
31383
+ if (!S) return logger.error(`[EloService] No registration for course ${c} on user's registration doc \u2014 skipping ELO update for card ${u}. (Is the user registered for this course?)`), null;
31387
31384
  let C = toCourseElo(S.elo), w = (await b.getCardEloData([m.card.card_id]))[0];
31388
31385
  if (w && C) {
31389
- let d = adjustCourseScores(C, w, t);
31390
- S.elo = d.userElo;
31391
- let m = await Promise.allSettled([this.user.updateUserElo(c, d.userElo), b.updateCardElo(u, d.cardElo)]), g = m[0].status === "fulfilled", T = m[1].status === "fulfilled";
31392
- if (g && T) {
31393
- let t = m[0].value, c = m[1].value;
31386
+ let d = C.global.score, m = w.global.score, g = Object.keys(w.tags), T = {};
31387
+ for (let t of g) T[t] = C.tags[t]?.score ?? C.global.score;
31388
+ let E = adjustCourseScores(C, w, t);
31389
+ S.elo = E.userElo;
31390
+ let D = {};
31391
+ for (let c of g) D[c] = {
31392
+ before: T[c],
31393
+ after: E.userElo.tags[c].score,
31394
+ score: t
31395
+ };
31396
+ let O = {
31397
+ cardId: u,
31398
+ at: (/* @__PURE__ */ new Date()).toISOString(),
31399
+ userScore: t,
31400
+ global: {
31401
+ before: d,
31402
+ after: E.userElo.global.score
31403
+ },
31404
+ card: {
31405
+ before: m,
31406
+ after: E.cardElo.global.score
31407
+ },
31408
+ ...g.length ? { tags: D } : {}
31409
+ }, xr = await Promise.allSettled([this.user.updateUserElo(c, E.userElo), b.updateCardElo(u, E.cardElo)]), Sr = xr[0].status === "fulfilled", Cr = xr[1].status === "fulfilled";
31410
+ if (Sr && Cr) {
31411
+ let t = xr[0].value, c = xr[1].value;
31394
31412
  t.ok && c && c.ok && logger.info(`[EloService] Updated ELOS:
31395
- User: ${JSON.stringify(d.userElo)})
31396
- Card: ${JSON.stringify(d.cardElo)})
31413
+ User: ${JSON.stringify(E.userElo)})
31414
+ Card: ${JSON.stringify(E.cardElo)})
31397
31415
  `);
31398
31416
  } else logger.warn(`[EloService] Partial ELO update:
31399
- User ELO update: ${g ? "SUCCESS" : "FAILED"}
31400
- Card ELO update: ${T ? "SUCCESS" : "FAILED"}`), !g && m[0].status === "rejected" && logger.error("[EloService] User ELO update error:", m[0].reason), !T && m[1].status === "rejected" && logger.error("[EloService] Card ELO update error:", m[1].reason);
31417
+ User ELO update: ${Sr ? "SUCCESS" : "FAILED"}
31418
+ Card ELO update: ${Cr ? "SUCCESS" : "FAILED"}`), !Sr && xr[0].status === "rejected" && logger.error("[EloService] User ELO update error:", xr[0].reason), !Cr && xr[1].status === "rejected" && logger.error("[EloService] Card ELO update error:", xr[1].reason);
31419
+ return O;
31401
31420
  }
31421
+ return null;
31402
31422
  }
31403
31423
  async updateUserAndCardEloPerTag(t, c, u, d, m) {
31404
31424
  let g = this.dataLayer.getCourseDB(m.card.course_id), b = d.courses.find((t) => t.courseID === c);
31405
- if (!b) {
31406
- logger.error(`[EloService] No registration for course ${c} on user's registration doc \u2014 skipping per-tag ELO update for card ${u}. (Is the user registered for this course?)`);
31407
- return;
31408
- }
31425
+ if (!b) return logger.error(`[EloService] No registration for course ${c} on user's registration doc \u2014 skipping per-tag ELO update for card ${u}. (Is the user registered for this course?)`), null;
31409
31426
  let S = toCourseElo(b.elo), [C, w] = await Promise.all([g.getCardEloData([m.card.card_id]), g.getAppliedTagsBatch([u])]), T = C[0], E = w.get(u) ?? [], D = { ...t }, O = t._global;
31410
31427
  for (let t of E) t in D || (D[t] = O);
31411
31428
  if (T && S) {
31412
- let t = adjustCourseScoresPerTag(S, T, D);
31413
- b.elo = t.userElo;
31414
- let d = await Promise.allSettled([this.user.updateUserElo(c, t.userElo), g.updateCardElo(u, t.cardElo)]), m = d[0].status === "fulfilled", C = d[1].status === "fulfilled";
31415
- if (m && C) {
31416
- let c = d[0].value, u = d[1].value;
31417
- if (c.ok && u && u.ok) {
31418
- let c = Object.keys(D).length - 1;
31419
- logger.info(`[EloService] Updated ELOS (per-tag, ${c} tags):
31420
- User: ${JSON.stringify(t.userElo)})
31421
- Card: ${JSON.stringify(t.cardElo)})
31429
+ let t = S.global.score, d = T.global.score, m = Object.keys(D).filter((t) => t !== "_global"), C = {};
31430
+ for (let t of m) C[t] = S.tags[t]?.score ?? S.global.score;
31431
+ let w = adjustCourseScoresPerTag(S, T, D);
31432
+ b.elo = w.userElo;
31433
+ let E = {};
31434
+ for (let t of m) {
31435
+ let c = D[t], u = c === null ? C[t] : w.userElo.tags[t]?.score ?? C[t];
31436
+ E[t] = {
31437
+ before: C[t],
31438
+ after: u,
31439
+ score: c
31440
+ };
31441
+ }
31442
+ let xr = {
31443
+ cardId: u,
31444
+ at: (/* @__PURE__ */ new Date()).toISOString(),
31445
+ userScore: O,
31446
+ global: {
31447
+ before: t,
31448
+ after: w.userElo.global.score
31449
+ },
31450
+ card: {
31451
+ before: d,
31452
+ after: w.cardElo.global.score
31453
+ },
31454
+ ...m.length ? { tags: E } : {}
31455
+ }, Sr = await Promise.allSettled([this.user.updateUserElo(c, w.userElo), g.updateCardElo(u, w.cardElo)]), Cr = Sr[0].status === "fulfilled", wr = Sr[1].status === "fulfilled";
31456
+ if (Cr && wr) {
31457
+ let t = Sr[0].value, c = Sr[1].value;
31458
+ if (t.ok && c && c.ok) {
31459
+ let t = Object.keys(D).length - 1;
31460
+ logger.info(`[EloService] Updated ELOS (per-tag, ${t} tags):
31461
+ User: ${JSON.stringify(w.userElo)})
31462
+ Card: ${JSON.stringify(w.cardElo)})
31422
31463
  `);
31423
31464
  }
31424
31465
  } else logger.warn(`[EloService] Partial ELO update (per-tag):
31425
- User ELO update: ${m ? "SUCCESS" : "FAILED"}
31426
- Card ELO update: ${C ? "SUCCESS" : "FAILED"}`), !m && d[0].status === "rejected" && logger.error("[EloService] User ELO update error:", d[0].reason), !C && d[1].status === "rejected" && logger.error("[EloService] Card ELO update error:", d[1].reason);
31466
+ User ELO update: ${Cr ? "SUCCESS" : "FAILED"}
31467
+ Card ELO update: ${wr ? "SUCCESS" : "FAILED"}`), !Cr && Sr[0].status === "rejected" && logger.error("[EloService] User ELO update error:", Sr[0].reason), !wr && Sr[1].status === "rejected" && logger.error("[EloService] Card ELO update error:", Sr[1].reason);
31468
+ return xr;
31427
31469
  }
31470
+ return null;
31428
31471
  }
31429
31472
  }, init_core(), init_logger(), ResponseProcessor = class {
31430
- constructor(t, c) {
31431
- _defineProperty$2(this, "srsService", void 0), _defineProperty$2(this, "eloService", void 0), this.srsService = t, this.eloService = c;
31473
+ constructor(t, c, u) {
31474
+ _defineProperty$2(this, "srsService", void 0), _defineProperty$2(this, "eloService", void 0), _defineProperty$2(this, "onEloEvent", void 0), this.srsService = t, this.eloService = c, this.onEloEvent = u;
31432
31475
  }
31433
31476
  logEloFailure(t, c) {
31434
31477
  return (u) => logger.error(`[ResponseProcessor] ELO update failed (${t}) for ${c}:`, u);
31435
31478
  }
31479
+ trackElo(t, c, u) {
31480
+ t.then((t) => {
31481
+ t && this.onEloEvent?.(t);
31482
+ }).catch(this.logEloFailure(c, u));
31483
+ }
31436
31484
  parsePerformance(t) {
31437
31485
  return typeof t == "number" ? {
31438
31486
  globalScore: t,
@@ -31472,13 +31520,13 @@ ${c.id}:`), logger.info(JSON.stringify(c.doc, null, 2));
31472
31520
  let { globalScore: S, taggedPerformance: C } = this.parsePerformance(t.performance);
31473
31521
  if (C) {
31474
31522
  let u = Object.keys(C).filter((t) => t !== "_global"), S = u.filter((t) => C[t] === null), w = u.filter((t) => C[t] !== null);
31475
- logger.info(`[FirstContactElo] correct first-attempt per-tag ELO update for ${b} (historyLen=${c.records.length}, priorAttemps=${t.priorAttemps}): scored=[${w.join(", ")}] count-only=[${S.join(", ")}]`), this.eloService.updateUserAndCardEloPerTag(C, g, b, d, m).catch(this.logEloFailure("correct per-tag", b));
31523
+ logger.info(`[FirstContactElo] correct first-attempt per-tag ELO update for ${b} (historyLen=${c.records.length}, priorAttemps=${t.priorAttemps}): scored=[${w.join(", ")}] count-only=[${S.join(", ")}]`), this.trackElo(this.eloService.updateUserAndCardEloPerTag(C, g, b, d, m), "correct per-tag", b);
31476
31524
  } else {
31477
31525
  let u = .5 + S / 2;
31478
- if (c.records.length === 1) this.eloService.updateUserAndCardElo(u, g, b, d, m).catch(this.logEloFailure("correct", b));
31526
+ if (c.records.length === 1) this.trackElo(this.eloService.updateUserAndCardElo(u, g, b, d, m), "correct", b);
31479
31527
  else {
31480
31528
  let t = Math.ceil(32 / c.records.length);
31481
- this.eloService.updateUserAndCardElo(u, g, b, d, m, t).catch(this.logEloFailure("correct repeat-view", b));
31529
+ this.trackElo(this.eloService.updateUserAndCardElo(u, g, b, d, m, t), "correct repeat-view", b);
31482
31530
  }
31483
31531
  logger.info(`[FirstContactElo] correct first-attempt ELO update (score=${u.toFixed(3)}) for ${b} (historyLen=${c.records.length}, priorAttemps=${t.priorAttemps})`);
31484
31532
  }
@@ -31504,7 +31552,7 @@ ${c.id}:`), logger.info(JSON.stringify(c.doc, null, 2));
31504
31552
  }
31505
31553
  processIncorrectResponse(t, c, u, d, m, g, b, S, C) {
31506
31554
  let { taggedPerformance: w } = this.parsePerformance(t.performance), T = !1;
31507
- return t.priorAttemps === 0 ? (w ? (this.eloService.updateUserAndCardEloPerTag(w, m, g, u, d).catch(this.logEloFailure("incorrect per-tag", g)), logger.info(`[FirstContactElo] incorrect first-attempt per-tag ELO update for ${g} (historyLen=${c.records.length}, priorAttemps=${t.priorAttemps}, tags=${Object.keys(w).length - 1})`)) : (this.eloService.updateUserAndCardElo(0, m, g, u, d).catch(this.logEloFailure("incorrect", g)), logger.info(`[FirstContactElo] incorrect first-attempt ELO update (score=0) for ${g} (historyLen=${c.records.length}, priorAttemps=${t.priorAttemps})`)), T = !0) : logger.info(`[FirstContactElo] incorrect retry \u2014 no ELO update for ${g} (historyLen=${c.records.length}, priorAttemps=${t.priorAttemps})`), d.records.length >= b ? C >= S ? (T ? logger.info(`[FirstContactElo] dismiss-failed \u2014 ELO already updated this response, skipping double penalty for ${g}`) : (w ? this.eloService.updateUserAndCardEloPerTag(w, m, g, u, d).catch(this.logEloFailure("dismiss-failed per-tag", g)) : this.eloService.updateUserAndCardElo(0, m, g, u, d).catch(this.logEloFailure("dismiss-failed", g)), logger.info(`[FirstContactElo] dismiss-failed final ELO penalty for ${g} (historyLen=${c.records.length}, sessionViews=${C})`)), {
31555
+ return t.priorAttemps === 0 ? (w ? (this.trackElo(this.eloService.updateUserAndCardEloPerTag(w, m, g, u, d), "incorrect per-tag", g), logger.info(`[FirstContactElo] incorrect first-attempt per-tag ELO update for ${g} (historyLen=${c.records.length}, priorAttemps=${t.priorAttemps}, tags=${Object.keys(w).length - 1})`)) : (this.trackElo(this.eloService.updateUserAndCardElo(0, m, g, u, d), "incorrect", g), logger.info(`[FirstContactElo] incorrect first-attempt ELO update (score=0) for ${g} (historyLen=${c.records.length}, priorAttemps=${t.priorAttemps})`)), T = !0) : logger.info(`[FirstContactElo] incorrect retry \u2014 no ELO update for ${g} (historyLen=${c.records.length}, priorAttemps=${t.priorAttemps})`), d.records.length >= b ? C >= S ? (T ? logger.info(`[FirstContactElo] dismiss-failed \u2014 ELO already updated this response, skipping double penalty for ${g}`) : (w ? this.trackElo(this.eloService.updateUserAndCardEloPerTag(w, m, g, u, d), "dismiss-failed per-tag", g) : this.trackElo(this.eloService.updateUserAndCardElo(0, m, g, u, d), "dismiss-failed", g), logger.info(`[FirstContactElo] dismiss-failed final ELO penalty for ${g} (historyLen=${c.records.length}, sessionViews=${C})`)), {
31508
31556
  nextCardAction: "dismiss-failed",
31509
31557
  shouldLoadNextCard: !0,
31510
31558
  isCorrect: !1,
@@ -32445,7 +32493,7 @@ ${c.id}:`), logger.info(JSON.stringify(c.doc, null, 2));
32445
32493
  return this.supplyQ.toString + "\n" + this.failedQ.toString;
32446
32494
  }
32447
32495
  constructor(t, c, u, d, m, g) {
32448
- super(), _defineProperty$2(this, "_className", "SessionController"), _defineProperty$2(this, "services", void 0), _defineProperty$2(this, "srsService", void 0), _defineProperty$2(this, "eloService", void 0), _defineProperty$2(this, "hydrationService", void 0), _defineProperty$2(this, "mixer", void 0), _defineProperty$2(this, "dataLayer", void 0), _defineProperty$2(this, "courseNameCache", /* @__PURE__ */ new Map()), _defineProperty$2(this, "_defaultBatchLimit", 20), _defineProperty$2(this, "sources", void 0), _defineProperty$2(this, "_sessionRecord", []), _defineProperty$2(this, "_currentCard", null), _defineProperty$2(this, "supplyQ", new ItemQueue()), _defineProperty$2(this, "failedQ", new ItemQueue()), _defineProperty$2(this, "_supplyDrawsSinceFailed", 0), _defineProperty$2(this, "_replanPromise", null), _defineProperty$2(this, "_activeReplanLabel", null), _defineProperty$2(this, "_wellIndicatedRemaining", 0), _defineProperty$2(this, "_suppressQualityReplan", !1), _defineProperty$2(this, "_minCardsGuarantee", 0), _defineProperty$2(this, "_sessionHints", null), _defineProperty$2(this, "_servedCardIds", /* @__PURE__ */ new Set()), _defineProperty$2(this, "_outcomeObservers", []), _defineProperty$2(this, "_sessionControls", null), _defineProperty$2(this, "sessionId", void 0), _defineProperty$2(this, "_courseId", void 0), _defineProperty$2(this, "_stateSnapshotProvider", void 0), _defineProperty$2(this, "_sessionDoc", null), _defineProperty$2(this, "_openDocPromise", null), _defineProperty$2(this, "_runLog", []), _defineProperty$2(this, "_sessionClosed", !1), _defineProperty$2(this, "startTime", void 0), _defineProperty$2(this, "endTime", void 0), _defineProperty$2(this, "_secondsRemaining", void 0), _defineProperty$2(this, "_intervalHandle", void 0), this.sessionId = newSessionId(), setDebugSessionId(this.sessionId), this.dataLayer = u, this.mixer = m || new QuotaRoundRobinMixer(), this.srsService = new SrsService(u.getUserDB()), this.eloService = new EloService(u, u.getUserDB()), this.hydrationService = new CardHydrationService(d, (t) => u.getCourseDB(t), () => this._getItemsToHydrate()), this.services = { response: new ResponseProcessor(this.srsService, this.eloService) }, this.sources = t, this.startTime = /* @__PURE__ */ new Date(), this._secondsRemaining = c, this.endTime = new Date(this.startTime.valueOf() + 1e3 * this._secondsRemaining), g?.defaultBatchLimit !== void 0 && (this._defaultBatchLimit = g.defaultBatchLimit), g?.outcomeObservers?.length && (this._outcomeObservers = [...g.outcomeObservers]), this._courseId = g?.courseId, this._stateSnapshotProvider = g?.stateSnapshotProvider, this.log(`Session constructed:
32496
+ super(), _defineProperty$2(this, "_className", "SessionController"), _defineProperty$2(this, "services", void 0), _defineProperty$2(this, "srsService", void 0), _defineProperty$2(this, "eloService", void 0), _defineProperty$2(this, "hydrationService", void 0), _defineProperty$2(this, "mixer", void 0), _defineProperty$2(this, "dataLayer", void 0), _defineProperty$2(this, "courseNameCache", /* @__PURE__ */ new Map()), _defineProperty$2(this, "_defaultBatchLimit", 20), _defineProperty$2(this, "sources", void 0), _defineProperty$2(this, "_sessionRecord", []), _defineProperty$2(this, "_currentCard", null), _defineProperty$2(this, "supplyQ", new ItemQueue()), _defineProperty$2(this, "failedQ", new ItemQueue()), _defineProperty$2(this, "_supplyDrawsSinceFailed", 0), _defineProperty$2(this, "_replanPromise", null), _defineProperty$2(this, "_activeReplanLabel", null), _defineProperty$2(this, "_wellIndicatedRemaining", 0), _defineProperty$2(this, "_suppressQualityReplan", !1), _defineProperty$2(this, "_minCardsGuarantee", 0), _defineProperty$2(this, "_sessionHints", null), _defineProperty$2(this, "_servedCardIds", /* @__PURE__ */ new Set()), _defineProperty$2(this, "_outcomeObservers", []), _defineProperty$2(this, "_sessionControls", null), _defineProperty$2(this, "sessionId", void 0), _defineProperty$2(this, "_courseId", void 0), _defineProperty$2(this, "_stateSnapshotProvider", void 0), _defineProperty$2(this, "_sessionDoc", null), _defineProperty$2(this, "_openDocPromise", null), _defineProperty$2(this, "_runLog", []), _defineProperty$2(this, "_eloLog", []), _defineProperty$2(this, "_sessionClosed", !1), _defineProperty$2(this, "startTime", void 0), _defineProperty$2(this, "endTime", void 0), _defineProperty$2(this, "_secondsRemaining", void 0), _defineProperty$2(this, "_intervalHandle", void 0), this.sessionId = newSessionId(), setDebugSessionId(this.sessionId), this.dataLayer = u, this.mixer = m || new QuotaRoundRobinMixer(), this.srsService = new SrsService(u.getUserDB()), this.eloService = new EloService(u, u.getUserDB()), this.hydrationService = new CardHydrationService(d, (t) => u.getCourseDB(t), () => this._getItemsToHydrate()), this.services = { response: new ResponseProcessor(this.srsService, this.eloService, (t) => this._recordEloEvent(t)) }, this.sources = t, this.startTime = /* @__PURE__ */ new Date(), this._secondsRemaining = c, this.endTime = new Date(this.startTime.valueOf() + 1e3 * this._secondsRemaining), g?.defaultBatchLimit !== void 0 && (this._defaultBatchLimit = g.defaultBatchLimit), g?.outcomeObservers?.length && (this._outcomeObservers = [...g.outcomeObservers]), this._courseId = g?.courseId, this._stateSnapshotProvider = g?.stateSnapshotProvider, this.log(`Session constructed:
32449
32497
  sessionId: ${this.sessionId}
32450
32498
  startTime: ${this.startTime}
32451
32499
  endTime: ${this.endTime}
@@ -32628,6 +32676,9 @@ ${c.id}:`), logger.info(JSON.stringify(c.doc, null, 2));
32628
32676
  requestReplan: (t) => this.requestReplan(t)
32629
32677
  }), this._sessionControls;
32630
32678
  }
32679
+ _recordEloEvent(t) {
32680
+ this._eloLog.length >= _SessionController.MAX_LOGGED_ELO_EVENTS || this._eloLog.push(t);
32681
+ }
32631
32682
  async _notifyOutcomeObservers(t, c, u) {
32632
32683
  if (this._outcomeObservers.length === 0 || !isQuestionRecord(t)) return;
32633
32684
  let d = {
@@ -32903,6 +32954,7 @@ ${c.id}:`), logger.info(JSON.stringify(c.doc, null, 2));
32903
32954
  secondsRemaining: Math.max(0, this._secondsRemaining)
32904
32955
  },
32905
32956
  runs: [...this._runLog],
32957
+ eloEvents: [...this._eloLog],
32906
32958
  finalHints: this._sessionHints,
32907
32959
  stateAtEnd: await this._captureState("end")
32908
32960
  };
@@ -32911,7 +32963,7 @@ ${c.id}:`), logger.info(JSON.stringify(c.doc, null, 2));
32911
32963
  logger.warn(`[SessionController] Failed to close session record: ${t}`);
32912
32964
  }
32913
32965
  }
32914
- }, _defineProperty$2(_SessionController2, "MAX_LOGGED_RUNS", 100), _defineProperty$2(_SessionController2, "MIN_WELL_INDICATED", 5), _defineProperty$2(_SessionController2, "WELL_INDICATED_SCORE", .1), _defineProperty$2(_SessionController2, "DEPLETION_PREFETCH_THRESHOLD", 3), _defineProperty$2(_SessionController2, "FAILED_INTERLEAVE_EVERY", 4), _defineProperty$2(_SessionController2, "FAILED_ENDGAME_SLACK_SECONDS", 20), _SessionController2), init_TagFilteredContentSource(), init_factory(), init_userDBHelpers();
32966
+ }, _defineProperty$2(_SessionController2, "MAX_LOGGED_RUNS", 100), _defineProperty$2(_SessionController2, "MAX_LOGGED_ELO_EVENTS", 2e3), _defineProperty$2(_SessionController2, "MIN_WELL_INDICATED", 5), _defineProperty$2(_SessionController2, "WELL_INDICATED_SCORE", .1), _defineProperty$2(_SessionController2, "DEPLETION_PREFETCH_THRESHOLD", 3), _defineProperty$2(_SessionController2, "FAILED_INTERLEAVE_EVERY", 4), _defineProperty$2(_SessionController2, "FAILED_ENDGAME_SLACK_SECONDS", 20), _SessionController2), init_TagFilteredContentSource(), init_factory(), init_userDBHelpers();
32915
32967
  }));
32916
32968
  //#endregion
32917
32969
  //#region ../../node_modules/vue-router/dist/vue-router.mjs