Browse Source

Optimize UI

master
Menci 7 years ago
parent
commit
0869b31d82
  1. 2
      models/problem.js
  2. 6
      modules/problem.js
  3. 6
      views/problem.ejs
  4. 7
      views/problem_manage.ejs

2
models/problem.js

@ -455,6 +455,7 @@ class Problem extends Model {
if (this.memory_limit <= 0) return 'Invalid memory limit'; if (this.memory_limit <= 0) return 'Invalid memory limit';
if (this.memory_limit > syzoj.config.limit.memory_limit) return 'Memory limit too large'; if (this.memory_limit > syzoj.config.limit.memory_limit) return 'Memory limit too large';
if (this.type === 'traditional') {
let filenameRE = /^[\w \-\+\.]*$/; let filenameRE = /^[\w \-\+\.]*$/;
if (this.file_io_input_name && !filenameRE.test(this.file_io_input_name)) return 'Invalid input file name'; if (this.file_io_input_name && !filenameRE.test(this.file_io_input_name)) return 'Invalid input file name';
if (this.file_io_output_name && !filenameRE.test(this.file_io_output_name)) return 'Invalid output file name'; if (this.file_io_output_name && !filenameRE.test(this.file_io_output_name)) return 'Invalid output file name';
@ -463,6 +464,7 @@ class Problem extends Model {
if (!this.file_io_input_name) return 'No input file name'; if (!this.file_io_input_name) return 'No input file name';
if (!this.file_io_output_name) return 'No output file name'; if (!this.file_io_output_name) return 'No output file name';
} }
}
return null; return null;
} }

6
modules/problem.js

@ -494,14 +494,10 @@ app.post('/problem/:id/manage', app.multer.fields([{ name: 'testdata', maxCount:
problem.time_limit = req.body.time_limit; problem.time_limit = req.body.time_limit;
problem.memory_limit = req.body.memory_limit; problem.memory_limit = req.body.memory_limit;
if (req.body.type === 'traditional') {
problem.file_io = req.body.io_method === 'file-io'; problem.file_io = req.body.io_method === 'file-io';
problem.file_io_input_name = req.body.file_io_input_name; problem.file_io_input_name = req.body.file_io_input_name;
problem.file_io_output_name = req.body.file_io_output_name; problem.file_io_output_name = req.body.file_io_output_name;
if (req.body.type === 'interaction') {
if (!problem.file_io) {
throw new ErrorMessage('交互题目必须使用文件 IO。');
}
} }
if (problem.type === 'submit-answer' && req.body.type !== 'submit-answer' || problem.type !== 'submit-answer' && req.body.type === 'submit-answer') { if (problem.type === 'submit-answer' && req.body.type !== 'submit-answer' || problem.type !== 'submit-answer' && req.body.type === 'submit-answer') {

6
views/problem.ejs

@ -38,7 +38,9 @@ div[class*=ace_br] {
<div class="row" style="margin-top: -15px"> <div class="row" style="margin-top: -15px">
<span class="ui label">内存限制:<%= problem.memory_limit %> MiB</span> <span class="ui label">内存限制:<%= problem.memory_limit %> MiB</span>
<span class="ui label">时间限制:<%= problem.time_limit %> ms</span> <span class="ui label">时间限制:<%= problem.time_limit %> ms</span>
<% if (problem.file_io) { %> <% if (problem.type === 'interaction') { %>
<span class="ui label">题目类型:交互</span>
<% } else if (problem.file_io) { %>
<span class="ui label">输入文件: <%= problem.file_io_input_name %></span> <span class="ui label">输入文件: <%= problem.file_io_input_name %></span>
<span class="ui label">输出文件: <%= problem.file_io_output_name %></span> <span class="ui label">输出文件: <%= problem.file_io_output_name %></span>
<% } else { %> <% } else { %>
@ -46,10 +48,12 @@ div[class*=ace_br] {
<% } %> <% } %>
</div> </div>
<% } %> <% } %>
<% if (problem.type !== 'interaction') { %>
<div class="row" style="margin-top: -<%= problem.type === 'submit-answer' ? 15 : 23 %>px"> <div class="row" style="margin-top: -<%= problem.type === 'submit-answer' ? 15 : 23 %>px">
<span class="ui label">题目类型:<%= { 'submit-answer': '答案提交', 'interaction': '交互', 'traditional': '传统' }[problem.type] %></span> <span class="ui label">题目类型:<%= { 'submit-answer': '答案提交', 'interaction': '交互', 'traditional': '传统' }[problem.type] %></span>
<span class="ui label">评测方式:<%= (testcases && !testcases.error) ? (testcases.spj ? 'Special Judge' : '文本比较') : '无测试数据' %></span> <span class="ui label">评测方式:<%= (testcases && !testcases.error) ? (testcases.spj ? 'Special Judge' : '文本比较') : '无测试数据' %></span>
</div> </div>
<% } %>
<% if (!contest) { %> <% if (!contest) { %>
<div class="row" style="margin-top: -23px"> <div class="row" style="margin-top: -23px">
<span class="ui label">上传者: <span class="ui label">上传者:

7
views/problem_manage.ejs

@ -25,6 +25,7 @@
<input type="number" name="memory_limit" value="<%= problem.memory_limit %>"> <input type="number" name="memory_limit" value="<%= problem.memory_limit %>">
</div> </div>
</div> </div>
<div id="io-type"<% if (problem.type === 'interaction') { %> style="display: none; "<% } %>>
<% if (!problem.file_io) { %> <% if (!problem.file_io) { %>
<div class="inline fields"> <div class="inline fields">
<label>IO 方式</label> <label>IO 方式</label>
@ -79,6 +80,7 @@
</div> </div>
<% } %> <% } %>
</div> </div>
</div>
<div class="ui <%= problem.type === 'submit-answer' ? 'active ' : '' %>tab" data-tab="submit-answer" style="margin-bottom: 10px; "> <div class="ui <%= problem.type === 'submit-answer' ? 'active ' : '' %>tab" data-tab="submit-answer" style="margin-bottom: 10px; ">
<b>为了避免系统出错,已有提交的题目不允许在提交答案和非提交答案之间更改。</b><br> <b>为了避免系统出错,已有提交的题目不允许在提交答案和非提交答案之间更改。</b><br>
提交答案题目不需要设置时间限制、空间限制以及 IO 方式。<br> 提交答案题目不需要设置时间限制、空间限制以及 IO 方式。<br>
@ -126,15 +128,14 @@ $(function () {
$('input[name=type]').val('traditional'); $('input[name=type]').val('traditional');
if ($('div[data-tab="interaction"]').attr('data-tab', 'traditional').length) $('a[data-tab="traditional"]').click(); if ($('div[data-tab="interaction"]').attr('data-tab', 'traditional').length) $('a[data-tab="traditional"]').click();
$('#std-io')[0].disabled = false; $('#io-type').show();
}); });
$('a[data-tab="interaction"]').click(function () { $('a[data-tab="interaction"]').click(function () {
$('input[name=type]').val('interaction'); $('input[name=type]').val('interaction');
if ($('div[data-tab="traditional"]').attr('data-tab', 'interaction').length) $('a[data-tab="interaction"]').click(); if ($('div[data-tab="traditional"]').attr('data-tab', 'interaction').length) $('a[data-tab="interaction"]').click();
$('#std-io')[0].disabled = true; $('#io-type').hide();
$('#file-io').click();
}); });
$('a[data-tab="submit-answer"]').click(function () { $('a[data-tab="submit-answer"]').click(function () {

Loading…
Cancel
Save