重构项目结构,移除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:
@@ -1,6 +1,7 @@
|
||||
using AutoMapper;
|
||||
using Entities.Contracts;
|
||||
using Entities.DTO;
|
||||
using Entities.DTO.Class;
|
||||
using Microsoft.VisualBasic;
|
||||
using SharedDATA.Api;
|
||||
using TechHelper.Context;
|
||||
@@ -32,7 +33,7 @@ namespace TechHelper.Server.Services
|
||||
try
|
||||
{
|
||||
|
||||
Assignment newAssi = _mapper.Map<Assignment>(assignmentDto);
|
||||
Exam newAssi = _mapper.Map<Exam>(assignmentDto);
|
||||
|
||||
await _examRepository.AddAsync(newAssi);
|
||||
|
||||
@@ -117,11 +118,11 @@ namespace TechHelper.Server.Services
|
||||
{
|
||||
try
|
||||
{
|
||||
var assignment = await _unitOfWork.GetRepository<Assignment>().GetFirstOrDefaultAsync(predicate: a => a.Id == id);
|
||||
var assignment = await _unitOfWork.GetRepository<Exam>().GetFirstOrDefaultAsync(predicate: a => a.Id == id);
|
||||
|
||||
if (assignment == null) return ApiResponse.Error("找不到该试卷");
|
||||
_unitOfWork.GetRepository<Assignment>().Delete(id);
|
||||
_unitOfWork.GetRepository<AssignmentQuestion>().Delete(assignment.ExamStructId);
|
||||
_unitOfWork.GetRepository<Exam>().Delete(id);
|
||||
_unitOfWork.GetRepository<ExamQuestion>().Delete(assignment.ExamStructId);
|
||||
|
||||
|
||||
if (await _unitOfWork.SaveChangesAsync() > 0)
|
||||
@@ -170,7 +171,7 @@ namespace TechHelper.Server.Services
|
||||
var cs = cla.Result as ICollection<ClassStudent>;
|
||||
cs?.ToList().ForEach(async s =>
|
||||
{
|
||||
var subCount = _unitOfWork.GetRepository<Submission>().GetAll(predicate: su => su.AssignmentId == assignmentId && su.StudentId == s.StudentId);
|
||||
var subCount = _unitOfWork.GetRepository<Submission>().GetAll(predicate: su => su.ExamId == assignmentId && su.StudentId == s.StudentId);
|
||||
|
||||
var submission = assignment.ConvertToSubmission(s.StudentId, TeacherId);
|
||||
submission.AttemptNumber = (byte)(subCount.Count() + 1);
|
||||
@@ -199,7 +200,7 @@ namespace TechHelper.Server.Services
|
||||
|
||||
examToStudentsDto.StudentIds?.ForEach(async s =>
|
||||
{
|
||||
var subCount = _unitOfWork.GetRepository<Submission>().GetAll(predicate: su => su.AssignmentId == examToStudentsDto.AssignmentId && su.StudentId == s);
|
||||
var subCount = _unitOfWork.GetRepository<Submission>().GetAll(predicate: su => su.ExamId == examToStudentsDto.AssignmentId && su.StudentId == s);
|
||||
var submission = assignment.ConvertToSubmission(s, examToStudentsDto.CreaterId);
|
||||
submission.AttemptNumber = (byte)(subCount.Count() + 1);
|
||||
await _unitOfWork.GetRepository<Submission>().InsertAsync(submission);
|
||||
|
||||
Reference in New Issue
Block a user