refactor(contest/self_review): uoj_form_v2

This commit is contained in:
Baoshuo Ren 2023-02-01 20:30:39 +08:00
parent 382ac27d63
commit 948d44ba8d
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A

View File

@ -238,8 +238,8 @@ if ($cur_tab == 'dashboard') {
} }
} elseif ($cur_tab == 'self_reviews') { } elseif ($cur_tab == 'self_reviews') {
if (UOJContest::cur()->userHasMarkedParticipated(Auth::user())) { if (UOJContest::cur()->userHasMarkedParticipated(Auth::user())) {
$self_reviews_update_form = new UOJBs4Form('self_review_update'); $self_reviews_update_form = new UOJForm('self_review_update');
$self_reviews_update_form->ctrl_enter_submit = true; $self_reviews_update_form->config['ctrl_enter_submit'] = true;
$contest_problems = DB::selectAll([ $contest_problems = DB::selectAll([
"select problem_id", "select problem_id",
@ -261,20 +261,18 @@ if ($cur_tab == 'dashboard') {
"poster" => Auth::id(), "poster" => Auth::id(),
], ],
]); ]);
$self_reviews_update_form->addVTextArea( $self_reviews_update_form->addTextArea('self_review_update__problem_' . $contest_problems[$i]['problem']->getLetter(), [
'self_review_update__problem_' . $contest_problems[$i]['problem']->getLetter(), 'div_class' => 'mb-3',
'<b>' . $contest_problems[$i]['problem']->getLetter() . '</b>: ' . $contest_problems[$i]['problem']->info['title'], 'label' => '<b>' . $contest_problems[$i]['problem']->getLetter() . '</b>: ' . $contest_problems[$i]['problem']->info['title'],
$content, 'default_value' => $content,
function ($content) { 'validator_php' => function ($content) {
if (strlen($content) > 200) { if (strlen($content) > 200) {
return '总结不能超过200字'; return '总结不能超过200字';
} }
return ''; return '';
}, },
null, ]);
true
);
} }
$content = DB::selectSingle([ $content = DB::selectSingle([
@ -286,20 +284,17 @@ if ($cur_tab == 'dashboard') {
"poster" => Auth::id(), "poster" => Auth::id(),
], ],
]); ]);
$self_reviews_update_form->addVTextArea( $self_reviews_update_form->addTextArea('self_review_update__overall', [
'self_review_update__overall', 'label' => '比赛总结',
'比赛总结', 'default_value' => $content,
$content, 'validator_php' => function ($content) {
function ($content) {
if (strlen($content) > 200) { if (strlen($content) > 200) {
return '总结不能超过200字'; return '总结不能超过200字';
} }
return ''; return '';
}, },
null, ]);
true
);
$self_reviews_update_form->handle = function () use ($contest, $contest_problems) { $self_reviews_update_form->handle = function () use ($contest, $contest_problems) {
for ($i = 0; $i < count($contest_problems); $i++) { for ($i = 0; $i < count($contest_problems); $i++) {