6c6dd26823
- Quizzes table with questions, answer options, attempts, answers - Question types: multiple_choice, exclusion, true_false, free_text - Progressive scoring: [1,1,2,2,3,3,4,6,8,10] = max 40 per quiz - Alpine.js countdown timer per question with auto-submit on timeout - Admin: CRUD for quizzes + per-question editor, JSON export/import - Child: quiz overview with best scores, question view, result breakdown - Nav: Quiz link in child header and admin sidebar
18 lines
751 B
PHP
18 lines
751 B
PHP
<?php
|
|
namespace App\Models;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
class QuizQuestion extends Model {
|
|
protected $fillable = ['quiz_id','sort_order','type','question_text','time_limit','correct_answer'];
|
|
public function quiz() { return $this->belongsTo(Quiz::class); }
|
|
public function answerOptions() { return $this->hasMany(QuizAnswerOption::class,'quiz_question_id')->orderBy('sort_order'); }
|
|
public function typeLabel(): string {
|
|
return match($this->type) {
|
|
'multiple_choice' => 'Multiple Choice',
|
|
'exclusion' => 'Ausschluss',
|
|
'true_false' => 'Wahr/Falsch',
|
|
'free_text' => 'Freitext',
|
|
default => $this->type,
|
|
};
|
|
}
|
|
}
|