@thanh01.pmt/interactive-quiz-kit 1.0.46 → 1.0.47

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.
@@ -3980,6 +3980,11 @@ var UserConfigService = class {
3980
3980
  init_react_shim();
3981
3981
  var LOCAL_STORAGE_KEY = "iqk_practice_history_v2";
3982
3982
  var PracticeHistoryService = class {
3983
+ // NEW: A configuration method to allow the host app (QMS) to inject its sync logic
3984
+ static configure(provider) {
3985
+ this.syncProvider = provider.syncProvider;
3986
+ console.log("PracticeHistoryService configured with a sync provider.");
3987
+ }
3983
3988
  static getPracticeHistory() {
3984
3989
  if (typeof window === "undefined") return [];
3985
3990
  try {
@@ -4023,6 +4028,12 @@ var PracticeHistoryService = class {
4023
4028
  };
4024
4029
  history2.unshift(newSession);
4025
4030
  this.saveHistory(history2);
4031
+ if (this.syncProvider) {
4032
+ console.log(`Sync provider found. Pushing session ${newSession.id} to backend.`);
4033
+ this.syncProvider.pushSession(newSession).catch((err) => {
4034
+ console.error("Sync provider failed to push session:", err);
4035
+ });
4036
+ }
4026
4037
  return newSession.id;
4027
4038
  }
4028
4039
  static updatePracticeReview(sessionId, review) {
@@ -4155,6 +4166,8 @@ var PracticeHistoryService = class {
4155
4166
  }
4156
4167
  }
4157
4168
  };
4169
+ // NEW: A static property to hold the injected sync provider
4170
+ PracticeHistoryService.syncProvider = null;
4158
4171
 
4159
4172
  // src/services/AchievementService.ts
4160
4173
  init_react_shim();
@@ -3954,6 +3954,11 @@ var UserConfigService = class {
3954
3954
  init_react_shim();
3955
3955
  var LOCAL_STORAGE_KEY = "iqk_practice_history_v2";
3956
3956
  var PracticeHistoryService = class {
3957
+ // NEW: A configuration method to allow the host app (QMS) to inject its sync logic
3958
+ static configure(provider) {
3959
+ this.syncProvider = provider.syncProvider;
3960
+ console.log("PracticeHistoryService configured with a sync provider.");
3961
+ }
3957
3962
  static getPracticeHistory() {
3958
3963
  if (typeof window === "undefined") return [];
3959
3964
  try {
@@ -3997,6 +4002,12 @@ var PracticeHistoryService = class {
3997
4002
  };
3998
4003
  history2.unshift(newSession);
3999
4004
  this.saveHistory(history2);
4005
+ if (this.syncProvider) {
4006
+ console.log(`Sync provider found. Pushing session ${newSession.id} to backend.`);
4007
+ this.syncProvider.pushSession(newSession).catch((err) => {
4008
+ console.error("Sync provider failed to push session:", err);
4009
+ });
4010
+ }
4000
4011
  return newSession.id;
4001
4012
  }
4002
4013
  static updatePracticeReview(sessionId, review) {
@@ -4129,6 +4140,8 @@ var PracticeHistoryService = class {
4129
4140
  }
4130
4141
  }
4131
4142
  };
4143
+ // NEW: A static property to hold the injected sync provider
4144
+ PracticeHistoryService.syncProvider = null;
4132
4145
 
4133
4146
  // src/services/AchievementService.ts
4134
4147
  init_react_shim();
package/dist/index.cjs CHANGED
@@ -1946,6 +1946,11 @@ var UserConfigService = class {
1946
1946
  // src/services/PracticeHistoryService.ts
1947
1947
  var LOCAL_STORAGE_KEY = "iqk_practice_history_v2";
1948
1948
  var PracticeHistoryService = class {
1949
+ // NEW: A configuration method to allow the host app (QMS) to inject its sync logic
1950
+ static configure(provider) {
1951
+ this.syncProvider = provider.syncProvider;
1952
+ console.log("PracticeHistoryService configured with a sync provider.");
1953
+ }
1949
1954
  static getPracticeHistory() {
1950
1955
  if (typeof window === "undefined") return [];
1951
1956
  try {
@@ -1989,6 +1994,12 @@ var PracticeHistoryService = class {
1989
1994
  };
1990
1995
  history.unshift(newSession);
1991
1996
  this.saveHistory(history);
1997
+ if (this.syncProvider) {
1998
+ console.log(`Sync provider found. Pushing session ${newSession.id} to backend.`);
1999
+ this.syncProvider.pushSession(newSession).catch((err) => {
2000
+ console.error("Sync provider failed to push session:", err);
2001
+ });
2002
+ }
1992
2003
  return newSession.id;
1993
2004
  }
1994
2005
  static updatePracticeReview(sessionId, review) {
@@ -2121,6 +2132,8 @@ var PracticeHistoryService = class {
2121
2132
  }
2122
2133
  }
2123
2134
  };
2135
+ // NEW: A static property to hold the injected sync provider
2136
+ PracticeHistoryService.syncProvider = null;
2124
2137
 
2125
2138
  // src/data/achievements.json
2126
2139
  var achievements_default = [
package/dist/index.d.cts CHANGED
@@ -230,7 +230,14 @@ declare class UserConfigService {
230
230
  static deleteGoal(goalId: string): void;
231
231
  }
232
232
 
233
+ interface SyncProvider {
234
+ pushSession: (session: PracticeSession) => Promise<void>;
235
+ }
233
236
  declare class PracticeHistoryService {
237
+ private static syncProvider;
238
+ static configure(provider: {
239
+ syncProvider: SyncProvider;
240
+ }): void;
234
241
  static getPracticeHistory(): PracticeSession[];
235
242
  private static saveHistory;
236
243
  static saveCompletedPracticeSession(quizConfig: QuizConfig, result: QuizResultType, review?: QuizReviewContent | null): string;
package/dist/index.d.ts CHANGED
@@ -230,7 +230,14 @@ declare class UserConfigService {
230
230
  static deleteGoal(goalId: string): void;
231
231
  }
232
232
 
233
+ interface SyncProvider {
234
+ pushSession: (session: PracticeSession) => Promise<void>;
235
+ }
233
236
  declare class PracticeHistoryService {
237
+ private static syncProvider;
238
+ static configure(provider: {
239
+ syncProvider: SyncProvider;
240
+ }): void;
234
241
  static getPracticeHistory(): PracticeSession[];
235
242
  private static saveHistory;
236
243
  static saveCompletedPracticeSession(quizConfig: QuizConfig, result: QuizResultType, review?: QuizReviewContent | null): string;
package/dist/index.mjs CHANGED
@@ -1940,6 +1940,11 @@ var UserConfigService = class {
1940
1940
  // src/services/PracticeHistoryService.ts
1941
1941
  var LOCAL_STORAGE_KEY = "iqk_practice_history_v2";
1942
1942
  var PracticeHistoryService = class {
1943
+ // NEW: A configuration method to allow the host app (QMS) to inject its sync logic
1944
+ static configure(provider) {
1945
+ this.syncProvider = provider.syncProvider;
1946
+ console.log("PracticeHistoryService configured with a sync provider.");
1947
+ }
1943
1948
  static getPracticeHistory() {
1944
1949
  if (typeof window === "undefined") return [];
1945
1950
  try {
@@ -1983,6 +1988,12 @@ var PracticeHistoryService = class {
1983
1988
  };
1984
1989
  history.unshift(newSession);
1985
1990
  this.saveHistory(history);
1991
+ if (this.syncProvider) {
1992
+ console.log(`Sync provider found. Pushing session ${newSession.id} to backend.`);
1993
+ this.syncProvider.pushSession(newSession).catch((err) => {
1994
+ console.error("Sync provider failed to push session:", err);
1995
+ });
1996
+ }
1986
1997
  return newSession.id;
1987
1998
  }
1988
1999
  static updatePracticeReview(sessionId, review) {
@@ -2115,6 +2126,8 @@ var PracticeHistoryService = class {
2115
2126
  }
2116
2127
  }
2117
2128
  };
2129
+ // NEW: A static property to hold the injected sync provider
2130
+ PracticeHistoryService.syncProvider = null;
2118
2131
 
2119
2132
  // src/data/achievements.json
2120
2133
  var achievements_default = [
package/dist/react-ui.cjs CHANGED
@@ -139570,6 +139570,11 @@ AlertDialogCancel2.displayName = Cancel.displayName;
139570
139570
  init_react_shim();
139571
139571
  var LOCAL_STORAGE_KEY = "iqk_practice_history_v2";
139572
139572
  var PracticeHistoryService = class {
139573
+ // NEW: A configuration method to allow the host app (QMS) to inject its sync logic
139574
+ static configure(provider) {
139575
+ this.syncProvider = provider.syncProvider;
139576
+ console.log("PracticeHistoryService configured with a sync provider.");
139577
+ }
139573
139578
  static getPracticeHistory() {
139574
139579
  if (typeof window === "undefined") return [];
139575
139580
  try {
@@ -139613,6 +139618,12 @@ var PracticeHistoryService = class {
139613
139618
  };
139614
139619
  history2.unshift(newSession);
139615
139620
  this.saveHistory(history2);
139621
+ if (this.syncProvider) {
139622
+ console.log(`Sync provider found. Pushing session ${newSession.id} to backend.`);
139623
+ this.syncProvider.pushSession(newSession).catch((err) => {
139624
+ console.error("Sync provider failed to push session:", err);
139625
+ });
139626
+ }
139616
139627
  return newSession.id;
139617
139628
  }
139618
139629
  static updatePracticeReview(sessionId, review) {
@@ -139745,6 +139756,8 @@ var PracticeHistoryService = class {
139745
139756
  }
139746
139757
  }
139747
139758
  };
139759
+ // NEW: A static property to hold the injected sync provider
139760
+ PracticeHistoryService.syncProvider = null;
139748
139761
 
139749
139762
  // src/services/RoadmapService.ts
139750
139763
  init_react_shim();
package/dist/react-ui.mjs CHANGED
@@ -139543,6 +139543,11 @@ AlertDialogCancel2.displayName = Cancel.displayName;
139543
139543
  init_react_shim();
139544
139544
  var LOCAL_STORAGE_KEY = "iqk_practice_history_v2";
139545
139545
  var PracticeHistoryService = class {
139546
+ // NEW: A configuration method to allow the host app (QMS) to inject its sync logic
139547
+ static configure(provider) {
139548
+ this.syncProvider = provider.syncProvider;
139549
+ console.log("PracticeHistoryService configured with a sync provider.");
139550
+ }
139546
139551
  static getPracticeHistory() {
139547
139552
  if (typeof window === "undefined") return [];
139548
139553
  try {
@@ -139586,6 +139591,12 @@ var PracticeHistoryService = class {
139586
139591
  };
139587
139592
  history2.unshift(newSession);
139588
139593
  this.saveHistory(history2);
139594
+ if (this.syncProvider) {
139595
+ console.log(`Sync provider found. Pushing session ${newSession.id} to backend.`);
139596
+ this.syncProvider.pushSession(newSession).catch((err) => {
139597
+ console.error("Sync provider failed to push session:", err);
139598
+ });
139599
+ }
139589
139600
  return newSession.id;
139590
139601
  }
139591
139602
  static updatePracticeReview(sessionId, review) {
@@ -139718,6 +139729,8 @@ var PracticeHistoryService = class {
139718
139729
  }
139719
139730
  }
139720
139731
  };
139732
+ // NEW: A static property to hold the injected sync provider
139733
+ PracticeHistoryService.syncProvider = null;
139721
139734
 
139722
139735
  // src/services/RoadmapService.ts
139723
139736
  init_react_shim();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thanh01.pmt/interactive-quiz-kit",
3
- "version": "1.0.46",
3
+ "version": "1.0.47",
4
4
  "description": "A comprehensive library for creating, managing, and playing interactive quizzes, with AI generation and SCORM support.",
5
5
  "keywords": [
6
6
  "react",