diff --git a/database/migrations/2024_01_03_000002_create_questions_table.php b/database/migrations/2024_01_03_000002_create_questions_table.php index 4bf63a0..2a41d41 100755 --- a/database/migrations/2024_01_03_000002_create_questions_table.php +++ b/database/migrations/2024_01_03_000002_create_questions_table.php @@ -11,7 +11,7 @@ return new class extends Migration Schema::create('questions', function (Blueprint $table) { $table->id(); $table->foreignId('test_id')->constrained()->onDelete('cascade'); - $table->enum('type', ['single_choice', 'multiple_choice', 'matching', 'ordering'])->default('multiple_choice'); + $table->enum('type', ['multiple_choice', 'matching', 'ordering'])->default('multiple_choice'); $table->text('question_text'); $table->text('explanation')->nullable(); $table->integer('score')->default(1); diff --git a/database/migrations/2026_03_27_011503_add_ordering_to_questions_type.php b/database/migrations/2026_03_27_011503_add_ordering_to_questions_type.php index 1b3a0a7..ea78561 100755 --- a/database/migrations/2026_03_27_011503_add_ordering_to_questions_type.php +++ b/database/migrations/2026_03_27_011503_add_ordering_to_questions_type.php @@ -9,8 +9,8 @@ return new class extends Migration { public function up(): void { - // Добавляем ordering и убираем input - DB::statement("ALTER TABLE questions MODIFY COLUMN type ENUM('single_choice', 'multiple_choice', 'matching', 'ordering') NOT NULL"); + // Добавляем ordering и убираем input, single_choice + DB::statement("ALTER TABLE questions MODIFY COLUMN type ENUM('multiple_choice', 'matching', 'ordering') NOT NULL"); // Создаём таблицу для ordering элементов Schema::create('question_ordering_items', function (Blueprint $table) { diff --git a/resources/views/admin/questions/index.blade.php b/resources/views/admin/questions/index.blade.php index f5fff8b..b8f0d34 100644 --- a/resources/views/admin/questions/index.blade.php +++ b/resources/views/admin/questions/index.blade.php @@ -20,14 +20,17 @@
#{{ $loop->iteration }} - @if($question->type === 'single_choice') - - @elseif($question->type === 'multiple_choice') - - @elseif($question->type === 'input') - + @if($question->type === 'multiple_choice') + @php $correctCount = $question->answers->where('is_correct', true)->count(); @endphp + @if($correctCount === 1) + + @else + + @endif @elseif($question->type === 'matching') + @elseif($question->type === 'ordering') + @endif {{ Str::limit($question->question_text, 100) }}
diff --git a/resources/views/admin/tests/show.blade.php b/resources/views/admin/tests/show.blade.php index cb49874..6645575 100644 --- a/resources/views/admin/tests/show.blade.php +++ b/resources/views/admin/tests/show.blade.php @@ -63,12 +63,13 @@ @if($question->is_required)@endif - @if($question->type === 'single_choice') - - @elseif($question->type === 'multiple_choice') - - @elseif($question->type === 'input') - + @if($question->type === 'multiple_choice') + @php $correctCount = $question->answers->where('is_correct', true)->count(); @endphp + @if($correctCount === 1) + + @else + + @endif @elseif($question->type === 'matching') @elseif($question->type === 'ordering')