Browse Source

Allow see problem after contest end

master
Menci 8 years ago
parent
commit
b33d1cd49f
  1. 5
      models/contest.js
  2. 4
      modules/contest.js
  3. 17
      views/problem.ejs

5
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; }
}

4
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();

17
views/problem.ejs

@ -45,11 +45,16 @@ if (contest) {
<div class="row">
<div class="column">
<div class="ui buttons">
<a class="small ui primary button" href="#submit_code">提交</a>
<% if (contest) { %>
<% if (typeof contest !== 'undefined' && contest) { %>
<% if (!contest.ended) { %>
<a class="small ui primary button" href="#submit_code">提交</a>
<% } else { %>
<a class="small ui primary button" href="<%= syzoj.utils.makeUrl(['problem', problem.id]) %>">转到题库</a>
<% } %>
<a class="small ui positive button" href="<%= syzoj.utils.makeUrl(['contest', contest.id, 'submissions'], { problem_id: pid }) %>">提交记录</a>
<a href="<%= syzoj.utils.makeUrl(['contest', contest.id]) %>" class="ui orange button">返回比赛</a>
<% } else { %>
<a class="small ui primary button" href="#submit_code">提交</a>
<a class="small ui positive button" href="<%= syzoj.utils.makeUrl(['submissions'], { problem_id: problem.id }) %>">提交记录</a>
<a class="small ui orange button" href="<%= syzoj.utils.makeUrl(['problem', problem.id, 'statistics', 'fastest']) %>">统计</a>
<a class="small ui yellow button" href="<%= syzoj.utils.makeUrl(['problem', problem.id, 'download']) %>">下载测试数据</a>
@ -112,6 +117,13 @@ if (contest) {
</div>
</div>
<% } %>
<% let noSubmit = false; %>
<%
if (typeof contest !== 'undefined' && contest && contest.ended) {
noSubmit = true;
}
%>
<% if (!noSubmit) { %>
<div class="row">
<div class="column">
<%
@ -147,6 +159,7 @@ if (contest) {
</form>
</div>
</div>
<% } %>
</div>
<script src="https://cdn.bootcss.com/ace/1.2.6/ace.js"></script>

Loading…
Cancel
Save