Browse Source

Import also problem types

pull/6/head
hewenyang 7 years ago
parent
commit
214cf694cc
  1. 1
      models/problem.js
  2. 2
      modules/problem.js

1
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.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 <= 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 (!['traditional', 'submit-answer', 'interaction'].includes(this.type)) return 'Invalid problem type';
if (this.type === 'traditional') { if (this.type === 'traditional') {
let filenameRE = /^[\w \-\+\.]*$/; let filenameRE = /^[\w \-\+\.]*$/;

2
modules/problem.js

@ -279,6 +279,7 @@ app.get('/problem/:id/export', async (req, res) => {
file_io: problem.file_io, file_io: problem.file_io,
file_io_input_name: problem.file_io_input_name, file_io_input_name: problem.file_io_input_name,
file_io_output_name: problem.file_io_output_name, file_io_output_name: problem.file_io_output_name,
type: problem.type,
tags: [] tags: []
}; };
@ -464,6 +465,7 @@ app.post('/problem/:id/import', async (req, res) => {
problem.file_io = json.obj.file_io; problem.file_io = json.obj.file_io;
problem.file_io_input_name = json.obj.file_io_input_name; problem.file_io_input_name = json.obj.file_io_input_name;
problem.file_io_output_name = json.obj.file_io_output_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(); let validateMsg = await problem.validate();
if (validateMsg) throw new ErrorMessage('无效的题目数据配置。', null, validateMsg); if (validateMsg) throw new ErrorMessage('无效的题目数据配置。', null, validateMsg);

Loading…
Cancel
Save