|
@@ -1756,37 +1756,15 @@ class ExamAnswerAnalysisService
|
|
|
$payloadsByQuestionId[$questionId] = $payload;
|
|
$payloadsByQuestionId[$questionId] = $payload;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (! empty($payloadsByQuestionId)) {
|
|
|
|
|
- $questionIds = array_keys($payloadsByQuestionId);
|
|
|
|
|
- $paperQuestionRows = DB::connection('mysql')->table('paper_questions')
|
|
|
|
|
|
|
+ foreach ($payloadsByQuestionId as $questionId => $payload) {
|
|
|
|
|
+ // 生产 paper_questions.id 存在为空的历史数据,判分回写必须使用业务键匹配。
|
|
|
|
|
+ $updated += DB::connection('mysql')->table('paper_questions')
|
|
|
->where('paper_id', $paperId)
|
|
->where('paper_id', $paperId)
|
|
|
- ->where(function ($q) use ($questionIds) {
|
|
|
|
|
- $q->whereIn('question_bank_id', $questionIds)
|
|
|
|
|
- ->orWhereIn('question_id', $questionIds);
|
|
|
|
|
|
|
+ ->where(function ($q) use ($questionId) {
|
|
|
|
|
+ $q->where('question_bank_id', $questionId)
|
|
|
|
|
+ ->orWhere('question_id', $questionId);
|
|
|
})
|
|
})
|
|
|
- ->get(['id', 'question_bank_id', 'question_id']);
|
|
|
|
|
-
|
|
|
|
|
- $idsByQuestionId = [];
|
|
|
|
|
- foreach ($paperQuestionRows as $row) {
|
|
|
|
|
- foreach ([$row->question_bank_id ?? null, $row->question_id ?? null] as $candidateId) {
|
|
|
|
|
- $candidateId = (string) $candidateId;
|
|
|
|
|
- if ($candidateId === '' || ! isset($payloadsByQuestionId[$candidateId])) {
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- $idsByQuestionId[$candidateId][] = $row->id;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- foreach ($payloadsByQuestionId as $questionId => $payload) {
|
|
|
|
|
- $rowIds = array_values(array_unique(array_filter($idsByQuestionId[$questionId] ?? [])));
|
|
|
|
|
- if ($rowIds === []) {
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- $updated += DB::connection('mysql')->table('paper_questions')
|
|
|
|
|
- ->whereIn('id', $rowIds)
|
|
|
|
|
- ->update($payload);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ ->update($payload);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if ($updated > 0) {
|
|
if ($updated > 0) {
|
|
@@ -1804,7 +1782,6 @@ class ExamAnswerAnalysisService
|
|
|
'input_question_count' => count($examData['questions']),
|
|
'input_question_count' => count($examData['questions']),
|
|
|
'processed_question_count' => count($processedQuestionIds),
|
|
'processed_question_count' => count($processedQuestionIds),
|
|
|
'updated_rows' => $updated,
|
|
'updated_rows' => $updated,
|
|
|
- 'matched_rows' => isset($paperQuestionRows) ? $paperQuestionRows->count() : 0,
|
|
|
|
|
]);
|
|
]);
|
|
|
}
|
|
}
|
|
|
|
|
|