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. 23
      views/problem_set.ejs

21
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'], user_id: user.id,
where: { problem_id: this.id
user_id: user.id, }, [['submit_time', 'desc']]);
problem_id: this.id
}
});
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;
}

19
views/judge_detail.ejs

@ -46,14 +46,17 @@
<div class="three wide column"><i class="dropdown icon"></i>测试点 #<%= i + 1 %></div> <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('_') %>"> <div class="four wide column status status_detail <%= testcase.status.toLowerCase().split(' ').join('_') %>">
<% <%
let icon = { let icon = {
'Accepted': 'checkmark', 'Accepted': 'checkmark',
'Wrong Answer': 'remove', 'Wrong Answer': 'remove',
'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>
<%= testcase.status %></div> <%= testcase.status %></div>

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>

23
views/problem_set.ejs

@ -7,7 +7,7 @@
<a href="<%= syzoj.utils.makeUrl(['problem', 0, 'edit']) %>" class="ui mini right floated button">添加题目</a> <a href="<%= syzoj.utils.makeUrl(['problem', 0, 'edit']) %>" class="ui mini right floated button">添加题目</a>
</div> </div>
</div> </div>
</div> </div>
<table class="ui very basic center aligned table"> <table class="ui very basic center aligned table">
<thead> <thead>
<tr> <tr>
@ -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