Browse Source

Add icons for judge status

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

17
models/problem.js

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

2
modules/problem.js

@ -31,7 +31,7 @@ app.get('/problem', async (req, res) => {
await problems.forEachAsync(async problem => { await problems.forEachAsync(async problem => {
problem.allowedEdit = await problem.isAllowedEditBy(res.locals.user); 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', { res.render('problem_set', {

16
static/style.css

@ -128,3 +128,19 @@ th {
color: rgba(0, 0, 0, 0.6); color: rgba(0, 0, 0, 0.6);
font-size: 0.85em; 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;
}

5
views/judge_detail.ejs

@ -52,7 +52,10 @@
'Runtime Error': 'bomb', 'Runtime Error': 'bomb',
'Time Limit Exceed': 'clock', 'Time Limit Exceed': 'clock',
'Memory Limit Exceed': 'disk outline', 'Memory Limit Exceed': 'disk outline',
'Output Limit Exceed': 'expand' 'Output Limit Exceed': 'expand',
'Waiting': 'spinner',
'Compile Error': 'code',
'System Error': 'server'
} }
%> %>
<i class="<%= icon[testcase.status] || 'remove' %> icon"></i> <i class="<%= icon[testcase.status] || 'remove' %> icon"></i>

14
views/judge_state.ejs

@ -36,6 +36,20 @@
<% if (!judge.hidden) { %> <% if (!judge.hidden) { %>
<td><a href="<%= syzoj.utils.makeUrl(['judge_detail', judge.id]) %>"> <td><a href="<%= syzoj.utils.makeUrl(['judge_detail', judge.id]) %>">
<span class="status <%= judge.status.toLowerCase().split(' ').join('_') %>"> <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 %> <%= judge.status %>
</span> </span>
</a></td> </a></td>

21
views/problem_set.ejs

@ -27,10 +27,23 @@
<tr> <tr>
<% if (user) { %> <% if (user) { %>
<td> <td>
<% if (problem.status === true) { %> <% if (problem.judge_state) { %>
<i class="checkmark icon"></i> <%
<% } else if (problem.status === false) { %> let icon = {
<i class="remove icon"></i> '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> </td>
<% } %> <% } %>

Loading…
Cancel
Save