Browse Source

Add icons for judge status

pull/6/head
Menci 8 years ago
parent
commit
1f4dcc0619
  1. 21
      models/problem.js
  2. 2
      modules/problem.js
  3. 16
      static/style.css
  4. 19
      views/judge_detail.ejs
  5. 14
      views/judge_state.ejs
  6. 21
      views/problem_set.ejs

21
models/problem.js

@ -129,26 +129,23 @@ class Problem extends Model {
this.testdata_id = file.id;
}
async getSubmitStatus(user) {
async getJudgeState(user) {
if (!user) return null;
let JudgeState = syzoj.model('judge_state');
let status = await JudgeState.model.findAll({
attributes: ['status'],
where: {
user_id: user.id,
problem_id: this.id
}
});
let states = await JudgeState.query(null, {
user_id: user.id,
problem_id: this.id
}, [['submit_time', 'desc']]);
if (!status || status.length === 0) return null;
if (!states || states.length === 0) return null;
for (let x of status) {
if (x.get('status') === 'Accepted') return true;
for (let x of states) {
if (x.status === 'Accepted') return x;
}
return false;
return states[0];
}
getModel() { return model; }

2
modules/problem.js

@ -31,7 +31,7 @@ app.get('/problem', async (req, res) => {
await problems.forEachAsync(async problem => {
problem.allowedEdit = await problem.isAllowedEditBy(res.locals.user);
problem.status = await problem.getSubmitStatus(res.locals.user);
problem.judge_state = await problem.getJudgeState(res.locals.user);
});
res.render('problem_set', {

16
static/style.css

@ -128,3 +128,19 @@ th {
color: rgba(0, 0, 0, 0.6);
font-size: 0.85em;
}
/* Animated spinner */
@keyframes spinner-icon-rotate {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
.spinner.icon {
animation: spinner-icon-rotate 3s linear infinite;
width: 16.52px;
height: 16.52px;
}

19
views/judge_detail.ejs

@ -46,14 +46,17 @@
<div class="three wide column"><i class="dropdown icon"></i>测试点 #<%= i + 1 %></div>
<div class="four wide column status status_detail <%= testcase.status.toLowerCase().split(' ').join('_') %>">
<%
let icon = {
'Accepted': 'checkmark',
'Wrong Answer': 'remove',
'Runtime Error': 'bomb',
'Time Limit Exceed': 'clock',
'Memory Limit Exceed': 'disk outline',
'Output Limit Exceed': 'expand'
}
let icon = {
'Accepted': 'checkmark',
'Wrong Answer': 'remove',
'Runtime Error': 'bomb',
'Time Limit Exceed': 'clock',
'Memory Limit Exceed': 'disk outline',
'Output Limit Exceed': 'expand',
'Waiting': 'spinner',
'Compile Error': 'code',
'System Error': 'server'
}
%>
<i class="<%= icon[testcase.status] || 'remove' %> icon"></i>
<%= testcase.status %></div>

14
views/judge_state.ejs

@ -36,6 +36,20 @@
<% if (!judge.hidden) { %>
<td><a href="<%= syzoj.utils.makeUrl(['judge_detail', judge.id]) %>">
<span class="status <%= judge.status.toLowerCase().split(' ').join('_') %>">
<%
let icon = {
'Accepted': 'checkmark',
'Wrong Answer': 'remove',
'Runtime Error': 'bomb',
'Time Limit Exceed': 'clock',
'Memory Limit Exceed': 'disk outline',
'Output Limit Exceed': 'expand',
'Waiting': 'spinner',
'Compile Error': 'code',
'System Error': 'server'
}
%>
<i class="<%= icon[judge.status] || 'remove' %> icon"></i>
<%= judge.status %>
</span>
</a></td>

21
views/problem_set.ejs

@ -27,10 +27,23 @@
<tr>
<% if (user) { %>
<td>
<% if (problem.status === true) { %>
<i class="checkmark icon"></i>
<% } else if (problem.status === false) { %>
<i class="remove icon"></i>
<% if (problem.judge_state) { %>
<%
let icon = {
'Accepted': 'checkmark',
'Wrong Answer': 'remove',
'Runtime Error': 'bomb',
'Time Limit Exceed': 'clock',
'Memory Limit Exceed': 'disk outline',
'Output Limit Exceed': 'expand',
'Waiting': 'spinner',
'Compile Error': 'code',
'System Error': 'server'
}
%>
<span class="status <%= problem.judge_state.status.toLowerCase().split(' ').join('_') %>">
<i class="<%= icon[problem.judge_state.status] || 'remove' %> icon"></i>
</span>
<% } %>
</td>
<% } %>

Loading…
Cancel
Save