|
@@ -114,7 +114,7 @@ class GenerateKnowledgeExplanationPdfJob implements ShouldQueue
|
|
|
'paper_name' => '知识点讲解_' . $displayCode,
|
|
'paper_name' => '知识点讲解_' . $displayCode,
|
|
|
'paper_type' => 22,
|
|
'paper_type' => 22,
|
|
|
'total_questions' => 0,
|
|
'total_questions' => 0,
|
|
|
- 'total_score' => 0,
|
|
|
|
|
|
|
+ 'total_score' => 100,
|
|
|
'status' => 'completed',
|
|
'status' => 'completed',
|
|
|
'difficulty_category' => null,
|
|
'difficulty_category' => null,
|
|
|
'exam_pdf_url' => $pdfUrl,
|
|
'exam_pdf_url' => $pdfUrl,
|
|
@@ -133,7 +133,7 @@ class GenerateKnowledgeExplanationPdfJob implements ShouldQueue
|
|
|
$displayCode = $paperId;
|
|
$displayCode = $paperId;
|
|
|
}
|
|
}
|
|
|
$kpCodes = is_array($record->kp_codes) ? array_values($record->kp_codes) : [];
|
|
$kpCodes = is_array($record->kp_codes) ? array_values($record->kp_codes) : [];
|
|
|
- $questions = $this->buildKnowledgeQuestions();
|
|
|
|
|
|
|
+ $questions = $this->buildKnowledgeQuestions(100);
|
|
|
$knowledgeDistribution = [];
|
|
$knowledgeDistribution = [];
|
|
|
foreach ($kpCodes as $kpCode) {
|
|
foreach ($kpCodes as $kpCode) {
|
|
|
$knowledgeDistribution[(string) $kpCode] = 0;
|
|
$knowledgeDistribution[(string) $kpCode] = 0;
|
|
@@ -153,7 +153,7 @@ class GenerateKnowledgeExplanationPdfJob implements ShouldQueue
|
|
|
'student_id' => (string) ($record->student_id ?? ''),
|
|
'student_id' => (string) ($record->student_id ?? ''),
|
|
|
'teacher_id' => (string) ($record->teacher_id ?? ''),
|
|
'teacher_id' => (string) ($record->teacher_id ?? ''),
|
|
|
'total_questions' => count($questions),
|
|
'total_questions' => count($questions),
|
|
|
- 'total_score' => 0,
|
|
|
|
|
|
|
+ 'total_score' => 100,
|
|
|
'difficulty_category' => null,
|
|
'difficulty_category' => null,
|
|
|
'created_at' => optional($record->created_at)->toISOString(),
|
|
'created_at' => optional($record->created_at)->toISOString(),
|
|
|
'updated_at' => optional($record->updated_at)->toISOString(),
|
|
'updated_at' => optional($record->updated_at)->toISOString(),
|
|
@@ -181,7 +181,7 @@ class GenerateKnowledgeExplanationPdfJob implements ShouldQueue
|
|
|
];
|
|
];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private function buildKnowledgeQuestions(): array
|
|
|
|
|
|
|
+ private function buildKnowledgeQuestions(int $totalScore = 100): array
|
|
|
{
|
|
{
|
|
|
$questions = [];
|
|
$questions = [];
|
|
|
$seq = 1;
|
|
$seq = 1;
|
|
@@ -216,6 +216,24 @@ class GenerateKnowledgeExplanationPdfJob implements ShouldQueue
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ $count = count($questions);
|
|
|
|
|
+ if ($count > 0) {
|
|
|
|
|
+ $baseScore = intdiv($totalScore, $count);
|
|
|
|
|
+ $remainder = $totalScore - ($baseScore * $count);
|
|
|
|
|
+ foreach ($questions as &$q) {
|
|
|
|
|
+ $q['score'] = $baseScore;
|
|
|
|
|
+ }
|
|
|
|
|
+ unset($q);
|
|
|
|
|
+ if ($remainder > 0) {
|
|
|
|
|
+ // 余数分散到末尾若干题,保证总分精确为 totalScore
|
|
|
|
|
+ for ($i = $count - $remainder; $i < $count; $i++) {
|
|
|
|
|
+ if ($i >= 0 && isset($questions[$i])) {
|
|
|
|
|
+ $questions[$i]['score'] += 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
return $questions;
|
|
return $questions;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|