From 496b87d0a4747a882ef74ce61f403aecc9dd1c94 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Fri, 17 Feb 2023 10:56:29 +0800 Subject: [PATCH 1/3] refactor(submission): two columns layout --- web/app/controllers/submission.php | 313 +++++++++++++++------- web/app/libs/uoj-html-lib.php | 8 +- web/app/models/UOJSubmission.php | 67 ++++- web/app/models/UOJSubmissionLikeTrait.php | 74 +++-- 4 files changed, 325 insertions(+), 137 deletions(-) diff --git a/web/app/controllers/submission.php b/web/app/controllers/submission.php index f89c9dc..57fb422 100644 --- a/web/app/controllers/submission.php +++ b/web/app/controllers/submission.php @@ -40,14 +40,14 @@ if ($can_see_minor) { $tid = DB::insert_id(); redirectTo(UOJSubmission::cur()->getUriForNewTID($tid)); }; - $minor_rejudge_form->config['submit_button']['class'] = 'btn btn-sm btn-primary'; + $minor_rejudge_form->config['submit_button']['class'] = 'list-group-item list-group-item-action border-start-0 border-end-0 list-group-item-secondary'; $minor_rejudge_form->config['submit_button']['text'] = '偷偷重新测试'; - $minor_rejudge_form->config['submit_container']['class'] = 'd-inline-block text-end'; + $minor_rejudge_form->config['submit_container']['class'] = ''; $minor_rejudge_form->runAtServer(); } if (UOJSubmission::cur()->isLatest()) { - if (UOJSubmission::cur()->preHackCheck()) { + if (UOJSubmission::cur()->preHackCheck() && ($perm['content'] || $perm['manager_view'])) { $hack_form = new UOJForm('hack'); $hack_form->addTextFileInput('input', ['filename' => 'input.txt']); $hack_form->addCheckBox('use_formatter', [ @@ -93,9 +93,9 @@ if (UOJSubmission::cur()->isLatest()) { $rejudge_form->handle = function () { UOJSubmission::rejudgeById(UOJSubmission::info('id')); }; - $rejudge_form->config['submit_button']['class'] = 'btn btn-sm btn-primary'; + $rejudge_form->config['submit_button']['class'] = 'list-group-item list-group-item-action border-start-0 border-end-0 list-group-item-secondary'; $rejudge_form->config['submit_button']['text'] = '重新测试'; - $rejudge_form->config['submit_container']['class'] = 'text-end d-inline-block'; + $rejudge_form->config['submit_container']['class'] = ''; $rejudge_form->runAtServer(); } @@ -104,10 +104,10 @@ if (UOJSubmission::cur()->isLatest()) { $delete_form->handle = function () { UOJSubmission::cur()->delete(); }; - $delete_form->config['submit_button']['class'] = 'btn btn-sm btn-danger'; + $delete_form->config['submit_button']['class'] = 'list-group-item list-group-item-action border-start-0 border-end-0 list-group-item-danger'; $delete_form->config['submit_button']['text'] = '删除此提交记录'; - $delete_form->config['submit_container']['class'] = 'text-end d-inline-block'; - $delete_form->config['confirm']['smart'] = true; + $delete_form->config['submit_container']['class'] = ''; + $delete_form->config['confirm']['text'] = '你真的要删除这条提交记录吗?'; $delete_form->succ_href = "/submissions"; $delete_form->runAtServer(); } @@ -117,126 +117,231 @@ if (UOJSubmission::cur()->isLatest()) { $delete_form->handle = function () { UOJSubmission::cur()->deleteThisMinorVersion(); }; - $delete_form->config['submit_button']['class'] = 'btn btn-sm btn-danger'; + $delete_form->config['submit_button']['class'] = 'list-group-item list-group-item-action border-start-0 border-end-0 list-group-item-danger'; $delete_form->config['submit_button']['text'] = '删除当前历史记录(保留其他历史记录)'; - $delete_form->config['submit_container']['class'] = 'text-end d-inline-block'; - $delete_form->config['confirm']['smart'] = true; + $delete_form->config['submit_container']['class'] = ''; + $delete_form->config['confirm']['text'] = '你真的要删除这条历史记录吗?删除这条历史记录不会影响其他的历史记录。'; $delete_form->succ_href = UOJSubmission::cur()->getUriForLatest(); $delete_form->runAtServer(); } } + +$tabs = []; + +if (UOJSubmission::cur()->hasJudged()) { + if ($perm['high_level_details']) { + $tabs['details'] = [ + 'name' => '详细信息', + 'card_body' => false, + 'displayer' => function () use ($perm, $submission_result) { + echo '
'; + $styler = new SubmissionDetailsStyler(); + if (!$perm['low_level_details']) { + $styler->fade_all_details = true; + $styler->show_small_tip = false; + } + echoJudgmentDetails($submission_result['details'], $styler, 'details'); + echo '
'; + } + ]; + + if ($perm['manager_view'] && !$perm['low_level_details']) { + $tabs['all-details'] = [ + 'name' => '详细信息(管理员)', + 'displayer' => function () use ($submission_result) { + echo '
'; + echoSubmissionDetails($submission_result['details'], 'all_details'); + echo '
'; + }, + 'card_body' => false, + ]; + } + } else if ($perm['manager_view']) { + $tabs['manager-details'] = [ + 'name' => '详细信息(管理员)', + 'displayer' => function () use ($submission_result) { + echo '
'; + echoSubmissionDetails($submission_result['details'], 'details'); + echo '
'; + }, + 'card_body' => false, + ]; + } else { + // TODO: 您当前无法查看详细信息 + } + + if ($perm['manager_view'] && isset($submission_result['final_result'])) { + $tabs['final-details'] = [ + 'name' => '终测结果预测(管理员)', + 'displayer' => function () use ($submission_result) { + echo '
'; + echoSubmissionDetails($submission_result['final_result']['details'], 'final_details'); + echo '
'; + }, + 'card_body' => false, + ]; + } +} else { + // TODO: move judge_status from UOJSubmission::echoStatusCard() to here +} + +if ($perm['content'] || $perm['manager_view']) { + $tabs['source'] = [ + 'name' => '源代码', + 'displayer' => function () { + echo '
'; + UOJSubmission::cur()->echoContent(['list_group' => true]); + echo '
'; + }, + 'card_body' => false, + ]; +} + +if ($perm['manager_view']) { + $tabs['judger'] = [ + 'name' => '测评机信息', + 'displayer' => function () { + if (empty(UOJSubmission::info('judger'))) { + echo '暂无'; + } else { + $judger = DB::selectFirst([ + "select * from judger_info", + "where", [ + "judger_name" => UOJSubmission::info('judger') + ] + ]); + if (!$judger) { + echo '测评机信息损坏'; + } else { + echo '', $judger['display_name'], ': ', $judger['description']; + } + } + }, + ]; +} + +if (isset($hack_form)) { + $tabs['hack'] = [ + 'name' => 'Hack!', + 'displayer' => function () use (&$hack_form) { + echo << + Hack 功能是给大家互相查错用的。请勿故意提交错误代码,然后自己 Hack 自己、贼喊捉贼哦(故意贼喊捉贼会予以封禁处理)。 + + EOD; + $hack_form->printHTML(); + }, + ]; +} ?> - - + + 'container-xxl', +]) ?>

-echoStatusTable(['show_actual_score' => $perm['score'], 'id_hidden' => true], Auth::user()) ?> + + +
+
+ echoStatusCard(['show_actual_score' => $perm['score'], 'id_hidden' => true], Auth::user()) ?>
- -

- 这程序好像有点 Bug,我给组数据试试? -

-