using Jiaowu.Api.Domain.Common;

namespace Jiaowu.Api.Domain.Academic;

/// <summary>
/// 评教方案 — 每个学期可以有一个评教方案，包含多个评分维度。
/// </summary>
public sealed class EvaluationSetup : EntityBase
{
    public Guid AcademicTermId { get; set; }
    public AcademicTerm AcademicTerm { get; set; } = null!;

    /// <summary>方案名称，如"2026年秋季学期学生评教"</summary>
    public string Name { get; set; } = string.Empty;

    /// <summary>状态：Draft / Open / Closed</summary>
    public EvaluationSetupStatus Status { get; set; } = EvaluationSetupStatus.Draft;

    public DateTime? StartsAt { get; set; }
    public DateTime? EndsAt { get; set; }

    public ICollection<EvaluationDimension> Dimensions { get; set; } = new List<EvaluationDimension>();
    public ICollection<EvaluationRecord> Records { get; set; } = new List<EvaluationRecord>();
}

public enum EvaluationSetupStatus
{
    Draft = 0,
    Open = 1,
    Closed = 2
}

/// <summary>
/// 评分维度 — 例如"教学内容 30分"、"教学方法 30分"等。
/// </summary>
public sealed class EvaluationDimension : EntityBase
{
    public Guid EvaluationSetupId { get; set; }
    public EvaluationSetup EvaluationSetup { get; set; } = null!;

    /// <summary>维度名称</summary>
    public string Name { get; set; } = string.Empty;

    /// <summary>该维度满分</summary>
    public int MaxScore { get; set; }

    /// <summary>排序</summary>
    public int SortOrder { get; set; }

    public ICollection<EvaluationScore> Scores { get; set; } = new List<EvaluationScore>();
}

/// <summary>
/// 学生评教记录 — 一个学生对一个教学班的评价。
/// </summary>
public sealed class EvaluationRecord : EntityBase
{
    public Guid EvaluationSetupId { get; set; }
    public EvaluationSetup EvaluationSetup { get; set; } = null!;

    public Guid StudentId { get; set; }
    public Student Student { get; set; } = null!;

    public Guid TeachingTaskId { get; set; }
    public TeachingTask TeachingTask { get; set; } = null!;

    public DateTime? SubmittedAt { get; set; }

    public ICollection<EvaluationScore> Scores { get; set; } = new List<EvaluationScore>();
}

/// <summary>
/// 评分明细 — 每个维度一条记录。
/// </summary>
public sealed class EvaluationScore
{
    public Guid EvaluationRecordId { get; set; }
    public EvaluationRecord EvaluationRecord { get; set; } = null!;

    public Guid EvaluationDimensionId { get; set; }
    public EvaluationDimension EvaluationDimension { get; set; } = null!;

    public int Score { get; set; }
}
