<?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('quiz_attempts', function (Blueprint $table) {
   $table->id();
   $table->foreignId('quiz_id')->constrained('quizzes')->cascadeOnDelete();
   $table->foreignId('enrollment_id')->constrained('enrollments')->cascadeOnDelete();
   $table->dateTime('started_at')->nullable();
   $table->dateTime('submitted_at')->nullable();
   $table->decimal('total_score',6,2)->default(0);
   $table->string('result')->nullable();
   $table->string('status')->default('Đang làm');
   $table->timestamps();
  });
 }
 public function down(): void { Schema::dropIfExists('quiz_attempts'); }
};
