mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-22 18:08:42 +00:00
refactor(contest): uoj_form_v2
This commit is contained in:
parent
e2c3a3eb4e
commit
9d66356566
@ -80,12 +80,10 @@ if (UOJContest::cur()->userCanStartFinalTest(Auth::user())) {
|
||||
|
||||
if ($cur_tab == 'dashboard') {
|
||||
if ($contest['cur_progress'] <= CONTEST_IN_PROGRESS) {
|
||||
$post_question = new UOJBs4Form('post_question');
|
||||
$post_question->addVTextArea(
|
||||
'qcontent',
|
||||
'问题',
|
||||
'',
|
||||
function ($content, &$vdata) {
|
||||
$post_question = new UOJForm('post_question');
|
||||
$post_question->addTextArea('qcontent', [
|
||||
'label' => '问题',
|
||||
'validator_php' => function ($content, &$vdata) {
|
||||
if (!Auth::check()) {
|
||||
return '您尚未登录';
|
||||
}
|
||||
@ -100,12 +98,11 @@ if ($cur_tab == 'dashboard') {
|
||||
|
||||
return '';
|
||||
},
|
||||
null
|
||||
);
|
||||
]);
|
||||
$post_question->handle = function (&$vdata) use ($contest) {
|
||||
DB::insert([
|
||||
"insert into contests_asks",
|
||||
"(contest_id, question, answer, username, post_time, is_hidden)",
|
||||
DB::bracketed_fields(["contest_id", "question", "answer", "username", "post_time", "is_hidden"]),
|
||||
"values", DB::tuple([$contest['id'], $vdata['content'], '', Auth::id(), DB::now(), 1])
|
||||
]);
|
||||
};
|
||||
@ -115,13 +112,11 @@ if ($cur_tab == 'dashboard') {
|
||||
}
|
||||
} elseif ($cur_tab == 'backstage') {
|
||||
if ($is_manager) {
|
||||
$post_notice = new UOJBs4Form('post_notice');
|
||||
$post_notice->addInput(
|
||||
'title',
|
||||
'text',
|
||||
'标题',
|
||||
'',
|
||||
function ($title, &$vdata) {
|
||||
$post_notice = new UOJForm('post_notice');
|
||||
$post_notice->addInput('title', [
|
||||
'div_class' => 'mb-3',
|
||||
'label' => '标题',
|
||||
'validator_php' => function ($title, &$vdata) {
|
||||
if (!$title) {
|
||||
return '标题不能为空';
|
||||
}
|
||||
@ -130,13 +125,10 @@ if ($cur_tab == 'dashboard') {
|
||||
|
||||
return '';
|
||||
},
|
||||
null
|
||||
);
|
||||
$post_notice->addTextArea(
|
||||
'content',
|
||||
'正文',
|
||||
'',
|
||||
function ($content, &$vdata) {
|
||||
]);
|
||||
$post_notice->addTextArea('content', [
|
||||
'label' => '正文',
|
||||
'validator_php' => function ($content, &$vdata) {
|
||||
if (!$content) {
|
||||
return '公告不能为空';
|
||||
}
|
||||
@ -145,8 +137,7 @@ if ($cur_tab == 'dashboard') {
|
||||
|
||||
return '';
|
||||
},
|
||||
null
|
||||
);
|
||||
]);
|
||||
$post_notice->handle = function (&$vdata) use ($contest) {
|
||||
DB::insert([
|
||||
"insert into contests_notice",
|
||||
@ -160,7 +151,7 @@ if ($cur_tab == 'dashboard') {
|
||||
}
|
||||
|
||||
if ($is_manager) {
|
||||
$reply_question = new UOJBs4Form('reply_question');
|
||||
$reply_question = new UOJForm('reply_question');
|
||||
$reply_question->addHidden(
|
||||
'rid',
|
||||
'0',
|
||||
@ -183,18 +174,21 @@ if ($cur_tab == 'dashboard') {
|
||||
},
|
||||
null
|
||||
);
|
||||
$reply_question->addVSelect('rtype', [
|
||||
'public' => '公开(如果该问题反复被不同人提出,或指出了题目中的错误,请选择该项)',
|
||||
'private' => '非公开',
|
||||
'statement' => '请仔细阅读题面(非公开)',
|
||||
'no_comment' => '无可奉告(非公开)',
|
||||
'no_play' => '请认真比赛(非公开)',
|
||||
], '回复类型', 'private');
|
||||
$reply_question->addVTextArea(
|
||||
'rcontent',
|
||||
'回复',
|
||||
'',
|
||||
function ($content, &$vdata) {
|
||||
$reply_question->addSelect('rtype', [
|
||||
'div_class' => 'mb-3',
|
||||
'label' => '回复类型',
|
||||
'default' => 'private',
|
||||
'options' => [
|
||||
'public' => '公开(如果该问题反复被不同人提出,或指出了题目中的错误,请选择该项)',
|
||||
'private' => '非公开',
|
||||
'statement' => '请仔细阅读题面(非公开)',
|
||||
'no_comment' => '无可奉告(非公开)',
|
||||
'no_play' => '请认真比赛(非公开)',
|
||||
],
|
||||
]);
|
||||
$reply_question->addTextArea('rcontent', [
|
||||
'label' => '回复',
|
||||
'validator_php' => function ($content, &$vdata) {
|
||||
if (!Auth::check()) {
|
||||
return '您尚未登录';
|
||||
}
|
||||
@ -209,9 +203,8 @@ if ($cur_tab == 'dashboard') {
|
||||
$vdata['content'] = HTML::escape($content);
|
||||
return '';
|
||||
},
|
||||
null
|
||||
);
|
||||
$reply_question->handle = function (&$vdata) use ($contest) {
|
||||
]);
|
||||
$reply_question->handle = function (&$vdata) {
|
||||
$content = $vdata['content'];
|
||||
$is_hidden = 1;
|
||||
switch ($_POST['rtype']) {
|
||||
|
@ -167,7 +167,7 @@ class UOJForm {
|
||||
$this->add($name, $html, $config['validator_php'], $config['validator_js']);
|
||||
}
|
||||
|
||||
public function addTextarea($name, $config) {
|
||||
public function addTextArea($name, $config) {
|
||||
$config += [
|
||||
'type' => 'text',
|
||||
'div_class' => '',
|
||||
|
Loading…
Reference in New Issue
Block a user