From 3b05110171abab96cf21d6426982d0fc9b500f85 Mon Sep 17 00:00:00 2001 From: zjz1993 <1429595365@qq.com> Date: Fri, 27 Sep 2019 10:22:43 +0800 Subject: [PATCH] =?UTF-8?q?bugfix:=20=E4=BF=AE=E5=A4=8D=E6=AF=94=E8=B5=9B?= =?UTF-8?q?=E5=8A=A0=E5=88=86=E5=BC=82=E5=B8=B8=E7=9A=84=E6=83=85=E5=86=B5?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/judger.js | 25 +++++++++++-------- libs/submissions_process.js | 1 + modules/practice.js | 2 +- views/submission.ejs | 1 + views/submission_contest.ejs | 1 + views/submission_practice.ejs | 45 ++++++++++++++++++----------------- views/submissions.ejs | 1 + views/submissions_item.ejs | 23 ++++++++++++++---- 8 files changed, 62 insertions(+), 37 deletions(-) diff --git a/libs/judger.js b/libs/judger.js index 02f62ed..a756051 100644 --- a/libs/judger.js +++ b/libs/judger.js @@ -27,8 +27,8 @@ let judgeQueue; async function connect() { const JudgeState = syzoj.model('judge_state'); - - const blockableRedisClient = syzoj.redis.duplicate(); + + const blockableRedisClient = syzoj.redis.duplicate(); judgeQueue = { redisZADD: util.promisify(syzoj.redis.zadd).bind(syzoj.redis), redisBZPOPMAX: util.promisify(blockableRedisClient.bzpopmax).bind(blockableRedisClient), @@ -174,7 +174,7 @@ async function connect() { if (!judge_state) return; const problemId = judge_state.problem_id; let problemQuery = await Problem.createQueryBuilder(); - const problemInfo = await problemQuery.where("id = :id", { id: problemId }).getOne(); + const problemInfo = await problemQuery.where("id = :id", {id: problemId}).getOne(); const problem_time_limit = problemInfo.time_limit; const subtasksArray = convertedResult.result.judge ? convertedResult.result.judge.subtasks : []; const timeArray = subtasksArray.map((subtasksItem) => { @@ -182,9 +182,10 @@ async function connect() { return subtasksItemCases.result.time }) }); - function flat(array, result=[]){ - for (let i=0;i { return { submissionId: s.id, taskId: s.task_id, + type: s.type, user: s.is_anonymous ? null: s.user.username, userId: s.is_anonymous ? null : s.user_id, problemName: s.problem.title, diff --git a/modules/practice.js b/modules/practice.js index 3781c98..3f8ae34 100644 --- a/modules/practice.js +++ b/modules/practice.js @@ -214,8 +214,8 @@ app.get('/api/pass/:cid/:pid/:sid',async (req, res) => { const originRating = syzoj.config.default.user.rating; const newRating = originRating + newScore; await userQuery.update(User).set({rating: newRating}).where('id=:u_id',{u_id}).execute(); + res.send({newRating: newRating}); } - res.send(); } catch(e) { res.send({ error_code: e.errno, error_msg: '练习失败,请稍后重试' }); } diff --git a/views/submission.ejs b/views/submission.ejs index bc9e671..c4c2f86 100644 --- a/views/submission.ejs +++ b/views/submission.ejs @@ -36,6 +36,7 @@ 已分享 编号 + 提交类型 题目 状态 分数 diff --git a/views/submission_contest.ejs b/views/submission_contest.ejs index 4bd7ab8..7868788 100644 --- a/views/submission_contest.ejs +++ b/views/submission_contest.ejs @@ -37,6 +37,7 @@ 已分享 编号 + 提交类型 题目 状态 分数 diff --git a/views/submission_practice.ejs b/views/submission_practice.ejs index 88865f0..6a2ceab 100644 --- a/views/submission_practice.ejs +++ b/views/submission_practice.ejs @@ -37,8 +37,9 @@ - + + @@ -383,32 +384,32 @@ if (token != null) { // } // data.running=false; if (data && data.ok) { + if (data.roughResult.result === 'Accepted') { + $.ajax({ + url: `/api/pass/${cid}/${pid}/${sid}`, + type: 'GET', + success: function (data) { + }, + error: function (XMLHttpRequest, textStatus, errorThrown) { + alert('练习功能发生故障'); + } + }); + } else { + $.ajax({ + url: `/api/nopass/${cid}/${pid}/${sid}`, + type: 'GET', + success: function (data) { + }, + error: function (XMLHttpRequest, textStatus, errorThrown) { + alert('练习功能发生故障'); + } + }); + } if (data.finished) { vueApp.roughData.result = data.roughResult; // if (!data.result) location.reload(true); vueApp.detailResult = data.result; vueApp.roughData.running = false; - // if (data.roughResult.result === 'Accepted') { - // $.ajax({ - // url: `/api/pass/${cid}/${pid}/${sid}`, - // type: 'GET', - // success: function (data) { - // }, - // error: function (XMLHttpRequest, textStatus, errorThrown) { - // alert('练习功能发生故障'); - // } - // }); - // } else { - // $.ajax({ - // url: `/api/nopass/${cid}/${pid}/${sid}`, - // type: 'GET', - // success: function (data) { - // }, - // error: function (XMLHttpRequest, textStatus, errorThrown) { - // alert('练习功能发生故障'); - // } - // }); - // } socket.close(); } else { if (data.running) { diff --git a/views/submissions.ejs b/views/submissions.ejs index 9729a2b..33b398c 100644 --- a/views/submissions.ejs +++ b/views/submissions.ejs @@ -108,6 +108,7 @@ + diff --git a/views/submissions_item.ejs b/views/submissions_item.ejs index 8d410c1..d5f4fad 100644 --- a/views/submissions_item.ejs +++ b/views/submissions_item.ejs @@ -22,6 +22,16 @@ template: '#submissionItemTemplate', props: ['data', 'config', 'showRejudge', 'showShare', 'progress', 'compiling', 'rough'], computed: { + type() { + let type = ""; + switch(this.data.info.type) { + case 0: type = "普通提交";break; + case 1: type = "比赛提交";break; + case 2: type = "练习提交";break; + default:type="普通提交"; + } + return type; + }, statusString() { const data = this.data; @@ -73,10 +83,15 @@ - + + <% if (active === 'submissions') { %>
是否分享已分享 编号提交类型 题目 状态 分数
已分享 编号提交类型 题目 状态 分数
#{{ data.info.submissionId }}#{{ config.inContest ? alpha(data.info.problemId) : - data.info.problemId }}. {{ data.info.problemName }}{{type}} + + #{{ config.inContest ? alpha(data.info.problemId) : data.info.problemId }}. + {{ data.info.problemName }} +