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] {