diff --git a/models/contest.js b/models/contest.js index 1edbbbc..21261ec 100644 --- a/models/contest.js +++ b/models/contest.js @@ -135,6 +135,11 @@ class Contest extends Model { return now >= this.start_time && now < this.end_time; } + async isEnded(now) { + if (!now) now = syzoj.utils.getCurrentDate(); + return now >= this.end_time; + } + getModel() { return model; } } diff --git a/modules/contest.js b/modules/contest.js index 1ca7ea7..62a04db 100644 --- a/modules/contest.js +++ b/modules/contest.js @@ -250,7 +250,9 @@ app.get('/contest/:id/:pid', async (req, res) => { try { let contest_id = parseInt(req.params.id); let contest = await Contest.fromID(contest_id); - if (!await contest.isRunning()) throw 'The contest has ended or not started.' + + contest.ended = await contest.isEnded(); + if (!(await contest.isRunning() || contest.ended)) throw 'The contest has not started.' let problems_id = await contest.getProblems(); diff --git a/views/problem.ejs b/views/problem.ejs index 75b581e..7a31548 100644 --- a/views/problem.ejs +++ b/views/problem.ejs @@ -45,11 +45,16 @@ if (contest) {