diff --git a/src/utils/ai.detection.ts b/src/utils/ai.detection.ts index fe5e1788..56020fab 100644 --- a/src/utils/ai.detection.ts +++ b/src/utils/ai.detection.ts @@ -1,7 +1,7 @@ import { UserSolution } from "@/interfaces/exam"; export default function ai_usage(solutions: UserSolution[]): number { return solutions.reduce((max, solution) => { - if (solution.type == "writing") { + if (solution.type == "writing" && solution && solution.solutions[0] && solution.solutions[0].evaluation && solution.solutions[0].evaluation.ai_detection) { const aiUse = solution.solutions[0].evaluation?.ai_detection?.class_probabilities["ai"]; return aiUse !== undefined ? Math.max(max, aiUse) : max; } else {