Browse Source

Merge pull request #33 from hewenyang/better_export

Import also problem types
pull/6/head
Tian Yunhao 7 years ago committed by GitHub
parent
commit
2a42659d98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  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.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 \-\+\.]*$/;

2
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);

Loading…
Cancel
Save