using System.ComponentModel.DataAnnotations; namespace DramaLing.Api.Models.Entities; /// /// 學習會話中的詞卡進度追蹤 /// public class StudyCard { public Guid Id { get; set; } public Guid StudySessionId { get; set; } public Guid FlashcardId { get; set; } [Required] [MaxLength(100)] public string Word { get; set; } = string.Empty; /// /// 該詞卡預定的測驗類型列表 (JSON序列化) /// 例如: ["flip-memory", "vocab-choice", "sentence-fill"] /// [Required] public string PlannedTestsJson { get; set; } = string.Empty; /// /// 詞卡在會話中的順序 /// public int Order { get; set; } /// /// 是否已完成所有測驗 /// public bool IsCompleted { get; set; } = false; /// /// 詞卡學習開始時間 /// public DateTime StartedAt { get; set; } = DateTime.UtcNow; /// /// 詞卡學習完成時間 /// public DateTime? CompletedAt { get; set; } // Navigation Properties public virtual StudySession StudySession { get; set; } = null!; public virtual Flashcard Flashcard { get; set; } = null!; public virtual ICollection TestResults { get; set; } = new List(); // Helper Properties (不映射到資料庫) public List PlannedTests { get => string.IsNullOrEmpty(PlannedTestsJson) ? new List() : System.Text.Json.JsonSerializer.Deserialize>(PlannedTestsJson) ?? new List(); set => PlannedTestsJson = System.Text.Json.JsonSerializer.Serialize(value); } public int CompletedTestsCount => TestResults?.Count ?? 0; public int PlannedTestsCount => PlannedTests.Count; public bool AllTestsCompleted => CompletedTestsCount >= PlannedTestsCount; } /// /// 詞卡內的測驗結果記錄 /// public class TestResult { public Guid Id { get; set; } public Guid StudyCardId { get; set; } [Required] [MaxLength(50)] public string TestType { get; set; } = string.Empty; // flip-memory, vocab-choice, etc. public bool IsCorrect { get; set; } public string? UserAnswer { get; set; } /// /// 信心等級 (1-5, 主要用於翻卡記憶測驗) /// [Range(1, 5)] public int? ConfidenceLevel { get; set; } public int ResponseTimeMs { get; set; } public DateTime CompletedAt { get; set; } = DateTime.UtcNow; // Navigation Properties public virtual StudyCard StudyCard { get; set; } = null!; }