chore(release): sync frontend from monorepo v4
This commit is contained in:
42
src/hooks/queries/useGrading.ts
Normal file
42
src/hooks/queries/useGrading.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import { queryKeys } from "./keys";
|
||||
import { gradingService } from "@/services/grading.service";
|
||||
import type { GradeSubmission } from "@/types";
|
||||
|
||||
export function useGradingQueue(params?: { skill?: string; status?: string; exam_id?: number }) {
|
||||
return useQuery({
|
||||
queryKey: queryKeys.grading.queue(params),
|
||||
queryFn: () => gradingService.getQueue(params),
|
||||
});
|
||||
}
|
||||
|
||||
export function useStudentResponse(attemptId: number, skill: string) {
|
||||
return useQuery({
|
||||
queryKey: queryKeys.grading.response(attemptId, skill),
|
||||
queryFn: () => gradingService.getStudentResponse(attemptId, skill),
|
||||
enabled: !!attemptId,
|
||||
});
|
||||
}
|
||||
|
||||
export function useGradingRubric(attemptId: number, skill: string) {
|
||||
return useQuery({
|
||||
queryKey: queryKeys.grading.rubric(attemptId, skill),
|
||||
queryFn: () => gradingService.getRubric(attemptId, skill),
|
||||
enabled: !!attemptId,
|
||||
});
|
||||
}
|
||||
|
||||
export function useAIGradeSuggestion() {
|
||||
return useMutation({
|
||||
mutationFn: (data: { attemptId: number; skill: string }) =>
|
||||
gradingService.getAISuggestion(data.attemptId, data.skill),
|
||||
});
|
||||
}
|
||||
|
||||
export function useSubmitGrade() {
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: (data: GradeSubmission) => gradingService.submitGrade(data),
|
||||
onSuccess: () => qc.invalidateQueries({ queryKey: ["grading"] }),
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user