Initial commit: AuraK人才测评系统基础框架
## 已实现功能 - 题库管理后端API完整实现 - 模板管理页面(Settings-测评模板) - 评估统计页面 - 人才测评页面(AssessmentView) - QuestionBank前端服务层 ## 技术栈 - 后端: Node.js + NestJS + TypeORM - 前端: React + TypeScript - 容器化: Docker Compose ## 已知待完善 - 题库列表页缺少删除按钮 - 题库详情页未实现(题目管理/AI生成/审核)
This commit is contained in:
@@ -0,0 +1,142 @@
|
||||
import { apiClient } from './apiClient';
|
||||
|
||||
export interface QuestionBank {
|
||||
id: string;
|
||||
name: string;
|
||||
description?: string;
|
||||
status: 'DRAFT' | 'PENDING_REVIEW' | 'PUBLISHED' | 'REJECTED';
|
||||
templateId?: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface QuestionBankItem {
|
||||
id: string;
|
||||
bankId: string;
|
||||
questionText: string;
|
||||
questionType: 'SHORT_ANSWER' | 'MULTIPLE_CHOICE' | 'TRUE_FALSE';
|
||||
options?: string[] | null;
|
||||
correctAnswer?: string | null;
|
||||
keyPoints: string[];
|
||||
difficulty: 'STANDARD' | 'ADVANCED' | 'SPECIALIST';
|
||||
dimension: 'PROMPT' | 'LLM' | 'IDE' | 'DEV_PATTERN' | 'WORK_CAPABILITY';
|
||||
basis?: string | null;
|
||||
status: 'PENDING_REVIEW' | 'PUBLISHED';
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export interface CreateQuestionBankDto {
|
||||
name: string;
|
||||
description?: string;
|
||||
templateId?: string;
|
||||
}
|
||||
|
||||
export interface CreateQuestionBankItemDto {
|
||||
questionText: string;
|
||||
questionType: 'SHORT_ANSWER' | 'MULTIPLE_CHOICE' | 'TRUE_FALSE';
|
||||
options?: string[];
|
||||
correctAnswer?: string;
|
||||
keyPoints: string[];
|
||||
difficulty: 'STANDARD' | 'ADVANCED' | 'SPECIALIST';
|
||||
dimension: 'PROMPT' | 'LLM' | 'IDE' | 'DEV_PATTERN' | 'WORK_CAPABILITY';
|
||||
}
|
||||
|
||||
export const questionBankService = {
|
||||
async getBanks(): Promise<QuestionBank[]> {
|
||||
const response = await apiClient.request('/question-banks', {});
|
||||
if (!response.ok) throw new Error('Failed to fetch question banks');
|
||||
const data = await response.json();
|
||||
return Array.isArray(data) ? data : data.data || [];
|
||||
},
|
||||
|
||||
async getBank(id: string): Promise<QuestionBank> {
|
||||
const response = await apiClient.request(`/question-banks/${id}`, {});
|
||||
if (!response.ok) throw new Error('Failed to fetch question bank');
|
||||
return await response.json();
|
||||
},
|
||||
|
||||
async createBank(data: CreateQuestionBankDto): Promise<QuestionBank> {
|
||||
const response = await apiClient.post('/question-banks', data);
|
||||
if (!response.ok) throw new Error('Failed to create question bank');
|
||||
return response.data;
|
||||
},
|
||||
|
||||
async updateBank(id: string, data: Partial<CreateQuestionBankDto>): Promise<QuestionBank> {
|
||||
const response = await apiClient.request(`/question-banks/${id}`, {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
if (!response.ok) throw new Error('Failed to update question bank');
|
||||
return await response.json();
|
||||
},
|
||||
|
||||
async deleteBank(id: string): Promise<void> {
|
||||
const response = await apiClient.request(`/question-banks/${id}`, { method: 'DELETE' });
|
||||
if (!response.ok) throw new Error('Failed to delete question bank');
|
||||
},
|
||||
|
||||
async submitForReview(id: string): Promise<QuestionBank> {
|
||||
const response = await apiClient.request(`/question-banks/${id}/submit`, { method: 'PUT' });
|
||||
if (!response.ok) throw new Error('Failed to submit for review');
|
||||
return await response.json();
|
||||
},
|
||||
|
||||
async approveBank(id: string): Promise<QuestionBank> {
|
||||
const response = await apiClient.request(`/question-banks/${id}/review`, {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ approved: true }),
|
||||
});
|
||||
if (!response.ok) throw new Error('Failed to approve');
|
||||
return await response.json();
|
||||
},
|
||||
|
||||
async rejectBank(id: string): Promise<QuestionBank> {
|
||||
const response = await apiClient.request(`/question-banks/${id}/review`, {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ approved: false }),
|
||||
});
|
||||
if (!response.ok) throw new Error('Failed to reject');
|
||||
return await response.json();
|
||||
},
|
||||
|
||||
async publishBank(id: string): Promise<QuestionBank> {
|
||||
const response = await apiClient.request(`/question-banks/${id}/publish`, { method: 'PUT' });
|
||||
if (!response.ok) throw new Error('Failed to publish');
|
||||
return await response.json();
|
||||
},
|
||||
|
||||
async getBankItems(bankId: string): Promise<QuestionBankItem[]> {
|
||||
const response = await apiClient.request(`/question-banks/${bankId}`, {});
|
||||
if (!response.ok) throw new Error('Failed to fetch items');
|
||||
const data = await response.json();
|
||||
return data.items || [];
|
||||
},
|
||||
|
||||
async createItem(bankId: string, data: CreateQuestionBankItemDto): Promise<QuestionBankItem> {
|
||||
const response = await apiClient.request(`/question-banks/${bankId}/items`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
if (!response.ok) throw new Error('Failed to create item');
|
||||
return await response.json();
|
||||
},
|
||||
|
||||
async updateItem(bankId: string, itemId: string, data: Partial<CreateQuestionBankItemDto>): Promise<QuestionBankItem> {
|
||||
const response = await apiClient.request(`/question-banks/${bankId}/items/${itemId}`, {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
if (!response.ok) throw new Error('Failed to update item');
|
||||
return await response.json();
|
||||
},
|
||||
|
||||
async deleteItem(bankId: string, itemId: string): Promise<void> {
|
||||
const response = await apiClient.request(`/question-banks/${bankId}/items/${itemId}`, { method: 'DELETE' });
|
||||
if (!response.ok) throw new Error('Failed to delete item');
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user