<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class DemoExamQuestion extends Model
{
    protected $fillable = [
        'demo_exam_id',
        'course_id',
        'question',
        'explanation',
        'sort_order',
        'is_active',
    ];

    protected $casts = [
        'is_active' => 'boolean',
    ];

    public function demoExam()
    {
        return $this->belongsTo(DemoExam::class);
    }

    public function course()
    {
        return $this->belongsTo(Course::class);
    }

    public function options()
    {
        return $this->hasMany(DemoExamOption::class);
    }

    public function correctOption()
    {
        return $this->hasOne(DemoExamOption::class)->where('is_correct', true);
    }
}