Added quiz features
This commit is contained in:
46
app/Models/Question.php
Normal file
46
app/Models/Question.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Question extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'quiz_id',
|
||||
'subject_id',
|
||||
'question_text',
|
||||
'type',
|
||||
'score',
|
||||
'solution_explanation',
|
||||
'order',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'score' => 'float',
|
||||
'order' => 'integer',
|
||||
];
|
||||
|
||||
public function quiz()
|
||||
{
|
||||
return $this->belongsTo(Quiz::class, 'quiz_id');
|
||||
}
|
||||
|
||||
public function subject()
|
||||
{
|
||||
return $this->belongsTo(QuizSubject::class, 'subject_id');
|
||||
}
|
||||
|
||||
public function options()
|
||||
{
|
||||
return $this->hasMany(QuestionOption::class, 'question_id');
|
||||
}
|
||||
|
||||
public function userAnswers()
|
||||
{
|
||||
return $this->hasMany(UserQuizAnswer::class, 'question_id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user