diff --git a/models/problem.js b/models/problem.js index 7386ea9..cc9b065 100644 --- a/models/problem.js +++ b/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; } diff --git a/modules/problem.js b/modules/problem.js index bdfc251..0f2e3d9 100644 --- a/modules/problem.js +++ b/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', { diff --git a/static/style.css b/static/style.css index 7f37cad..72fd771 100644 --- a/static/style.css +++ b/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; +} diff --git a/views/judge_detail.ejs b/views/judge_detail.ejs index 1c4dad4..97b720e 100644 --- a/views/judge_detail.ejs +++ b/views/judge_detail.ejs @@ -46,14 +46,17 @@
测试点 #<%= i + 1 %>
<% - 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' + } %> <%= testcase.status %>
diff --git a/views/judge_state.ejs b/views/judge_state.ejs index d55ce82..675cfde 100644 --- a/views/judge_state.ejs +++ b/views/judge_state.ejs @@ -36,6 +36,20 @@ <% if (!judge.hidden) { %> + <% + 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' + } + %> + <%= judge.status %> diff --git a/views/problem_set.ejs b/views/problem_set.ejs index 00c193f..899f3cf 100644 --- a/views/problem_set.ejs +++ b/views/problem_set.ejs @@ -7,7 +7,7 @@ 添加题目 - + @@ -27,10 +27,23 @@ <% if (user) { %> <% } %>
- <% if (problem.status === true) { %> - - <% } else if (problem.status === false) { %> - + <% 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' + } + %> + + + <% } %>