43 lines
853 B
PHP
43 lines
853 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class TestResponse extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'attempt_id',
|
|
'question_id',
|
|
'answer_id',
|
|
'text_response',
|
|
'matching_response',
|
|
'is_correct',
|
|
'score',
|
|
];
|
|
|
|
protected $casts = [
|
|
'matching_response' => 'array',
|
|
'is_correct' => 'boolean',
|
|
];
|
|
|
|
public function attempt(): BelongsTo
|
|
{
|
|
return $this->belongsTo(TestAttempt::class);
|
|
}
|
|
|
|
public function question(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Question::class);
|
|
}
|
|
|
|
public function answer(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Answer::class);
|
|
}
|
|
}
|