Add Quiz feature: 10-question quizzes with progressive scoring (max 40 pts)
- 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
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
return new class extends Migration {
|
||||
public function up(): void {
|
||||
Schema::create('quizzes', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('subject_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('title');
|
||||
$table->text('description')->nullable();
|
||||
$table->boolean('active')->default(true);
|
||||
$table->timestamps();
|
||||
});
|
||||
Schema::create('quiz_questions', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('quiz_id')->constrained()->cascadeOnDelete();
|
||||
$table->unsignedSmallInteger('sort_order')->default(0);
|
||||
$table->enum('type', ['multiple_choice','exclusion','true_false','free_text']);
|
||||
$table->text('question_text');
|
||||
$table->unsignedSmallInteger('time_limit')->nullable();
|
||||
$table->string('correct_answer')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
Schema::create('quiz_answer_options', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('quiz_question_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('text');
|
||||
$table->boolean('is_correct')->default(false);
|
||||
$table->unsignedSmallInteger('sort_order')->default(0);
|
||||
});
|
||||
}
|
||||
public function down(): void {
|
||||
Schema::dropIfExists('quiz_answer_options');
|
||||
Schema::dropIfExists('quiz_questions');
|
||||
Schema::dropIfExists('quizzes');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user