struct&&assiQues

This commit is contained in:
SpecialX
2025-06-20 15:37:39 +08:00
parent f37262d72e
commit d20c051c51
68 changed files with 1927 additions and 2869 deletions

View File

@@ -0,0 +1,77 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Entities.Contracts
{
public enum Layout : byte
{
horizontal = 0,
vertical = 1,
Auto = 2
}
public enum Publisher : byte
{
Unknown = 0,
,
,
}
public enum Grade : byte
{
Unknown = 0,
= 1,
= 2,
= 3,
= 4,
= 5,
= 6
}
public enum DifficultyLevel : byte
{
easy,
medium,
hard
}
public enum QuestionType : byte
{
Unknown = 0,
Spelling, // 拼写
Pronunciation, // 给带点字选择正确读音
WordFormation, // 组词
FillInTheBlanks, // 选词填空 / 补充词语
SentenceDictation, // 默写句子
SentenceRewriting, // 仿句 / 改写句子
ReadingComprehension, // 阅读理解
Composition // 作文
}
public enum SubjectAreaEnum : byte
{
Unknown = 0,
Mathematics, // 数学
Physics, // 物理
Chemistry, // 化学
Biology, // 生物
History, // 历史
Geography, // 地理
Literature, // 语文/文学
English, // 英语
ComputerScience, // 计算机科学
}
public enum QuestionGroupState : byte
{
Standalone,
Group,
Subquestion
}
}

View File

@@ -24,32 +24,36 @@ namespace Entities.Contracts
public string Description { get; set; }
[Column("subject_area")]
public string SubjectArea { get; set; }
public SubjectAreaEnum SubjectArea { get; set; }
[Required]
[Column("due_date")]
public DateTime DueDate { get; set; }
[Column("total_points")]
public float? TotalPoints { get; set; }
public byte TotalQuestions { get; set; }
[Column("score")]
public float Score { get; set; }
[Column("created_by")]
[ForeignKey("Creator")]
public Guid CreatedBy { get; set; }
public Guid CreatorId { get; set; }
[Column("created_at")]
public DateTime CreatedAt { get; set; }
[Column("updated_at")]
public DateTime UpdatedAt { get; set; }
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
[Column("deleted")]
public bool IsDeleted { get; set; }
public bool IsDeleted { get; set; } = false;
// Navigation Properties
[ForeignKey(nameof(CreatorId))]
public User Creator { get; set; }
public ICollection<AssignmentClass> AssignmentClasses { get; set; }
public ICollection<AssignmentGroup> AssignmentGroups { get; set; }
public AssignmentStruct ExamStruct { get; set; }
public ICollection<AssignmentAttachment> AssignmentAttachments { get; set; }
public ICollection<Submission> Submissions { get; set; }
@@ -58,7 +62,6 @@ namespace Entities.Contracts
Id = Guid.NewGuid();
Submissions = new HashSet<Submission>();
AssignmentGroups = new HashSet<AssignmentGroup>();
AssignmentClasses = new HashSet<AssignmentClass>();
AssignmentAttachments = new HashSet<AssignmentAttachment>();
}

View File

