Fix quiz API URLs and verify exam flow
This commit is contained in:
1 parent
392ac642b0
commit
f042861fcd
1 file changed
+4
-4
@@ -44,21 +44,21 @@ export interface ExamResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function fetchActiveSubjects(): Promise<SubjectItem[]> {
|
export async function fetchActiveSubjects(): Promise<SubjectItem[]> {
|
||||||
const response = await axios.get<SubjectItem[]>('/api/subjects?page=0&size=100');
|
const response = await axios.get<SubjectItem[]>('api/subjects?page=0&size=100');
|
||||||
return response.data.filter(s => s.active);
|
return response.data.filter(s => s.active);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function startExam(subjectId: number): Promise<{ attemptId: number; startedAt: string }> {
|
export async function startExam(subjectId: number): Promise<{ attemptId: number; startedAt: string }> {
|
||||||
const response = await axios.post('/api/exam-attempts/start', { subjectId });
|
const response = await axios.post('api/exam-attempts/start', { subjectId });
|
||||||
return response.data;
|
return response.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function loadQuestions(attemptId: number): Promise<ExamQuestionView[]> {
|
export async function loadQuestions(attemptId: number): Promise<ExamQuestionView[]> {
|
||||||
const response = await axios.get<ExamQuestionView[]>(`/api/exam-attempts/${attemptId}/questions`);
|
const response = await axios.get<ExamQuestionView[]>(`api/exam-attempts/${attemptId}/questions`);
|
||||||
return response.data;
|
return response.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function submitExam(attemptId: number, answers: SubmitAnswer[]): Promise<ExamResult> {
|
export async function submitExam(attemptId: number, answers: SubmitAnswer[]): Promise<ExamResult> {
|
||||||
const response = await axios.post<ExamResult>(`/api/exam-attempts/${attemptId}/submit`, { answers });
|
const response = await axios.post<ExamResult>(`api/exam-attempts/${attemptId}/submit`, { answers });
|
||||||
return response.data;
|
return response.data;
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user