54 lines
1.1 KiB
PHP
Executable File
54 lines
1.1 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
class Test extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'course_id',
|
|
'module_id',
|
|
'title',
|
|
'description',
|
|
'type',
|
|
'time_limit_minutes',
|
|
'passing_score',
|
|
'max_attempts',
|
|
'shuffle_questions',
|
|
'show_correct_answers',
|
|
'is_active',
|
|
];
|
|
|
|
protected $casts = [
|
|
'shuffle_questions' => 'boolean',
|
|
'show_correct_answers' => 'boolean',
|
|
'is_active' => 'boolean',
|
|
];
|
|
|
|
public function course(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Course::class);
|
|
}
|
|
|
|
public function module(): BelongsTo
|
|
{
|
|
return $this->belongsTo(CourseModule::class);
|
|
}
|
|
|
|
public function questions(): HasMany
|
|
{
|
|
return $this->hasMany(Question::class);
|
|
}
|
|
|
|
public function attempts(): HasMany
|
|
{
|
|
return $this->hasMany(TestAttempt::class);
|
|
}
|
|
}
|