@@ -6,6 +6,7 @@ using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Entities.DTO;
namespace Entities.Contracts
{
@@ -17,41 +18,43 @@ namespace Entities.Contracts
public Guid Id { get; set; }
[Column("question_id")]
public Guid? QuestionId { get; set; } // 设为可空
// 当 IsGroup 为 true 时,此为 QuestionGroup 的外键
[Column("question_group_id")] // 新增一个外键列
public Guid? QuestionGroupId { get; set; } // 设为可空
public Guid QuestionId { get; set; }
[Required]
[Column("group_id")]
[ForeignKey("AssignmentGroup")]
public Guid AssignmentGroupId { get; set; }
public Guid AssignmentStructId { get; set; }
[Required]
[Column("question_number")]
public byte QuestionNumber { get; set; }
public byte Index { get; set; }
[Column("parent_question_group_id")]
public Guid? ParentAssignmentQuestionId { get; set; }
[Column("group_state")]
public QuestionGroupState GroupState { get; set; } = QuestionGroupState.Standalone;
[Column("created_at")]
public DateTime CreatedAt { get; set; }
[Column("score")]
public float? Score { get; set; }
[Required]
[Column("bgroup")]
public bool IsGroup { get; set; }
[Column("deleted")]
public bool IsDeleted { get; set; }
public Question Question { get; set; }
public QuestionGroup QuestionGroup { get; set; }
public AssignmentStruct AssignmentStruct { get; set; }
public ICollection<SubmissionDetail> SubmissionDetails { get; set; }
public AssignmentGroup AssignmentGroup { get; set; }
[ForeignKey(nameof(ParentAssignmentQuestionId))]
public AssignmentQuestion? ParentAssignmentQuestion { get; set; }
public ICollection<AssignmentQuestion> ChildrenAssignmentQuestion { get; set; } = new List<AssignmentQuestion>();
public AssignmentQuestion()
{

View File

@@ -5,11 +5,12 @@ using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
namespace Entities.Contracts
{
[Table("assignment_group")]
public class AssignmentGroup
public class AssignmentStruct
{
[Key]
[Column("id")]
@@ -26,35 +27,34 @@ namespace Entities.Contracts
[Column("descript")]
[MaxLength(65535)]
public string Descript { get; set; }
public string Description { get; set; }
[Column("layout")]
public Layout Layout { get; set; }
[Column("total_points")]
public float? TotalPoints { get; set; }
public float? Score { get; set; }
[Column("number")]
public byte Number { get; set; }
[Column("index")]
public byte Index { get; set; }
[Column("parent_group")]
public Guid? ParentGroup { get; set; }
public Guid? ParentStructId { get; set; }
[Column("deleted")]
public bool IsDeleted { get; set; }
[Column("valid_question_group")]
public bool ValidQuestionGroup { get; set; }
public bool IsDeleted { get; set; } = false;
// Navigation Properties
public Assignment? Assignment { get; set; }
public AssignmentGroup? ParentAssignmentGroup { get; set;}
public ICollection<AssignmentGroup> ChildAssignmentGroups { get; set; }
public AssignmentStruct? ParentStruct { get; set;}
public ICollection<AssignmentStruct> ChildrenGroups { get; set; }
public ICollection<AssignmentQuestion> AssignmentQuestions { get; set; }
public AssignmentGroup()
public AssignmentStruct()
{
Id = Guid.NewGuid();
ChildAssignmentGroups = new HashSet<AssignmentGroup>();
ChildrenGroups = new HashSet<AssignmentStruct>();
AssignmentQuestions = new HashSet<AssignmentQuestion>();
}
}

View File

@@ -22,6 +22,6 @@ namespace Entities.Contracts
public User Teacher { get; set; }
[Column("subject_taught")]
public string SubjectTaught { get; set; }
public SubjectAreaEnum SubjectTaught { get; set; }
}
}

View File

@@ -16,36 +16,43 @@ namespace Entities.Contracts
public Guid Id { get; set; }
[Required]
[Column("question_text")]
[Column("title")]
[MaxLength(65535)]
public string QuestionText { get; set; }
public string Title { get; set; }
[Column("answer")]
[MaxLength(65535)]
public string? Answer { get; set; }
[Column("description")]
public Guid? DescriptionId { get; set; }
[Required]
[Column("question_type")]
[Column("type")]
[MaxLength(20)]
public QuestionType QuestionType { get; set; }
[Column("correct_answer")]
[MaxLength(65535)]
public string CorrectAnswer { get; set; }
[Column("question_group_id")]
public Guid? QuestionGroupId { get; set; }
public QuestionType Type { get; set; } = QuestionType.Unknown;
[Column("difficulty_level")]
[MaxLength(10)]
public DifficultyLevel DifficultyLevel { get; set; }
public DifficultyLevel DifficultyLevel { get; set; } = DifficultyLevel.easy;
[Column("subject_area")]
public SubjectAreaEnum SubjectArea { get; set; }
public SubjectAreaEnum SubjectArea { get; set; } = SubjectAreaEnum.Unknown;
[Column("options")]
public string? Options { get; set; }
[Column("key_point")]
public Guid? KeyPointId { get; set; }
[Column("lesson")]
public Guid? LessonId { get; set; }
[Required]
[Column("created_by")]
[ForeignKey("Creator")]
public Guid CreatedBy { get; set; }
public Guid CreatorId { get; set; }
[Column("created_at")]
public DateTime CreatedAt { get; set; }
@@ -56,54 +63,30 @@ namespace Entities.Contracts
[Column("deleted")]
public bool IsDeleted { get; set; }
[Column("valid_question")]
public bool ValidQuestion { get; set; }
// Navigation Properties
[ForeignKey(nameof(CreatorId))]
public User Creator { get; set; }
public QuestionGroup QuestionGroup { get; set; }
public ICollection<AssignmentQuestion> AssignmentQuestions { get; set; }
[ForeignKey(nameof(DescriptionId))]
public QuestionContext Description { get; set; }
public Question? ParentQuestion { get; set; }
public ICollection<Question>? ChildrenQuestion { get; set; }
[ForeignKey(nameof(KeyPointId))]
public KeyPoint? KeyPoint { get; set; }
[ForeignKey(nameof(LessonId))]
public Lesson? Lesson { get; set; }
public ICollection<AssignmentQuestion>? AssignmentQuestions { get; set; }
public Question()
{
Id = Guid.NewGuid();
AssignmentQuestions = new HashSet<AssignmentQuestion>();
ChildrenQuestion = new HashSet<Question>();
}
}
public enum DifficultyLevel
{
easy,
medium,
hard
}
public enum QuestionType
{
Unknown, // 可以有一个未知类型或作为默认
Spelling, // 拼写
Pronunciation, // 给带点字选择正确读音
WordFormation, // 组词
FillInTheBlanks, // 选词填空 / 补充词语
SentenceDictation, // 默写句子
SentenceRewriting, // 仿句 / 改写句子
ReadingComprehension, // 阅读理解
Composition // 作文
// ... 添加您其他题目类型
}
public enum SubjectAreaEnum // 建议命名为 SubjectAreaEnum 以避免与属性名冲突
{
Unknown, // 未知或默认
Mathematics, // 数学
Physics, // 物理
Chemistry, // 化学
Biology, // 生物
History, // 历史
Geography, // 地理
Literature, // 语文/文学
English, // 英语
ComputerScience, // 计算机科学
// ... 你可以根据需要添加更多科目
}
}

