Browse Source

Optimize rejudge

master
Menci 7 years ago
parent
commit
9efa2dc3d0
  1. 2
      modules/submission.js
  2. 46
      views/submission_content.ejs

2
modules/submission.js

@ -244,7 +244,7 @@ app.post('/submission/:id/rejudge', async (req, res) => {
let id = parseInt(req.params.id); let id = parseInt(req.params.id);
let judge = await JudgeState.fromID(id); let judge = await JudgeState.fromID(id);
if (judge.pending && !req.query.force) throw new ErrorMessage('无法重新评测一个评测中的提交。'); if (judge.pending && !(res.locals.user && await res.locals.user.hasPrivilege('manage_problem'))) throw new ErrorMessage('无法重新评测一个评测中的提交。');
await judge.loadRelationships(); await judge.loadRelationships();

46
views/submission_content.ejs

@ -92,7 +92,38 @@ else problemUrl = syzoj.utils.makeUrl(['problem', judge.problem_id]);
<% if (judge.problem.type !== 'submit-answer' && judge.allowedSeeCode) { %> <% if (judge.problem.type !== 'submit-answer' && judge.allowedSeeCode) { %>
<div class="ui existing segment" style="position: relative; "> <div class="ui existing segment" style="position: relative; ">
<% if (judge.allowedRejudge) { %> <% if (judge.allowedRejudge) { %>
<a id="rejudge-button" href-post="<%= syzoj.utils.makeUrl(['submission', judge.id, 'rejudge']) %>" class="ui button" style="position: absolute; top: 0px; right: -4px; border-top-left-radius: 0; border-bottom-right-radius: 0; <% if (judge.pending) { %>display: none; <% } %>">重新评测</a> <a id="rejudge-button" class="ui button" style="position: absolute; top: 0px; right: -4px; border-top-left-radius: 0; border-bottom-right-radius: 0; " onclick="check_rejudge()">重新评测</a>
<div class="ui basic modal" id="modal-rejudge">
<div class="ui icon header">
<i class="retweet icon"></i>
<p style="margin-top: 15px; ">重新评测</p>
</div>
<div class="content" style="text-align: center; ">
<p>确认重新评测该提交记录吗?</p>
<p id="warning_pending"><strong>警告:只有管理员可以重新评测一个未评测完成的记录,<br>这种情况一般发生在评测服务中断后,如果一个提交正在被评测,<br>则将其重新评测会导致系统错乱!</strong></p>
<script>
var pending = <%= judge.pending %>;
function check_rejudge() {
if (pending) {
$('#warning_pending').css('display', '');
} else {
$('#warning_pending').css('display', 'none');
}
$('#modal-rejudge').modal('show');
}
</script>
</div>
<div class="actions">
<div class="ui red basic cancel inverted button">
<i class="remove icon"></i>
</div>
<a class="ui green ok inverted button" href-post="<%= syzoj.utils.makeUrl(['submission', judge.id, 'rejudge']) %>">
<i class="checkmark icon"></i>
</a>
</div>
</div>
<% } %> <% } %>
<pre style="margin-top: 0; margin-bottom: 0; "><code id="code"><%- judge.code %></code></pre> <pre style="margin-top: 0; margin-bottom: 0; "><code id="code"><%- judge.code %></code></pre>
</div> </div>
@ -196,7 +227,7 @@ $(function() {
}); });
</script> </script>
<% if (!isPending(judge.status)) { %><div><div id="stop_ajax"></div><div id="show_rejudge"></div></div><% } %> <% if (!isPending(judge.status)) { %><div><div id="not_pending"></div></div><% } %>
<script> <script>
<% if (isPending(judge.status)) { %> <% if (isPending(judge.status)) { %>
document.addEventListener('mousedown', function (event) { document.addEventListener('mousedown', function (event) {
@ -209,12 +240,6 @@ function update_submission() {
setTimeout(function () { setTimeout(function () {
$.get('/submission/<%= judge.id %>/ajax', function (data) { $.get('/submission/<%= judge.id %>/ajax', function (data) {
var e = $('#submission_content'), x = $($.parseHTML(data)); var e = $('#submission_content'), x = $($.parseHTML(data));
if (x.find('#show_rejudge').length) {
try {
document.getElementById('rejudge-button').style.display = '';
} catch (e) {}
}
if (e.find('td.status').text().trim() != x.find('td.status').text().trim()) { if (e.find('td.status').text().trim() != x.find('td.status').text().trim()) {
var a = e.find('div.auto_update'); var a = e.find('div.auto_update');
if (!a.length) { if (!a.length) {
@ -235,10 +260,11 @@ function update_submission() {
} }
window.applyTextFit(); window.applyTextFit();
if (!x.find('#stop_ajax').length) update_submission(); if (!x.find('#not_pending').length) update_submission();
else pending = false;
} }
} }
else if (!x.find('#stop_ajax').length) update_submission(); else if (!x.find('#not_pending').length) update_submission();
}); });
}, 500); }, 500);
} }

Loading…
Cancel
Save