From 7aa51e889a13fa43faba080d46204a1900ddb1a3 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Sun, 25 Sep 2022 10:44:33 +0800 Subject: [PATCH] refactor: hack detail page with bs5 --- web/app/controllers/hack.php | 28 +++++++- web/app/controllers/submission.php | 2 +- web/app/libs/uoj-html-lib.php | 102 +++++++++++++++++++++++++---- 3 files changed, 117 insertions(+), 15 deletions(-) diff --git a/web/app/controllers/hack.php b/web/app/controllers/hack.php index d152c68..a60cc87 100644 --- a/web/app/controllers/hack.php +++ b/web/app/controllers/hack.php @@ -12,6 +12,11 @@ if (!validateUInt($_GET['id']) || !($hack = queryHack($_GET['id']))) { become404Page(); } + + if (!isset($_COOKIE['bootstrap4'])) { + $REQUIRE_LIB['bootstrap5'] = ''; + } + $submission = querySubmission($hack['submission_id']); $problem = queryProblemBrief($submission['problem_id']); $problem_extra_config = getProblemExtraConfig($problem); @@ -62,17 +67,27 @@ } ?> - +

+ +

+ + ''), $myUser) ?> -
+

+
+ fade_all_details): ?> @@ -80,9 +95,16 @@ +
+
+ +

+ +

+ diff --git a/web/app/controllers/submission.php b/web/app/controllers/submission.php index 0038156..ed2e678 100644 --- a/web/app/controllers/submission.php +++ b/web/app/controllers/submission.php @@ -154,7 +154,7 @@ - + ''), $myUser) ?> diff --git a/web/app/libs/uoj-html-lib.php b/web/app/libs/uoj-html-lib.php index 3e56dcc..ea3664a 100644 --- a/web/app/libs/uoj-html-lib.php +++ b/web/app/libs/uoj-html-lib.php @@ -299,12 +299,28 @@ function echoSubmission($submission, $config, $user) { echo ''; if ($status == 'Judged') { if ($submission['score'] == null) { - echo '', $submission['result_error'], ''; + echo '', $submission['result_error'], ''; } else { echo '', $submission['score'], ''; } } else { - echo '', $status, ''; + echo '', $status, ''; } echo ''; } @@ -757,7 +773,13 @@ class JudgementDetailsPrinter { echo htmlspecialchars($test_info); echo '
'; } else { - echo '
'; + if (isset($REQUIRE_LIB['bootstrap5'])) { + echo '
'; + + echo $this->styler->getTestInfoIcon($test_info); + } else { + echo '
'; + } echo htmlspecialchars($test_info); echo '
'; } @@ -994,6 +1016,19 @@ class HackDetailsStyler { return 'card-uoj-wrong'; } } + public function getTestInfoIcon($test_info) { + if ($test_info == 'Accepted' || $test_info == 'Extra Test Passed') { + return ' '; + } elseif ($test_info == 'Time Limit Exceeded') { + return ' '; + } elseif ($test_info == 'Acceptable Answer') { + return ' '; + } elseif ($test_info == 'Wrong Answer') { + return ' '; + } else { + return ' '; + } + } public function shouldFadeDetails($info) { return $this->fade_all_details; } @@ -1008,6 +1043,8 @@ function echoCustomTestSubmissionDetails($submission_details, $name) { echoJudgementDetails($submission_details, new CustomTestSubmissionDetailsStyler(), $name); } function echoHackDetails($hack_details, $name) { + global $REQUIRE_LIB; + echoJudgementDetails($hack_details, new HackDetailsStyler(), $name); } @@ -1015,10 +1052,22 @@ function echoHack($hack, $config, $user) { $problem = queryProblemBrief($hack['problem_id']); echo ''; if (!isset($config['id_hidden'])) { - echo '#', $hack['id'], ''; + echo '#', $hack['id'], ''; } if (!isset($config['submission_hidden'])) { - echo '#', $hack['submission_id'], ''; + echo '#', $hack['submission_id'], ''; } if (!isset($config['problem_hidden'])) { if ($hack['contest_id']) { @@ -1035,13 +1084,37 @@ function echoHack($hack, $config, $user) { } if (!isset($config['result_hidden'])) { if ($hack['judge_time'] == null) { - echo 'Waiting'; + echo 'Waiting'; } elseif ($hack['success'] == null) { - echo 'Judging'; + echo 'Judging'; } elseif ($hack['success']) { - echo 'Success!'; + echo 'Success!'; } else { - echo 'Failed.'; + echo 'Failed.'; } } else { echo 'Hidden'; @@ -1055,8 +1128,15 @@ function echoHack($hack, $config, $user) { echo ''; } function echoHackListOnlyOne($hack, $config, $user) { - echo '
'; - echo ''; + global $REQUIRE_LIB; + + if (isset($REQUIRE_LIB['bootstrap5'])) { + echo '
'; + echo '
'; + } else { + echo '
'; + echo '
'; + } echo ''; echo ''; if (!isset($config['id_hidden'])) {