View File

@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Entities.Contracts
{
public class QuestionContext
{
public Guid Id { get; set; }
public string Description { get; set; } = string.Empty;
[InverseProperty(nameof(Question.Description))]
public ICollection<Question> Questions { get; set; } = new List<Question>();
public QuestionContext()
{
Questions = new HashSet<Question>();
}
}
}

View File

@@ -1,79 +0,0 @@
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("question_groups")]
public class QuestionGroup
{
[Key]
[Column("id")]
public Guid Id { get; set; }
[Column("title")]
[MaxLength(255)]
public string Title { get; set; }
[Required]
[Column("description")]
[MaxLength(65535)]
public string Description { get; set; }
[Column("type")]
[MaxLength(50)]
public string Type { get; set; }
[Column("difficulty_level")]
[MaxLength(10)]
public DifficultyLevel DifficultyLevel { get; set; }
[Column("subject_area")]
public SubjectAreaEnum SubjectArea { get; set; }
[Column("total_questions")]
public int TotalQuestions { get; set; } = 0;
[Column("parent_question_group")]
public Guid? ParentQG { get; set; }
[Required]
[Column("created_by")]
[ForeignKey("Creator")]
public Guid CreatedBy { get; set; }
[Column("created_at")]
public DateTime CreatedAt { get; set; }
[Column("updated_at")]
public DateTime UpdatedAt { get; set; }
[Column("deleted")]
public bool IsDeleted { get; set; }
[Column("valid_group")]
public bool ValidGroup { get; set; }
public User Creator { get; set; }
public QuestionGroup ParentQuestionGroup { get; set; }
public ICollection<QuestionGroup> ChildQuestionGroups { get; set; }
public ICollection<AssignmentQuestion> AssignmentQuestions { get; set; }
public ICollection<Question> Questions { get; set; }
public QuestionGroup()
{
Id = Guid.NewGuid();
Questions = new HashSet<Question>();
CreatedAt = DateTime.UtcNow;
UpdatedAt = DateTime.UtcNow;
IsDeleted = false;
ValidGroup = true;
}
}
}

View File

