From 3118c60bed553d0c84af7b1256de126882df9e8e Mon Sep 17 00:00:00 2001 From: zjz1993 <1429595365@qq.com> Date: Fri, 26 Jul 2019 16:12:55 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=BC=96=E8=BE=91=E6=AF=94=E8=B5=9B?= =?UTF-8?q?=E9=80=89=E9=A2=98=E6=97=B6=E4=BA=A4=E4=BA=92=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/contest.js | 14 ++++- views/admin_classify.ejs | 2 + views/contest_edit.ejs | 129 +++++++++++++++++++++++++++++++++++--- views/header.ejs | 4 ++ views/problem_table.ejs | 130 +++++++++++++++++++++++++++++++++++++++ views/submissions.ejs | 3 - 6 files changed, 271 insertions(+), 11 deletions(-) create mode 100644 views/problem_table.ejs diff --git a/modules/contest.js b/modules/contest.js index 85c9ec9..656c772 100644 --- a/modules/contest.js +++ b/modules/contest.js @@ -53,6 +53,7 @@ app.get('/contest/:id/edit', async (req, res) => { res.render('contest_edit', { contest: contest, problems: problems, + contest_id, admins: admins }); } catch (e) { @@ -63,6 +64,17 @@ app.get('/contest/:id/edit', async (req, res) => { } }); +app.get('/api/contest/problem/:id', async (req, res) => { + try { + const id = req.params.id; + let contest = await Contest.findById(id); + let problems = await contest.problems.split('|').mapAsync(async id => await Problem.findById(id)); + res.send({ problems}); + } catch(e) { + res.send({ error_code: e.errno, error_msg: '失败' }); + } +}) + app.post('/contest/:id/edit', async (req, res) => { try { if (!res.locals.user || !res.locals.user.is_admin) throw new ErrorMessage('您没有权限进行此操作。'); @@ -96,7 +108,7 @@ app.post('/contest/:id/edit', async (req, res) => { if (!req.body.title.trim()) throw new ErrorMessage('比赛名不能为空。'); contest.title = req.body.title; contest.subtitle = req.body.subtitle; - if (!Array.isArray(req.body.problems)) req.body.problems = [req.body.problems]; + if (!Array.isArray(req.body.problems) && typeof req.body.problems==='string') req.body.problems = req.body.problems.split(','); if (!Array.isArray(req.body.admins)) req.body.admins = [req.body.admins]; contest.problems = req.body.problems.join('|'); contest.admins = req.body.admins.join('|'); diff --git a/views/admin_classify.ejs b/views/admin_classify.ejs index 6310d9b..1e40705 100644 --- a/views/admin_classify.ejs +++ b/views/admin_classify.ejs @@ -71,6 +71,7 @@ :total="problemCount"> + @@ -112,6 +113,7 @@ +<% include problem_table %> + + + + <% if (syzoj.config.google_analytics && syzoj.config.google_analytics !== 'UA-XXXXXXXX-X') { %> + + diff --git a/views/submissions.ejs b/views/submissions.ejs index 08fc7aa..c4bb7c8 100644 --- a/views/submissions.ejs +++ b/views/submissions.ejs @@ -6,9 +6,6 @@ font-size: 1.2em; margin-right: 1px; } - .padding{ - overflow-x: auto; - }