|
@@ -37,6 +37,9 @@ using Exam.Infrastructure.Data.Interface;
|
|
|
using Hotline.Repository.SqlSugar.Exam.Interface;
|
|
|
using DocumentFormat.OpenXml.Drawing.Charts;
|
|
|
using SqlSugar;
|
|
|
+using System.Threading;
|
|
|
+using DocumentFormat.OpenXml.Office2013.Excel;
|
|
|
+using Hotline.Share.Enums.Exams;
|
|
|
|
|
|
namespace Hotline.Application.Exam.Service.ExamManages
|
|
|
{
|
|
@@ -244,13 +247,13 @@ namespace Hotline.Application.Exam.Service.ExamManages
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
- public async Task<GradingExamQuestionDto> GradingAsync(GradingExtamItemDto gradingExtamItemDto, CancellationToken cancellationToken)
|
|
|
+ public async Task<GradingExamQuestionDto> GradingAsync(GradingExamItemDto gradingExtamItemDto, CancellationToken cancellationToken)
|
|
|
{
|
|
|
var userExamItem = await _userExamItemRepository.GetAsync(m => m.Id == gradingExtamItemDto.UserExamItemId);
|
|
|
|
|
|
if (userExamItem != null)
|
|
|
{
|
|
|
- userExamItem = _mapper.Map<GradingExtamItemDto, ExamUserExamItem>(gradingExtamItemDto, userExamItem);
|
|
|
+ userExamItem = _mapper.Map<GradingExamItemDto, ExamUserExamItem>(gradingExtamItemDto, userExamItem);
|
|
|
|
|
|
await _userExamItemRepository.ValidateUpdateAsync(userExamItem, cancellationToken);
|
|
|
}
|
|
@@ -505,31 +508,33 @@ namespace Hotline.Application.Exam.Service.ExamManages
|
|
|
var testPaperItemAnswerTable = new ExamRepository<ExamQuestionAnswerBak>(_uow, _dataPermissionFilterBuilder, _serviceProvider).Queryable();
|
|
|
var questionScoreTable = questionScoreRepository.Queryable();
|
|
|
|
|
|
- var queryResult = await userExamTable.InnerJoin(userExamItemTable, (e, i) => e.Id == i.UserExamId)
|
|
|
+ var queryable = userExamTable.InnerJoin(userExamItemTable, (e, i) => e.Id == i.UserExamId)
|
|
|
.InnerJoin(questionTable, (e, i, q) => i.QuestionId == q.Id)
|
|
|
.LeftJoin(userExamItemOptionTable, (e, i, q, o) => i.Id == o.UserExamItemId)
|
|
|
.LeftJoin(quesitonOptionTable, (e, i, q, o, qo) => o.QuestionOptionId == qo.Id)
|
|
|
.LeftJoin(examAnswerTable, (e, i, q, o, qo, a) => i.Id == a.UserExamItemId)
|
|
|
.LeftJoin(testPaperItemAnswerTable, (e, i, q, o, qo, a, ta) => ta.QuestionId == qo.QuestionId)
|
|
|
.InnerJoin(questionScoreTable, (e, i, q, o, qo, a, ta, s) => q.QuestionType == s.QuestionType && e.ExamId == s.ExamManageId)
|
|
|
- .Where((e, i, q, o, qo, a, ta, s) => !q.QuestionType.CheckSelectType())
|
|
|
- .Select(
|
|
|
- (e, i, q, o, qo, a, ta, s) => new GradingExamQuestionTempDto
|
|
|
- {
|
|
|
- Id = i.Id,
|
|
|
- QuestionType = q.QuestionType,
|
|
|
- CorrectAnswer = ta != null ? ta.Answer : string.Empty,
|
|
|
- Answer = a != null ? a.Answer : string.Empty,
|
|
|
- Title = q.Title,
|
|
|
- QuestionOptionId = o.Id,
|
|
|
- UserExamItemId = i.Id,
|
|
|
- Content = qo.Content,
|
|
|
- Label = qo.Label,
|
|
|
- IsAnswer = qo.IsAnswer,
|
|
|
- IsSelected = o != null,
|
|
|
- Score = s.Score
|
|
|
- }
|
|
|
- ).ToListAsync();
|
|
|
+ .Where((e, i, q, o, qo, a, ta, s) => q.QuestionType == EQuestionType.Single || q.QuestionType == EQuestionType.Multi || q.QuestionType == EQuestionType.Judge)
|
|
|
+ .Select(
|
|
|
+ (e, i, q, o, qo, a, ta, s) => new GradingExamQuestionTempDto
|
|
|
+ {
|
|
|
+ Id = i.Id,
|
|
|
+ QuestionType = q.QuestionType,
|
|
|
+ CorrectAnswer = ta.Id != null ? ta.Answer : string.Empty,
|
|
|
+ Answer = a.Id != null ? a.Answer : string.Empty,
|
|
|
+ Title = q.Title,
|
|
|
+ QuestionOptionId = o.Id,
|
|
|
+ UserExamItemId = i.Id,
|
|
|
+ Content = qo.Content,
|
|
|
+ Label = qo.Label,
|
|
|
+ IsAnswer = qo.IsAnswer,
|
|
|
+ IsSelected = o.Id != null,
|
|
|
+ Score = s.Score
|
|
|
+ }
|
|
|
+ );
|
|
|
+
|
|
|
+ var queryResult = await queryable.ToListAsync();
|
|
|
|
|
|
var gradingExamQuestionDtos = queryResult.GroupBy(x => new
|
|
|
{
|
|
@@ -551,7 +556,7 @@ namespace Hotline.Application.Exam.Service.ExamManages
|
|
|
|
|
|
public async Task<GradingExamQuestionDto> ViewGradingExamQuestion(ViewGradingExamRequest viewGradingExamRequest)
|
|
|
{
|
|
|
- var gradingExtamItemDto = _mapper.Map<ViewGradingExamRequest, GradingExtamItemDto>(viewGradingExamRequest);
|
|
|
+ var gradingExtamItemDto = _mapper.Map<ViewGradingExamRequest, GradingExamItemDto>(viewGradingExamRequest);
|
|
|
|
|
|
return await GetNextExamQuestion(gradingExtamItemDto);
|
|
|
}
|
|
@@ -631,7 +636,7 @@ namespace Hotline.Application.Exam.Service.ExamManages
|
|
|
public async Task<GradingResultPageViewResponse> GetGradingResultPagedList(GradingPagedRequest gradingPagedRequest)
|
|
|
{
|
|
|
// 只要有阅卷记录就在已阅卷列表中,已阅卷和未阅卷会有重复数据,只有所有记录都已阅卷才会从未阅卷列表中排除
|
|
|
- var userExamTable = _repository.Queryable().Where(x => x.IsCheck == gradingPagedRequest.IsCheck);
|
|
|
+ var userExamTable = _repository.Queryable().WhereIF(gradingPagedRequest.IsCheck!=null, x => x.IsCheck == gradingPagedRequest.IsCheck);
|
|
|
|
|
|
var examManageTable = new ExamRepository<ExamManage>(_uow, _dataPermissionFilterBuilder, _serviceProvider).Queryable();
|
|
|
|
|
@@ -643,6 +648,7 @@ namespace Hotline.Application.Exam.Service.ExamManages
|
|
|
TotalScore = e.TotalScore,
|
|
|
Id = e.Id,
|
|
|
Status = e.Status,
|
|
|
+ Remark = e.Remark
|
|
|
}).Select((u, e) => new GradingResultViewResponse
|
|
|
{
|
|
|
CutoffScore = e.CutoffScore,
|
|
@@ -650,7 +656,8 @@ namespace Hotline.Application.Exam.Service.ExamManages
|
|
|
ExamName = e.Name,
|
|
|
ExamCode = e.Code,
|
|
|
IsCheck = SqlFunc.Subqueryable<ExamUserExam>().Where(x=>x.ExamId == e.Id && x.IsCheck).Any(),
|
|
|
- Id = e.Id
|
|
|
+ Id = e.Id,
|
|
|
+ Remark = e.Remark
|
|
|
});
|
|
|
|
|
|
var list = await queryable.ToPageListAsync(gradingPagedRequest.PageIndex, gradingPagedRequest.PageSize);
|
|
@@ -664,6 +671,20 @@ namespace Hotline.Application.Exam.Service.ExamManages
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
+ public async Task BatchGradingAsync(BatchGradingExamItemDto batchGradingExamItemDto, CancellationToken cancellationToken)
|
|
|
+ {
|
|
|
+
|
|
|
+ var userExamItemIds = batchGradingExamItemDto.Items.Select(x => x.UserExamItemId);
|
|
|
+ var userExamItems = await _userExamItemRepository.Queryable().Where(m => userExamItemIds.Contains(m.Id)).ToListAsync();
|
|
|
+
|
|
|
+ if (userExamItems != null && userExamItemIds.Any())
|
|
|
+ {
|
|
|
+ userExamItems = _mapper.Map<List<GradingExamItemDto>, List<ExamUserExamItem>>(batchGradingExamItemDto.Items, userExamItems);
|
|
|
+
|
|
|
+ await _userExamItemRepository.ValidateUpdateAsync(userExamItems, cancellationToken);
|
|
|
+ }
|
|
|
+ }
|
|
|
#endregion
|
|
|
|
|
|
#region private method
|
|
@@ -727,7 +748,7 @@ namespace Hotline.Application.Exam.Service.ExamManages
|
|
|
.Include(x => x.ExamAnswers)
|
|
|
.ExecuteCommandAsync();
|
|
|
}
|
|
|
- private async Task<GradingExamQuestionDto> GetNextExamQuestion(GradingExtamItemDto gradingExtamItemDto)
|
|
|
+ private async Task<GradingExamQuestionDto> GetNextExamQuestion(GradingExamItemDto gradingExtamItemDto)
|
|
|
{
|
|
|
// TODO: 获取未阅卷的第一道题
|
|
|
var current = _userExamItemRepository.Queryable().Where(x => x.Id == gradingExtamItemDto.UserExamItemId);
|