@@ -41,7 +41,7 @@ namespace Entities.Contracts
[Column("graded_by")]
[ForeignKey("Grader")]
public Guid? GradedBy { get; set; }
public Guid? GraderId { get; set; }
[Column("graded_at")]
public DateTime? GradedAt { get; set; }
@@ -74,6 +74,5 @@ namespace Entities.Contracts
Resubmission, // 待重新提交 (如果允许)
Late, // 迟交
Draft, // 草稿
// ... 添加你需要的其他状态
}
}

View File

@@ -23,7 +23,6 @@ namespace Entities.Contracts
[Required]
[Column("student_id")]
[ForeignKey("User")]
public Guid StudentId { get; set; }
[Required]
@@ -52,8 +51,11 @@ namespace Entities.Contracts
[Column("deleted")]
public bool IsDeleted { get; set; }
[ForeignKey(nameof(StudentId))]
public User Student { get; set; }
public Submission Submission { get; set; }
public User User { get; set; }
public AssignmentQuestion AssignmentQuestion { get; set; }
public SubmissionDetail()

View File

@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Entities.Contracts
{
[Table("key_point")]
public class KeyPoint
{
[Key]
public Guid Id { get; set; }
[StringLength(255)]
public string Key { get; set; } = string.Empty;
[Required]
public Guid LessonID { get; set; }
[ForeignKey(nameof(LessonID))]
public Lesson Lesson { get; set; }
public ICollection<Question> Questions { get; set; }
public KeyPoint()
{
Id = Guid.NewGuid();
Questions = new HashSet<Question>();
}
}
}

View File

