Feat: Обновление вопросов

 Удалён input тип (не имеет смысла без автопроверки)
 Добавлен ordering тип (сортировка элементов)
 Добавлено поле image для ответов
 Миграции применены
 QuestionOrderingItem модель

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
mirivlad
2026-03-27 09:51:17 +08:00
co-authored by Qwen-Coder
parent e730cd4856
commit acf616fc08
6 changed files with 80 additions and 2 deletions
@@ -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', 'input', 'matching'])->default('single_choice');
$table->enum('type', ['single_choice', 'multiple_choice', 'matching', 'ordering'])->default('multiple_choice');
$table->text('question_text');
$table->text('explanation')->nullable();
$table->integer('score')->default(1);
@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;
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 элементов
Schema::create('question_ordering_items', function (Blueprint $table) {
$table->id();
$table->foreignId('question_id')->constrained()->onDelete('cascade');
$table->string('item_text');
$table->integer('correct_order');
$table->integer('sort_order')->default(0);
$table->timestamps();
$table->index('question_id');
});
}
public function down(): void
{
Schema::dropIfExists('question_ordering_items');
DB::statement("ALTER TABLE questions MODIFY COLUMN type ENUM('single_choice', 'multiple_choice', 'input', 'matching') NOT NULL");
}
};
@@ -0,0 +1,28 @@
<?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::table('answers', function (Blueprint $table) {
//
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('answers', function (Blueprint $table) {
//
});
}
};