@vue-skuilder/db 0.1.11-9 → 0.1.12
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/core/index.d.mts +7 -6
- package/dist/core/index.d.ts +7 -6
- package/dist/core/index.js +358 -87
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.mjs +358 -87
- package/dist/core/index.mjs.map +1 -1
- package/dist/{dataLayerProvider-DqtNroSh.d.ts → dataLayerProvider-BiP3kWix.d.mts} +8 -1
- package/dist/{dataLayerProvider-BInqI_RF.d.mts → dataLayerProvider-DSdeyRT3.d.ts} +8 -1
- package/dist/impl/couch/index.d.mts +19 -7
- package/dist/impl/couch/index.d.ts +19 -7
- package/dist/impl/couch/index.js +375 -100
- package/dist/impl/couch/index.js.map +1 -1
- package/dist/impl/couch/index.mjs +374 -99
- package/dist/impl/couch/index.mjs.map +1 -1
- package/dist/impl/static/index.d.mts +23 -8
- package/dist/impl/static/index.d.ts +23 -8
- package/dist/impl/static/index.js +289 -85
- package/dist/impl/static/index.js.map +1 -1
- package/dist/impl/static/index.mjs +289 -85
- package/dist/impl/static/index.mjs.map +1 -1
- package/dist/{index-CUNnL38E.d.mts → index-Bmll7Xse.d.mts} +1 -1
- package/dist/{index-CLL31bEy.d.ts → index-CD8BZz2k.d.ts} +1 -1
- package/dist/index.d.mts +123 -20
- package/dist/index.d.ts +123 -20
- package/dist/index.js +1133 -343
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1137 -343
- package/dist/index.mjs.map +1 -1
- package/dist/pouch/index.d.mts +1 -0
- package/dist/pouch/index.d.ts +1 -0
- package/dist/pouch/index.js +49 -0
- package/dist/pouch/index.js.map +1 -0
- package/dist/pouch/index.mjs +16 -0
- package/dist/pouch/index.mjs.map +1 -0
- package/dist/{types-BefDGkKa.d.ts → types-CewsN87z.d.ts} +1 -1
- package/dist/{types-DC-ckZug.d.mts → types-Dbp5DaRR.d.mts} +1 -1
- package/dist/{types-legacy-Birv-Jx6.d.mts → types-legacy-6ettoclI.d.mts} +17 -2
- package/dist/{types-legacy-Birv-Jx6.d.ts → types-legacy-6ettoclI.d.ts} +17 -2
- package/dist/{userDB-DusL7OXe.d.ts → userDB-C4yyAnpp.d.mts} +89 -56
- package/dist/{userDB-C33Hzjgn.d.mts → userDB-CD6s6ZCp.d.ts} +89 -56
- package/dist/util/packer/index.d.mts +3 -3
- package/dist/util/packer/index.d.ts +3 -3
- package/package.json +3 -3
- package/src/core/interfaces/contentSource.ts +3 -2
- package/src/core/interfaces/courseDB.ts +26 -3
- package/src/core/interfaces/dataLayerProvider.ts +9 -1
- package/src/core/interfaces/userDB.ts +80 -64
- package/src/core/navigators/elo.ts +10 -7
- package/src/core/navigators/hardcodedOrder.ts +64 -0
- package/src/core/navigators/index.ts +2 -1
- package/src/core/types/contentNavigationStrategy.ts +2 -1
- package/src/core/types/types-legacy.ts +7 -2
- package/src/impl/common/BaseUserDB.ts +60 -14
- package/src/impl/couch/CouchDBSyncStrategy.ts +2 -2
- package/src/impl/couch/PouchDataLayerProvider.ts +21 -0
- package/src/impl/couch/adminDB.ts +2 -2
- package/src/impl/couch/auth.ts +13 -4
- package/src/impl/couch/classroomDB.ts +10 -12
- package/src/impl/couch/courseAPI.ts +2 -2
- package/src/impl/couch/courseDB.ts +204 -38
- package/src/impl/couch/courseLookupDB.ts +4 -3
- package/src/impl/couch/index.ts +36 -4
- package/src/impl/couch/pouchdb-setup.ts +3 -3
- package/src/impl/couch/updateQueue.ts +59 -36
- package/src/impl/static/StaticDataLayerProvider.ts +68 -17
- package/src/impl/static/courseDB.ts +64 -20
- package/src/impl/static/coursesDB.ts +10 -6
- package/src/pouch/index.ts +2 -0
- package/src/study/ItemQueue.ts +58 -0
- package/src/study/SessionController.ts +182 -111
- package/src/study/SpacedRepetition.ts +1 -1
- package/src/study/services/CardHydrationService.ts +153 -0
- package/src/study/services/EloService.ts +85 -0
- package/src/study/services/ResponseProcessor.ts +224 -0
- package/src/study/services/SrsService.ts +44 -0
- package/tsup.config.ts +1 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { P as PackerConfig, a as PackedCourseData, S as StaticCourseManifest } from './types-
|
|
1
|
+
import { P as PackerConfig, a as PackedCourseData, S as StaticCourseManifest } from './types-Dbp5DaRR.mjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Abstraction for file system operations needed by the migrator.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { P as PackerConfig, a as PackedCourseData, S as StaticCourseManifest } from './types-
|
|
1
|
+
import { P as PackerConfig, a as PackedCourseData, S as StaticCourseManifest } from './types-CewsN87z.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Abstraction for file system operations needed by the migrator.
|
package/dist/index.d.mts
CHANGED
|
@@ -1,17 +1,90 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import { D as DataLayerProvider } from './dataLayerProvider-
|
|
4
|
-
import { C as CardRecord } from './types-legacy-
|
|
5
|
-
export {
|
|
1
|
+
import { U as UserDBInterface, r as CourseRegistrationDoc, k as StudySessionItem, i as StudyContentSource } from './userDB-C4yyAnpp.mjs';
|
|
2
|
+
export { H as ActivityRecord, A as AdminDBInterface, u as AssignedCard, h as AssignedContent, t as AssignedCourse, s as AssignedTag, c as ClassroomDBInterface, E as ClassroomRegistration, B as ClassroomRegistrationDesignation, F as ClassroomRegistrationDoc, p as ContentSourceID, C as CourseDBInterface, d as CourseInfo, I as CourseRegistration, b as CoursesDBInterface, J as DocumentUpdater, g as ScheduledCard, j as StudentClassroomDBInterface, l as StudySessionFailedItem, m as StudySessionFailedNewItem, n as StudySessionFailedReviewItem, S as StudySessionNewItem, f as StudySessionReviewItem, T as TeacherClassroomDBInterface, G as UserConfig, y as UserCourseSetting, x as UserCourseSettings, w as UserDBAuthenticator, a as UserDBReader, v as UserDBWriter, z as UsrCrsDataInterface, q as getStudySource, o as isReview, K as newInterval } from './userDB-C4yyAnpp.mjs';
|
|
3
|
+
import { D as DataLayerProvider } from './dataLayerProvider-BiP3kWix.mjs';
|
|
4
|
+
import { C as CardHistory, c as CardRecord } from './types-legacy-6ettoclI.mjs';
|
|
5
|
+
export { d as CardData, e as CourseListData, g as DataShapeData, f as DisplayableData, D as DocType, b as DocTypePrefixes, F as Field, G as GuestUsername, Q as QualifiedCardID, h as QuestionData, i as QuestionRecord, S as SkuilderCourseData, a as Tag, T as TagStub, l as log } from './types-legacy-6ettoclI.mjs';
|
|
6
6
|
import { Loggable } from './core/index.mjs';
|
|
7
7
|
export { BulkCardProcessorConfig, ContentNavigator, ImportResult, Navigators, areQuestionRecords, docIsDeleted, getCardHistoryID, importParsedCards, isQuestionRecord, parseCardHistoryID, validateProcessorConfig } from './core/index.mjs';
|
|
8
|
-
import { S as StaticCourseManifest } from './types-
|
|
9
|
-
export { A as AttachmentData, C as ChunkMetadata, D as DesignDocument, I as IndexMetadata, a as PackedCourseData, P as PackerConfig } from './types-
|
|
10
|
-
import { F as FileSystemAdapter } from './index-
|
|
11
|
-
export { C as CouchDBToStaticPacker, a as FileStats, b as FileSystemError } from './index-
|
|
8
|
+
import { S as StaticCourseManifest } from './types-Dbp5DaRR.mjs';
|
|
9
|
+
export { A as AttachmentData, C as ChunkMetadata, D as DesignDocument, I as IndexMetadata, a as PackedCourseData, P as PackerConfig } from './types-Dbp5DaRR.mjs';
|
|
10
|
+
import { F as FileSystemAdapter } from './index-Bmll7Xse.mjs';
|
|
11
|
+
export { C as CouchDBToStaticPacker, a as FileStats, b as FileSystemError } from './index-Bmll7Xse.mjs';
|
|
12
12
|
import '@vue-skuilder/common';
|
|
13
13
|
import 'moment';
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Service responsible for ELO rating calculations and updates.
|
|
17
|
+
*/
|
|
18
|
+
declare class EloService {
|
|
19
|
+
private dataLayer;
|
|
20
|
+
private user;
|
|
21
|
+
constructor(dataLayer: DataLayerProvider, user: UserDBInterface);
|
|
22
|
+
/**
|
|
23
|
+
* Updates both user and card ELO ratings based on user performance.
|
|
24
|
+
* @param userScore Score between 0-1 representing user performance
|
|
25
|
+
* @param course_id Course identifier
|
|
26
|
+
* @param card_id Card identifier
|
|
27
|
+
* @param userCourseRegDoc User's course registration document (will be mutated)
|
|
28
|
+
* @param currentCard Current card session record
|
|
29
|
+
* @param k Optional K-factor for ELO calculation
|
|
30
|
+
*/
|
|
31
|
+
updateUserAndCardElo(userScore: number, course_id: string, card_id: string, userCourseRegDoc: CourseRegistrationDoc, currentCard: StudySessionRecord, k?: number): Promise<void>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Service responsible for Spaced Repetition System (SRS) scheduling logic.
|
|
36
|
+
*/
|
|
37
|
+
declare class SrsService {
|
|
38
|
+
private user;
|
|
39
|
+
constructor(user: UserDBInterface);
|
|
40
|
+
/**
|
|
41
|
+
* Calculates the next review time for a card based on its history and
|
|
42
|
+
* schedules it in the user's database.
|
|
43
|
+
* @param history The full history of the card.
|
|
44
|
+
* @param item The study session item, used to determine if a previous review needs to be cleared.
|
|
45
|
+
*/
|
|
46
|
+
scheduleReview(history: CardHistory<CardRecord>, item: StudySessionItem): Promise<void>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Service responsible for orchestrating the complete response processing workflow.
|
|
51
|
+
* Coordinates SRS scheduling and ELO updates for user card interactions.
|
|
52
|
+
*/
|
|
53
|
+
declare class ResponseProcessor {
|
|
54
|
+
private srsService;
|
|
55
|
+
private eloService;
|
|
56
|
+
constructor(srsService: SrsService, eloService: EloService);
|
|
57
|
+
/**
|
|
58
|
+
* Processes a user's response to a card, handling SRS scheduling and ELO updates.
|
|
59
|
+
* @param cardRecord User's response record
|
|
60
|
+
* @param cardHistory Promise resolving to the card's history
|
|
61
|
+
* @param studySessionItem Current study session item
|
|
62
|
+
* @param courseRegistrationDoc User's course registration (for ELO updates)
|
|
63
|
+
* @param currentCard Current study session record
|
|
64
|
+
* @param courseId Course identifier
|
|
65
|
+
* @param cardId Card identifier
|
|
66
|
+
* @param maxAttemptsPerView Maximum attempts allowed per view
|
|
67
|
+
* @param maxSessionViews Maximum session views for this card
|
|
68
|
+
* @param sessionViews Current number of session views
|
|
69
|
+
* @returns ResponseResult with navigation and UI instructions
|
|
70
|
+
*/
|
|
71
|
+
processResponse(cardRecord: CardRecord, cardHistory: Promise<CardHistory<CardRecord>>, studySessionItem: StudySessionItem, courseRegistrationDoc: CourseRegistrationDoc, currentCard: StudySessionRecord, courseId: string, cardId: string, maxAttemptsPerView: number, maxSessionViews: number, sessionViews: number): Promise<ResponseResult>;
|
|
72
|
+
/**
|
|
73
|
+
* Handles processing for correct responses: SRS scheduling and ELO updates.
|
|
74
|
+
*/
|
|
75
|
+
private processCorrectResponse;
|
|
76
|
+
/**
|
|
77
|
+
* Handles processing for incorrect responses: ELO updates only.
|
|
78
|
+
*/
|
|
79
|
+
private processIncorrectResponse;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
interface HydratedCard<TView = unknown> {
|
|
83
|
+
item: StudySessionItem;
|
|
84
|
+
view: TView;
|
|
85
|
+
data: any[];
|
|
86
|
+
}
|
|
87
|
+
|
|
15
88
|
interface MigrationOptions {
|
|
16
89
|
chunkBatchSize: number;
|
|
17
90
|
validateRoundTrip: boolean;
|
|
@@ -203,20 +276,31 @@ interface StudySessionRecord {
|
|
|
203
276
|
item: StudySessionItem;
|
|
204
277
|
records: CardRecord[];
|
|
205
278
|
}
|
|
206
|
-
|
|
279
|
+
|
|
280
|
+
type SessionAction = 'dismiss-success' | 'dismiss-failed' | 'marked-failed' | 'dismiss-error';
|
|
281
|
+
interface ResponseResult {
|
|
282
|
+
nextCardAction: Exclude<SessionAction, 'dismiss-error'> | 'none';
|
|
283
|
+
shouldLoadNextCard: boolean;
|
|
284
|
+
isCorrect: boolean;
|
|
285
|
+
performanceScore?: number;
|
|
286
|
+
shouldClearFeedbackShadow: boolean;
|
|
287
|
+
}
|
|
288
|
+
interface SessionServices {
|
|
289
|
+
response: ResponseProcessor;
|
|
290
|
+
}
|
|
291
|
+
declare class SessionController<TView = unknown> extends Loggable {
|
|
207
292
|
_className: string;
|
|
293
|
+
services: SessionServices;
|
|
294
|
+
private srsService;
|
|
295
|
+
private eloService;
|
|
296
|
+
private hydrationService;
|
|
208
297
|
private sources;
|
|
209
298
|
private _sessionRecord;
|
|
210
299
|
set sessionRecord(r: StudySessionRecord[]);
|
|
300
|
+
private _currentCard;
|
|
211
301
|
private reviewQ;
|
|
212
302
|
private newQ;
|
|
213
303
|
private failedQ;
|
|
214
|
-
private _currentCard;
|
|
215
|
-
/**
|
|
216
|
-
* Indicates whether the session has been initialized - eg, the
|
|
217
|
-
* queues have been populated.
|
|
218
|
-
*/
|
|
219
|
-
private _isInitialized;
|
|
220
304
|
private startTime;
|
|
221
305
|
private endTime;
|
|
222
306
|
private _secondsRemaining;
|
|
@@ -227,7 +311,7 @@ declare class SessionController extends Loggable {
|
|
|
227
311
|
/**
|
|
228
312
|
*
|
|
229
313
|
*/
|
|
230
|
-
constructor(sources: StudyContentSource[], time: number);
|
|
314
|
+
constructor(sources: StudyContentSource[], time: number, dataLayer: DataLayerProvider, getViewComponent: (viewId: string) => TView);
|
|
231
315
|
private tick;
|
|
232
316
|
/**
|
|
233
317
|
* Returns a rough, erring toward conservative, guess at
|
|
@@ -249,9 +333,28 @@ declare class SessionController extends Loggable {
|
|
|
249
333
|
reportString(): string;
|
|
250
334
|
private getScheduledReviews;
|
|
251
335
|
private getNewCards;
|
|
252
|
-
private
|
|
253
|
-
nextCard(action?:
|
|
336
|
+
private _selectNextItemToHydrate;
|
|
337
|
+
nextCard(action?: SessionAction): Promise<HydratedCard<TView> | null>;
|
|
338
|
+
/**
|
|
339
|
+
* Public API for processing user responses to cards.
|
|
340
|
+
* @param cardRecord User's response record
|
|
341
|
+
* @param cardHistory Promise resolving to the card's history
|
|
342
|
+
* @param courseRegistrationDoc User's course registration document
|
|
343
|
+
* @param currentCard Current study session record
|
|
344
|
+
* @param courseId Course identifier
|
|
345
|
+
* @param cardId Card identifier
|
|
346
|
+
* @param maxAttemptsPerView Maximum attempts allowed per view
|
|
347
|
+
* @param maxSessionViews Maximum session views for this card
|
|
348
|
+
* @param sessionViews Current number of session views
|
|
349
|
+
* @returns ResponseResult with navigation and UI instructions
|
|
350
|
+
*/
|
|
351
|
+
submitResponse(cardRecord: CardRecord, cardHistory: Promise<CardHistory<CardRecord>>, courseRegistrationDoc: CourseRegistrationDoc, currentCard: StudySessionRecord, courseId: string, cardId: string, maxAttemptsPerView: number, maxSessionViews: number, sessionViews: number): Promise<ResponseResult>;
|
|
254
352
|
private dismissCurrentCard;
|
|
353
|
+
private hasAvailableCards;
|
|
354
|
+
/**
|
|
355
|
+
* Helper method for CardHydrationService to remove items from appropriate queue.
|
|
356
|
+
*/
|
|
357
|
+
private removeItemFromQueue;
|
|
255
358
|
}
|
|
256
359
|
|
|
257
360
|
interface CourseLookupDoc {
|
|
@@ -333,4 +436,4 @@ declare function getDataLayer(): DataLayerProvider;
|
|
|
333
436
|
*/
|
|
334
437
|
declare function _resetDataLayer(): Promise<void>;
|
|
335
438
|
|
|
336
|
-
export { type AggregatedDocument, type AttachmentUploadResult, CardRecord, CourseLookup, DEFAULT_MIGRATION_OPTIONS, type DataLayerConfig, DataLayerProvider, type DocumentCounts, ENV, FileSystemAdapter, Loggable, type MigrationOptions, type MigrationResult, NOT_SET, type RestoreProgress, SessionController, StaticCourseManifest, type StaticCourseValidation, StaticToCouchDBMigrator, StudyContentSource, StudySessionItem, type StudySessionRecord, type ValidationIssue, type ValidationResult, _resetDataLayer, ensureAppDataDirectory, getAppDataDirectory, getDataLayer, getDbPath, getLogFilePath, initializeDataDirectory, initializeDataLayer, initializeTuiLogging, logger, showUserError, showUserMessage, validateMigration, validateStaticCourse };
|
|
439
|
+
export { type AggregatedDocument, type AttachmentUploadResult, CardHistory, CardRecord, CourseLookup, CourseRegistrationDoc, DEFAULT_MIGRATION_OPTIONS, type DataLayerConfig, DataLayerProvider, type DocumentCounts, ENV, FileSystemAdapter, Loggable, type MigrationOptions, type MigrationResult, NOT_SET, type ResponseResult, type RestoreProgress, type SessionAction, SessionController, StaticCourseManifest, type StaticCourseValidation, StaticToCouchDBMigrator, StudyContentSource, StudySessionItem, type StudySessionRecord, UserDBInterface, type ValidationIssue, type ValidationResult, _resetDataLayer, ensureAppDataDirectory, getAppDataDirectory, getDataLayer, getDbPath, getLogFilePath, initializeDataDirectory, initializeDataLayer, initializeTuiLogging, logger, showUserError, showUserMessage, validateMigration, validateStaticCourse };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,90 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import { D as DataLayerProvider } from './dataLayerProvider-
|
|
4
|
-
import { C as CardRecord } from './types-legacy-
|
|
5
|
-
export {
|
|
1
|
+
import { U as UserDBInterface, r as CourseRegistrationDoc, k as StudySessionItem, i as StudyContentSource } from './userDB-CD6s6ZCp.js';
|
|
2
|
+
export { H as ActivityRecord, A as AdminDBInterface, u as AssignedCard, h as AssignedContent, t as AssignedCourse, s as AssignedTag, c as ClassroomDBInterface, E as ClassroomRegistration, B as ClassroomRegistrationDesignation, F as ClassroomRegistrationDoc, p as ContentSourceID, C as CourseDBInterface, d as CourseInfo, I as CourseRegistration, b as CoursesDBInterface, J as DocumentUpdater, g as ScheduledCard, j as StudentClassroomDBInterface, l as StudySessionFailedItem, m as StudySessionFailedNewItem, n as StudySessionFailedReviewItem, S as StudySessionNewItem, f as StudySessionReviewItem, T as TeacherClassroomDBInterface, G as UserConfig, y as UserCourseSetting, x as UserCourseSettings, w as UserDBAuthenticator, a as UserDBReader, v as UserDBWriter, z as UsrCrsDataInterface, q as getStudySource, o as isReview, K as newInterval } from './userDB-CD6s6ZCp.js';
|
|
3
|
+
import { D as DataLayerProvider } from './dataLayerProvider-DSdeyRT3.js';
|
|
4
|
+
import { C as CardHistory, c as CardRecord } from './types-legacy-6ettoclI.js';
|
|
5
|
+
export { d as CardData, e as CourseListData, g as DataShapeData, f as DisplayableData, D as DocType, b as DocTypePrefixes, F as Field, G as GuestUsername, Q as QualifiedCardID, h as QuestionData, i as QuestionRecord, S as SkuilderCourseData, a as Tag, T as TagStub, l as log } from './types-legacy-6ettoclI.js';
|
|
6
6
|
import { Loggable } from './core/index.js';
|
|
7
7
|
export { BulkCardProcessorConfig, ContentNavigator, ImportResult, Navigators, areQuestionRecords, docIsDeleted, getCardHistoryID, importParsedCards, isQuestionRecord, parseCardHistoryID, validateProcessorConfig } from './core/index.js';
|
|
8
|
-
import { S as StaticCourseManifest } from './types-
|
|
9
|
-
export { A as AttachmentData, C as ChunkMetadata, D as DesignDocument, I as IndexMetadata, a as PackedCourseData, P as PackerConfig } from './types-
|
|
10
|
-
import { F as FileSystemAdapter } from './index-
|
|
11
|
-
export { C as CouchDBToStaticPacker, a as FileStats, b as FileSystemError } from './index-
|
|
8
|
+
import { S as StaticCourseManifest } from './types-CewsN87z.js';
|
|
9
|
+
export { A as AttachmentData, C as ChunkMetadata, D as DesignDocument, I as IndexMetadata, a as PackedCourseData, P as PackerConfig } from './types-CewsN87z.js';
|
|
10
|
+
import { F as FileSystemAdapter } from './index-CD8BZz2k.js';
|
|
11
|
+
export { C as CouchDBToStaticPacker, a as FileStats, b as FileSystemError } from './index-CD8BZz2k.js';
|
|
12
12
|
import '@vue-skuilder/common';
|
|
13
13
|
import 'moment';
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Service responsible for ELO rating calculations and updates.
|
|
17
|
+
*/
|
|
18
|
+
declare class EloService {
|
|
19
|
+
private dataLayer;
|
|
20
|
+
private user;
|
|
21
|
+
constructor(dataLayer: DataLayerProvider, user: UserDBInterface);
|
|
22
|
+
/**
|
|
23
|
+
* Updates both user and card ELO ratings based on user performance.
|
|
24
|
+
* @param userScore Score between 0-1 representing user performance
|
|
25
|
+
* @param course_id Course identifier
|
|
26
|
+
* @param card_id Card identifier
|
|
27
|
+
* @param userCourseRegDoc User's course registration document (will be mutated)
|
|
28
|
+
* @param currentCard Current card session record
|
|
29
|
+
* @param k Optional K-factor for ELO calculation
|
|
30
|
+
*/
|
|
31
|
+
updateUserAndCardElo(userScore: number, course_id: string, card_id: string, userCourseRegDoc: CourseRegistrationDoc, currentCard: StudySessionRecord, k?: number): Promise<void>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Service responsible for Spaced Repetition System (SRS) scheduling logic.
|
|
36
|
+
*/
|
|
37
|
+
declare class SrsService {
|
|
38
|
+
private user;
|
|
39
|
+
constructor(user: UserDBInterface);
|
|
40
|
+
/**
|
|
41
|
+
* Calculates the next review time for a card based on its history and
|
|
42
|
+
* schedules it in the user's database.
|
|
43
|
+
* @param history The full history of the card.
|
|
44
|
+
* @param item The study session item, used to determine if a previous review needs to be cleared.
|
|
45
|
+
*/
|
|
46
|
+
scheduleReview(history: CardHistory<CardRecord>, item: StudySessionItem): Promise<void>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Service responsible for orchestrating the complete response processing workflow.
|
|
51
|
+
* Coordinates SRS scheduling and ELO updates for user card interactions.
|
|
52
|
+
*/
|
|
53
|
+
declare class ResponseProcessor {
|
|
54
|
+
private srsService;
|
|
55
|
+
private eloService;
|
|
56
|
+
constructor(srsService: SrsService, eloService: EloService);
|
|
57
|
+
/**
|
|
58
|
+
* Processes a user's response to a card, handling SRS scheduling and ELO updates.
|
|
59
|
+
* @param cardRecord User's response record
|
|
60
|
+
* @param cardHistory Promise resolving to the card's history
|
|
61
|
+
* @param studySessionItem Current study session item
|
|
62
|
+
* @param courseRegistrationDoc User's course registration (for ELO updates)
|
|
63
|
+
* @param currentCard Current study session record
|
|
64
|
+
* @param courseId Course identifier
|
|
65
|
+
* @param cardId Card identifier
|
|
66
|
+
* @param maxAttemptsPerView Maximum attempts allowed per view
|
|
67
|
+
* @param maxSessionViews Maximum session views for this card
|
|
68
|
+
* @param sessionViews Current number of session views
|
|
69
|
+
* @returns ResponseResult with navigation and UI instructions
|
|
70
|
+
*/
|
|
71
|
+
processResponse(cardRecord: CardRecord, cardHistory: Promise<CardHistory<CardRecord>>, studySessionItem: StudySessionItem, courseRegistrationDoc: CourseRegistrationDoc, currentCard: StudySessionRecord, courseId: string, cardId: string, maxAttemptsPerView: number, maxSessionViews: number, sessionViews: number): Promise<ResponseResult>;
|
|
72
|
+
/**
|
|
73
|
+
* Handles processing for correct responses: SRS scheduling and ELO updates.
|
|
74
|
+
*/
|
|
75
|
+
private processCorrectResponse;
|
|
76
|
+
/**
|
|
77
|
+
* Handles processing for incorrect responses: ELO updates only.
|
|
78
|
+
*/
|
|
79
|
+
private processIncorrectResponse;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
interface HydratedCard<TView = unknown> {
|
|
83
|
+
item: StudySessionItem;
|
|
84
|
+
view: TView;
|
|
85
|
+
data: any[];
|
|
86
|
+
}
|
|
87
|
+
|
|
15
88
|
interface MigrationOptions {
|
|
16
89
|
chunkBatchSize: number;
|
|
17
90
|
validateRoundTrip: boolean;
|
|
@@ -203,20 +276,31 @@ interface StudySessionRecord {
|
|
|
203
276
|
item: StudySessionItem;
|
|
204
277
|
records: CardRecord[];
|
|
205
278
|
}
|
|
206
|
-
|
|
279
|
+
|
|
280
|
+
type SessionAction = 'dismiss-success' | 'dismiss-failed' | 'marked-failed' | 'dismiss-error';
|
|
281
|
+
interface ResponseResult {
|
|
282
|
+
nextCardAction: Exclude<SessionAction, 'dismiss-error'> | 'none';
|
|
283
|
+
shouldLoadNextCard: boolean;
|
|
284
|
+
isCorrect: boolean;
|
|
285
|
+
performanceScore?: number;
|
|
286
|
+
shouldClearFeedbackShadow: boolean;
|
|
287
|
+
}
|
|
288
|
+
interface SessionServices {
|
|
289
|
+
response: ResponseProcessor;
|
|
290
|
+
}
|
|
291
|
+
declare class SessionController<TView = unknown> extends Loggable {
|
|
207
292
|
_className: string;
|
|
293
|
+
services: SessionServices;
|
|
294
|
+
private srsService;
|
|
295
|
+
private eloService;
|
|
296
|
+
private hydrationService;
|
|
208
297
|
private sources;
|
|
209
298
|
private _sessionRecord;
|
|
210
299
|
set sessionRecord(r: StudySessionRecord[]);
|
|
300
|
+
private _currentCard;
|
|
211
301
|
private reviewQ;
|
|
212
302
|
private newQ;
|
|
213
303
|
private failedQ;
|
|
214
|
-
private _currentCard;
|
|
215
|
-
/**
|
|
216
|
-
* Indicates whether the session has been initialized - eg, the
|
|
217
|
-
* queues have been populated.
|
|
218
|
-
*/
|
|
219
|
-
private _isInitialized;
|
|
220
304
|
private startTime;
|
|
221
305
|
private endTime;
|
|
222
306
|
private _secondsRemaining;
|
|
@@ -227,7 +311,7 @@ declare class SessionController extends Loggable {
|
|
|
227
311
|
/**
|
|
228
312
|
*
|
|
229
313
|
*/
|
|
230
|
-
constructor(sources: StudyContentSource[], time: number);
|
|
314
|
+
constructor(sources: StudyContentSource[], time: number, dataLayer: DataLayerProvider, getViewComponent: (viewId: string) => TView);
|
|
231
315
|
private tick;
|
|
232
316
|
/**
|
|
233
317
|
* Returns a rough, erring toward conservative, guess at
|
|
@@ -249,9 +333,28 @@ declare class SessionController extends Loggable {
|
|
|
249
333
|
reportString(): string;
|
|
250
334
|
private getScheduledReviews;
|
|
251
335
|
private getNewCards;
|
|
252
|
-
private
|
|
253
|
-
nextCard(action?:
|
|
336
|
+
private _selectNextItemToHydrate;
|
|
337
|
+
nextCard(action?: SessionAction): Promise<HydratedCard<TView> | null>;
|
|
338
|
+
/**
|
|
339
|
+
* Public API for processing user responses to cards.
|
|
340
|
+
* @param cardRecord User's response record
|
|
341
|
+
* @param cardHistory Promise resolving to the card's history
|
|
342
|
+
* @param courseRegistrationDoc User's course registration document
|
|
343
|
+
* @param currentCard Current study session record
|
|
344
|
+
* @param courseId Course identifier
|
|
345
|
+
* @param cardId Card identifier
|
|
346
|
+
* @param maxAttemptsPerView Maximum attempts allowed per view
|
|
347
|
+
* @param maxSessionViews Maximum session views for this card
|
|
348
|
+
* @param sessionViews Current number of session views
|
|
349
|
+
* @returns ResponseResult with navigation and UI instructions
|
|
350
|
+
*/
|
|
351
|
+
submitResponse(cardRecord: CardRecord, cardHistory: Promise<CardHistory<CardRecord>>, courseRegistrationDoc: CourseRegistrationDoc, currentCard: StudySessionRecord, courseId: string, cardId: string, maxAttemptsPerView: number, maxSessionViews: number, sessionViews: number): Promise<ResponseResult>;
|
|
254
352
|
private dismissCurrentCard;
|
|
353
|
+
private hasAvailableCards;
|
|
354
|
+
/**
|
|
355
|
+
* Helper method for CardHydrationService to remove items from appropriate queue.
|
|
356
|
+
*/
|
|
357
|
+
private removeItemFromQueue;
|
|
255
358
|
}
|
|
256
359
|
|
|
257
360
|
interface CourseLookupDoc {
|
|
@@ -333,4 +436,4 @@ declare function getDataLayer(): DataLayerProvider;
|
|
|
333
436
|
*/
|
|
334
437
|
declare function _resetDataLayer(): Promise<void>;
|
|
335
438
|
|
|
336
|
-
export { type AggregatedDocument, type AttachmentUploadResult, CardRecord, CourseLookup, DEFAULT_MIGRATION_OPTIONS, type DataLayerConfig, DataLayerProvider, type DocumentCounts, ENV, FileSystemAdapter, Loggable, type MigrationOptions, type MigrationResult, NOT_SET, type RestoreProgress, SessionController, StaticCourseManifest, type StaticCourseValidation, StaticToCouchDBMigrator, StudyContentSource, StudySessionItem, type StudySessionRecord, type ValidationIssue, type ValidationResult, _resetDataLayer, ensureAppDataDirectory, getAppDataDirectory, getDataLayer, getDbPath, getLogFilePath, initializeDataDirectory, initializeDataLayer, initializeTuiLogging, logger, showUserError, showUserMessage, validateMigration, validateStaticCourse };
|
|
439
|
+
export { type AggregatedDocument, type AttachmentUploadResult, CardHistory, CardRecord, CourseLookup, CourseRegistrationDoc, DEFAULT_MIGRATION_OPTIONS, type DataLayerConfig, DataLayerProvider, type DocumentCounts, ENV, FileSystemAdapter, Loggable, type MigrationOptions, type MigrationResult, NOT_SET, type ResponseResult, type RestoreProgress, type SessionAction, SessionController, StaticCourseManifest, type StaticCourseValidation, StaticToCouchDBMigrator, StudyContentSource, StudySessionItem, type StudySessionRecord, UserDBInterface, type ValidationIssue, type ValidationResult, _resetDataLayer, ensureAppDataDirectory, getAppDataDirectory, getDataLayer, getDbPath, getLogFilePath, initializeDataDirectory, initializeDataLayer, initializeTuiLogging, logger, showUserError, showUserMessage, validateMigration, validateStaticCourse };
|