重构试卷相关内容
This commit is contained in:
@@ -16,10 +16,12 @@ namespace Entities.Contracts
|
||||
[Column("id")]
|
||||
public Guid Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("question_id")]
|
||||
[ForeignKey("Question")]
|
||||
public Guid QuestionId { get; set; }
|
||||
public Guid? QuestionId { get; set; } // 设为可空
|
||||
|
||||
// 当 IsGroup 为 true 时,此为 QuestionGroup 的外键
|
||||
[Column("question_group_id")] // 新增一个外键列
|
||||
public Guid? QuestionGroupId { get; set; } // 设为可空
|
||||
|
||||
[Required]
|
||||
[Column("group_id")]
|
||||
@@ -38,11 +40,16 @@ namespace Entities.Contracts
|
||||
[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 ICollection<SubmissionDetail> SubmissionDetails { get; set; }
|
||||
public AssignmentGroup AssignmentGroup { get; set; }
|
||||
|
||||
|
@@ -29,6 +29,9 @@ namespace Entities.Contracts
|
||||
[MaxLength(65535)]
|
||||
public string CorrectAnswer { get; set; }
|
||||
|
||||
[Column("question_group_id")]
|
||||
public Guid? QuestionGroupId { get; set; }
|
||||
|
||||
[Column("difficulty_level")]
|
||||
[MaxLength(10)]
|
||||
public DifficultyLevel DifficultyLevel { get; set; }
|
||||
@@ -36,6 +39,9 @@ namespace Entities.Contracts
|
||||
[Column("subject_area")]
|
||||
public SubjectAreaEnum SubjectArea { get; set; }
|
||||
|
||||
[Column("options")]
|
||||
public string? Options { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("created_by")]
|
||||
[ForeignKey("Creator")]
|
||||
@@ -55,6 +61,7 @@ namespace Entities.Contracts
|
||||
|
||||
// Navigation Properties
|
||||
public User Creator { get; set; }
|
||||
public QuestionGroup QuestionGroup { get; set; }
|
||||
public ICollection<AssignmentQuestion> AssignmentQuestions { get; set; }
|
||||
|
||||
public Question()
|
||||
|
79
Entities/Contracts/QuestionGroup.cs
Normal file
79
Entities/Contracts/QuestionGroup.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
@@ -52,7 +52,6 @@ namespace Entities.Contracts
|
||||
[Column("deleted")]
|
||||
public bool IsDeleted { get; set; }
|
||||
|
||||
// Navigation Properties
|
||||
public Submission Submission { get; set; }
|
||||
public User User { get; set; }
|
||||
public AssignmentQuestion AssignmentQuestion { get; set; }
|
||||
|
@@ -27,7 +27,6 @@ namespace Entities.DTO
|
||||
|
||||
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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user