userCanManage(Auth::user()) || UOJResponse::page403(); $tabs_info = [ 'statement' => [ 'name' => '题面', 'url' => UOJProblem::cur()->getUri('/manage/statement'), ], 'permissions' => [ 'name' => '权限', 'url' => UOJProblem::cur()->getUri('/manage/permissions'), ], ]; if (UOJProblem::info('type') === 'local') { $tabs_info['data'] = [ 'name' => '数据', 'url' => UOJProblem::cur()->getUri('/manage/data'), ]; } else if (UOJProblem::info('type') === 'remote') { // } $problem_content = UOJProblem::cur()->queryContent(); $problem_editor = new UOJBlogEditor(); $problem_editor->name = 'problem'; $problem_editor->blog_url = '/problem/' . UOJProblem::info('id'); $problem_editor->cur_data = [ 'title' => UOJProblem::info('title'), 'content_md' => $problem_content['statement_md'], 'content' => $problem_content['statement'], 'tags' => UOJProblem::cur()->queryTags(), 'is_hidden' => UOJProblem::info('is_hidden') ]; $problem_editor->label_text = array_merge($problem_editor->label_text, [ 'view blog' => '查看题目', 'blog visibility' => '题目可见性' ]); $problem_editor->save = function ($data) { DB::update([ "update problems", "set", ["title" => $data['title']], "where", ["id" => UOJProblem::info('id')] ]); DB::update([ "update problems_contents", "set", [ "statement" => $data['content'], "statement_md" => $data['content_md'] ], "where", ["id" => UOJProblem::info('id')] ]); UOJProblem::cur()->updateTags($data['tags']); if ($data['is_hidden'] != UOJProblem::info('is_hidden')) { DB::update([ "update problems", "set", ["is_hidden" => $data['is_hidden']], "where", ["id" => UOJProblem::info('id')] ]); DB::update([ "update submissions", "set", ["is_hidden" => $data['is_hidden']], "where", ["problem_id" => UOJProblem::info('id')] ]); DB::update([ "update hacks", "set", ["is_hidden" => $data['is_hidden']], "where", ["problem_id" => UOJProblem::info('id')] ]); } }; $problem_editor->runAtServer(); $difficulty_form = new UOJForm('difficulty'); $difficulty_form->addSelect('difficulty', [ 'div_class' => 'flex-grow-1', 'options' => [-1 => '暂无评定'] + array_combine(UOJProblem::$difficulty, UOJProblem::$difficulty), 'default_value' => UOJProblem::info('difficulty'), ]); $difficulty_form->config['form']['class'] = 'd-flex'; $difficulty_form->config['submit_container']['class'] = 'ms-2'; $difficulty_form->handle = function () { DB::update([ "update problems", "set", [ "difficulty" => $_POST['difficulty'], ], "where", [ "id" => UOJProblem::info('id'), ], ]); }; $difficulty_form->runAtServer(); if (UOJProblem::info('type') == 'remote') { $remote_online_judge = UOJProblem::cur()->getExtraConfig('remote_online_judge'); $remote_problem_id = UOJProblem::cur()->getExtraConfig('remote_problem_id'); $remote_provider = UOJRemoteProblem::$providers[$remote_online_judge]; $re_crawl_form = new UOJForm('re_crawl'); $re_crawl_form->appendHTML(<<
  • 远程题库:{$remote_provider['name']}
  • 远程题号:{$remote_problem_id}
  • EOD); $re_crawl_form->config['submit_button']['text'] = '重新爬取'; $re_crawl_form->handle = function () use ($remote_online_judge, $remote_problem_id, $remote_provider) { try { $data = UOJRemoteProblem::getProblemBasicInfo($remote_online_judge, $remote_problem_id); } catch (Exception $e) { $data = null; UOJLog::error($e->getMessage()); } if ($data === null) { UOJResponse::page500('题目抓取失败,可能是题目不存在或者没有题面!如果题目没有问题,请稍后再试。返回'); } if ($data['difficulty'] == -1) { $data['difficulty'] = UOJProblem::info('difficulty'); } $submission_requirement = [ [ "name" => "answer", "type" => "source code", "file_name" => "answer.code", "languages" => $remote_provider['languages'], ] ]; $enc_submission_requirement = json_encode($submission_requirement); $extra_config = [ 'remote_online_judge' => $remote_online_judge, 'remote_problem_id' => $remote_problem_id, 'time_limit' => $data['time_limit'], 'memory_limit' => $data['memory_limit'], ]; $enc_extra_config = json_encode($extra_config); DB::update([ "update problems", "set", [ "title" => $data['title'], "submission_requirement" => $enc_submission_requirement, "extra_config" => $enc_extra_config, "difficulty" => $data['difficulty'] ?: -1, ], "where", [ "id" => UOJProblem::info('id'), ], ]); if ($data['type'] == 'pdf') { file_put_contents(UOJContext::storagePath() . "/problem_resources/" . UOJProblem::info('id') . "/statement.pdf", $data['pdf_data']); $data['statement'] = '
    ' . "\n" . $data['statement']; } DB::update([ "update problems_contents", "set", [ "remote_content" => HTML::purifier(['a' => ['target' => 'Enum#_blank']])->purify($data['statement']), ], "where", [ "id" => UOJProblem::info('id'), ], ]); UOJRemoteProblem::downloadImagesInRemoteContent(UOJProblem::info('id')); redirectTo(UOJProblem::cur()->getUri()); }; $re_crawl_form->runAtServer(); $convert_local_form = new UOJForm('convert_local'); $convert_local_form->handle = function () { DB::update([ "update problems", "set", [ "type" => 'local', "submission_requirement" => "{}", "extra_config" => "{}", ], "where", [ "id" => UOJProblem::info('id'), ], ]); DB::update([ "update problems_contents", "set", [ "remote_content" => '', ], "where", [ "id" => UOJProblem::info('id'), ], ]); }; $convert_local_form->config['submit_container']['class'] = ''; $convert_local_form->config['submit_button']['class'] = 'btn btn-danger'; $convert_local_form->config['submit_button']['text'] = '将本题转换为本地题目(不可逆)'; $convert_local_form->config['confirm']['text'] = '您真的要*不可逆*地将本题转换为本地题目吗?'; $convert_local_form->runAtServer(); } ?>

    getTitle(['with' => 'id']) ?> 管理

    printHTML() ?>

    提示

    1. 请勿引用不稳定的外部资源(如来自个人服务器的图片或文档等),可以上传至 题目资源 中,以便备份及后期维护;
    2. 请勿在题面中直接插入大段 HTML 代码,这可能会破坏页面的显示,可以考虑使用 转换工具 转换后再作修正;
    3. 图片上传推荐使用 S2OJ 图床,以免后续产生外链图片大量失效的情况。

    更多内容请查看 S2OJ 用户手册中的「传题指引」部分。