重构项目结构,移除Assignment相关功能,优化Submission模块
Some checks failed
TechAct / explore-gitea-actions (push) Failing after 12s
Some checks failed
TechAct / explore-gitea-actions (push) Failing after 12s
This commit is contained in:
@@ -33,7 +33,7 @@ namespace TechHelper.Server.Services
|
||||
// 获取submission基本信息
|
||||
var submission = await _unitOfWork.GetRepository<Submission>()
|
||||
.GetAll(s => s.Id == submissionId)
|
||||
.Include(s => s.Assignment)
|
||||
.Include(s => s.Exam)
|
||||
.ThenInclude(a => a.Creator)
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace TechHelper.Server.Services
|
||||
return ApiResponse.Error("未找到指定的提交记录");
|
||||
}
|
||||
|
||||
var assignment = await examService.GetAsync(submission.AssignmentId);
|
||||
var assignment = await examService.GetAsync(submission.ExamId);
|
||||
if (assignment == null)
|
||||
{
|
||||
return ApiResponse.Error("未找到指定的作业");
|
||||
@@ -51,7 +51,7 @@ namespace TechHelper.Server.Services
|
||||
// 获取所有提交详情
|
||||
var submissionDetails = await _unitOfWork.GetRepository<SubmissionDetail>()
|
||||
.GetAll(sd => sd.SubmissionId == submissionId)
|
||||
.Include(sd => sd.AssignmentQuestion)
|
||||
.Include(sd => sd.ExamQuestion)
|
||||
.ThenInclude(aq => aq.Question)
|
||||
.ThenInclude(q => q.Lesson)
|
||||
.ThenInclude(q => q.KeyPoints)
|
||||
@@ -59,7 +59,7 @@ namespace TechHelper.Server.Services
|
||||
|
||||
// 获取同作业的所有提交用于排名和成绩分布
|
||||
var allSubmissions = await _unitOfWork.GetRepository<Submission>()
|
||||
.GetAll(s => s.AssignmentId == submission.AssignmentId)
|
||||
.GetAll(s => s.ExamId == submission.ExamId)
|
||||
.ToListAsync();
|
||||
|
||||
// 映射基本信息
|
||||
@@ -67,11 +67,11 @@ namespace TechHelper.Server.Services
|
||||
result.Assignment = assignment.Result as AssignmentDto ?? new AssignmentDto();
|
||||
|
||||
var errorQuestion = submissionDetails
|
||||
.Where(sd => sd.IsCorrect == false && sd.AssignmentQuestion?.StructType == AssignmentStructType.Question && sd.AssignmentQuestion?.Question != null)
|
||||
.Where(sd => sd.IsCorrect == false && sd.ExamQuestion?.StructType == AssignmentStructType.Question && sd.ExamQuestion?.Question != null)
|
||||
.ToList();
|
||||
|
||||
// 计算基础统计
|
||||
result.TotalQuestions = submissionDetails.Select(x => x.AssignmentQuestion.StructType == AssignmentStructType.Question && x.AssignmentQuestion?.Question != null).Count();
|
||||
result.TotalQuestions = submissionDetails.Select(x => x.ExamQuestion.StructType == AssignmentStructType.Question && x.ExamQuestion?.Question != null).Count();
|
||||
result.ErrorCount = errorQuestion.Count;
|
||||
result.CorrectCount = result.TotalQuestions - result.ErrorCount;
|
||||
result.AccuracyRate = result.TotalQuestions > 0 ?
|
||||
@@ -79,12 +79,12 @@ namespace TechHelper.Server.Services
|
||||
|
||||
// 计算错误类型分布 - 只获取题目类型的错误
|
||||
result.ErrorTypeDistribution = errorQuestion
|
||||
.GroupBy(sd => sd.AssignmentQuestion.Question.Type.ToString())
|
||||
.GroupBy(sd => sd.ExamQuestion.Question.Type.ToString())
|
||||
.ToDictionary(g => g.Key, g => g.Count()); ;
|
||||
|
||||
// 计算错误类型成绩分布 - 只获取题目类型的错误
|
||||
result.ErrorTypeScoreDistribution = errorQuestion
|
||||
.GroupBy(sd => sd.AssignmentQuestion.Question.Type.ToString())
|
||||
.GroupBy(sd => sd.ExamQuestion.Question.Type.ToString())
|
||||
.ToDictionary(g => g.Key, g => g.Sum(sd => sd.PointsAwarded ?? 0));
|
||||
|
||||
// 计算成绩排名
|
||||
@@ -101,14 +101,14 @@ namespace TechHelper.Server.Services
|
||||
|
||||
// 计算课文错误分布
|
||||
result.LessonErrorDistribution = errorQuestion
|
||||
.Where(eq => eq.AssignmentQuestion.Question.Lesson != null)
|
||||
.GroupBy(sd => sd.AssignmentQuestion.Question.Lesson.Title)
|
||||
.Where(eq => eq.ExamQuestion.Question.Lesson != null)
|
||||
.GroupBy(sd => sd.ExamQuestion.Question.Lesson.Title)
|
||||
.ToDictionary(g => g.Key, g => g.Count());
|
||||
|
||||
// 计算关键点错误分布
|
||||
result.KeyPointErrorDistribution = errorQuestion
|
||||
.Where(eq => eq.AssignmentQuestion.Question.Lesson != null)
|
||||
.GroupBy(sd => sd.AssignmentQuestion.Question.KeyPoint.Key)
|
||||
.Where(eq => eq.ExamQuestion.Question.Lesson != null)
|
||||
.GroupBy(sd => sd.ExamQuestion.Question.KeyPoint.Key)
|
||||
.ToDictionary(g => g.Key, g => g.Count());
|
||||
|
||||
return ApiResponse.Success(result: result);
|
||||
@@ -126,9 +126,9 @@ namespace TechHelper.Server.Services
|
||||
|
||||
public void SetBCorrect(AssignmentQuestionDto assignmentQuestion, List<SubmissionDetail> submissionDetails)
|
||||
{
|
||||
var sd = submissionDetails.FirstOrDefault(x => x.AssignmentQuestionId == assignmentQuestion.Id);
|
||||
var sd = submissionDetails.FirstOrDefault(x => x.ExamQuestionId == assignmentQuestion.Id);
|
||||
if (sd != null)
|
||||
assignmentQuestion.BCorrect = sd.AssignmentQuestion.BCorrect;
|
||||
assignmentQuestion.BCorrect = sd.ExamQuestion.BCorrect;
|
||||
else
|
||||
assignmentQuestion.BCorrect = false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user