import { Injectable } from '@nestjs/common'; import { generateShortId } from '../../common/utils/id.util'; export interface RecallQuestion { id: string; userId: string; knowledgeItemId: string; questionText: string; difficulty: string; } export interface RecallAnswer { id: string; userId: string; questionId: string; answerText: string; submittedAt: Date; } @Injectable() export class ActiveRecallRepository { private questions: Map = new Map(); private answers: RecallAnswer[] = []; async findByUserId(userId: string): Promise { return Array.from(this.questions.values()).filter((q) => q.userId === userId); } async findById(id: string): Promise { return this.questions.get(id); } async createQuestion(data: Partial): Promise { const q: RecallQuestion = { id: data.id || generateShortId(), userId: data.userId || '', knowledgeItemId: data.knowledgeItemId || '', questionText: data.questionText || '', difficulty: data.difficulty || 'normal', }; this.questions.set(q.id, q); return q; } async createAnswer(userId: string, questionId: string, body: any): Promise { const answer: RecallAnswer = { id: generateShortId(), userId, questionId, answerText: body.answerText || '', submittedAt: new Date(), }; this.answers.push(answer); return answer; } }