Added quiz features
This commit is contained in:
41
app/Models/UserQuizAnswer.php
Normal file
41
app/Models/UserQuizAnswer.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user