From f323f96a6680a77a32592ed47f49fb6b8c9e8803 Mon Sep 17 00:00:00 2001 From: lgb <353856593@qq.com> Date: Thu, 9 May 2024 10:26:20 +0800 Subject: [PATCH 1/2] exam assign check if user normal --- app/Repositories/ExamRepository.php | 8 +++++++- include/constants.php | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/Repositories/ExamRepository.php b/app/Repositories/ExamRepository.php index 3f6b9768..9a471273 100644 --- a/app/Repositories/ExamRepository.php +++ b/app/Repositories/ExamRepository.php @@ -329,7 +329,13 @@ class ExamRepository extends BaseRepository return false; } - return true; + try { + $user->checkIsNormal(); + return true; + } catch (\Throwable $throwable) { + do_log("$logPrefix, user is not normal: " . $throwable->getMessage()); + return false; + } } diff --git a/include/constants.php b/include/constants.php index 40d2701c..e146f63c 100644 --- a/include/constants.php +++ b/include/constants.php @@ -1,6 +1,6 @@ Date: Fri, 10 May 2024 10:24:50 +0800 Subject: [PATCH 2/2] fix recurring exam assign --- app/Repositories/ExamRepository.php | 20 ++++++++++---------- include/constants.php | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/Repositories/ExamRepository.php b/app/Repositories/ExamRepository.php index 9a471273..c406b571 100644 --- a/app/Repositories/ExamRepository.php +++ b/app/Repositories/ExamRepository.php @@ -1112,6 +1112,16 @@ class ExamRepository extends BaseRepository do_log("$currentLogPrefix, [is_done]"); $subjectTransKey = 'exam.checkout_pass_message_subject'; $msgTransKey = 'exam.checkout_pass_message_content'; + if (!empty($exam->recurring) && $this->isExamMatchUser($exam, $examUser->user)) { + $examUserToInsert[] = [ + 'uid' => $examUser->user->id, + 'exam_id' => $exam->id, + 'begin' => $exam->getBeginForUser(), + 'end' => $exam->getEndForUser(), + 'created_at' => $now, + 'updated_at' => $now, + ]; + } } else { do_log("$currentLogPrefix, [will be banned]"); clear_user_cache($examUser->user->id, $examUser->user->passkey); @@ -1149,16 +1159,6 @@ class ExamRepository extends BaseRepository 'subject' => $subject, 'msg' => $msg ]; - if (!empty($exam->recurring) && $this->isExamMatchUser($exam, $examUser->user)) { - $examUserToInsert[] = [ - 'uid' => $examUser->user->id, - 'exam_id' => $exam->id, - 'begin' => $exam->getBeginForUser(), - 'end' => $exam->getEndForUser(), - 'created_at' => $now, - 'updated_at' => $now, - ]; - } } DB::transaction(function () use ($uidToDisable, $messageToSend, $examUserIdArr, $examUserToInsert, $userBanLog, $userModcommentUpdate, $userTable, $logPrefix) { ExamUser::query()->whereIn('id', $examUserIdArr)->update(['status' => ExamUser::STATUS_FINISHED]); diff --git a/include/constants.php b/include/constants.php index e146f63c..5c5515ca 100644 --- a/include/constants.php +++ b/include/constants.php @@ -1,6 +1,6 @@