重构项目结构,移除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:
@@ -0,0 +1,82 @@
|
||||
using Entities.Contracts;
|
||||
using Entities.DTO;
|
||||
|
||||
namespace TechHelper.Services.Beta
|
||||
{
|
||||
/// <summary>
|
||||
/// 提交详情服务接口(Beta版本)
|
||||
/// 提供提交详情相关的业务逻辑操作
|
||||
/// </summary>
|
||||
public interface ISubmissionDetailService : IBaseService<SubmissionDetailDto, Guid>
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取提交详情列表
|
||||
/// </summary>
|
||||
/// <param name="submissionId">提交ID</param>
|
||||
/// <returns>提交详情列表</returns>
|
||||
Task<ApiResponse> GetBySubmissionIdAsync(Guid submissionId);
|
||||
|
||||
/// <summary>
|
||||
/// 获取学生的提交详情
|
||||
/// </summary>
|
||||
/// <param name="studentId">学生ID</param>
|
||||
/// <param name="examId">考试ID</param>
|
||||
/// <returns>提交详情列表</returns>
|
||||
Task<ApiResponse> GetByStudentAndExamAsync(Guid studentId, Guid examId);
|
||||
|
||||
/// <summary>
|
||||
/// 批量创建提交详情
|
||||
/// </summary>
|
||||
/// <param name="submissionId">提交ID</param>
|
||||
/// <param name="details">提交详情列表</param>
|
||||
/// <returns>创建结果</returns>
|
||||
Task<ApiResponse> BatchCreateAsync(Guid submissionId, List<SubmissionDetailDto> details);
|
||||
|
||||
/// <summary>
|
||||
/// 批量更新提交详情
|
||||
/// </summary>
|
||||
/// <param name="details">提交详情列表</param>
|
||||
/// <returns>更新结果</returns>
|
||||
Task<ApiResponse> BatchUpdateAsync(List<SubmissionDetailDto> details);
|
||||
|
||||
/// <summary>
|
||||
/// 更新提交详情评分
|
||||
/// </summary>
|
||||
/// <param name="detailId">提交详情ID</param>
|
||||
/// <param name="points">分数</param>
|
||||
/// <param name="feedback">反馈</param>
|
||||
/// <returns>更新结果</returns>
|
||||
Task<ApiResponse> UpdateScoreAsync(Guid detailId, float? points, string? feedback);
|
||||
|
||||
/// <summary>
|
||||
/// 获取错题详情
|
||||
/// </summary>
|
||||
/// <param name="studentId">学生ID</param>
|
||||
/// <param name="examId">考试ID</param>
|
||||
/// <returns>错题详情列表</returns>
|
||||
Task<ApiResponse> GetErrorDetailsAsync(Guid studentId, Guid examId);
|
||||
|
||||
/// <summary>
|
||||
/// 获取正确题详情
|
||||
/// </summary>
|
||||
/// <param name="studentId">学生ID</param>
|
||||
/// <param name="examId">考试ID</param>
|
||||
/// <returns>正确题详情列表</returns>
|
||||
Task<ApiResponse> GetCorrectDetailsAsync(Guid studentId, Guid examId);
|
||||
|
||||
/// <summary>
|
||||
/// 获取未批改的提交详情
|
||||
/// </summary>
|
||||
/// <param name="teacherId">教师ID</param>
|
||||
/// <returns>未批改的提交详情列表</returns>
|
||||
Task<ApiResponse> GetUngradedDetailsAsync(Guid teacherId);
|
||||
|
||||
/// <summary>
|
||||
/// 批量更新提交详情状态
|
||||
/// </summary>
|
||||
/// <param name="submissionId">提交ID</param>
|
||||
/// <param name="status">状态</param>
|
||||
/// <returns>更新结果</returns>
|
||||
Task<ApiResponse> UpdateStatusAsync(Guid submissionId, SubmissionStatus status);
|
||||
}
|
||||
}
|
||||
86
TechHelper.Server/Services/Submission/ISubmissionService.cs
Normal file
86
TechHelper.Server/Services/Submission/ISubmissionService.cs
Normal file
@@ -0,0 +1,86 @@
|
||||
using Entities.DTO;
|
||||
|
||||
namespace TechHelper.Services.Beta
|
||||
{
|
||||
/// <summary>
|
||||
/// 提交服务接口(Beta版本)
|
||||
/// 提供提交相关的业务逻辑操作
|
||||
/// </summary>
|
||||
public interface ISubmissionService : IBaseService<SubmissionDto, Guid>
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取用户的错题列表
|
||||
/// </summary>
|
||||
/// <param name="userId">用户ID</param>
|
||||
/// <returns>错题列表</returns>
|
||||
Task<ApiResponse> GetAllErrorQuestionsAsync(Guid userId);
|
||||
|
||||
/// <summary>
|
||||
/// 获取指定作业的错题列表
|
||||
/// </summary>
|
||||
/// <param name="assignmentId">作业ID</param>
|
||||
/// <param name="userId">用户ID</param>
|
||||
/// <returns>错题列表</returns>
|
||||
Task<ApiResponse> GetAssignmentErrorQuestionsAsync(Guid assignmentId, Guid userId);
|
||||
|
||||
/// <summary>
|
||||
/// 获取错题类型分布
|
||||
/// </summary>
|
||||
/// <param name="assignmentId">作业ID</param>
|
||||
/// <param name="userId">用户ID</param>
|
||||
/// <returns>错题类型分布</returns>
|
||||
Task<ApiResponse> GetAssignmentErrorQuestionTypeDisAsync(Guid assignmentId, Guid userId);
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有错题类型分布
|
||||
/// </summary>
|
||||
/// <param name="assignmentId">作业ID</param>
|
||||
/// <param name="userId">用户ID</param>
|
||||
/// <returns>错题类型分布</returns>
|
||||
Task<ApiResponse> GetAllErrorQuestionTypeDisAsync(Guid assignmentId, Guid userId);
|
||||
|
||||
/// <summary>
|
||||
/// 获取作业中所有学生的错题情况
|
||||
/// </summary>
|
||||
/// <param name="assignmentId">作业ID</param>
|
||||
/// <param name="teacherId">教师ID</param>
|
||||
/// <returns>学生错题情况</returns>
|
||||
Task<ApiResponse> GetAssignmentAllStudentsError(Guid assignmentId, Guid teacherId);
|
||||
|
||||
/// <summary>
|
||||
/// 获取出现错题的学生列表
|
||||
/// </summary>
|
||||
/// <param name="assignmentQuestionId">作业题目ID</param>
|
||||
/// <returns>错题学生列表</returns>
|
||||
Task<ApiResponse> GetQuestionErrorStudents(Guid assignmentQuestionId);
|
||||
|
||||
/// <summary>
|
||||
/// 判断是否已经存在提交记录
|
||||
/// </summary>
|
||||
/// <param name="assignmentId">作业ID</param>
|
||||
/// <param name="studentId">学生ID</param>
|
||||
/// <returns>提交记录数量</returns>
|
||||
Task<byte> IsHasSubmissionAsync(Guid assignmentId, Guid studentId);
|
||||
|
||||
/// <summary>
|
||||
/// 获取学生提交摘要
|
||||
/// </summary>
|
||||
/// <param name="userId">用户ID</param>
|
||||
/// <returns>学生提交摘要列表</returns>
|
||||
Task<ApiResponse> GetStudentSubmissionSummariesAsync(Guid userId);
|
||||
|
||||
/// <summary>
|
||||
/// 获取学生提交详情
|
||||
/// </summary>
|
||||
/// <param name="submissionId">提交ID</param>
|
||||
/// <returns>学生提交详情</returns>
|
||||
Task<ApiResponse> GetStudentSubmissionDetailAsync(Guid submissionId);
|
||||
|
||||
/// <summary>
|
||||
/// 批改的试卷
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
Task<ApiResponse> GradeExam(SubmissionTeacherUpdateDto model);
|
||||
}
|
||||
}
|
||||
457
TechHelper.Server/Services/Submission/SubmissionDetailService.cs
Normal file
457
TechHelper.Server/Services/Submission/SubmissionDetailService.cs
Normal file
@@ -0,0 +1,457 @@
|
||||
using AutoMapper;
|
||||
using Entities.Contracts;
|
||||
using Entities.DTO;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using SharedDATA.Api;
|
||||
using SharedDATA.Context;
|
||||
using TechHelper.Services;
|
||||
|
||||
namespace TechHelper.Services.Beta
|
||||
{
|
||||
/// <summary>
|
||||
/// 提交详情服务实现(Beta版本)
|
||||
/// 实现提交详情相关的业务逻辑操作
|
||||
/// </summary>
|
||||
public class SubmissionDetailService : ISubmissionDetailService
|
||||
{
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
private readonly IMapper _mapper;
|
||||
private readonly IRepository<SubmissionDetail> _submissionDetailRepository;
|
||||
private readonly IRepository<Submission> _submissionRepository;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化提交详情服务
|
||||
/// </summary>
|
||||
/// <param name="mapper">AutoMapper实例</param>
|
||||
/// <param name="unitOfWork">工作单元</param>
|
||||
public SubmissionDetailService(IMapper mapper, IUnitOfWork unitOfWork)
|
||||
{
|
||||
_mapper = mapper;
|
||||
_unitOfWork = unitOfWork;
|
||||
_submissionDetailRepository = _unitOfWork.GetRepository<SubmissionDetail>();
|
||||
_submissionRepository = _unitOfWork.GetRepository<Submission>();
|
||||
}
|
||||
|
||||
#region 基本CRUD操作
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有提交详情
|
||||
/// </summary>
|
||||
/// <param name="query">查询参数</param>
|
||||
/// <returns>提交详情列表</returns>
|
||||
public async Task<ApiResponse> GetAllAsync(QueryParameter query)
|
||||
{
|
||||
try
|
||||
{
|
||||
var pagedDetails = await _submissionDetailRepository.GetPagedListAsync(
|
||||
pageIndex: query.PageIndex,
|
||||
pageSize: query.PageSize,
|
||||
orderBy: sd => sd.OrderByDescending(sd => sd.CreatedAt),
|
||||
predicate: sd => !sd.IsDeleted,
|
||||
include: i => i.Include(sd => sd.Student)
|
||||
.Include(sd => sd.ExamQuestion)
|
||||
.ThenInclude(aq => aq.Question));
|
||||
|
||||
var detailDtos = _mapper.Map<List<SubmissionDetailDto>>(pagedDetails.Items);
|
||||
|
||||
return ApiResponse.Success("获取所有提交详情成功。", new PagedList<SubmissionDetailDto>
|
||||
{
|
||||
PageIndex = pagedDetails.PageIndex,
|
||||
PageSize = pagedDetails.PageSize,
|
||||
TotalCount = pagedDetails.TotalCount,
|
||||
TotalPages = pagedDetails.TotalPages,
|
||||
Items = detailDtos
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ApiResponse.Error($"获取所有提交详情失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据ID获取提交详情
|
||||
/// </summary>
|
||||
/// <param name="id">提交详情ID</param>
|
||||
/// <returns>提交详情详情</returns>
|
||||
public async Task<ApiResponse> GetAsync(Guid id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var detail = await _submissionDetailRepository.GetFirstOrDefaultAsync(
|
||||
predicate: sd => sd.Id == id && !sd.IsDeleted,
|
||||
include: i => i.Include(sd => sd.Student)
|
||||
.Include(sd => sd.ExamQuestion)
|
||||
.ThenInclude(aq => aq.Question));
|
||||
|
||||
if (detail == null)
|
||||
{
|
||||
return ApiResponse.Error("未找到提交详情。", 404);
|
||||
}
|
||||
|
||||
var detailDto = _mapper.Map<SubmissionDetailDto>(detail);
|
||||
return ApiResponse.Success("获取提交详情成功。", detailDto);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ApiResponse.Error($"获取提交详情失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建提交详情
|
||||
/// </summary>
|
||||
/// <param name="model">提交详情数据传输对象</param>
|
||||
/// <returns>创建结果</returns>
|
||||
public async Task<ApiResponse> AddAsync(SubmissionDetailDto model)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(await _unitOfWork.GetRepository<SubmissionDetail>().GetFirstOrDefaultAsync(predicate: sd => sd.Id == model.Id ) != null)
|
||||
{
|
||||
return ApiResponse.Error("提交详情已存在。", 400);
|
||||
}
|
||||
|
||||
var detail = _mapper.Map<SubmissionDetail>(model);
|
||||
detail.CreatedAt = DateTime.Now;
|
||||
detail.UpdatedAt = DateTime.Now;
|
||||
detail.IsDeleted = false;
|
||||
|
||||
await _submissionDetailRepository.InsertAsync(detail);
|
||||
await _unitOfWork.SaveChangesAsync();
|
||||
|
||||
var result = _mapper.Map<SubmissionDetailDto>(detail);
|
||||
return ApiResponse.Success("创建提交详情成功。", result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ApiResponse.Error($"创建提交详情失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新提交详情
|
||||
/// </summary>
|
||||
/// <param name="model">提交详情数据传输对象</param>
|
||||
/// <returns>更新结果</returns>
|
||||
public async Task<ApiResponse> UpdateAsync(SubmissionDetailDto model)
|
||||
{
|
||||
try
|
||||
{
|
||||
var existingDetail = await _submissionDetailRepository.GetFirstOrDefaultAsync(predicate: sd => sd.Id == model.Id && !sd.IsDeleted);
|
||||
if (existingDetail == null)
|
||||
{
|
||||
return ApiResponse.Error("未找到要更新的提交详情。", 404);
|
||||
}
|
||||
|
||||
_mapper.Map(model, existingDetail);
|
||||
existingDetail.UpdatedAt = DateTime.Now;
|
||||
_submissionDetailRepository.Update(existingDetail);
|
||||
await _unitOfWork.SaveChangesAsync();
|
||||
|
||||
var result = _mapper.Map<SubmissionDetailDto>(existingDetail);
|
||||
return ApiResponse.Success("更新提交详情成功。", result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ApiResponse.Error($"更新提交详情失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除提交详情
|
||||
/// </summary>
|
||||
/// <param name="id">提交详情ID</param>
|
||||
/// <returns>删除结果</returns>
|
||||
public async Task<ApiResponse> DeleteAsync(Guid id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var detail = await _submissionDetailRepository.GetFirstOrDefaultAsync(predicate: sd => sd.Id == id && !sd.IsDeleted);
|
||||
if (detail == null)
|
||||
{
|
||||
return ApiResponse.Error("未找到要删除的提交详情。", 404);
|
||||
}
|
||||
|
||||
detail.IsDeleted = true;
|
||||
_submissionDetailRepository.Update(detail);
|
||||
await _unitOfWork.SaveChangesAsync();
|
||||
|
||||
return ApiResponse.Success("删除提交详情成功。", null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ApiResponse.Error($"删除提交详情失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 特殊操作
|
||||
|
||||
/// <summary>
|
||||
/// 获取提交详情列表
|
||||
/// </summary>
|
||||
/// <param name="submissionId">提交ID</param>
|
||||
/// <returns>提交详情列表</returns>
|
||||
public async Task<ApiResponse> GetBySubmissionIdAsync(Guid submissionId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var details = await _submissionDetailRepository.GetPagedListAsync(
|
||||
predicate: sd => sd.SubmissionId == submissionId && !sd.IsDeleted,
|
||||
include: i => i.Include(sd => sd.Student)
|
||||
.Include(sd => sd.ExamQuestion)
|
||||
.ThenInclude(aq => aq.Question));
|
||||
|
||||
var detailDtos = _mapper.Map<List<SubmissionDetailDto>>(details.Items);
|
||||
return ApiResponse.Success("获取提交详情列表成功。", detailDtos);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ApiResponse.Error($"获取提交详情列表失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取学生的提交详情
|
||||
/// </summary>
|
||||
/// <param name="studentId">学生ID</param>
|
||||
/// <param name="examId">考试ID</param>
|
||||
/// <returns>提交详情列表</returns>
|
||||
public async Task<ApiResponse> GetByStudentAndExamAsync(Guid studentId, Guid examId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var details = await _submissionDetailRepository.GetPagedListAsync(
|
||||
predicate: sd => sd.StudentId == studentId &&
|
||||
sd.Submission.ExamId == examId &&
|
||||
!sd.IsDeleted,
|
||||
include: i => i.Include(sd => sd.ExamQuestion)
|
||||
.ThenInclude(aq => aq.Question));
|
||||
|
||||
var detailDtos = _mapper.Map<List<SubmissionDetailDto>>(details.Items);
|
||||
return ApiResponse.Success("获取学生提交详情成功。", detailDtos);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ApiResponse.Error($"获取学生提交详情失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量创建提交详情
|
||||
/// </summary>
|
||||
/// <param name="submissionId">提交ID</param>
|
||||
/// <param name="details">提交详情列表</param>
|
||||
/// <returns>创建结果</returns>
|
||||
public async Task<ApiResponse> BatchCreateAsync(Guid submissionId, List<SubmissionDetailDto> details)
|
||||
{
|
||||
try
|
||||
{
|
||||
var detailEntities = _mapper.Map<List<SubmissionDetail>>(details);
|
||||
foreach (var detail in detailEntities)
|
||||
{
|
||||
detail.SubmissionId = submissionId;
|
||||
detail.CreatedAt = DateTime.Now;
|
||||
detail.UpdatedAt = DateTime.Now;
|
||||
detail.IsDeleted = false;
|
||||
await _submissionDetailRepository.InsertAsync(detail);
|
||||
}
|
||||
|
||||
await _unitOfWork.SaveChangesAsync();
|
||||
var result = _mapper.Map<List<SubmissionDetailDto>>(detailEntities);
|
||||
return ApiResponse.Success("批量创建提交详情成功。", result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ApiResponse.Error($"批量创建提交详情失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量更新提交详情
|
||||
/// </summary>
|
||||
/// <param name="details">提交详情列表</param>
|
||||
/// <returns>更新结果</returns>
|
||||
public async Task<ApiResponse> BatchUpdateAsync(List<SubmissionDetailDto> details)
|
||||
{
|
||||
try
|
||||
{
|
||||
var detailIds = details.Select(d => d.Id).ToList();
|
||||
var existingDetails = await _submissionDetailRepository.GetAllAsync(
|
||||
predicate: sd => detailIds.Contains(sd.Id) && !sd.IsDeleted);
|
||||
|
||||
foreach (var detail in details)
|
||||
{
|
||||
var existingDetail = existingDetails.FirstOrDefault(sd => sd.Id == detail.Id);
|
||||
if (existingDetail != null)
|
||||
{
|
||||
_mapper.Map(detail, existingDetail);
|
||||
existingDetail.UpdatedAt = DateTime.Now;
|
||||
_submissionDetailRepository.Update(existingDetail);
|
||||
}
|
||||
}
|
||||
|
||||
await _unitOfWork.SaveChangesAsync();
|
||||
return ApiResponse.Success("批量更新提交详情成功。", null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ApiResponse.Error($"批量更新提交详情失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新提交详情评分
|
||||
/// </summary>
|
||||
/// <param name="detailId">提交详情ID</param>
|
||||
/// <param name="points">分数</param>
|
||||
/// <param name="feedback">反馈</param>
|
||||
/// <returns>更新结果</returns>
|
||||
public async Task<ApiResponse> UpdateScoreAsync(Guid detailId, float? points, string? feedback)
|
||||
{
|
||||
try
|
||||
{
|
||||
var detail = await _submissionDetailRepository.GetFirstOrDefaultAsync(
|
||||
predicate: sd => sd.Id == detailId && !sd.IsDeleted);
|
||||
|
||||
if (detail == null)
|
||||
{
|
||||
return ApiResponse.Error("未找到提交详情。", 404);
|
||||
}
|
||||
|
||||
detail.PointsAwarded = points;
|
||||
detail.TeacherFeedback = feedback;
|
||||
detail.UpdatedAt = DateTime.Now;
|
||||
|
||||
_submissionDetailRepository.Update(detail);
|
||||
await _unitOfWork.SaveChangesAsync();
|
||||
|
||||
var result = _mapper.Map<SubmissionDetailDto>(detail);
|
||||
return ApiResponse.Success("更新评分成功。", result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ApiResponse.Error($"更新评分失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取错题详情
|
||||
/// </summary>
|
||||
/// <param name="studentId">学生ID</param>
|
||||
/// <param name="examId">考试ID</param>
|
||||
/// <returns>错题详情列表</returns>
|
||||
public async Task<ApiResponse> GetErrorDetailsAsync(Guid studentId, Guid examId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var details = await _submissionDetailRepository.GetPagedListAsync(
|
||||
predicate: sd => sd.StudentId == studentId &&
|
||||
sd.Submission.ExamId == examId &&
|
||||
sd.IsCorrect == false &&
|
||||
!sd.IsDeleted,
|
||||
include: i => i.Include(sd => sd.ExamQuestion)
|
||||
.ThenInclude(aq => aq.Question));
|
||||
|
||||
var detailDtos = _mapper.Map<List<SubmissionDetailDto>>(details.Items);
|
||||
return ApiResponse.Success("获取错题详情成功。", detailDtos);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ApiResponse.Error($"获取错题详情失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取正确题详情
|
||||
/// </summary>
|
||||
/// <param name="studentId">学生ID</param>
|
||||
/// <param name="examId">考试ID</param>
|
||||
/// <returns>正确题详情列表</returns>
|
||||
public async Task<ApiResponse> GetCorrectDetailsAsync(Guid studentId, Guid examId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var details = await _submissionDetailRepository.GetPagedListAsync(
|
||||
predicate: sd => sd.StudentId == studentId &&
|
||||
sd.Submission.ExamId == examId &&
|
||||
sd.IsCorrect == true &&
|
||||
!sd.IsDeleted,
|
||||
include: i => i.Include(sd => sd.ExamQuestion)
|
||||
.ThenInclude(aq => aq.Question));
|
||||
|
||||
var detailDtos = _mapper.Map<List<SubmissionDetailDto>>(details.Items);
|
||||
return ApiResponse.Success("获取正确题详情成功。", detailDtos);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ApiResponse.Error($"获取正确题详情失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取未批改的提交详情
|
||||
/// </summary>
|
||||
/// <param name="teacherId">教师ID</param>
|
||||
/// <returns>未批改的提交详情列表</returns>
|
||||
public async Task<ApiResponse> GetUngradedDetailsAsync(Guid teacherId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var submissions = await _submissionRepository.GetPagedListAsync(
|
||||
predicate: s => s.GraderId == teacherId &&
|
||||
s.Status == SubmissionStatus.Submitted &&
|
||||
!s.IsDeleted);
|
||||
|
||||
var submissionIds = submissions.Items.Select(s => s.Id).ToList();
|
||||
|
||||
var details = await _submissionDetailRepository.GetPagedListAsync(
|
||||
predicate: sd => submissionIds.Contains(sd.SubmissionId) &&
|
||||
sd.PointsAwarded == null &&
|
||||
!sd.IsDeleted,
|
||||
include: i => i.Include(sd => sd.Student)
|
||||
.Include(sd => sd.ExamQuestion)
|
||||
.ThenInclude(aq => aq.Question));
|
||||
|
||||
var detailDtos = _mapper.Map<List<SubmissionDetailDto>>(details.Items);
|
||||
return ApiResponse.Success("获取未批改的提交详情成功。", detailDtos);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ApiResponse.Error($"获取未批改的提交详情失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量更新提交详情状态
|
||||
/// </summary>
|
||||
/// <param name="submissionId">提交ID</param>
|
||||
/// <param name="status">状态</param>
|
||||
/// <returns>更新结果</returns>
|
||||
public async Task<ApiResponse> UpdateStatusAsync(Guid submissionId, SubmissionStatus status)
|
||||
{
|
||||
try
|
||||
{
|
||||
var details = await _submissionDetailRepository.GetAllAsync(
|
||||
predicate: sd => sd.SubmissionId == submissionId && !sd.IsDeleted);
|
||||
|
||||
foreach (var detail in details)
|
||||
{
|
||||
detail.UpdatedAt = DateTime.Now;
|
||||
_submissionDetailRepository.Update(detail);
|
||||
}
|
||||
|
||||
await _unitOfWork.SaveChangesAsync();
|
||||
return ApiResponse.Success("批量更新状态成功。", null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ApiResponse.Error($"批量更新状态失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
505
TechHelper.Server/Services/Submission/SubmissionService.cs
Normal file
505
TechHelper.Server/Services/Submission/SubmissionService.cs
Normal file
@@ -0,0 +1,505 @@
|
||||
using AutoMapper;
|
||||
using Entities.Contracts;
|
||||
using Entities.DTO;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using SharedDATA.Api;
|
||||
using SharedDATA.Context;
|
||||
using TechHelper.Services.Beta;
|
||||
|
||||
namespace TechHelper.Services.Beta
|
||||
{
|
||||
/// <summary>
|
||||
/// 提交服务实现(Beta版本)
|
||||
/// 实现提交相关的业务逻辑操作
|
||||
/// </summary>
|
||||
public class SubmissionService : ISubmissionService
|
||||
{
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
private readonly IMapper _mapper;
|
||||
private readonly IRepository<Submission> _submissionRepository;
|
||||
private readonly IRepository<SubmissionDetail> _submissionDetailRepository;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化提交服务
|
||||
/// </summary>
|
||||
/// <param name="mapper">AutoMapper实例</param>
|
||||
/// <param name="unitOfWork">工作单元</param>
|
||||
public SubmissionService(IMapper mapper, IUnitOfWork unitOfWork)
|
||||
{
|
||||
_mapper = mapper;
|
||||
_unitOfWork = unitOfWork;
|
||||
_submissionRepository = _unitOfWork.GetRepository<Submission>();
|
||||
_submissionDetailRepository = _unitOfWork.GetRepository<SubmissionDetail>();
|
||||
}
|
||||
|
||||
#region 基本CRUD操作
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有提交记录
|
||||
/// </summary>
|
||||
/// <param name="query">查询参数</param>
|
||||
/// <returns>提交记录列表</returns>
|
||||
public async Task<ApiResponse> GetAllAsync(QueryParameter query)
|
||||
{
|
||||
try
|
||||
{
|
||||
var pagedSubmissions = await _submissionRepository.GetPagedListAsync(
|
||||
pageIndex: query.PageIndex,
|
||||
pageSize: query.PageSize,
|
||||
orderBy: s => s.OrderByDescending(s => s.SubmissionTime),
|
||||
predicate: s => !s.IsDeleted);
|
||||
|
||||
var submissionDtos = _mapper.Map<List<SubmissionListDto>>(pagedSubmissions.Items);
|
||||
|
||||
return ApiResponse.Success("获取所有提交成功。", submissionDtos);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ApiResponse.Error($"获取所有提交失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据ID获取提交记录
|
||||
/// </summary>
|
||||
/// <param name="id">提交ID</param>
|
||||
/// <returns>提交记录详情</returns>
|
||||
public async Task<ApiResponse> GetAsync(Guid id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var submission = await _submissionRepository.GetFirstOrDefaultAsync(
|
||||
predicate: s => s.Id == id && !s.IsDeleted);
|
||||
|
||||
if (submission == null)
|
||||
{
|
||||
return ApiResponse.Error("未找到提交记录。", 404);
|
||||
}
|
||||
|
||||
var submissionDto = _mapper.Map<SubmissionDto>(submission);
|
||||
return ApiResponse.Success("获取提交记录成功。", submissionDto);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ApiResponse.Error($"获取提交记录失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建提交记录
|
||||
/// </summary>
|
||||
/// <param name="model">提交数据传输对象</param>
|
||||
/// <returns>创建结果</returns>
|
||||
public async Task<ApiResponse> AddAsync(SubmissionDto model)
|
||||
{
|
||||
try
|
||||
{
|
||||
var submission = _mapper.Map<Submission>(model);
|
||||
submission.SubmissionTime = DateTime.Now;
|
||||
submission.IsDeleted = false;
|
||||
|
||||
await _submissionRepository.InsertAsync(submission);
|
||||
await _unitOfWork.SaveChangesAsync();
|
||||
|
||||
var result = _mapper.Map<SubmissionDto>(submission);
|
||||
return ApiResponse.Success("提交成功。", result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ApiResponse.Error($"创建提交失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新提交记录
|
||||
/// </summary>
|
||||
/// <param name="model">提交数据传输对象</param>
|
||||
/// <returns>更新结果</returns>
|
||||
public async Task<ApiResponse> UpdateAsync(SubmissionDto model)
|
||||
{
|
||||
try
|
||||
{
|
||||
var existingSubmission = await _submissionRepository.GetFirstOrDefaultAsync(predicate: s => s.Id == model.Id && !s.IsDeleted);
|
||||
if (existingSubmission == null)
|
||||
{
|
||||
return ApiResponse.Error("未找到要更新的提交记录。", 404);
|
||||
}
|
||||
|
||||
_mapper.Map(model, existingSubmission);
|
||||
_submissionRepository.Update(existingSubmission);
|
||||
await _unitOfWork.SaveChangesAsync();
|
||||
|
||||
var result = _mapper.Map<SubmissionDto>(existingSubmission);
|
||||
return ApiResponse.Success("更新提交记录成功。", result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ApiResponse.Error($"更新提交记录失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除提交记录
|
||||
/// </summary>
|
||||
/// <param name="id">提交ID</param>
|
||||
/// <returns>删除结果</returns>
|
||||
public async Task<ApiResponse> DeleteAsync(Guid id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var submission = await _submissionRepository.GetFirstOrDefaultAsync(predicate: s => s.Id == id && !s.IsDeleted);
|
||||
if (submission == null)
|
||||
{
|
||||
return ApiResponse.Error("未找到要删除的提交记录。", 404);
|
||||
}
|
||||
|
||||
submission.IsDeleted = true;
|
||||
_submissionRepository.Update(submission);
|
||||
|
||||
var submissionDetails = await _submissionDetailRepository.GetPagedListAsync(predicate: sd => sd.SubmissionId == id);
|
||||
foreach (var detail in submissionDetails.Items)
|
||||
{
|
||||
detail.IsDeleted = true;
|
||||
_submissionDetailRepository.Update(detail);
|
||||
}
|
||||
|
||||
await _unitOfWork.SaveChangesAsync();
|
||||
return ApiResponse.Success("提交记录及相关详情删除成功。", null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ApiResponse.Error($"删除提交记录失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 错题相关操作
|
||||
|
||||
/// <summary>
|
||||
/// 获取用户的错题列表
|
||||
/// </summary>
|
||||
/// <param name="userId">用户ID</param>
|
||||
/// <returns>错题列表</returns>
|
||||
public async Task<ApiResponse> GetAllErrorQuestionsAsync(Guid userId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var errorSDs = await _submissionDetailRepository.GetPagedListAsync(
|
||||
predicate: sd => sd.StudentId == userId && sd.IsCorrect == false,
|
||||
include: i => i
|
||||
.Include(s => s.ExamQuestion)
|
||||
.ThenInclude(aq => aq.Question));
|
||||
|
||||
var errorQuestions = errorSDs.Items.Select(sd => sd.ExamQuestion.Question)
|
||||
.Where(q => q != null)
|
||||
.DistinctBy(q => q.Id)
|
||||
.ToList();
|
||||
|
||||
var result = _mapper.Map<List<QuestionDto>>(errorQuestions);
|
||||
return ApiResponse.Success("获取所有错题成功。", result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ApiResponse.Error($"获取所有错题失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取指定作业的错题列表
|
||||
/// </summary>
|
||||
/// <param name="assignmentId">作业ID</param>
|
||||
/// <param name="userId">用户ID</param>
|
||||
/// <returns>错题列表</returns>
|
||||
public async Task<ApiResponse> GetAssignmentErrorQuestionsAsync(Guid assignmentId, Guid userId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var errorSDs = await _submissionDetailRepository.GetPagedListAsync(
|
||||
predicate: sd => sd.Submission.ExamId == assignmentId &&
|
||||
sd.StudentId == userId &&
|
||||
sd.IsCorrect == false,
|
||||
include: i => i
|
||||
.Include(s => s.ExamQuestion)
|
||||
.ThenInclude(aq => aq.Question));
|
||||
|
||||
var errorQuestions = errorSDs.Items.Select(sd => sd.ExamQuestion.Question)
|
||||
.Where(q => q != null)
|
||||
.DistinctBy(q => q.Id)
|
||||
.ToList();
|
||||
|
||||
var result = _mapper.Map<List<QuestionDto>>(errorQuestions);
|
||||
return ApiResponse.Success("获取指定作业错题成功。", result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ApiResponse.Error($"获取指定作业错题失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取错题类型分布
|
||||
/// </summary>
|
||||
/// <param name="assignmentId">作业ID</param>
|
||||
/// <param name="userId">用户ID</param>
|
||||
/// <returns>错题类型分布</returns>
|
||||
public async Task<ApiResponse> GetAssignmentErrorQuestionTypeDisAsync(Guid assignmentId, Guid userId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var errorSDs = await _submissionDetailRepository.GetPagedListAsync(
|
||||
predicate: sd => sd.Submission.ExamId == assignmentId &&
|
||||
sd.StudentId == userId &&
|
||||
sd.IsCorrect == false,
|
||||
include: i => i
|
||||
.Include(s => s.ExamQuestion)
|
||||
.ThenInclude(aq => aq.Question));
|
||||
|
||||
var errorTypeDistribution = errorSDs.Items
|
||||
.Where(sd => sd.ExamQuestion?.Question?.QuestionType != null)
|
||||
.GroupBy(sd => sd.ExamQuestion.Question.QuestionType.Name)
|
||||
.Select(g => new
|
||||
{
|
||||
QuestionType = g.Key.ToString(),
|
||||
Count = g.Count()
|
||||
})
|
||||
.ToList();
|
||||
|
||||
return ApiResponse.Success("获取指定作业错题类型分布成功。", errorTypeDistribution);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ApiResponse.Error($"获取指定作业错题类型分布失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有错题类型分布
|
||||
/// </summary>
|
||||
/// <param name="assignmentId">作业ID</param>
|
||||
/// <param name="userId">用户ID</param>
|
||||
/// <returns>错题类型分布</returns>
|
||||
public async Task<ApiResponse> GetAllErrorQuestionTypeDisAsync(Guid assignmentId, Guid userId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var errorSDs = await _submissionDetailRepository.GetPagedListAsync(
|
||||
predicate: sd => sd.Submission.ExamId == assignmentId &&
|
||||
sd.StudentId == userId &&
|
||||
sd.IsCorrect == false,
|
||||
include: i => i
|
||||
.Include(s => s.ExamQuestion)
|
||||
.ThenInclude(aq => aq.Question));
|
||||
|
||||
var errorTypeDistribution = errorSDs.Items
|
||||
.Where(sd => sd.ExamQuestion?.Question?.QuestionType != null)
|
||||
.GroupBy(sd => sd.ExamQuestion.Question.QuestionType.Name)
|
||||
.Select(g => new
|
||||
{
|
||||
QuestionType = g.Key.ToString(),
|
||||
Count = g.Count()
|
||||
})
|
||||
.ToList();
|
||||
|
||||
return ApiResponse.Success("获取错题类型分布成功。", errorTypeDistribution);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ApiResponse.Error($"获取错题类型分布失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取作业中所有学生的错题情况
|
||||
/// </summary>
|
||||
/// <param name="assignmentId">作业ID</param>
|
||||
/// <param name="teacherId">教师ID</param>
|
||||
/// <returns>学生错题情况</returns>
|
||||
public async Task<ApiResponse> GetAssignmentAllStudentsError(Guid assignmentId, Guid teacherId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var submissionDetails = await _submissionDetailRepository.GetPagedListAsync(
|
||||
predicate: sd => sd.Submission.ExamId == assignmentId &&
|
||||
sd.IsCorrect == false,
|
||||
include: i => i.Include(sd => sd.Student));
|
||||
|
||||
var studentsErrorSummary = submissionDetails.Items
|
||||
.Where(sd => sd.Student != null)
|
||||
.GroupBy(sd => new { sd.StudentId, sd.Student.UserName })
|
||||
.Select(g => new
|
||||
{
|
||||
StudentId = g.Key.StudentId,
|
||||
StudentName = g.Key.UserName,
|
||||
ErrorQuestionCount = g.Count()
|
||||
})
|
||||
.ToList();
|
||||
|
||||
return ApiResponse.Success("获取作业中所有学生的错题情况成功。", studentsErrorSummary);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ApiResponse.Error($"获取作业中所有学生的错题情况失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取出现错题的学生列表
|
||||
/// </summary>
|
||||
/// <param name="assignmentQuestionId">作业题目ID</param>
|
||||
/// <returns>错题学生列表</returns>
|
||||
public async Task<ApiResponse> GetQuestionErrorStudents(Guid assignmentQuestionId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var errorSubmissionDetails = await _submissionDetailRepository.GetPagedListAsync(
|
||||
predicate: sd => sd.ExamQuestionId == assignmentQuestionId &&
|
||||
sd.IsCorrect == false,
|
||||
include: i => i
|
||||
.Include(sd => sd.Student)
|
||||
.Include(sd => sd.ExamQuestion)
|
||||
.ThenInclude(aq => aq.Question));
|
||||
|
||||
var errorStudentsByQuestion = errorSubmissionDetails.Items
|
||||
.Where(sd => sd.ExamQuestion?.Question != null && sd.Student != null)
|
||||
.GroupBy(sd => new { sd.ExamQuestionId, sd.ExamQuestion.Question.Title })
|
||||
.Select(g => new
|
||||
{
|
||||
AssignmentQuestionId = g.Key.ExamQuestionId,
|
||||
QuestionTitle = g.Key.Title,
|
||||
ErrorStudents = g.Select(sd => new
|
||||
{
|
||||
StudentId = sd.StudentId,
|
||||
StudentName = sd.Student.UserName
|
||||
}).Distinct().ToList()
|
||||
})
|
||||
.ToList();
|
||||
|
||||
return ApiResponse.Success("获取出现错题的学生成功。", errorStudentsByQuestion);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ApiResponse.Error($"获取出现错题的学生失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 特殊操作
|
||||
|
||||
/// <summary>
|
||||
/// 判断是否已经存在提交记录
|
||||
/// </summary>
|
||||
/// <param name="assignmentId">作业ID</param>
|
||||
/// <param name="studentId">学生ID</param>
|
||||
/// <returns>提交记录数量</returns>
|
||||
public async Task<byte> IsHasSubmissionAsync(Guid assignmentId, Guid studentId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _unitOfWork.GetRepository<Submission>().GetAllAsync(predicate: s => s.ExamId == assignmentId && s.StudentId == studentId);
|
||||
return (byte)result.Count;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取学生提交摘要
|
||||
/// </summary>
|
||||
/// <param name="userId">用户ID</param>
|
||||
/// <returns>学生提交摘要列表</returns>
|
||||
public async Task<ApiResponse> GetStudentSubmissionSummariesAsync(Guid userId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var submissions = await _submissionRepository.GetPagedListAsync(
|
||||
predicate: s => s.StudentId == userId && !s.IsDeleted,
|
||||
orderBy: s => s.OrderByDescending(s => s.SubmissionTime));
|
||||
|
||||
var summaries = submissions.Items.Select(s => new StudentSubmissionSummaryDto
|
||||
{
|
||||
Id = s.Id,
|
||||
AssignmentName = s.Exam?.Title ?? "未知作业",
|
||||
CreatedDate = s.SubmissionTime,
|
||||
Score = s.OverallGrade,
|
||||
StudentName = s.Student?.UserName ?? "未知学生",
|
||||
Status = s.Status.GetDisplayName()
|
||||
}).ToList();
|
||||
|
||||
return ApiResponse.Success("获取学生提交摘要成功。", new StudentSubmissionSummaryResponseDto
|
||||
{
|
||||
Submissions = summaries,
|
||||
TotalCount = submissions.TotalCount
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ApiResponse.Error($"获取学生提交摘要失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取学生提交详情
|
||||
/// </summary>
|
||||
/// <param name="submissionId">提交ID</param>
|
||||
/// <returns>学生提交详情</returns>
|
||||
public async Task<ApiResponse> GetStudentSubmissionDetailAsync(Guid submissionId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var submission = await _submissionRepository.GetFirstOrDefaultAsync(
|
||||
predicate: s => s.Id == submissionId && !s.IsDeleted);
|
||||
|
||||
if (submission == null)
|
||||
{
|
||||
return ApiResponse.Error("未找到提交记录。", 404);
|
||||
}
|
||||
|
||||
var detail = _mapper.Map<StudentSubmissionDetailDto>(submission);
|
||||
|
||||
|
||||
return ApiResponse.Success("获取学生提交详情成功。", detail);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ApiResponse.Error($"获取学生提交详情失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ApiResponse> GradeExam(SubmissionTeacherUpdateDto model)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
var existingSubmission = await _submissionRepository.GetFirstOrDefaultAsync(predicate: s => s.Id == model.Id && !s.IsDeleted);
|
||||
if (existingSubmission == null)
|
||||
{
|
||||
return ApiResponse.Error("未找到要批改的试卷记录。", 404);
|
||||
}
|
||||
|
||||
_mapper.Map(model, existingSubmission);
|
||||
|
||||
foreach (var item in existingSubmission.SubmissionDetails)
|
||||
{
|
||||
var sdd = model.SubmissionUpdateDetails.FirstOrDefault(d => d.Id == item.Id);
|
||||
if (sdd == null) continue;
|
||||
_mapper.Map(sdd, item);
|
||||
}
|
||||
_submissionRepository.Update(existingSubmission);
|
||||
await _unitOfWork.SaveChangesAsync();
|
||||
|
||||
var result = _mapper.Map<SubmissionDto>(existingSubmission);
|
||||
return ApiResponse.Success("批改试卷记录成功。", result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ApiResponse.Error($"批改试卷记录失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user