From bdbce26f3be509c366ee7240a0206cbb50a7ffb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=A8=E5=9C=A3=E6=9D=B0?= <32413588+dblark@users.noreply.github.com> Date: Mon, 1 Apr 2019 17:28:21 +0800 Subject: [PATCH 01/10] Fix import/export no additional file --- modules/problem.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/problem.js b/modules/problem.js index 84df7e2..7c97280 100644 --- a/modules/problem.js +++ b/modules/problem.js @@ -257,6 +257,7 @@ app.get('/problem/:id/export', async (req, res) => { limit_and_hint: problem.limit_and_hint, time_limit: problem.time_limit, memory_limit: problem.memory_limit, + additional_file_id: problem.additional_file_id, file_io: problem.file_io, file_io_input_name: problem.file_io_input_name, file_io_output_name: problem.file_io_output_name, @@ -465,6 +466,11 @@ app.post('/problem/:id/import', async (req, res) => { let data = await download(req.body.url + (req.body.url.endsWith('/') ? 'testdata/download' : '/testdata/download')); await fs.writeFileAsync(tmpFile.path, data); await problem.updateTestdata(tmpFile.path, await res.locals.user.hasPrivilege('manage_problem')); + if (json.obj.additional_file_id != null) { + let additional_file = await download(req.body.url + (req.body.url.endsWith('/') ? 'download/additional_file' : '/download/additional_file')); + await fs.writeFileAsync(tmpFile.path, additional_file); + await problem.updateFile(tmpFile.path, 'additional_file', await res.locals.user.hasPrivilege('manage_problem')); + } } catch (e) { syzoj.log(e); } From a3dc32ff6dc805746587b9b024bc8539b1cee1b0 Mon Sep 17 00:00:00 2001 From: Menci Date: Mon, 1 Apr 2019 21:39:52 +0800 Subject: [PATCH 02/10] Fix wrong comparison when querying longest or shortest in statistics --- models/problem.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/models/problem.js b/models/problem.js index 6c5ecf0..e844fe5 100644 --- a/models/problem.js +++ b/models/problem.js @@ -58,15 +58,15 @@ SELECT \ `id` \ FROM `judge_state` `inner_table` \ WHERE `problem_id` = `outer_table`.`problem_id` AND `user_id` = `outer_table`.`user_id` AND `status` = "Accepted" AND `type` = 0 \ - ORDER BY LENGTH(`code`) ASC \ + ORDER BY `code_length` ASC \ LIMIT 1 \ ) AS `id`, \ ( \ SELECT \ - LENGTH(`code`) \ + `code_length` \ FROM `judge_state` `inner_table` \ WHERE `problem_id` = `outer_table`.`problem_id` AND `user_id` = `outer_table`.`user_id` AND `status` = "Accepted" AND `type` = 0 \ - ORDER BY LENGTH(`code`) ASC \ + ORDER BY `code_length` ASC \ LIMIT 1 \ ) AS `code_length` \ FROM `judge_state` `outer_table` \ @@ -83,15 +83,15 @@ SELECT \ `id` \ FROM `judge_state` `inner_table` \ WHERE `problem_id` = `outer_table`.`problem_id` AND `user_id` = `outer_table`.`user_id` AND `status` = "Accepted" AND `type` = 0 \ - ORDER BY LENGTH(`code`) DESC \ + ORDER BY `code_length` DESC \ LIMIT 1 \ ) AS `id`, \ ( \ SELECT \ - LENGTH(`code`) \ + `code_length` \ FROM `judge_state` `inner_table` \ WHERE `problem_id` = `outer_table`.`problem_id` AND `user_id` = `outer_table`.`user_id` AND `status` = "Accepted" AND `type` = 0 \ - ORDER BY LENGTH(`code`) DESC \ + ORDER BY `code_length` DESC \ LIMIT 1 \ ) AS `code_length` \ FROM `judge_state` `outer_table` \ From 7d20537ce60ffd19873836ed0dbb9cb4998acb29 Mon Sep 17 00:00:00 2001 From: Menci Date: Mon, 1 Apr 2019 21:47:50 +0800 Subject: [PATCH 03/10] Add to some elements --- views/contest.ejs | 2 ++ views/statistics.ejs | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/views/contest.ejs b/views/contest.ejs index 8ee23a5..2de9aa9 100644 --- a/views/contest.ejs +++ b/views/contest.ejs @@ -75,8 +75,10 @@ <% if (typeof problem.status === 'string') { %> + <%= problem.feedback || problem.status %> + <% } else if (typeof problem.status === 'object') { %> <% if (problem.status.accepted) { %> diff --git a/views/statistics.ejs b/views/statistics.ejs index 05d2481..8166f12 100644 --- a/views/statistics.ejs +++ b/views/statistics.ejs @@ -71,19 +71,21 @@ function getColorOfScore(score) { <% for (let judge of statistics.judge_state) { %> <% include util %> - #<%= judge.id %> - #<%= judge.problem_id %>. <%= judge.problem.title %> + #<%= judge.id %> + #<%= judge.problem_id %>. <%= judge.problem.title %> + <%= judge.status %> + <%= judge.score %> <% if (problem.type !== 'submit-answer') { %> <%= judge.total_time %> ms <%= parseInt(judge.max_memory) || 0 %> K - <%= syzoj.languages[judge.language].show %> / <%= syzoj.utils.formatSize(judge.code.length) %> + <%= syzoj.languages[judge.language].show %> / <%= syzoj.utils.formatSize(judge.code.length) %> <% } else { %> <%= syzoj.utils.formatSize(judge.max_memory) %> <% } %> From 54cd962e6005f18c37e36257f6b1e7754cc56861 Mon Sep 17 00:00:00 2001 From: Menci Date: Tue, 2 Apr 2019 10:50:36 +0800 Subject: [PATCH 04/10] Fix testcase's System Error message not shown --- libs/submissions_process.js | 1 + views/submission.ejs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/submissions_process.js b/libs/submissions_process.js index 910f70b..79f4642 100644 --- a/libs/submissions_process.js +++ b/libs/submissions_process.js @@ -66,6 +66,7 @@ const processOverallResult = (source, config) => { score: st.score, cases: st.cases.map(cs => ({ status: cs.status, + errorMessage: cs.errorMessage, result: cs.result && { type: cs.result.type, time: config.showUsage ? cs.result.time : undefined, diff --git a/views/submission.ejs b/views/submission.ejs index 23a6a4f..7fdffc2 100644 --- a/views/submission.ejs +++ b/views/submission.ejs @@ -85,7 +85,7 @@