'array',
'score_area_bbox' => 'array',
'ai_score' => 'float',
'mark_confidence' => 'float',
'student_answer_bbox' => 'array',
'answer_confidence' => 'float',
'question_bbox' => 'array',
'ai_confidence' => 'float',
'ai_analyzed_at' => 'datetime',
];
public function ocrRecord(): BelongsTo
{
return $this->belongsTo(OCRRecord::class, 'ocr_record_id', 'id');
}
public function getMarkBadgeAttribute(): string
{
if (!$this->mark_detected) {
return '未识别';
}
return match ($this->mark_detected) {
'✓', '√', '✔', 'correct' => '正确 ✓',
'✗', '×', '❌', 'wrong' => '错误 ✗',
default => '' . $this->mark_detected . '',
};
}
public function getConfidenceColorAttribute(): string
{
$confidence = $this->score_confidence ?? 0;
return match (true) {
$confidence >= 0.8 => 'text-green-600',
$confidence >= 0.6 => 'text-yellow-600',
$confidence >= 0.4 => 'text-orange-600',
default => 'text-red-600',
};
}
public function getAnswerAreaCropUrlAttribute(): string
{
if ($this->answer_area_crop_path && file_exists(public_path($this->answer_area_crop_path))) {
return asset($this->answer_area_crop_path);
}
return '';
}
}