116 lines
3.0 KiB
C#
116 lines
3.0 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
|
|
namespace DramaLing.Api.Models.Entities;
|
|
|
|
/// <summary>
|
|
/// 會話狀態枚舉
|
|
/// </summary>
|
|
public enum SessionStatus
|
|
{
|
|
Active, // 進行中
|
|
Completed, // 已完成
|
|
Paused, // 暫停
|
|
Abandoned // 放棄
|
|
}
|
|
|
|
/// <summary>
|
|
/// 學習會話實體 (擴展版本)
|
|
/// </summary>
|
|
public class StudySession
|
|
{
|
|
public Guid Id { get; set; }
|
|
|
|
public Guid UserId { get; set; }
|
|
|
|
[Required]
|
|
[MaxLength(50)]
|
|
public string SessionType { get; set; } = string.Empty; // flip, quiz, fill, listening, speaking
|
|
|
|
public DateTime StartedAt { get; set; } = DateTime.UtcNow;
|
|
|
|
public DateTime? EndedAt { get; set; }
|
|
|
|
public int TotalCards { get; set; } = 0;
|
|
|
|
public int CorrectCount { get; set; } = 0;
|
|
|
|
public int DurationSeconds { get; set; } = 0;
|
|
|
|
public int AverageResponseTimeMs { get; set; } = 0;
|
|
|
|
/// <summary>
|
|
/// 會話狀態
|
|
/// </summary>
|
|
public SessionStatus Status { get; set; } = SessionStatus.Active;
|
|
|
|
/// <summary>
|
|
/// 當前詞卡索引 (從0開始)
|
|
/// </summary>
|
|
public int CurrentCardIndex { get; set; } = 0;
|
|
|
|
/// <summary>
|
|
/// 當前測驗類型
|
|
/// </summary>
|
|
[MaxLength(50)]
|
|
public string? CurrentTestType { get; set; }
|
|
|
|
/// <summary>
|
|
/// 總測驗數量 (所有詞卡的測驗總和)
|
|
/// </summary>
|
|
public int TotalTests { get; set; } = 0;
|
|
|
|
/// <summary>
|
|
/// 已完成測驗數量
|
|
/// </summary>
|
|
public int CompletedTests { get; set; } = 0;
|
|
|
|
/// <summary>
|
|
/// 已完成詞卡數量
|
|
/// </summary>
|
|
public int CompletedCards { get; set; } = 0;
|
|
|
|
// Navigation Properties
|
|
public virtual User User { get; set; } = null!;
|
|
public virtual ICollection<StudyRecord> StudyRecords { get; set; } = new List<StudyRecord>();
|
|
public virtual ICollection<StudyCard> StudyCards { get; set; } = new List<StudyCard>();
|
|
}
|
|
|
|
public class StudyRecord
|
|
{
|
|
public Guid Id { get; set; }
|
|
|
|
public Guid UserId { get; set; }
|
|
|
|
public Guid FlashcardId { get; set; }
|
|
|
|
public Guid SessionId { get; set; }
|
|
|
|
[Required]
|
|
[MaxLength(50)]
|
|
public string StudyMode { get; set; } = string.Empty;
|
|
|
|
[Range(1, 5)]
|
|
public int QualityRating { get; set; }
|
|
|
|
public int? ResponseTimeMs { get; set; }
|
|
|
|
public string? UserAnswer { get; set; }
|
|
|
|
public bool IsCorrect { get; set; }
|
|
|
|
// SM-2 算法記錄
|
|
public float PreviousEasinessFactor { get; set; }
|
|
public float NewEasinessFactor { get; set; }
|
|
public int PreviousIntervalDays { get; set; }
|
|
public int NewIntervalDays { get; set; }
|
|
public int PreviousRepetitions { get; set; }
|
|
public int NewRepetitions { get; set; }
|
|
public DateTime NextReviewDate { get; set; }
|
|
|
|
public DateTime StudiedAt { get; set; } = DateTime.UtcNow;
|
|
|
|
// Navigation Properties
|
|
public virtual User User { get; set; } = null!;
|
|
public virtual Flashcard Flashcard { get; set; } = null!;
|
|
public virtual StudySession Session { get; set; } = null!;
|
|
} |