Refactor: Убран single_choice (частный случай multiple_choice)
✅ Все single_choice конвертированы в multiple_choice ✅ Отображение (radio/checkbox) зависит от кол-ва правильных ответов: - 1 правильный → radio (bi-circle) - 2+ правильных → checkbox (bi-check2-square) ✅ Обновлены миграции ✅ Обновлены view файлы Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
parent
acf616fc08
commit
025b03c94b
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -20,14 +20,17 @@
|
|||
<div class="d-flex justify-content-between align-items-start">
|
||||
<div>
|
||||
<span class="badge bg-secondary me-2">#{{ $loop->iteration }}</span>
|
||||
@if($question->type === 'single_choice')
|
||||
<span class="badge bg-info" title="Один ответ"><i class="bi bi-radio-button"></i></span>
|
||||
@elseif($question->type === 'multiple_choice')
|
||||
<span class="badge bg-success" title="Несколько ответов"><i class="bi bi-check2-square"></i></span>
|
||||
@elseif($question->type === 'input')
|
||||
<span class="badge bg-warning" title="Ввод текста"><i class="bi bi-textarea-resize"></i></span>
|
||||
@if($question->type === 'multiple_choice')
|
||||
@php $correctCount = $question->answers->where('is_correct', true)->count(); @endphp
|
||||
@if($correctCount === 1)
|
||||
<span class="badge bg-info" title="Один правильный ответ"><i class="bi bi-circle"></i></span>
|
||||
@else
|
||||
<span class="badge bg-success" title="Несколько правильных ответов"><i class="bi bi-check2-square"></i></span>
|
||||
@endif
|
||||
@elseif($question->type === 'matching')
|
||||
<span class="badge badge-purple" title="Соответствие"><i class="bi bi-arrow-left-right"></i></span>
|
||||
@elseif($question->type === 'ordering')
|
||||
<span class="badge bg-dark" title="Правильный порядок"><i class="bi bi-sort-numeric-down"></i></span>
|
||||
@endif
|
||||
<strong>{{ Str::limit($question->question_text, 100) }}</strong>
|
||||
<div class="mt-2">
|
||||
|
|
|
|||
|
|
@ -63,12 +63,13 @@
|
|||
@if($question->is_required)<span class="badge bg-warning ms-1"><i class="bi bi-exclamation-circle"></i></span>@endif
|
||||
</td>
|
||||
<td>
|
||||
@if($question->type === 'single_choice')
|
||||
<span class="badge bg-info" title="Один ответ"><i class="bi bi-circle"></i></span>
|
||||
@elseif($question->type === 'multiple_choice')
|
||||
<span class="badge bg-success" title="Несколько ответов"><i class="bi bi-check2-square"></i></span>
|
||||
@elseif($question->type === 'input')
|
||||
<span class="badge bg-warning" title="Ввод текста"><i class="bi bi-textarea-resize"></i></span>
|
||||
@if($question->type === 'multiple_choice')
|
||||
@php $correctCount = $question->answers->where('is_correct', true)->count(); @endphp
|
||||
@if($correctCount === 1)
|
||||
<span class="badge bg-info" title="Один правильный ответ"><i class="bi bi-circle"></i></span>
|
||||
@else
|
||||
<span class="badge bg-success" title="Несколько правильных ответов"><i class="bi bi-check2-square"></i></span>
|
||||
@endif
|
||||
@elseif($question->type === 'matching')
|
||||
<span class="badge badge-purple" title="Соответствие"><i class="bi bi-arrow-left-right"></i></span>
|
||||
@elseif($question->type === 'ordering')
|
||||
|
|
|
|||
Loading…
Reference in New Issue