feat: implement QuestionBank CRUD with pagination and template query
- Add pagination support to findAll (page, limit query params) - Add findByTemplateId method to service - Add GET /by-template/:templateId endpoint to controller - Service already includes CRUD for QuestionBank and QuestionBankItem
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
import { apiClient } from './apiClient';
|
||||
|
||||
export interface AssessmentStats {
|
||||
totalAttempts: number;
|
||||
highestScore: number;
|
||||
averageScore: number;
|
||||
completionRate: number;
|
||||
recentRecords: {
|
||||
id: string;
|
||||
userId?: string;
|
||||
knowledgeBase: string;
|
||||
template: string;
|
||||
score: number | null;
|
||||
status: 'IN_PROGRESS' | 'COMPLETED';
|
||||
createdAt: string;
|
||||
user?: { id: string };
|
||||
}[];
|
||||
}
|
||||
|
||||
export interface StatsQueryParams {
|
||||
startDate?: string;
|
||||
endDate?: string;
|
||||
templateId?: string;
|
||||
knowledgeGroupId?: string;
|
||||
}
|
||||
|
||||
export class AssessmentStatsService {
|
||||
async getStats(params?: StatsQueryParams): Promise<AssessmentStats> {
|
||||
const query = new URLSearchParams();
|
||||
if (params?.startDate) query.set('startDate', params.startDate);
|
||||
if (params?.endDate) query.set('endDate', params.endDate);
|
||||
if (params?.templateId) query.set('templateId', params.templateId);
|
||||
if (params?.knowledgeGroupId) query.set('knowledgeGroupId', params.knowledgeGroupId);
|
||||
|
||||
const queryString = query.toString();
|
||||
const url = `/assessment/stats${queryString ? `?${queryString}` : ''}`;
|
||||
const { data } = await apiClient.get<AssessmentStats>(url);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
export const assessmentStatsService = new AssessmentStatsService();
|
||||
Reference in New Issue
Block a user