<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('student_self_quiz_answer_parts', function (Blueprint $table) {
            $table->id();
            $table->foreignId('quiz_self_answer_id')->constrained('student_self_quiz_answers')->cascadeOnUpdate()->cascadeOnDelete();
            $table->foreignId('question_id')->constrained('quiz_topic_questions')->cascadeOnUpdate()->cascadeOnDelete();
            $table->foreignId('question_part_id')->constrained('topic_question_parts')->cascadeOnUpdate()->cascadeOnDelete();
            $table->text('answer');
            $table->integer('outcome')->default(2);
            $table->string('score')->nullable();
            $table->integer('obtainMarks')->nullable();
            $table->integer('totalMarks')->nullable();
            $table->text('reason')->nullable();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('student_self_quiz_answer_parts');
    }
};
