- Add QuizQuestion and QuizOption domain entities with QuestionType enum - Add IQuizQuestionRepository and IQuizOptionRepository interfaces - Add QuizQuestionRepository and QuizOptionRepository EF Core implementations - Add QuizQuestionService with CRUD, quiz submission, and statistics - Add QuizQuestionsController with comprehensive REST API endpoints - Add QuizQuestionDto and related DTOs for API communication - Add EF Core migration (20260612050652_AddQuizQuestionTables) for QuizQuestion and QuizOption - Add seed data with sample quiz questions for Greetings, Numbers, Grammar lessons - Update AppDbContext with DbSets and entity configurations - Update Program.cs with migration retry logic for Docker - Update docker-compose.yml with SeedDatabase configuration - Add unit tests for QuizQuestionService Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
87 lines
4 KiB
C#
87 lines
4 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
|
|
#nullable disable
|
|
|
|
namespace GermanApp.Infrastructure.Data.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class AddQuizQuestionTables : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "QuizQuestions",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
LessonId = table.Column<int>(type: "integer", nullable: false),
|
|
QuestionText = table.Column<string>(type: "character varying(2000)", maxLength: 2000, nullable: false),
|
|
Type = table.Column<int>(type: "integer", nullable: false),
|
|
CorrectAnswer = table.Column<string>(type: "character varying(1000)", maxLength: 1000, nullable: true),
|
|
Difficulty = table.Column<int>(type: "integer", nullable: false, defaultValue: 3),
|
|
Order = table.Column<int>(type: "integer", nullable: false, defaultValue: 1),
|
|
IsActive = table.Column<bool>(type: "boolean", nullable: false, defaultValue: true),
|
|
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_QuizQuestions", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_QuizQuestions_Lessons_LessonId",
|
|
column: x => x.LessonId,
|
|
principalTable: "Lessons",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "QuizOptions",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
QuizQuestionId = table.Column<int>(type: "integer", nullable: false),
|
|
Text = table.Column<string>(type: "character varying(1000)", maxLength: 1000, nullable: false),
|
|
IsCorrect = table.Column<bool>(type: "boolean", nullable: false, defaultValue: false),
|
|
Order = table.Column<int>(type: "integer", nullable: false, defaultValue: 1)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_QuizOptions", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_QuizOptions_QuizQuestions_QuizQuestionId",
|
|
column: x => x.QuizQuestionId,
|
|
principalTable: "QuizQuestions",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_QuizOptions_QuizQuestionId_Order",
|
|
table: "QuizOptions",
|
|
columns: new[] { "QuizQuestionId", "Order" },
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_QuizQuestions_LessonId_Order",
|
|
table: "QuizQuestions",
|
|
columns: new[] { "LessonId", "Order" },
|
|
unique: true);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "QuizOptions");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "QuizQuestions");
|
|
}
|
|
}
|
|
}
|