Browse Source

Add Special Judge support

master
Menci 8 years ago
parent
commit
383cad25b0
  1. 12
      static/style.css
  2. 19
      utility.js
  3. 9
      views/judge_detail_item.ejs
  4. 5
      views/upload_testdata.ejs
  5. 4
      views/util.ejs

12
static/style.css

@ -79,6 +79,18 @@ th {
color: #6cf; color: #6cf;
} }
:not(.status_detail).status.partially_correct,
.title:hover .status_detail.status.partially_correct,
.title.active .status_detail.status.partially_correct {
color: #01bab2;
}
:not(.status_detail).status.judgement_failed,
.title:hover .status_detail.status.judgement_failed,
.title.active .status_detail.status.judgement_failed {
color: #78909C;
}
:not(.status_detail).status.compiling { :not(.status_detail).status.compiling {
color: #00b5ad; color: #00b5ad;
} }

19
utility.js

@ -144,20 +144,20 @@ module.exports = {
parseTestData(filename) { parseTestData(filename) {
let zip = new AdmZip(filename); let zip = new AdmZip(filename);
let list = zip.getEntries().filter(e => !e.isDirectory).map(e => e.entryName); let list = zip.getEntries().filter(e => !e.isDirectory).map(e => e.entryName);
let res = [];
if (!list.includes('data_rule.txt')) { if (!list.includes('data_rule.txt')) {
let testcases = [];
for (let file of list) { for (let file of list) {
let parsedName = path.parse(file); let parsedName = path.parse(file);
if (parsedName.ext === '.in') { if (parsedName.ext === '.in') {
if (list.includes(`${parsedName.name}.out`)) { if (list.includes(`${parsedName.name}.out`)) {
testcases.push({ res.push({
input: file, input: file,
output: `${parsedName.name}.out` output: `${parsedName.name}.out`
}); });
} }
if (list.includes(`${parsedName.name}.ans`)) { if (list.includes(`${parsedName.name}.ans`)) {
testcases.push({ res.push({
input: file, input: file,
output: `${parsedName.name}.ans` output: `${parsedName.name}.ans`
}); });
@ -165,7 +165,7 @@ module.exports = {
} }
} }
testcases.sort((a, b) => { res.sort((a, b) => {
function getLastInteger(s) { function getLastInteger(s) {
let re = /(\d+)\D*$/; let re = /(\d+)\D*$/;
let x = re.exec(s); let x = re.exec(s);
@ -175,9 +175,7 @@ module.exports = {
return getLastInteger(a.input) - getLastInteger(b.input); return getLastInteger(a.input) - getLastInteger(b.input);
}); });
} else {
return testcases;
}
let lines = zip.readAsText('data_rule.txt').split('\r').join('').split('\n'); let lines = zip.readAsText('data_rule.txt').split('\r').join('').split('\n');
if (lines.length < 3) throw 'Invalid data_rule.txt'; if (lines.length < 3) throw 'Invalid data_rule.txt';
@ -186,7 +184,6 @@ module.exports = {
let input = lines[1]; let input = lines[1];
let output = lines[2]; let output = lines[2];
let res = [];
for (let i of numbers) { for (let i of numbers) {
res[i] = {}; res[i] = {};
res[i].input = input.replace('#', i); res[i].input = input.replace('#', i);
@ -196,7 +193,11 @@ module.exports = {
if (!list.includes(res[i].output)) throw `Can't find file ${res[i].output}`; if (!list.includes(res[i].output)) throw `Can't find file ${res[i].output}`;
} }
return res.filter(x => x); res = res.filter(x => x);
}
res.spj = list.includes('spj.js');
return res;
}, },
ansiToHTML(s) { ansiToHTML(s) {
let Convert = require('ansi-to-html'); let Convert = require('ansi-to-html');

9
views/judge_detail_item.ejs

@ -69,8 +69,9 @@
<i class="<%= icon[getStatusMeta(testcase.status)] || 'remove' %> icon"></i> <i class="<%= icon[getStatusMeta(testcase.status)] || 'remove' %> icon"></i>
<%= testcase.status %></div> <%= testcase.status %></div>
<% if (!pending) { %> <% if (!pending) { %>
<div class="four wide column">用时:<span style="font-weight: normal; "><%= testcase.time_used %> ms</span></div> <div class="three wide column">得分:<span style="font-weight: normal; "><%= parseFloat((testcase.score / judge.result.case_num).toFixed(2)).toString() %></span></div>
<div class="four wide column">内存:<span style="font-weight: normal; "><%= testcase.memory_used %> KiB</span></div> <div class="three wide column">用时:<span style="font-weight: normal; "><%= testcase.time_used %> ms</span></div>
<div class="three wide column">内存:<span style="font-weight: normal; "><%= testcase.memory_used %> KiB</span></div>
<% } %> <% } %>
</div> </div>
</div> </div>
@ -83,6 +84,10 @@
<div class="ui existing segment"><pre style="margin-top: 0; margin-bottom: 0; "><code><%= testcase.answer %></code></pre></div> <div class="ui existing segment"><pre style="margin-top: 0; margin-bottom: 0; "><code><%= testcase.answer %></code></pre></div>
<strong>你的输出</strong> <strong>你的输出</strong>
<div class="ui existing segment"><pre style="margin-top: 0; margin-bottom: 0; "><code><%= testcase.user_out %></code></pre></div> <div class="ui existing segment"><pre style="margin-top: 0; margin-bottom: 0; "><code><%= testcase.user_out %></code></pre></div>
<% if (testcase.spj_message) { %>
<strong>Special Judge 信息</strong>
<div class="ui existing segment"><pre style="margin-top: 0; margin-bottom: 0; "><code><%= testcase.spj_message %></code></pre></div>
<% } %>
</p> </p>
<% } %> <% } %>
</div> </div>

5
views/upload_testdata.ejs

@ -10,6 +10,11 @@
try { try {
let list = syzoj.utils.parseTestData(problem.testdata.getPath()); let list = syzoj.utils.parseTestData(problem.testdata.getPath());
%> %>
<% if (list.spj) { %>
<p>评测方式:Special Judge</p>
<% } else { %>
<p>评测方式:文本比较</p>
<% } %>
<table class="ui very basic table"> <table class="ui very basic table">
<thead> <thead>
<tr> <tr>

4
views/util.ejs

@ -26,6 +26,8 @@ this.icon = {
'Compiling': 'spinner', 'Compiling': 'spinner',
'Compile Error': 'code', 'Compile Error': 'code',
'System Error': 'server', 'System Error': 'server',
'No Testdata': 'folder open outline' 'No Testdata': 'folder open outline',
'Partially Correct': 'minus',
'Judgement Failed': 'ban'
} }
%> %>

Loading…
Cancel
Save