diff --git a/models/contest_ranklist.js b/models/contest_ranklist.js
index 7140066..d8ea6b6 100644
--- a/models/contest_ranklist.js
+++ b/models/contest_ranklist.js
@@ -69,7 +69,6 @@ class ContestRanklist extends Model {
for (let player of players) {
player.latest = 0;
for (let i in player.score_details) {
- console.log(player.score_details);
let judge_state = await JudgeState.fromID(player.score_details[i].judge_id);
player.latest = Math.max(player.latest, judge_state.submit_time);
}
diff --git a/modules/contest.js b/modules/contest.js
index 2284da0..eb74991 100644
--- a/modules/contest.js
+++ b/modules/contest.js
@@ -131,7 +131,7 @@ app.get('/contest/:id', async (req, res) => {
});
}
- problems = problems.map(x => ({ problem: x, status: null, judge_id: null }));
+ problems = problems.map(x => ({ problem: x, status: null, judge_id: null, statistics: null }));
if (player) {
for (let problem of problems) {
if (contest.type === 'noi') {
@@ -168,9 +168,38 @@ app.get('/contest/:id', async (req, res) => {
}
}
+ let hasStatistics = false;
+ if (contest.type === 'ioi' || contest.type === 'acm' || (contest.type === 'noi' && (contest.ended || (res.locals.user && res.locals.user.is_admin)))) {
+ hasStatistics = true;
+
+ await contest.loadRelationships();
+ let players = await contest.ranklist.getPlayers();
+ for (let problem of problems) {
+ problem.statistics = { attempt: 0, accepted: 0 };
+
+ if (contest.type === 'ioi' || contest.type === 'noi') {
+ problem.statistics.partially = 0;
+ }
+
+ for (let player of players) {
+ if (player.score_details[problem.problem.id]) {
+ problem.statistics.attempt++;
+ if ((contest.type === 'acm' && player.score_details[problem.problem.id].accepted) || ((contest.type === 'noi' || contest.type === 'ioi') && player.score_details[problem.problem.id].score === 100)) {
+ problem.statistics.accepted++;
+ }
+
+ if ((contest.type === 'noi' || contest.type === 'ioi') && player.score_details[problem.problem.id].score > 0) {
+ problem.statistics.partially++;
+ }
+ }
+ }
+ }
+ }
+
res.render('contest', {
contest: contest,
- problems: problems
+ problems: problems,
+ hasStatistics: hasStatistics
});
} catch (e) {
syzoj.log(e);
diff --git a/views/contest.ejs b/views/contest.ejs
index 04efaa7..aa6dfe1 100644
--- a/views/contest.ejs
+++ b/views/contest.ejs
@@ -49,7 +49,10 @@
状态
- 题目
+ 题目
+ <% if (hasStatistics) { %>
+ 统计
+ <% } %>