Browse Source

bugfix: 修改因为练习阶段题目变动造成的无法进入下一阶段的问题

pull/4/head
赵俊哲 3 years ago
parent
commit
5361d09f02
  1. 17
      modules/practice.js

17
modules/practice.js

@ -38,12 +38,17 @@ app.get('/practice', async (req, res) => {
await result.forEachAsync(async resultItem => { await result.forEachAsync(async resultItem => {
const c_id = resultItem.id; 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(); 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; let ctopQuery = CToP.createQueryBuilder();
if (resultItem.ac_num === resultItem.problem_num) { const classifyProblems = await ctopQuery.where("c_id = :id", { id:resultItem.id }).getMany();
if (resultItem.order < result.length ) { const classifyProblemsArr = classifyProblems.map(item => item.p_id);
currentPId = resultItem.order + 1 const utopInfoArr = utopInfo.map(item => item.p_id);
await userQuery.update(User).set({current_p_id: currentPId}).where("id = :id", { id:userId }).execute(); 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 { } else {
unFinishedIdArray.push(resultItem.order); unFinishedIdArray.push(resultItem.order);
} }

Loading…
Cancel
Save