|
|
@ -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); |
|
|
|
|
|
|
|
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 |
|
|
|
currentPId = resultItem.order + 1 |
|
|
|
await userQuery.update(User).set({current_p_id: currentPId}).where("id = :id", { id:userId }).execute(); |
|
|
|
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); |
|
|
|
} |
|
|
|
} |
|
|
|