using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; namespace NexusReader.Domain.Entities; /// /// Tracks the result of an AI-generated quiz completed by a user. /// public class QuizResult { [Key] public Guid Id { get; set; } = Guid.NewGuid(); [Required] public string UserId { get; set; } = string.Empty; [ForeignKey(nameof(UserId))] public NexusUser? User { get; set; } [Required] [MaxLength(128)] public string TenantId { get; set; } = "global"; [Required] public string Topic { get; set; } = string.Empty; public int Score { get; set; } public int TotalQuestions { get; set; } public double Percentage => TotalQuestions > 0 ? (double)Score / TotalQuestions * 100 : 0; public DateTime CompletedDate { get; set; } = DateTime.UtcNow; }