[ 'name' => '基本信息', 'url' => "/contest/{$contest['id']}/manage/profile", ], 'problems' => [ 'name' => '试题', 'url' => "/contest/{$contest['id']}/manage/problems", ], 'managers' => [ 'name' => '管理者', 'url' => "/contest/{$contest['id']}/manage/managers", ], 'others' => [ 'name' => '其他', 'url' => "/contest/{$contest['id']}/manage/others", ], ]; if (!isset($tabs_info[$cur_tab])) { become404Page(); } if ($cur_tab == 'profile') { $profile_form = new UOJForm('time'); $profile_form->addVInput( 'name', 'text', '比赛标题', $contest['name'], function($name, &$vdata) { if ($name == '') { return '标题不能为空'; } if (strlen($name) > 100) { return '标题过长'; } $name = HTML::escape($name); if ($name === '') { return '无效编码'; } $vdata['name'] = $name; return ''; }, null ); $profile_form->addVInput( 'start_time', 'text', '开始时间', $contest['start_time_str'], function($str, &$vdata) { try { $vdata['start_time'] = new DateTime($str); } catch (Exception $e) { return '无效时间格式'; } return ''; }, null ); $profile_form->addVInput( 'last_min', 'text', '时长(单位:分钟)', $contest['last_min'], function($str, &$vdata) { if (!validateUInt($str)) { return '必须为一个整数'; } $vdata['last_min'] = $str; return ''; }, null ); $profile_form->handle = function(&$vdata) use ($contest) { $start_time_str = $vdata['start_time']->format('Y-m-d H:i:s'); $esc_name = DB::escape($vdata['name']); $esc_last_min = DB::escape($vdata['last_min']); DB::update("update contests set start_time = '$start_time_str', last_min = {$_POST['last_min']}, name = '$esc_name' where id = {$contest['id']}"); dieWithJsonData(['status' => 'success', 'message' => '修改成功']); }; $profile_form->setAjaxSubmit(<<runAtServer(); } elseif ($cur_tab == 'problems') { if (isset($_POST['submit-remove_problem']) && $_POST['submit-remove_problem'] == 'remove_problem') { $problem_id = $_POST['problem_id']; if (!validateUInt($problem_id)) { dieWithAlert('无效的题目 ID。'); } if (!queryProblemBrief($problem_id)) { dieWithAlert('题目不存在。'); } if (!DB::selectFirst("SELECT * FROM contests_problems WHERE contest_id = {$contest['id']} AND problem_id = $problem_id")) { dieWithAlert('题目不在比赛中。'); } DB::delete("DELETE FROM contests_problems WHERE contest_id = {$contest['id']} AND problem_id = $problem_id"); unset($contest['extra_config']["problem_$problem_id"]); $esc_extra_config = DB::escape(json_encode($contest['extra_config'])); DB::update("UPDATE `contests` SET extra_config = '$esc_extra_config' WHERE id = {$contest['id']}"); dieWithAlert('移除成功!'); } $add_problem_form = new UOJForm('add_problem'); $add_problem_form->addVInput('problem_id', 'text', '题目 ID', '', function($problem_id, &$vdata) { if (!validateUInt($problem_id)) { return '无效的题目 ID。'; } $problem = queryProblemBrief($problem_id); if (!$problem) { return '题目不存在。'; } if (!hasProblemPermission(Auth::user(), $problem)) { return "无权添加题目 #$problem_id。"; } $vdata['problem_id'] = $problem_id; return ''; }, null ); $add_problem_form->addVSelect('judge_config', [ 'sample' => '只测样例', 'no-details' => '测试全部数据,但不显示测试点详情', 'full' => '测试全部数据', ], '评测设置', 'sample'); $add_problem_form->handle = function(&$vdata) use ($contest) { $dfn = DB::selectFirst("SELECT max(dfn) FROM contests_problems WHERE contest_id = {$contest['id']}")['max(dfn)'] + 1; DB::insert("INSERT INTO `contests_problems` (contest_id, problem_id, dfn) VALUES ({$contest['id']}, '{$vdata['problem_id']}', $dfn)"); if ($_POST['judge_config'] != 'sample') { $contest['extra_config']["problem_$problem_id"] = $_POST['judge_config']; $esc_extra_config = DB::escape(json_encode($contest['extra_config'])); DB::update("UPDATE `contests` SET extra_config = '$esc_extra_config' WHERE id = {$contest['id']}"); } dieWithJsonData(['status' => 'success', 'message' => "题目 #{$vdata['problem_id']} 添加成功!"]); }; $add_problem_form->submit_button_config['text'] = '添加'; $add_problem_form->submit_button_config['margin_class'] = 'mt-3'; $add_problem_form->setAjaxSubmit(<<runAtServer(); } elseif ($cur_tab == 'managers') { if (isset($_POST['submit-remove_manager']) && $_POST['submit-remove_manager'] == 'remove_manager') { $username = $_POST['username']; if (!validateUsername($username)) { dieWithAlert('用户名不合法。'); } if (!queryUser($username)) { dieWithAlert('用户不存在。'); } if (!DB::selectFirst("SELECT * FROM contests_permissions WHERE contest_id = {$contest['id']} AND username = '$username'")) { dieWithAlert('用户不是这场比赛的管理员。'); } DB::delete("DELETE FROM `contests_permissions` WHERE contest_id = ${contest['id']} AND username = '$username'"); dieWithAlert('移除成功!'); } $add_manager_form = new UOJForm('add_manager'); $add_manager_form->addVInput('username', 'text', '用户名', '', function($username, &$vdata) { if (!validateUsername($username)) { return '用户名不合法'; } if (!queryUser($username)) { return '用户不存在'; } if (DB::selectFirst("SELECT * FROM contests_permissions WHERE contest_id = {$contest['id']} AND username = '$username'")) { return '用户已经是这场比赛的管理员'; } $vdata['username'] = $username; return ''; }, null ); $add_manager_form->handle = function(&$vdata) use ($contest) { DB::query("INSERT INTO `contests_permissions` (contest_id, username) VALUES (${contest['id']}, '{$vdata['username']}')"); dieWithJsonData(['status' => 'success', 'message' => '已将用户名为 ' . $vdata['username'] . ' 的用户设置为本场比赛的管理者。']); }; $add_manager_form->submit_button_config['text'] = '添加'; $add_manager_form->submit_button_config['margin_class'] = 'mt-3'; $add_manager_form->setAjaxSubmit(<<runAtServer(); } elseif ($cur_tab == 'others') { $version_form = new UOJForm('version'); $version_form->addVSelect('standings_version', [ '1' => '1', '2' => '2', ], '比赛排名版本', $contest['extra_config']['standings_version']); $version_form->handle = function() use ($contest) { $contest['extra_config']['standings_version'] = $_POST['standings_version']; $esc_extra_config = json_encode($contest['extra_config']); $esc_extra_config = DB::escape($esc_extra_config); DB::update("UPDATE contests SET extra_config = '$esc_extra_config' WHERE id = {$contest['id']}"); dieWithJsonData(['status' => 'success', 'message' => '修改成功']); }; $version_form->setAjaxSubmit(<<runAtServer(); $contest_type_form = new UOJForm('contest_type'); $contest_type_form->addVSelect('contest_type', [ 'OI' => 'OI', 'IOI' => 'IOI' ], '比赛类型', $contest['extra_config']['contest_type']); $contest_type_form->handle = function() use ($contest) { $contest['extra_config']['contest_type'] = $_POST['contest_type']; $esc_extra_config = json_encode($contest['extra_config']); $esc_extra_config = DB::escape($esc_extra_config); DB::update("UPDATE contests set extra_config = '$esc_extra_config' where id = {$contest['id']}"); dieWithJsonData(['status' => 'success', 'message' => '修改成功']); }; $contest_type_form->setAjaxSubmit(<<runAtServer(); $blog_link_contests = new UOJForm('blog_link_contests'); $blog_link_contests->addVInput('blog_id', 'text', '博客 ID', '', function ($blog_id, &$vdata) { if (!validateUInt($blog_id)) { return 'ID 不合法'; } if (!queryBlog($blog_id)) { return '博客不存在'; } $vdata['blog_id'] = $blog_id; return ''; }, null ); $blog_link_contests->addVInput('title', 'text', '名称', '', function($title, &$vdata) { if ($title == '') { return '名称不能为空'; } if (strlen($title) > 40) { return '名称过长'; } $title = HTML::escape($title); if ($title === '') { return '无效编码'; } $vdata['title'] = $title; return ''; }, null ); $blog_link_contests->addVSelect('op_type', [ 'add' => '添加', 'del' => '移除', ], '操作类型', ''); $blog_link_contests->handle = function($vdata) use ($contest) { if ($_POST['op_type'] == 'add') { if (!isset($contest['extra_config']['links'])) { $contest['extra_config']['links'] = []; } $contest['extra_config']['links'][] = [$vdata['title'], $vdata['blog_id']]; } elseif ($_POST['op_type'] == 'del') { $n = count($contest['extra_config']['links']); for ($i = 0; $i < $n; $i++) { if ($contest['extra_config']['links'][$i][1] == $vdata['blog_id']) { $contest['extra_config']['links'][$i] = $contest['extra_config']['links'][$n - 1]; unset($contest['extra_config']['links'][$n - 1]); break; } } if (!count($contest['extra_config']['links'])) { unset($contest['extra_config']['links']); } } $esc_extra_config = json_encode($contest['extra_config']); $esc_extra_config = DB::escape($esc_extra_config); DB::update("UPDATE contests set extra_config = '$esc_extra_config' where id = {$contest['id']}"); dieWithJsonData(['status' => 'success', 'message' => '修改成功']); }; $blog_link_contests->setAjaxSubmit(<<runAtServer(); } ?>

(ID: ) 管理

printHTML(); ?>
注意事项
  • 请为选手预留合理的做题时间。一般而言,CSP 和 NOIP 的比赛时长为 4 小时,省选 / NOI 的比赛时长为 5 小时。
ID 标题 评测设置 操作 EOD, function($row) { $problem = queryProblemBrief($row['problem_id']); echo ''; echo '', $row['problem_id'], ''; echo '', getProblemLink($problem), ''; echo '', isset($contest['extra_config']["problem_{$problem['id']}"]) ? $contest['extra_config']["problem_{$problem['id']}"] : 'sample', ''; echo ''; echo '
'; echo ''; echo ''; echo ''; echo '
'; echo ''; echo ''; }, [ 'echo_full' => true, 'div_classes' => ['table-responsive'], 'table_classes' => ['table', 'align-middle'], ] ) ?>
printHTML() ?>
注意事项
  • 推荐在比赛结束前将题目设置为隐藏。
  • 对于「评测设置」选项,一般情况下保持默认(即只测样例)即可。
用户名 操作 EOD, function ($row) { echo ''; echo '', getUserLink($row['username']), ''; echo ''; echo '
'; echo ''; echo ''; echo ''; echo '
'; echo ''; echo ''; }, [ 'echo_full' => true, 'div_classes' => ['table-responsive'], 'table_classes' => ['table'], ] ); ?>
printHTML(); ?>
注意事项
  • 添加管理者前请确认用户名是否正确以免带来不必要的麻烦。
  • 比赛管理者如果报名了比赛仍可以正常参赛,但不报名比赛也可以查看并管理本场比赛。
printHTML(); ?>
注意事项
  • 目前 S2OJ 支持 OI 和 IOI 赛制。
printHTML(); ?>
注意事项
  • 正常情况下无需调整此项设置。
printHTML(); ?>
注意事项
  • 添加比赛资料前请确认博客是否处于公开状态。