AsiignmentStruct

This commit is contained in:
SpecialX
2025-06-20 18:58:11 +08:00
parent d20c051c51
commit 681c0862b6
32 changed files with 414 additions and 752 deletions

View File

@@ -67,11 +67,11 @@ namespace Entities.Contracts
ComputerScience, // 计算机科学
}
public enum QuestionGroupState : byte
public enum AssignmentStructType : byte
{
Standalone,
Group,
Subquestion
Question,
Struct,
SubQuestion
}
}

View File

@@ -5,6 +5,7 @@ using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Entities.DTO;
namespace Entities.Contracts
{
@@ -53,7 +54,7 @@ namespace Entities.Contracts
[ForeignKey(nameof(CreatorId))]
public User Creator { get; set; }
public ICollection<AssignmentClass> AssignmentClasses { get; set; }
public AssignmentStruct ExamStruct { get; set; }
public AssignmentQuestion ExamStruct { get; set; }
public ICollection<AssignmentAttachment> AssignmentAttachments { get; set; }
public ICollection<Submission> Submissions { get; set; }

View File

@@ -18,23 +18,28 @@ namespace Entities.Contracts
public Guid Id { get; set; }
[Column("question_id")]
public Guid QuestionId { get; set; }
public Guid? QuestionId { get; set; }
[Required]
[Column("group_id")]
[ForeignKey("AssignmentGroup")]
public Guid AssignmentStructId { get; set; }
[Column("assignment")]
[ForeignKey("Assignment")]
public Guid? AssignmentId { get; set; }
[Column("title")]
[MaxLength(1024)]
public string? Title { get; set; }
[Column("description")]
public Guid? QuestionContextId { get; set; }
[Required]
[Column("question_number")]
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;
public AssignmentStructType StructType { get; set; } = AssignmentStructType.Question;
[Column("created_at")]
public DateTime CreatedAt { get; set; }
@@ -42,13 +47,17 @@ namespace Entities.Contracts
[Column("score")]
public float? Score { get; set; }
[Column("deleted")]
public bool IsDeleted { get; set; }
public Question Question { get; set; }
public AssignmentStruct AssignmentStruct { get; set; }
public Question? Question { get; set; }
public Assignment? Assignment { get; set; }
[ForeignKey(nameof(QuestionContextId))]
public QuestionContext? QuestionContext { get; set; }
public ICollection<SubmissionDetail> SubmissionDetails { get; set; }
[ForeignKey(nameof(ParentAssignmentQuestionId))]

View File

@@ -1,61 +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;
using System.Runtime.InteropServices;
namespace Entities.Contracts
{
[Table("assignment_group")]
public class AssignmentStruct
{
[Key]
[Column("id")]
public Guid Id { get; set; }
[Column("assignment")]
[ForeignKey("Assignment")]
public Guid? AssignmentId { get; set; }
[Required]
[Column("title")]
[MaxLength(65535)]
public string Title { get; set; }
[Column("descript")]
[MaxLength(65535)]
public string Description { get; set; }
[Column("layout")]
public Layout Layout { get; set; }
[Column("total_points")]
public float? Score { get; set; }
[Column("index")]
public byte Index { get; set; }
[Column("parent_group")]
public Guid? ParentStructId { get; set; }
[Column("deleted")]
public bool IsDeleted { get; set; } = false;
// Navigation Properties
public Assignment? Assignment { get; set; }
public AssignmentStruct? ParentStruct { get; set;}
public ICollection<AssignmentStruct> ChildrenGroups { get; set; }
public ICollection<AssignmentQuestion> AssignmentQuestions { get; set; }
public AssignmentStruct()
{
Id = Guid.NewGuid();
ChildrenGroups = new HashSet<AssignmentStruct>();
AssignmentQuestions = new HashSet<AssignmentQuestion>();
}
}
}

View File

@@ -24,8 +24,7 @@ namespace Entities.Contracts
[MaxLength(65535)]
public string? Answer { get; set; }
[Column("description")]
public Guid? DescriptionId { get; set; }
[Required]
[Column("type")]
@@ -68,11 +67,6 @@ namespace Entities.Contracts
[ForeignKey(nameof(CreatorId))]
public User Creator { 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))]
@@ -84,7 +78,6 @@ namespace Entities.Contracts
{
Id = Guid.NewGuid();
AssignmentQuestions = new HashSet<AssignmentQuestion>();
ChildrenQuestion = new HashSet<Question>();
}
}

View File

@@ -13,13 +13,13 @@ namespace Entities.Contracts
public string Description { get; set; } = string.Empty;
[InverseProperty(nameof(Question.Description))]
public ICollection<Question> Questions { get; set; } = new List<Question>();
[InverseProperty(nameof(AssignmentQuestion.QuestionContext))]
public ICollection<AssignmentQuestion>? Questions { get; set; } = new List<AssignmentQuestion>();
public QuestionContext()
{
Questions = new HashSet<Question>();
Questions = new HashSet<AssignmentQuestion>();
}
}
}