Browse Source

Fix hidden judge state

pull/6/head
Menci 8 years ago
parent
commit
e03357c192
  1. 2
      models/judge_state.js
  2. 24
      modules/contest.js
  3. 66
      views/contest_submissions.ejs
  4. 4
      views/submission_content.ejs
  5. 6
      views/submissions_item.ejs

2
models/judge_state.js

@ -111,7 +111,7 @@ class JudgeState extends Model {
} else {
return true;
}
} else if (this.type === 2) return false;
} else if (this.type === 2) return true;
}
async isAllowedSeeCodeBy(user) {

24
modules/contest.js

@ -209,6 +209,8 @@ app.get('/contest/:id/submissions', async (req, res) => {
if (!contest) throw 'No such contest.';
contest.ended = await contest.isEnded();
let problems_id = await contest.getProblems();
let user = await User.fromName(req.query.submitter || '');
@ -218,6 +220,23 @@ app.get('/contest/:id/submissions', async (req, res) => {
where.type = 1;
where.type_info = contest_id;
if (contest.ended || (res.locals.user && res.locals.user.is_admin)) {
let minScore = parseInt(req.query.min_score);
if (isNaN(minScore)) minScore = 0;
let maxScore = parseInt(req.query.max_score);
if (isNaN(maxScore)) maxScore = 0;
where.score = {
$and: {
$gte: parseInt(minScore),
$lte: parseInt(maxScore)
}
};
if (req.query.language) where.language = req.query.language;
if (req.query.status) where.status = req.query.status;
}
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']]);
@ -233,10 +252,7 @@ app.get('/contest/:id/submissions', async (req, res) => {
contest: contest,
judge_state: judge_state,
paginate: paginate,
form: {
submitter: req.query.submitter || '',
problem_id: req.query.problem_id || ''
}
form: req.query
});
} catch (e) {
syzoj.log(e);

66
views/contest_submissions.ejs

@ -1,20 +1,66 @@
<% this.title = '提交记录 - ' + contest.title %>
<% include header %>
<div class="padding">
<div class="ui two column grid">
<div class="twelve wide column">
<form action="<%= syzoj.utils.makeUrl(['contest', contest.id, 'submissions']) %>" class="ui mini form" method="get" role="form">
<div class="inline field">
<input name="submitter" placeholder="提交者" style="margin: 0px;" type="text" value="<%= form.submitter %>"> <input name="problem_id" placeholder="题目编号" type="text" value="<%= form.problem_id %>"> <button class="ui mini button" type="submit">搜索</button>
<form action="<%= syzoj.utils.makeUrl(['contest', contest.id, 'submissions']) %>" class="ui mini form" method="get" role="form" id="form">
<div class="inline fields" style="margin-bottom: 25px; ">
<label style="font-size: 1.2em; margin-right: 3px; ">题目 ID:</label>
<div class="field"><input name="problem_id" style="width: 50px; " type="text" value="<%= form.problem_id %>"></div>
<label style="font-size: 1.2em; margin-right: 3px; ">提交者:</label>
<div class="field"><input name="submitter" style="width: 100px; " type="text" value="<%= form.submitter %>"></div>
<% if (contest.ended || (user && user.is_admin)) { %>
<label style="font-size: 1.2em; margin-right: 3px; ">分数:</label>
<div class="field" style="padding-right: 6px; "><input name="min_score" style="width: 45px; " type="text" value="<%= form.min_score || 0 %>"></div>
<label style="font-size: 1.2em; margin-right: 7px; ">~</label>
<div class="field"><input name="max_score" style="width: 45px; " type="text" value="<%= form.max_score || 100 %>"></div>
<label style="font-size: 1.2em; margin-right: 3px; ">语言:</label>
<div class="field">
<div class="ui fluid selection dropdown" id="select_language" style="width: 110px; ">
<input type="hidden" name="language" value="<%= form.language %>">
<i class="dropdown icon"></i>
<div class="default text"></div>
<div class="menu">
<div class="item" data-value="">不限</div>
<% for (let lang in syzoj.config.languages) { %>
<div class="item" data-value="<%= lang %>"><%= syzoj.config.languages[lang].show %></div>
<% } %>
</div>
</form>
</div>
<% if (user) { %>
<div class="four wide column padding">
<a class="ui mini button right floated" href="<%= syzoj.utils.makeUrl(['contest', contest.id, 'submissions'], { submitter: user.username }) %>">我的提交</a>
</div>
<label style="font-size: 1.2em; margin-right: 3px; ">状态:</label>
<div class="field">
<div class="ui fluid selection dropdown" id="select_status" style="width: 210px; ">
<input type="hidden" name="status" value="<%= form.status %>">
<i class="dropdown icon"></i>
<div class="default text"></div>
<div class="menu">
<div class="item" data-value="">不限<i class="dropdown icon" style="visibility: hidden; "></i></div>
<% for (let status in this.icon) { %>
<div class="item" data-value="<%= status %>"><span class="status <%= status.toLowerCase().split(' ').join('_') %>"><i class="<%= this.icon[status] %> icon"></i> <%= status %></div>
<% } %>
</div><br>
</div>
</div>
</div>
<% } %>
<button class="ui labeled icon mini button" type="submit">
<i class="search icon"></i>
搜索
</button>
<% if (user) { %>
<a class="ui mini labeled icon blue button" style="margin-left: auto; " id="my_submit">
<i class="user icon"></i>
我的提交
</a>
<script>
$(function () {
$('#my_submit').click(function () {
$('[name=submitter]').val(<%- JSON.stringify(user.username) %>);
$('#form').submit();
});
});
</script>
<% } %>
</div>
</form>
<table class="ui very basic center aligned table" style="white-space: nowrap; ">
<thead>
<tr>

4
views/submission_content.ejs

@ -55,7 +55,11 @@ else problemUrl = syzoj.utils.makeUrl(['problem', judge.problem_id]);
<td class="score score_<%= parseInt(judge.result.score / 10) || 0 %>"><%= judge.result.score %></td>
<td><%= judge.result.total_time %> ms</td>
<td><%= parseInt(judge.result.max_memory) || 0 %> K</td>
<% if (judge.allowedSeeCode) { %>
<td><%= syzoj.config.languages[judge.language].show %> / <%= syzoj.utils.formatSize(judge.codeLength) %></td>
<% } else { %>
<td><%= syzoj.config.languages[judge.language].show %> / 隐藏 %></td>
<% } %>
<% } else { %>
<td>隐藏</td>
<td>隐藏</td>

6
views/submissions_item.ejs

@ -16,7 +16,11 @@ else problemUrl = syzoj.utils.makeUrl(['problem', judge.problem_id]);
<td><a href="<%= syzoj.utils.makeUrl(['submission', judge.id]) %>"><span class="score score_<%= parseInt(judge.result.score / 10) || 0 %>"><%= judge.result.score %></span></a></td>
<td><%= judge.result.total_time %> ms</td>
<td><%= parseInt(judge.result.max_memory) || 0 %> K</td>
<td><a href="<%= syzoj.utils.makeUrl(['submission', judge.id]) %>"><%= syzoj.config.languages[judge.language].show %></a> / <%= syzoj.utils.formatSize(judge.code.length) %></td>
<% if (judge.allowedSeeCode) { %>
<td><a href="<%= syzoj.utils.makeUrl(['submission', judge.id]) %>"><%= syzoj.config.languages[judge.language].show %></a> / <%= syzoj.utils.formatSize(judge.code.length) %></td>
<% } else { %>
<td><a href="<%= syzoj.utils.makeUrl(['submission', judge.id]) %>"><%= syzoj.config.languages[judge.language].show %></a> / 隐藏</td>
<% } %>
<% } else { %>
<td>隐藏</td>
<td>隐藏</td>

Loading…
Cancel
Save