feat(mobile): AI question generation panel in supervisor exam editor

Hints input + preset chips + count picker; generated questions land in
the existing editor blocks for the supervisor to review before publish.
This commit is contained in:
2026-07-20 10:16:40 +08:00
parent 4e9ccfa8b5
commit 7716f0040d
2 changed files with 68 additions and 2 deletions
+33 -1
View File
@@ -1,4 +1,4 @@
import type { ExamDetail, ExamResultItem, ExamSubmitResult, ExamSummary, SupervisorExamDraft } from '@/types/api';
import type { ExamDetail, ExamQuestion, ExamResultItem, ExamSubmitResult, ExamSummary, SupervisorExamDraft } from '@/types/api';
import { apiRequest } from './api';
type RawExamQuestion = {
@@ -149,3 +149,35 @@ export const getSupervisorExamResults = (id: number) =>
method: 'GET',
timeout: 15000
});
type RawAiGenerateResponse = {
questions: RawExamQuestion[];
groundedFragments?: number;
};
export const generateSupervisorExamQuestions = async (data: {
positionCode: string;
hints: string;
count: number;
formats: string[];
}): Promise<{ questions: ExamQuestion[]; groundedFragments: number }> => {
const response = await apiRequest<RawAiGenerateResponse>({
url: '/api/aihr/mobile/exams/supervisor/ai-generate',
method: 'POST',
data,
timeout: 60000
});
return {
groundedFragments: response.groundedFragments || 0,
questions: (response.questions || []).map((question, index) => ({
id: Date.now() + index,
format: question.questionType,
stem: question.stem,
options: question.options || [],
score: question.score,
answer: question.questionType === 'multiple' ? (question.correctAnswers || []) : (question.correctAnswers?.[0] || ''),
explanation: question.explanation || ''
}))
};
};