From ec8f271713f42b3fe82043279396ecd5ee8910fe Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Sat, 18 Feb 2023 09:19:21 +0800 Subject: [PATCH] refactor(submissions): new design --- web/app/controllers/problem.php | 8 +- web/app/controllers/submissions_list.php | 111 ++++++++++++++++++++-- web/app/models/Paginator.php | 2 +- web/app/models/UOJSubmission.php | 38 +++++++- web/app/models/UOJSubmissionLikeTrait.php | 19 +++- 5 files changed, 161 insertions(+), 17 deletions(-) diff --git a/web/app/controllers/problem.php b/web/app/controllers/problem.php index adb15a6..a4bd380 100644 --- a/web/app/controllers/problem.php +++ b/web/app/controllers/problem.php @@ -136,7 +136,13 @@ function handleUpload($zip_file_name, $content, $tot_size) { } } - UOJSubmission::onUpload($zip_file_name, $content, $tot_size, $is_participating); + $id = UOJSubmission::onUpload($zip_file_name, $content, $tot_size, $is_participating); + + if ($is_participating) { + // redirect by UOJForm + } else { + redirectTo("/submission/$id"); + } } function handleCustomTestUpload($zip_file_name, $content, $tot_size) { UOJCustomTestSubmission::onUpload($zip_file_name, $content, $tot_size); diff --git a/web/app/controllers/submissions_list.php b/web/app/controllers/submissions_list.php index 620cd5f..646a1a3 100644 --- a/web/app/controllers/submissions_list.php +++ b/web/app/controllers/submissions_list.php @@ -3,7 +3,9 @@ requirePHPLib('judger'); Auth::check() || redirectToLogin(); -$conds = []; +$conds = [ + UOJSubmission::sqlForUserCanView(Auth::user()), +]; $config = [ 'time_format' => 'friendly', 'time_font_size' => 'normal', @@ -44,6 +46,83 @@ if ($q_lang != null) { if (!$conds) { $conds = '1'; } + +function echoSubmissionItem($info) { + $submission = new UOJSubmission($info); + $submission->setProblem(); + $submitter = UOJUser::query($submission->info['submitter']); + $cfg = [ + 'show_actual_score' => $submission->viewerCanSeeScore(Auth::user()), + 'unknown_char' => '?', + 'result_badge' => true, + ]; + + echo '
'; + echo '
'; + + echo '
'; + echo '
'; + echo HTML::tag('a', [ + 'href' => HTML::url('/user/' . $submitter['username']), + 'class' => 'd-inline-block me-2', + ], HTML::empty_tag('img', [ + 'src' => HTML::avatar_addr($submitter, 64), + 'class' => 'uoj-user-avatar rounded', + 'style' => 'width: 2.5rem; height: 2.5rem;', + ])); + echo '
'; + echo '
'; + echo '
', UOJUser::getLink($submitter), '
'; + echo '
', ' ', UOJTime::userFriendlyFormat($submission->info['submit_time']), '
'; + echo '
'; + echo '
'; + + echo '
'; + echo '
', $submission->echoStatusBarTD('result', $cfg), '
'; + echo '
'; + + echo '
'; + echo $submission->problem->getLink(); + echo '
'; + + $lang = UOJLang::getLanguageDisplayName($submission->info['language']); + + echo '
'; + echo '', ' ', $submission->echoStatusBarTD('used_time', $cfg), '', ' / '; + echo '', ' ', $submission->echoStatusBarTD('used_memory', $cfg), '', ' / '; + echo '', ' ', $submission->echoStatusBarTD('tot_size', $cfg), ''; + if ($lang != '/') { + echo ' / ', $lang, ' '; + } + echo '
'; + + echo '
'; + echo '
'; +} + +$pag = new Paginator([ + 'page_len' => 10, + 'table_name' => 'submissions', + 'col_names' => [ + 'id', + 'problem_id', + 'contest_id', + 'submitter', + 'used_time', + 'used_memory', + 'tot_size', + 'language', + 'submit_time', + 'status_details', + 'status', + 'result_error', + 'score', + 'hide_score_to_others', + 'hidden_score', + ], + 'cond' => $conds, + 'tail' => 'order by id desc', +]); ?> @@ -55,13 +134,13 @@ if (!$conds) {