重构作业结构:优化实体模型、DTO映射和前端界面
Some checks failed
TechAct / explore-gitea-actions (push) Failing after 13s

- 重构AppMainStruct、AssignmentQuestion、Question等实体模型
- 更新相关DTO以匹配新的数据结构
- 优化前端页面布局和组件
- 添加全局信息和笔记功能相关代码
- 更新数据库迁移和程序配置
This commit is contained in:
SpecialX
2025-09-04 15:43:33 +08:00
parent 730b0ba04b
commit 6a65281850
58 changed files with 5459 additions and 244 deletions

View File

@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
@@ -34,9 +36,11 @@ namespace Entities.Contracts
public enum DifficultyLevel : byte
{
simple,
easy,
medium,
hard
hard,
veryHard
}
public enum QuestionType : byte
@@ -55,47 +59,131 @@ namespace Entities.Contracts
public enum SubjectAreaEnum : byte
{
Unknown = 0,
Mathematics, // 数学
Physics, // 物理
Chemistry, // 化学
Biology, // 生物
History, // 历史
Geography, // 地理
[Display(Name = "未知", Description = "未知")]
Unknown = 0,
[Display(Name = "数学", Description = "数")]
Mathematics, // 数学
[Display(Name = "物理", Description = "物")]
Physics, // 物理
[Display(Name = "化学", Description = "化")]
Chemistry, // 化学
[Display(Name = "生物", Description = "生")]
Biology, // 生物
[Display(Name = "历史", Description = "史")]
History, // 历史
[Display(Name = "地理", Description = "地")]
Geography, // 地理
[Display(Name = "语文", Description = "语")]
Literature, // 语文/文学
English, // 英语
ComputerScience, // 计算机科学
[Display(Name = "英语", Description = "英")]
English, // 英语
[Display(Name = "计算机科学", Description = "计")]
ComputerScience // 计算机科学
}
public enum AssignmentStructType : byte
{
[Display(Name = "根节点", Description = "根")]
Root,
[Display(Name = "单个问题", Description = "问")]
Question,
[Display(Name = "问题组", Description = "组")]
Group,
[Display(Name = "结构", Description = "结")]
Struct,
[Display(Name = "子问题", Description = "子")]
SubQuestion,
[Display(Name = "选项", Description = "选")]
Option
}
public enum ExamType : byte
{
MidtermExam, // 期中
FinalExam, // 期末
MonthlyExam, // 月考
WeeklyExam, // 周考
DailyTest, // 平时测试
AITest, // AI测试
}
[Display(Name = "期中考试", Description = "中")]
MidtermExam,
[Display(Name = "期末考试", Description = "末")]
FinalExam,
[Display(Name = "月考", Description = "月")]
MonthlyExam,
[Display(Name = "周考", Description = "周")]
WeeklyExam,
[Display(Name = "平时测试", Description = "平")]
DailyTest,
[Display(Name = "AI测试", Description = "AI")]
AITest,
}
public enum SubmissionStatus
{
Pending, // 待提交/未开始
Submitted, // 已提交
Graded, // 已批改
Resubmission, // 待重新提交 (如果允许)
Late, // 迟交
Draft, // 草稿
[Display(Name = "待提交/未开始", Description = "待")]
Pending,
[Display(Name = "已提交", Description = "提")]
Submitted,
[Display(Name = "已批改", Description = "批")]
Graded,
[Display(Name = "待重新提交", Description = "重")]
Resubmission,
[Display(Name = "迟交", Description = "迟")]
Late,
[Display(Name = "草稿", Description = "草")]
Draft,
}
public static class EnumExtensions
{
public static string GetDisplayName(this Enum enumValue)
{
var fieldInfo = enumValue.GetType().GetField(enumValue.ToString());
if (fieldInfo == null)
{
return enumValue.ToString();
}
var displayAttribute = fieldInfo.GetCustomAttribute<DisplayAttribute>();
if (displayAttribute != null)
{
return displayAttribute.Name;
}
return enumValue.ToString();
}
public static string GetShortName(this Enum enumValue)
{
var memberInfo = enumValue.GetType().GetMember(enumValue.ToString()).FirstOrDefault();
if (memberInfo != null)
{
var displayAttribute = memberInfo.GetCustomAttribute<DisplayAttribute>();
if (displayAttribute != null && !string.IsNullOrEmpty(displayAttribute.Description))
{
return displayAttribute.Description;
}
}
return enumValue.ToString();
}
}
}

View File

@@ -40,6 +40,8 @@ namespace Entities.Contracts
[Column("group_state")]
public AssignmentStructType StructType { get; set; } = AssignmentStructType.Question;
public QuestionType Type { get; set; } = QuestionType.Unknown;
[Column("created_at")]
public DateTime CreatedAt { get; set; }

View File

@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Entities.Contracts
{
[Table("global")]
public class Global
{
[Key]
[Column("id")]
public Guid Id { get; set; } = Guid.NewGuid();
public SubjectAreaEnum Area { get; set; }
public string Info { get; set; } = string.Empty;
}
}

View File

@@ -38,6 +38,7 @@ namespace Entities.Contracts
[Column("subject_area")]
public SubjectAreaEnum SubjectArea { get; set; } = SubjectAreaEnum.Unknown;
public string QType { get; set; } = string.Empty;
[Column("options")]
public string? Options { get; set; }

View File

@@ -15,8 +15,8 @@ namespace Entities.Contracts
public string? RefreshToken { get; set; }
public DateTime? RefreshTokenExpiryTime { get; set; }
public string? Address { get; set; }
public string? DisplayName { get; set; }
public string? DisplayName { get; set; }
public SubjectAreaEnum SubjectArea { get; set; } = SubjectAreaEnum.Unknown;
[Column("deleted")]
public bool IsDeleted { get; set; }

View File

@@ -17,6 +17,8 @@ namespace Entities.DTO
public float Score { get; set; } = 0;
public string Sequence { get; set; } = string.Empty;
public bool BCorrect { get; set; } = true;
public QuestionType Type { get; set; } = QuestionType.Unknown;
public string QType { get; set; } = string.Empty;
public Layout Layout { get; set; } = Layout.horizontal;
public AssignmentStructType StructType { get; set; } = AssignmentStructType.Question;

23
Entities/DTO/GlobalDto.cs Normal file
View File

@@ -0,0 +1,23 @@
using Entities.Contracts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Entities.DTO
{
public class GlobalDto
{
public SubjectAreaEnum SubjectArea { get; set; } = SubjectAreaEnum.Unknown;
public string Data { get; set; } = string.Empty;
}
public class QuestionDisplayTypeData
{
public string Color { get; set; }
public string DisplayName { get; set; }
}
}

View File

@@ -16,6 +16,7 @@ namespace Entities.DTO
public string Title { get; set; } = string.Empty;
public QuestionType Type { get; set; } = QuestionType.Unknown;
public string QType { get; set; } = string.Empty;
public string? Answer { get; set; } = string.Empty;

View File

@@ -0,0 +1,14 @@
using System.ComponentModel.DataAnnotations;
using System.Collections.Generic;
using Entities.Contracts;
namespace Entities.DTO
{
public class SubjectTypeMetadataDto
{
public SubjectAreaEnum SubjectArea { get; set; } = SubjectAreaEnum.Unknown;
//public Dictionary<string, (string Color, string DisplayName)> Data = new Dictionary<string, (string Color, string DisplayName)>();
public string Data = string.Empty;
}
}