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:
@@ -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 || ''
|
||||
}))
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user