42 lines
848 B
PHP
42 lines
848 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class UserQuizAnswer extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'attempt_id',
|
|
'question_id',
|
|
'selected_option_id',
|
|
'text_answer',
|
|
'is_correct',
|
|
'earned_score',
|
|
'reviewer_feedback',
|
|
];
|
|
|
|
protected $casts = [
|
|
'is_correct' => 'boolean',
|
|
'earned_score' => 'float',
|
|
];
|
|
|
|
public function attempt()
|
|
{
|
|
return $this->belongsTo(UserQuizAttempt::class, 'attempt_id');
|
|
}
|
|
|
|
public function question()
|
|
{
|
|
return $this->belongsTo(Question::class, 'question_id');
|
|
}
|
|
|
|
public function selectedOption()
|
|
{
|
|
return $this->belongsTo(QuestionOption::class, 'selected_option_id');
|
|
}
|
|
}
|