@@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Entities.Contracts
{
[Table("lesson")]
public class Lesson
{
[Key]
public Guid Id { get; set; }
[StringLength(255)]
public string Title { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
[Required]
public Guid TextbookID { get; set; }
[ForeignKey(nameof(TextbookID))]
public Textbook Textbook { get; set; }
[InverseProperty(nameof(KeyPoint.Lesson))]
public ICollection<KeyPoint>? KeyPoints { get; set; }
[InverseProperty(nameof(Question.Lesson))]
public ICollection<Question>? Questions { get; set; }
[InverseProperty(nameof(LessonQuestion.Lesson))]
public ICollection<LessonQuestion>? LessonQuestions { get; set; }
public Lesson()
{
Id = Guid.NewGuid();
KeyPoints = new HashSet<KeyPoint>();
Questions = new HashSet<Question>();
LessonQuestions = new HashSet<LessonQuestion>();
}
}
}

View File

@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Entities.Contracts
{
[Table("lesson_question")]
public class LessonQuestion
{
[Key]
public Guid Id { get; set; }
[MaxLength(65535)]
public string Question { get; set; }
[Required]
public Guid LessonID { get; set; }
[ForeignKey(nameof(LessonID))]
public Lesson Lesson { get; set; }
public LessonQuestion()
{
Id = Guid.NewGuid();
}
}
}

View File

@@ -0,0 +1,36 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Entities.Contracts
{
[Table("textbook")]
public class Textbook
{
[Key]
public Guid Id { get; set; }
public Grade Grade { get; set; } = Grade.Unknown;
public string Title { get; set; } = string.Empty;
public Publisher Publisher { get; set; } = Publisher.;
public SubjectAreaEnum SubjectArea { get; set; } = SubjectAreaEnum.Unknown;
[InverseProperty(nameof(Lesson.Textbook))]
public ICollection<Lesson> Lessons { get; set; }
public Textbook()
{
Id = Guid.NewGuid();
Lessons = new HashSet<Lesson>();
}
}
}

View File

@@ -0,0 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Entities.DTO
{
}

View File

@@ -0,0 +1,25 @@
using Entities.Contracts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Entities.DTO
{
public class AssignmentQuestionDto
{
public float Score { get; set; } = 0;
public byte Index { get; set; } = 0;
public QuestionGroupState GroupState { get; set; } = QuestionGroupState.Standalone;
public AssignmentQuestionDto? ParentAssignmentQuestion { get; set; }
public ICollection<AssignmentQuestionDto> ChildrenAssignmentQuestion { get; set; } = new List<AssignmentQuestionDto>();
public QuestionDto Question { get; set; }
}
}

View File

@@ -1,4 +1,5 @@
using System;
using Entities.Contracts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -7,36 +8,88 @@ using System.Xml.Serialization;
namespace Entities.DTO
{
public class AssignmentStructDto
{
public Guid Id { get; set; } = Guid.Empty;
public string Title { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
public float Score { get; set; } = 0;
public byte Index { get; set; } = 0;
public Layout Layout { get; set; } = Layout.horizontal;
public ICollection<AssignmentQuestionDto> AssignmentQuestions { get; set; } = new List<AssignmentQuestionDto>();
public AssignmentStructDto? ParentStruct { get; set; }
public ICollection<AssignmentStructDto> ChildrenGroups { get; set; } = new List<AssignmentStructDto>();
}
public class AssignmentDto
{
public Guid Id { get; set; } = Guid.Empty;
public string Title { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
public byte TotalQuestions { get; set; }
public float Score { get; set; } = 0;
public SubjectAreaEnum SubjectArea { get; set; } = SubjectAreaEnum.Unknown;
public DateTime CreatedAt { get; set; }
public DateTime UpdatedAt { get; set; }
public DateTime DueDate { get; set; }
public Guid CreatorId { get; set; }
public AssignmentStructDto ExamStruct { get; set; } = new AssignmentStructDto();
}
public class AssignmentClassDto
{
public AssignmentDto Assignment { get; set; }
public Class ClassId { get; set; }
public DateTime AssignedAt { get; set; }
}
public class QuestionContextDto
{
public Guid Id { get; set; } = Guid.Empty;
public string Description { get; set; } = string.Empty;
}
public class ExamDto
{
public Guid? AssignmentId { get; set; }
public string CreaterEmail { get; set; }
public string CreaterEmail { get; set; }
public string AssignmentTitle { get; set; } = string.Empty;
public string Description { get; set; }
public string SubjectArea { get; set; }
public QuestionGroupDto QuestionGroups { get; set; } = new QuestionGroupDto();
public QuestionGroupDto ExamStruct { get; set; } = new QuestionGroupDto();
}
public class QuestionGroupDto
{
public byte Index { get; set; }
public byte Index { get; set; }
public string? Title { get; set; }
public float Score { get; set; }
public string? Descript { get; set; }
public string? Descript { get; set; }
public List<SubQuestionDto> SubQuestions { get; set; } = new List<SubQuestionDto>();
public List<QuestionGroupDto> SubQuestionGroups { get; set; } = new List<QuestionGroupDto>();
// 标记是否是一个具有上下文的单独问题
public bool ValidQuestionGroup { get; set; } = false;
}
public class SubQuestionDto
{
public byte Index { get; set; }
public byte Index { get; set; }
public string? Stem { get; set; }
@@ -44,12 +97,11 @@ namespace Entities.DTO
public List<OptionDto> Options { get; set; } = new List<OptionDto>();
public string? SampleAnswer { get; set; }
public string? SampleAnswer { get; set; }
public string? QuestionType { get; set; }
public string? QuestionType { get; set; }
public string? DifficultyLevel { get; set; }
// 标记是否是一个独立的问题
public bool ValidQuestion { get; set; } = false;
}
@@ -64,13 +116,13 @@ namespace Entities.DTO
{
public static void Convert(this ExamDto examDto)
{
var qg = examDto.QuestionGroups;
var qg = examDto.ExamStruct;
}
public static void Convert(this QuestionGroupDto examDto)
{
if(examDto.ValidQuestionGroup)
if (examDto.ValidQuestionGroup)
{
}

View File

@@ -0,0 +1,41 @@
using Entities.Contracts;
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.DTO
{
public class QuestionDto
{
public Guid Id { get; set; } = Guid.Empty;
public string Title { get; set; } = string.Empty;
public QuestionContextDto? Description { get; set; }
public QuestionType Type { get; set; } = QuestionType.Unknown;
public string? Answer { get; set; } = string.Empty;
public string? Options { get; set; }
public DifficultyLevel DifficultyLevel { get; set; } = DifficultyLevel.easy;
public SubjectAreaEnum SubjectArea { get; set; } = SubjectAreaEnum.Unknown;
public Guid CreatorId { get; set; }
public Guid? KeyPointId { get; set; }
public Guid? LessonId { get; set; }
public DateTime CreatedAt { get; set; }
public DateTime UpdatedAt { get; set; } = DateTime.Now;
}
}