diff --git a/app/Filament/Resources/User/ExamUserResource/Pages/ViewExamUser.php b/app/Filament/Resources/User/ExamUserResource/Pages/ViewExamUser.php index d3efc1726..6a21caa98 100644 --- a/app/Filament/Resources/User/ExamUserResource/Pages/ViewExamUser.php +++ b/app/Filament/Resources/User/ExamUserResource/Pages/ViewExamUser.php @@ -3,6 +3,7 @@ namespace App\Filament\Resources\User\ExamUserResource\Pages; use App\Filament\Resources\User\ExamUserResource; +use App\Models\Exam; use App\Repositories\ExamRepository; use Carbon\Carbon; use Filament\Pages\Actions; @@ -62,8 +63,12 @@ private function getDetailCardData(): array protected function getViewData(): array { + /** @var Exam $exam */ + $exam = $this->record->exam; return [ 'cardData' => $this->getDetailCardData(), + 'result_pass_trans_key' => $exam->getPassResultTransKey('pass'), + 'result_not_pass_trans_key' => $exam->getPassResultTransKey('not_pass'), ]; } diff --git a/app/Models/Exam.php b/app/Models/Exam.php index efe820cf5..8f7c0d3f6 100644 --- a/app/Models/Exam.php +++ b/app/Models/Exam.php @@ -275,6 +275,15 @@ public function getMessageContentTransKey(string $result): string }; } + public function getPassResultTransKey(string $result): string + { + return match ($this->type) { + self::TYPE_EXAM => "exam.result_{$result}_for_exam", + self::TYPE_TASK => "exam.result_{$result}_for_task", + default => throw new \RuntimeException("Invalid type: " . $this->type) + }; + } + public function isTypeExam(): bool { return $this->type == self::TYPE_EXAM; diff --git a/include/constants.php b/include/constants.php index e41a31505..a5e86bdd4 100644 --- a/include/constants.php +++ b/include/constants.php @@ -1,6 +1,6 @@ exam; $row = []; $row[] = sprintf('%s:%s', nexus_trans('exam.name'), $exam->name); @@ -26,7 +27,7 @@ public function render($uid) nexus_trans('exam.require_value'), $index['require_value_formatted'], nexus_trans('exam.current_value'), $index['current_value_formatted'], nexus_trans('exam.result'), - $index['passed'] ? nexus_trans('exam.result_pass') : nexus_trans('exam.result_not_pass') + $index['passed'] ? nexus_trans($exam->getPassResultTransKey("pass")) : nexus_trans($exam->getPassResultTransKey("not_pass")) ); } } diff --git a/resources/lang/en/exam.php b/resources/lang/en/exam.php index 5bca51832..f3523dd61 100644 --- a/resources/lang/en/exam.php +++ b/resources/lang/en/exam.php @@ -20,12 +20,21 @@ 'require_value' => 'Require', 'current_value' => 'Current', 'result' => 'Result', - 'result_pass' => 'Pass!', - 'result_not_pass' => 'Not pass!', - 'checkout_pass_message_subject' => 'Exam pass!', - 'checkout_pass_message_content' => 'Congratulation! You have complete the exam: :exam_name in time(:begin ~ :end)', - 'checkout_not_pass_message_subject' => 'Exam not pass, and account is banned!', - 'checkout_not_pass_message_content' => 'You did not complete the exam: :exam_name in time(:begin ~ :end), and your account has be banned!', + + 'result_pass_for_exam' => 'Passed!', + 'result_pass_for_task' => 'Completed!', + 'result_not_pass_for_exam' => 'Not Passed!', + 'result_not_pass_for_task' => 'Not Completed!', + 'checkout_pass_message_subject_for_exam' => 'Exam passed!', + 'checkout_pass_message_content_for_exam' => 'Congratulation! You have pass the exam: :exam_name in time(:begin ~ :end)', + 'checkout_not_pass_message_subject_for_exam' => 'Exam not pass, and account is banned!', + 'checkout_not_pass_message_content_for_exam' => 'You did not pass the exam: :exam_name in time(:begin ~ :end), and your account has be banned!', + + 'checkout_pass_message_subject_for_task' => 'Task completed!', + 'checkout_pass_message_content_for_task' => 'Congratulation! You have complete the task: :exam_name in time(:begin ~ :end), got bonus: :success_reward_bonus', + 'checkout_not_pass_message_subject_for_task' => 'Task not completed!', + 'checkout_not_pass_message_content_for_task' => 'You dit not complete the task: :exam_name in time (:begin ~ :end), deduct bonus: :fail_deduct_bonus.', + 'ban_log_reason' => 'Not complete exam: :exam_name in time(:begin ~ :end)', 'ban_user_modcomment' => 'Due to not complete exam: :exam_name(:begin ~ :end), ban by system.', 'admin' => [ diff --git a/resources/lang/zh_TW/exam.php b/resources/lang/zh_TW/exam.php index b43fb763b..c0b465b4a 100644 --- a/resources/lang/zh_TW/exam.php +++ b/resources/lang/zh_TW/exam.php @@ -20,12 +20,21 @@ 'require_value' => '要求', 'current_value' => '當前', 'result' => '結果', - 'result_pass' => '通過!', - 'result_not_pass' => '未通過!', - 'checkout_pass_message_subject' => '考核通過!', - 'checkout_pass_message_content' => '恭喜!你在規定時間內(:begin ~ :end)順利完成了考核::exam_name。', - 'checkout_not_pass_message_subject' => '考核未通過,賬號被禁用!', - 'checkout_not_pass_message_content' => '你在規定時間內(:begin ~ :end)未完成考核::exam_name,賬號已被禁用。', + + 'result_pass_for_exam' => '通過!', + 'result_pass_for_task' => '完成!', + 'result_not_pass_for_exam' => '未通過!', + 'result_not_pass_for_task' => '未完成!', + 'checkout_pass_message_subject_for_exam' => '考核通過!', + 'checkout_pass_message_content_for_exam' => '恭喜!你在規定時間內(:begin ~ :end)順利完成了考核::exam_name。', + 'checkout_not_pass_message_subject_for_exam' => '考核未通過,賬號被禁用!', + 'checkout_not_pass_message_content_for_exam' => '你在規定時間內(:begin ~ :end)未完成考核::exam_name,賬號已被禁用。', + + 'checkout_pass_message_subject_for_task' => '任務完成!', + 'checkout_pass_message_content_for_task' => '恭喜!你在規定時間內(:begin ~ :end)順利完成了任務::exam_name,獲得獎勵魔力::success_reward_bonus', + 'checkout_not_pass_message_subject_for_task' => '任務未完成!', + 'checkout_not_pass_message_content_for_task' => '你在規定時間內(:begin ~ :end)未完成任務::exam_name,扣除魔力::fail_deduct_bonus。', + 'ban_log_reason' => '未完成考核::exam_name(:begin ~ :end)', 'ban_user_modcomment' => '未完成考核: :exam_name(:begin ~ :end), 被系統禁用.', 'admin' => [ diff --git a/resources/views/filament/resources/user/exam-user-resource/pages/detail.blade.php b/resources/views/filament/resources/user/exam-user-resource/pages/detail.blade.php index 74a0649f4..83a092194 100644 --- a/resources/views/filament/resources/user/exam-user-resource/pages/detail.blade.php +++ b/resources/views/filament/resources/user/exam-user-resource/pages/detail.blade.php @@ -25,7 +25,7 @@ {{ $index['index_formatted'] }} {{ $index['require_value_formatted'] }} {{ $index['current_value_formatted'] }} - {{ $index['passed'] ? __('admin.resources.exam_user.result_passed') : __('admin.resources.exam_user.result_not_passed') }} + {!! $index['passed'] ? __($result_pass_trans_key) : __($result_not_pass_trans_key) !!} @endforeach