Added quiz features
This commit is contained in:
47
app/Models/UserQuizAttempt.php
Normal file
47
app/Models/UserQuizAttempt.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class UserQuizAttempt extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'quiz_id',
|
||||
'started_at',
|
||||
'completed_at',
|
||||
'total_score',
|
||||
'correct_answers',
|
||||
'wrong_answers',
|
||||
'unanswered',
|
||||
'status',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'started_at' => 'datetime',
|
||||
'completed_at' => 'datetime',
|
||||
'total_score' => 'float',
|
||||
'correct_answers' => 'integer',
|
||||
'wrong_answers' => 'integer',
|
||||
'unanswered' => 'integer',
|
||||
];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'user_id');
|
||||
}
|
||||
|
||||
public function quiz()
|
||||
{
|
||||
return $this->belongsTo(Quiz::class, 'quiz_id');
|
||||
}
|
||||
|
||||
public function answers()
|
||||
{
|
||||
return $this->hasMany(UserQuizAnswer::class, 'attempt_id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user