|
|
|
@ -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); |
|
|
|
|
} |
|
|
|
|