feat: support composite practice questions

This commit is contained in:
Codex
2026-06-29 15:57:03 +08:00
parent 07a6edeea2
commit e54efbc294
14 changed files with 893 additions and 43 deletions

View File

@@ -28,6 +28,39 @@ export interface QuestionItem {
createdAt?: string;
}
export interface SubAnswerInput {
subQuestionId: string;
selectedOptions?: string[];
answerText?: string;
selfJudgedCorrect?: boolean;
}
export interface SubAnswerResult {
subQuestionId: string;
order?: number;
type?: string;
typeLabel?: string | null;
content?: string | null;
selectedOptions?: string[];
answerText?: string | null;
isCorrect?: boolean | null;
selfJudged?: boolean;
correctOptionIndex?: number | null;
correctOptionIndices?: number[];
correctAnswerText?: string | null;
explanation?: string | null;
answered?: boolean;
score?: number;
totalScore?: number;
}
export interface AnswerPayload {
mode?: string;
subAnswers?: SubAnswerInput[];
subResults?: SubAnswerResult[];
summary?: Record<string, unknown>;
}
export interface PracticeSession {
id: string;
mode: string;
@@ -57,8 +90,11 @@ export interface AnswerResult {
isCorrect: boolean | null;
selectedOptions?: string[];
answerText?: string | null;
answerPayload?: AnswerPayload;
answeredAt?: string;
selfJudged?: boolean;
subResults?: SubAnswerResult[];
compositeSummary?: Record<string, unknown>;
}
export interface PracticeReport {
@@ -153,6 +189,7 @@ export async function submitAnswer(body: {
selectedOptions?: string[];
answerText?: string;
selfJudgedCorrect?: boolean;
subAnswers?: SubAnswerInput[];
}) {
return apiRequest<{ item: AnswerResult }>('/api/learning/answers', {
method: 'POST',