<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class QuizAnswer extends Model
{
    protected $fillable = [
        'question_id',
        'user_quiz_id',
        'question_level_id',
        'level_id',
        'answer_text',
        'is_correct',
        'taken_time',
        'score',
    ];

    protected $casts = [
        'answer_text' => 'array',
        'is_correct' => 'boolean',
        'taken_time' => 'integer',
        'score' => 'integer',
    ];

    public function userQuiz()
    {
        return $this->belongsTo(UserQuiz::class);
    }

    public function question()
    {
        return $this->belongsTo(QuizQuestion::class, 'question_id');
    }

    public function level()
    {
        return $this->belongsTo(QuestionLevel::class, 'question_level_id');
    }
}
