From 5361d09f02fd3a852e9c76cea2584c9f3629ec16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=BF=8A=E5=93=B2?= <1429595365@qq.com> Date: Tue, 15 Jun 2021 15:01:38 +0800 Subject: [PATCH] =?UTF-8?q?bugfix:=20=E4=BF=AE=E6=94=B9=E5=9B=A0=E4=B8=BA?= =?UTF-8?q?=E7=BB=83=E4=B9=A0=E9=98=B6=E6=AE=B5=E9=A2=98=E7=9B=AE=E5=8F=98?= =?UTF-8?q?=E5=8A=A8=E9=80=A0=E6=88=90=E7=9A=84=E6=97=A0=E6=B3=95=E8=BF=9B?= =?UTF-8?q?=E5=85=A5=E4=B8=8B=E4=B8=80=E9=98=B6=E6=AE=B5=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/practice.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/modules/practice.js b/modules/practice.js index a87fbd3..73d8fea 100644 --- a/modules/practice.js +++ b/modules/practice.js @@ -38,12 +38,17 @@ app.get('/practice', async (req, res) => { await result.forEachAsync(async resultItem => { const c_id = resultItem.id; let utopInfo = await utopQuery.where('c_id=:c_id',{c_id}).andWhere('u_id=:u_id',{u_id:userId}).andWhere("is_finished=1").getMany(); - resultItem.ac_num = utopInfo.length || 0; - if (resultItem.ac_num === resultItem.problem_num) { - if (resultItem.order < result.length ) { - currentPId = resultItem.order + 1 - await userQuery.update(User).set({current_p_id: currentPId}).where("id = :id", { id:userId }).execute(); - } + let ctopQuery = CToP.createQueryBuilder(); + const classifyProblems = await ctopQuery.where("c_id = :id", { id:resultItem.id }).getMany(); + const classifyProblemsArr = classifyProblems.map(item => item.p_id); + const utopInfoArr = utopInfo.map(item => item.p_id); + const restArr = classifyProblemsArr.filter(item => !utopInfoArr.includes(item)); + // 当前阶段里已经练习的题目的数量 + const currentPassProblemNum = classifyProblemsArr.filter(item => utopInfoArr.includes(item)); + resultItem.ac_num = currentPassProblemNum.length || 0; + if (restArr.length === 0) { + currentPId = resultItem.order + 1 + await userQuery.update(User).set({current_p_id: currentPId}).where("id = :id", { id:userId }).execute(); } else { unFinishedIdArray.push(resultItem.order); }