diff --git a/models/problem.js b/models/problem.js index 1121c6d..93fad43 100644 --- a/models/problem.js +++ b/models/problem.js @@ -455,13 +455,15 @@ class Problem extends Model { if (this.memory_limit <= 0) return 'Invalid memory limit'; if (this.memory_limit > syzoj.config.limit.memory_limit) return 'Memory limit too large'; - 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_output_name && !filenameRE.test(this.file_io_output_name)) return 'Invalid output file name'; - - if (this.file_io) { - if (!this.file_io_input_name) return 'No input file name'; - if (!this.file_io_output_name) return 'No output file name'; + if (this.type === 'traditional') { + 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_output_name && !filenameRE.test(this.file_io_output_name)) return 'Invalid output file name'; + + if (this.file_io) { + if (!this.file_io_input_name) return 'No input file name'; + if (!this.file_io_output_name) return 'No output file name'; + } } return null; diff --git a/modules/problem.js b/modules/problem.js index 22ce870..b72cdb2 100644 --- a/modules/problem.js +++ b/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.memory_limit = req.body.memory_limit; - problem.file_io = req.body.io_method === 'file-io'; - problem.file_io_input_name = req.body.file_io_input_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 (req.body.type === 'traditional') { + problem.file_io = req.body.io_method === 'file-io'; + problem.file_io_input_name = req.body.file_io_input_name; + problem.file_io_output_name = req.body.file_io_output_name; } if (problem.type === 'submit-answer' && req.body.type !== 'submit-answer' || problem.type !== 'submit-answer' && req.body.type === 'submit-answer') { diff --git a/views/problem.ejs b/views/problem.ejs index 71a25fc..8bafbb6 100644 --- a/views/problem.ejs +++ b/views/problem.ejs @@ -38,7 +38,9 @@ div[class*=ace_br] {
内存限制:<%= problem.memory_limit %> MiB 时间限制:<%= problem.time_limit %> ms - <% if (problem.file_io) { %> + <% if (problem.type === 'interaction') { %> + 题目类型:交互 + <% } else if (problem.file_io) { %> 输入文件: <%= problem.file_io_input_name %> 输出文件: <%= problem.file_io_output_name %> <% } else { %> @@ -46,10 +48,12 @@ div[class*=ace_br] { <% } %>
<% } %> -
- 题目类型:<%= { 'submit-answer': '答案提交', 'interaction': '交互', 'traditional': '传统' }[problem.type] %> - 评测方式:<%= (testcases && !testcases.error) ? (testcases.spj ? 'Special Judge' : '文本比较') : '无测试数据' %> -
+ <% if (problem.type !== 'interaction') { %> +
+ 题目类型:<%= { 'submit-answer': '答案提交', 'interaction': '交互', 'traditional': '传统' }[problem.type] %> + 评测方式:<%= (testcases && !testcases.error) ? (testcases.spj ? 'Special Judge' : '文本比较') : '无测试数据' %> +
+ <% } %> <% if (!contest) { %>
上传者: diff --git a/views/problem_manage.ejs b/views/problem_manage.ejs index 9be6ea0..b553cf8 100644 --- a/views/problem_manage.ejs +++ b/views/problem_manage.ejs @@ -25,59 +25,61 @@
- <% if (!problem.file_io) { %> -
- -
-
- - +
style="display: none; "<% } %>> + <% if (!problem.file_io) { %> +
+ +
+
+ + +
-
-
-
- - +
+
+ + +
-
-
-
- - -
-
- - -
-
- <% } else { %> -
- -
-
- - +
+
+ +
-
-
-
- - +
+ +
-
-
-
- - + <% } else { %> +
+ +
+
+ + +
+
+
+
+ + +
+
-
- - +
+
+ + +
+
+ + +
+ <% } %>
- <% } %>
为了避免系统出错,已有提交的题目不允许在提交答案和非提交答案之间更改。
@@ -126,15 +128,14 @@ $(function () { $('input[name=type]').val('traditional'); 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 () { $('input[name=type]').val('interaction'); if ($('div[data-tab="traditional"]').attr('data-tab', 'interaction').length) $('a[data-tab="interaction"]').click(); - $('#std-io')[0].disabled = true; - $('#file-io').click(); + $('#io-type').hide(); }); $('a[data-tab="submit-answer"]').click(function () {