- 新增 ImportQuestionItem / ImportSuccessResult / ImportValidationError 类型,匹配 API 规范
- importQuestions 改用 API 规范的 stem: { text }、contentType、嵌套 knowledgeCard 结构
- 新增 importQuestionsCsv 函数,POST text/plain 到 /admin/questions/import-csv
- 重写 ImportQuestionsDialog:JSON/CSV 双模式 Tab 切换、预览、校验错误详情展示
65 lines
1.3 KiB
TypeScript
65 lines
1.3 KiB
TypeScript
export type QuestionStatus = "draft" | "reviewing" | "published" | "archived"
|
|
export type Difficulty = 1 | 2 | 3 | 4 | 5
|
|
|
|
export interface Question {
|
|
id: string
|
|
stem: string
|
|
correctAnswer: string
|
|
distractors: string[]
|
|
categoryId: string
|
|
difficulty: Difficulty
|
|
status: QuestionStatus
|
|
knowledgeCardBasic: string
|
|
knowledgeCardDeep?: string
|
|
sourceRef?: string
|
|
source: "system" | "ugc"
|
|
stats: {
|
|
timesAnswered: number
|
|
correctRate: number
|
|
avgTimeMs: number
|
|
}
|
|
createdAt: string
|
|
updatedAt: string
|
|
}
|
|
|
|
export interface QuestionFormData {
|
|
stem: string
|
|
correctAnswer: string
|
|
distractors: string[]
|
|
categoryId: string
|
|
difficulty: Difficulty
|
|
status: QuestionStatus
|
|
knowledgeCardBasic: string
|
|
knowledgeCardDeep?: string
|
|
sourceRef?: string
|
|
}
|
|
|
|
// ── Import API types (match duoqi-api spec) ──
|
|
|
|
export type QuestionContentType = "text" | "image" | "video" | "audio"
|
|
|
|
export interface ImportQuestionItem {
|
|
stem: { text: string }
|
|
contentType: QuestionContentType
|
|
correctAnswer: string
|
|
distractors: string[]
|
|
categoryId: string
|
|
difficulty?: number
|
|
knowledgeCard?: {
|
|
summary: string
|
|
deepDive?: string
|
|
sourceRef?: string
|
|
}
|
|
}
|
|
|
|
export interface ImportSuccessResult {
|
|
total: number
|
|
succeeded: number
|
|
ids: string[]
|
|
}
|
|
|
|
export interface ImportValidationError {
|
|
index: number
|
|
errors: string[]
|
|
}
|