<?php

declare(strict_types=1);

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

final class QuizAttemptQuestion extends Model
{
    protected $fillable = [
        'quiz_attempt_id',
        'question_id',
        'score',
        'sort',
        'answer',
        'is_correct',
        'duration_seconds',
        'explanation_viewed',
        'answered_at',
    ];

    protected $casts = [
        'answer' => 'array',
        'is_correct' => 'boolean',
        'explanation_viewed' => 'boolean',
        'answered_at' => 'datetime',
        'score' => 'decimal:2',
    ];

    public function question(): BelongsTo
    {
        return $this->belongsTo(Question::class);
    }
}
