From 025b03c94b57411f0c91d018db3d08441e39cd60 Mon Sep 17 00:00:00 2001 From: mirivlad Date: Fri, 27 Mar 2026 09:55:33 +0800 Subject: [PATCH] =?UTF-8?q?Refactor:=20=D0=A3=D0=B1=D1=80=D0=B0=D0=BD=20si?= =?UTF-8?q?ngle=5Fchoice=20(=D1=87=D0=B0=D1=81=D1=82=D0=BD=D1=8B=D0=B9=20?= =?UTF-8?q?=D1=81=D0=BB=D1=83=D1=87=D0=B0=D0=B9=20multiple=5Fchoice)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ✅ Все single_choice конвертированы в multiple_choice ✅ Отображение (radio/checkbox) зависит от кол-ва правильных ответов: - 1 правильный → radio (bi-circle) - 2+ правильных → checkbox (bi-check2-square) ✅ Обновлены миграции ✅ Обновлены view файлы Co-authored-by: Qwen-Coder --- .../2024_01_03_000002_create_questions_table.php | 2 +- ...3_27_011503_add_ordering_to_questions_type.php | 4 ++-- resources/views/admin/questions/index.blade.php | 15 +++++++++------ resources/views/admin/tests/show.blade.php | 13 +++++++------ 4 files changed, 19 insertions(+), 15 deletions(-) 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')