diff --git a/modules/contest.js b/modules/contest.js index 242a270..1ca7ea7 100644 --- a/modules/contest.js +++ b/modules/contest.js @@ -202,6 +202,50 @@ app.get('/contest/:id/ranklist', async (req, res) => { } }); +app.get('/contest/:id/submissions', async (req, res) => { + try { + let contest_id = parseInt(req.params.id); + let contest = await Contest.fromID(contest_id); + + if (!contest) throw 'No such contest.'; + + let problems_id = await contest.getProblems(); + + let user = await User.fromName(req.query.submitter || ''); + let where = {}; + if (user) where.user_id = user.id; + if (req.query.problem_id) where.problem_id = problems_id[parseInt(req.query.problem_id) - 1]; + where.type = 1; + where.type_info = contest_id; + + let paginate = syzoj.utils.paginate(await JudgeState.count(where), req.query.page, syzoj.config.page.judge_state); + let judge_state = await JudgeState.query(paginate, where, [['submit_time', 'desc']]); + + await judge_state.forEachAsync(async obj => obj.hidden = !(await obj.isAllowedSeeResultBy(res.locals.user))); + await judge_state.forEachAsync(async obj => obj.allowedSeeCode = await obj.isAllowedSeeCodeBy(res.locals.user)); + await judge_state.forEachAsync(async obj => { + await obj.loadRelationships(); + obj.problem_id = problems_id.indexOf(obj.problem_id) + 1; + obj.problem.title = syzoj.utils.removeTitleTag(obj.problem.title); + }); + + res.render('contest_submissions', { + contest: contest, + judge_state: judge_state, + paginate: paginate, + form: { + submitter: req.query.submitter || '', + problem_id: req.query.problem_id || '' + } + }); + } catch (e) { + syzoj.log(e); + res.render('error', { + err: e + }); + } +}); + app.get('/contest/:id/:pid', async (req, res) => { try { let contest_id = parseInt(req.params.id); @@ -221,6 +265,7 @@ app.get('/contest/:id/:pid', async (req, res) => { let state = await problem.getJudgeState(res.locals.user, false); res.render('problem', { + pid: pid, contest: contest, problem: problem, state: state diff --git a/modules/submission.js b/modules/submission.js index 841352f..550a7ce 100644 --- a/modules/submission.js +++ b/modules/submission.js @@ -21,6 +21,7 @@ let JudgeState = syzoj.model('judge_state'); let User = syzoj.model('user'); +let Contest = syzoj.model('contest'); app.get('/submissions', async (req, res) => { try { @@ -28,6 +29,7 @@ app.get('/submissions', async (req, res) => { let where = {}; if (user) where.user_id = user.id; if (req.query.problem_id) where.problem_id = parseInt(req.query.problem_id); + where.type = { $ne: 1 }; let paginate = syzoj.utils.paginate(await JudgeState.count(where), req.query.page, syzoj.config.page.judge_state); let judge_state = await JudgeState.query(paginate, where, [['submit_time', 'desc']]); @@ -78,6 +80,9 @@ app.get('/submission/:id', async (req, res) => { let id = parseInt(req.params.id); let judge = await JudgeState.fromID(id); + let contest; + if (judge.type === 1) contest = await Contest.fromID(judge.type_info); + await judge.loadRelationships(); judge.codeLength = judge.code.length; @@ -87,7 +92,14 @@ app.get('/submission/:id', async (req, res) => { judge.allowedSeeCode = await judge.isAllowedSeeCodeBy(res.locals.user); judge.allowedRejudge = await judge.problem.isAllowedEditBy(res.locals.user); + if (contest) { + let problems_id = await contest.getProblems(); + judge.problem_id = problems_id.indexOf(judge.problem_id) + 1; + judge.problem.title = syzoj.utils.removeTitleTag(judge.problem.title); + } + res.render('submission', { + contest: contest, judge: judge }); } catch (e) { @@ -103,6 +115,9 @@ app.get('/submission/:id/ajax', async (req, res) => { let id = parseInt(req.params.id); let judge = await JudgeState.fromID(id); + let contest; + if (judge.type === 1) contest = await Contest.fromID(judge.type_info); + await judge.loadRelationships(); judge.codeLength = judge.code.length; @@ -112,7 +127,14 @@ app.get('/submission/:id/ajax', async (req, res) => { judge.allowedSeeCode = await judge.isAllowedSeeCodeBy(res.locals.user); judge.allowedRejudge = await judge.problem.isAllowedEditBy(res.locals.user); + if (contest) { + let problems_id = await contest.getProblems(); + judge.problem_id = problems_id.indexOf(judge.problem_id) + 1; + judge.problem.title = syzoj.utils.removeTitleTag(judge.problem.title); + } + res.render('submission_content', { + contest: contest, judge: judge }); } catch (e) { diff --git a/views/contest.ejs b/views/contest.ejs index 55f9815..6faabe1 100644 --- a/views/contest.ejs +++ b/views/contest.ejs @@ -24,10 +24,11 @@
- 排行榜 - <% if (contest.allowedEdit) { %> - 编辑比赛 - <% } %> + 排行榜 + 提交记录 + <% if (contest.allowedEdit) { %> + 编辑比赛 + <% } %>
diff --git a/views/contest_submissions.ejs b/views/contest_submissions.ejs new file mode 100644 index 0000000..a8b1655 --- /dev/null +++ b/views/contest_submissions.ejs @@ -0,0 +1,41 @@ +<% this.title = '提交记录 - ' + contest.title %> +<% include header %> +
+
+
+
+
+ +
+
+
+ <% if (user) { %> + + <% } %> +

+ + + + + + + + + + + + + + + + <% for (let judge of judge_state) { %> + <% include submissions_item %> + <% } %> + +
编号题目状态分数总时间内存代码提交者提交时间
+
+ <% include page %> +
+<% include footer %> diff --git a/views/problem.ejs b/views/problem.ejs index af03886..75b581e 100644 --- a/views/problem.ejs +++ b/views/problem.ejs @@ -47,7 +47,8 @@ if (contest) {
提交 <% if (contest) { %> - 返回比赛 + 提交记录 + 返回比赛 <% } else { %> 提交记录 统计 diff --git a/views/submission_content.ejs b/views/submission_content.ejs index 9477ce4..6ca08f3 100644 --- a/views/submission_content.ejs +++ b/views/submission_content.ejs @@ -22,6 +22,12 @@ for (let s of judge.result.subtasks) { } %> +<% +let problemUrl; +if (typeof contest !== 'undefined') problemUrl = syzoj.utils.makeUrl(['contest', contest.id, judge.problem_id]); +else problemUrl = syzoj.utils.makeUrl(['problem', judge.problem_id]); +%> +
@@ -40,7 +46,7 @@ for (let s of judge.result.subtasks) { - + <% if (judge.allowedSeeResult) { %> - + <% if (!judge.hidden) { %>
#<%= judge.id %>#<%= judge.problem_id %>. <%= judge.problem.title %>#<%= judge.problem_id %>. <%= judge.problem.title %> diff --git a/views/submissions_item.ejs b/views/submissions_item.ejs index 26cd510..4ce9eed 100644 --- a/views/submissions_item.ejs +++ b/views/submissions_item.ejs @@ -1,6 +1,11 @@ <% include util %> +<% +let problemUrl; +if (typeof contest !== 'undefined' && contest) problemUrl = syzoj.utils.makeUrl(['contest', contest.id, judge.problem_id]); +else problemUrl = syzoj.utils.makeUrl(['problem', judge.problem_id]); +%> #<%= judge.id %>#<%= judge.problem_id %>. <%= judge.problem.title %>#<%= judge.problem_id %>. <%= judge.problem.title %> @@ -25,7 +30,12 @@