diff --git a/api/prisma/exam-environment.prisma b/api/prisma/exam-environment.prisma index 7419b14e50d..1d27c548842 100644 --- a/api/prisma/exam-environment.prisma +++ b/api/prisma/exam-environment.prisma @@ -14,7 +14,6 @@ model ExamEnvironmentExam { /// The default must be incremented by 1, if anything in the schema changes version Int @default(2) - // Relations generatedExams ExamEnvironmentGeneratedExam[] examAttempts ExamEnvironmentExamAttempt[] @@ -140,7 +139,6 @@ model ExamEnvironmentExamAttempt { /// The default must be incremented by 1, if anything in the schema changes version Int @default(2) - // Relations user user @relation(fields: [userId], references: [id], onDelete: Cascade) exam ExamEnvironmentExam @relation(fields: [examId], references: [id], onDelete: Cascade) @@ -180,7 +178,6 @@ model ExamEnvironmentGeneratedExam { /// The default must be incremented by 1, if anything in the schema changes version Int @default(1) - // Relations exam ExamEnvironmentExam @relation(fields: [examId], references: [id], onDelete: Cascade) EnvExamAttempt ExamEnvironmentExamAttempt[] @@ -208,7 +205,6 @@ model ExamEnvironmentChallenge { version Int @default(1) - exam ExamEnvironmentExam @relation(fields: [examId], references: [id], onDelete: Cascade) } @@ -220,7 +216,6 @@ model ExamEnvironmentAuthorizationToken { userId String @unique @db.ObjectId version Int @default(1) - // Relations user user @relation(fields: [userId], references: [id], onDelete: Cascade) } @@ -238,12 +233,11 @@ model ExamEnvironmentExamModeration { /// Foreign key to moderator. This is `null` until the item is moderated. moderatorId String? @db.ObjectId - /// Date the exam attempt was added to the moderation queue + /// Date the exam attempt expired submissionDate DateTime @default(now()) @db.Date /// Version of the record /// The default must be incremented by 1, if anything in the schema changes - version Int @default(1) - + version Int @default(2) // Relations examAttempt ExamEnvironmentExamAttempt @relation(fields: [examAttemptId], references: [id], onDelete: Cascade) diff --git a/api/src/exam-environment/routes/exam-environment.ts b/api/src/exam-environment/routes/exam-environment.ts index 327c78f8d1e..e22da6660ef 100644 --- a/api/src/exam-environment/routes/exam-environment.ts +++ b/api/src/exam-environment/routes/exam-environment.ts @@ -823,8 +823,17 @@ async function getExams( : exam.config.retakeTimeInMS; const retakeDateInMS = lastAttemptStartTime + examTotalTimeInMS + examRetakeTimeInMS; - const isRetakeTimePassed = Date.now() > retakeDateInMS; + const lastAttemptExpired = + Date.now() > lastAttemptStartTime + examTotalTimeInMS; + if (!lastAttemptExpired) { + logger.info(`Exam ${exam.id} in progress.`); + availableExam.canTake = true; + availableExams.push(availableExam); + continue; + } + + const isRetakeTimePassed = Date.now() > retakeDateInMS; if (!isRetakeTimePassed) { logger.info(`Time until retake: ${retakeDateInMS - Date.now()} [ms]`); availableExam.canTake = false;