fix(api): update attempt with created moderation record (#64812)

This commit is contained in:
Shaun Hamilton
2026-02-04 12:19:28 +02:00
committed by GitHub
parent 455813545a
commit 5fa67063f5
@@ -687,7 +687,7 @@ async function postExamAttemptHandler(
: 'Unknown attempt validation error';
logger.warn({ validExamAttemptError: message }, 'Invalid exam attempt.');
// As attempt is invalid, create moderation record to investigate or update existing record
await this.prisma.examEnvironmentExamModeration.upsert({
const moderation = await this.prisma.examEnvironmentExamModeration.upsert({
where: { examAttemptId: latestAttempt.id },
create: {
examAttemptId: latestAttempt.id,
@@ -699,6 +699,17 @@ async function postExamAttemptHandler(
}
});
// Link attempt with moderation id if it has not already been done
await this.prisma.examEnvironmentExamAttempt.update({
where: {
id: latestAttempt.id,
examModerationId: null
},
data: {
examModerationId: moderation.id
}
});
void reply.code(400);
return reply.send(ERRORS.FCC_EINVAL_EXAM_ENVIRONMENT_EXAM_ATTEMPT(message));
}