From 214cf694cc711a17576a439456e65458e733aee7 Mon Sep 17 00:00:00 2001 From: hewenyang Date: Thu, 15 Feb 2018 18:58:22 +0800 Subject: [PATCH] Import also problem types --- models/problem.js | 1 + modules/problem.js | 2 ++ 2 files changed, 3 insertions(+) diff --git a/models/problem.js b/models/problem.js index 2f79e6b..1e6a32f 100644 --- a/models/problem.js +++ b/models/problem.js @@ -454,6 +454,7 @@ class Problem extends Model { if (this.time_limit > syzoj.config.limit.time_limit) return 'Time limit too large'; if (this.memory_limit <= 0) return 'Invalid memory limit'; if (this.memory_limit > syzoj.config.limit.memory_limit) return 'Memory limit too large'; + if (!['traditional', 'submit-answer', 'interaction'].includes(this.type)) return 'Invalid problem type'; if (this.type === 'traditional') { let filenameRE = /^[\w \-\+\.]*$/; diff --git a/modules/problem.js b/modules/problem.js index 2c8ad01..05e0b38 100644 --- a/modules/problem.js +++ b/modules/problem.js @@ -279,6 +279,7 @@ app.get('/problem/:id/export', async (req, res) => { file_io: problem.file_io, file_io_input_name: problem.file_io_input_name, file_io_output_name: problem.file_io_output_name, + type: problem.type, tags: [] }; @@ -464,6 +465,7 @@ app.post('/problem/:id/import', async (req, res) => { problem.file_io = json.obj.file_io; problem.file_io_input_name = json.obj.file_io_input_name; problem.file_io_output_name = json.obj.file_io_output_name; + if(json.obj.type) problem.type = json.obj.type; let validateMsg = await problem.validate(); if (validateMsg) throw new ErrorMessage('无效的题目数据配置。', null, validateMsg);