db.XXXXXX.aggregate([
{
"$match": {
"paperId": 18, "status": 2
}
},
{
"$unwind": "$examSections"
},
{
"$unwind": "$examSections.details"
},
{
"$match": {
"examSections.details.isGroup": 0, "examSections.details.choicetypeId": 29
}
}, {
$group: {
_id: { questionId: "$examSections.details.questionId" },
questionId: { $first: "$examSections.details.questionId" },
choicetypeId: { $first: "$examSections.details.choicetypeId" },
answerNum: { $sum: 1 },
erroNum: { $sum: { $cond: { if: { $eq: ["$examSections.details.isRight", 0] }, then: 1, else: 0 } } },
choice_A_num: { $sum: { $cond: { if: { $eq: ["$examSections.details.myAnswer", ""] }, then: 1, else: 0 } } },
choice_B_num: { $sum: { $cond: { if: { $eq: ["$examSections.details.myAnswer", ""] }, then: 1, else: 0 } } },
choice_C_num: { $sum: { $cond: { if: { $eq: ["$examSections.details.myAnswer", ""] }, then: 1, else: 0 } } },
choice_D_num: { $sum: { $cond: { if: { $eq: ["$examSections.details.myAnswer", ""] }, then: 1, else: 0 } } },
choice_E_num: { $sum: { $cond: { if: { $eq: ["$examSections.details.myAnswer", ""] }, then: 1, else: 0 } } },
choice_F_num: { $sum: { $cond: { if: { $eq: ["$examSections.details.myAnswer", ""] }, then: 1, else: 0 } } },
choice_G_num: { $sum: { $cond: { if: { $eq: ["$examSections.details.myAnswer", ""] }, then: 1, else: 0 } } },
choice_H_num: { $sum: { $cond: { if: { $eq: ["$examSections.details.myAnswer", ""] }, then: 1, else: 0 } } }
}
},
{
$project: {
"_id": 0,
"questionId": 1,
"choicetypeId": 1,
"answerNum": 1,
"choice_A_num": 1,
"choice_B_num": 1,
"choice_C_num": 1,
"choice_D_num": 1,
"choice_E_num": 1,
"choice_F_num": 1,
"choice_G_num": 1,
"choice_H_num": 1,
"memberId": 1,
}
}
])
db.abcPo.aggregate([
{
"$match": {
"sSubjectId": 1, "memberId": 1
}
}, {
$group: {
_id: { choicetypeId: "$choicetypeId" }, choicetypeIdCollectCount: { $sum: 1 }
}
},
{
$project: {
"_id": 0,
"choicetypeId": '$_id.choicetypeId',
"choicetypeIdCollectCount": 1
}
}
])
db.updateRecordOrTranscriptOrPaperRecordDataDetailLogPo.updateMany(
{},
{
"$rename":{"old":"new"}
}
)