新增修改裁表单修改
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
6bb4167ac7
commit
7b1449189e
|
|
@ -2457,6 +2457,41 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
|
|||
public string R2Answer { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class GetJudgeFormInDto
|
||||
{
|
||||
[NotDefault]
|
||||
public Guid VisitTaskId { get; set; }
|
||||
}
|
||||
|
||||
public class GetJudgeFormOutDto
|
||||
{
|
||||
public List<JudgeFormQuestionDto> QuestionList { get; set; } = new List<JudgeFormQuestionDto>();
|
||||
}
|
||||
|
||||
public class JudgeFormQuestionDto
|
||||
{
|
||||
public Guid ReadingQuestionId { get; set; }
|
||||
public string QuestionName { get; set; } = string.Empty;
|
||||
public string Type { get; set; } = string.Empty;
|
||||
public string TypeValue { get; set; } = string.Empty;
|
||||
public int ShowOrder { get; set; }
|
||||
public string Answer { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class SetJudgeFormInDto
|
||||
{
|
||||
[NotDefault]
|
||||
public Guid VisitTaskId { get; set; }
|
||||
|
||||
public List<JudgeFormAnswerDto> QuestionList { get; set; } = new List<JudgeFormAnswerDto>();
|
||||
}
|
||||
|
||||
public class JudgeFormAnswerDto
|
||||
{
|
||||
public Guid ReadingQuestionId { get; set; }
|
||||
public string Answer { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class JudgeReadingInfoDto
|
||||
{
|
||||
public string VisitName { get; set; }
|
||||
|
|
|
|||
|
|
@ -119,41 +119,17 @@ namespace IRaCIS.Core.Application.Service
|
|||
.Select(x => x.JudgeRuleEnum)
|
||||
.FirstNotNullAsync();
|
||||
|
||||
var questionList = await _readingQuestionTrialRepository
|
||||
.Where(x => x.ReadingQuestionCriterionTrialId == taskInfo.TrialReadingCriterionId && x.IsJudgeQuestion)
|
||||
.OrderBy(x => x.ShowOrder)
|
||||
.Select(x => new
|
||||
var displayQuestions = await GetJudgeDisplayQuestions(taskInfo.TrialReadingCriterionId, taskInfo.VisitTaskNum, judgeRule);
|
||||
var judgeAnswers = displayQuestions
|
||||
.Select(x => new SingleVisitJudgeAnswerItemDto
|
||||
{
|
||||
ReadingQuestionId = x.Id,
|
||||
QuestionName = x.QuestionName.LanguageName(x.QuestionEnName, _userInfo.IsEn_Us),
|
||||
ShowOrder = x.ShowOrder,
|
||||
x.JudgeType,
|
||||
x.ExcludeShowVisitList,
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
var questionIds = questionList.Select(x => x.ReadingQuestionId).ToList();
|
||||
var visitJudgeRules = judgeRule == JudgeRule.Difference
|
||||
? await _readingQuestionVisitJudgeRuleRepository
|
||||
.Where(x => questionIds.Contains(x.ReadingQuestionId) && (x.VisitNum == taskInfo.VisitTaskNum || x.VisitNum == -1))
|
||||
.ToListAsync()
|
||||
: new List<ReadingQuestionVisitJudgeRule>();
|
||||
|
||||
var displayQuestions = questionList
|
||||
.Where(x => !x.ExcludeShowVisitList.Contains(taskInfo.VisitTaskNum))
|
||||
.Where(x => judgeRule == JudgeRule.Consistent
|
||||
? x.JudgeType != JudgeTypeEnum.NotApplicable
|
||||
: (visitJudgeRules.FirstOrDefault(rule => rule.ReadingQuestionId == x.ReadingQuestionId && rule.VisitNum == taskInfo.VisitTaskNum)
|
||||
?? visitJudgeRules.FirstOrDefault(rule => rule.ReadingQuestionId == x.ReadingQuestionId && rule.VisitNum == -1))?.JudgeType != JudgeTypeEnum.NotApplicable)
|
||||
.Select(x => new SingleVisitJudgeAnswerItemDto
|
||||
{
|
||||
ReadingQuestionId = x.ReadingQuestionId,
|
||||
QuestionName = x.QuestionName,
|
||||
ShowOrder = x.ShowOrder,
|
||||
})
|
||||
.ToList();
|
||||
|
||||
var displayQuestionIds = displayQuestions.Select(x => x.ReadingQuestionId).ToList();
|
||||
var displayQuestionIds = judgeAnswers.Select(x => x.ReadingQuestionId).ToList();
|
||||
var answerList = await _readingTaskQuestionAnswerRepository
|
||||
.Where(x => taskIds.Contains(x.VisitTaskId) && displayQuestionIds.Contains(x.ReadingQuestionTrialId))
|
||||
.Select(x => new
|
||||
|
|
@ -164,7 +140,7 @@ namespace IRaCIS.Core.Application.Service
|
|||
})
|
||||
.ToListAsync();
|
||||
|
||||
displayQuestions.ForEach(question =>
|
||||
judgeAnswers.ForEach(question =>
|
||||
{
|
||||
question.R1Answer = answerList.FirstOrDefault(x => x.VisitTaskId == judgeDataInfo.TaskIdOne && x.ReadingQuestionTrialId == question.ReadingQuestionId)?.Answer ?? string.Empty;
|
||||
question.R2Answer = answerList.FirstOrDefault(x => x.VisitTaskId == judgeDataInfo.TaskIdTwo && x.ReadingQuestionTrialId == question.ReadingQuestionId)?.Answer ?? string.Empty;
|
||||
|
|
@ -172,10 +148,81 @@ namespace IRaCIS.Core.Application.Service
|
|||
|
||||
return new GetSingleVisitJudgeAnswerOutDto
|
||||
{
|
||||
QuestionList = displayQuestions,
|
||||
QuestionList = judgeAnswers,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取裁判表单
|
||||
/// </summary>
|
||||
[HttpPost]
|
||||
public async Task<GetJudgeFormOutDto> GetJudgeForm(GetJudgeFormInDto inDto)
|
||||
{
|
||||
var taskInfo = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).FirstNotNullAsync();
|
||||
var judgeRule = await _readingQuestionCriterionTrialRepository.Where(x => x.Id == taskInfo.TrialReadingCriterionId).Select(x => x.JudgeRuleEnum).FirstNotNullAsync();
|
||||
var questionList = await GetJudgeDisplayQuestions(taskInfo.TrialReadingCriterionId, taskInfo.VisitTaskNum, judgeRule);
|
||||
var questionIds = questionList.Select(x => x.Id).ToList();
|
||||
var answers = await _readingTaskQuestionAnswerRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId && questionIds.Contains(x.ReadingQuestionTrialId)).ToListAsync();
|
||||
|
||||
return new GetJudgeFormOutDto
|
||||
{
|
||||
QuestionList = questionList.Select(x => new JudgeFormQuestionDto
|
||||
{
|
||||
ReadingQuestionId = x.Id,
|
||||
QuestionName = x.QuestionName.LanguageName(x.QuestionEnName, _userInfo.IsEn_Us),
|
||||
Type = x.Type,
|
||||
TypeValue = x.TypeValue,
|
||||
ShowOrder = x.ShowOrder,
|
||||
Answer = answers.FirstOrDefault(answer => answer.ReadingQuestionTrialId == x.Id)?.Answer ?? string.Empty,
|
||||
}).ToList(),
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 编辑裁判表单
|
||||
/// </summary>
|
||||
[HttpPost]
|
||||
public async Task<IResponseOutput> SetJudgeForm(SetJudgeFormInDto inDto)
|
||||
{
|
||||
var taskInfo = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).FirstNotNullAsync();
|
||||
var judgeRule = await _readingQuestionCriterionTrialRepository.Where(x => x.Id == taskInfo.TrialReadingCriterionId).Select(x => x.JudgeRuleEnum).FirstNotNullAsync();
|
||||
var displayQuestionIds = (await GetJudgeDisplayQuestions(taskInfo.TrialReadingCriterionId, taskInfo.VisitTaskNum, judgeRule)).Select(x => x.Id).ToList();
|
||||
var submittedQuestionIds = inDto.QuestionList.Select(x => x.ReadingQuestionId).ToList();
|
||||
|
||||
|
||||
await _readingTaskQuestionAnswerRepository.BatchDeleteNoTrackingAsync(x => x.VisitTaskId == inDto.VisitTaskId && submittedQuestionIds.Contains(x.ReadingQuestionTrialId));
|
||||
if (inDto.QuestionList.Count > 0)
|
||||
{
|
||||
await _readingTaskQuestionAnswerRepository.AddRangeAsync(inDto.QuestionList.Select(x => new ReadingTaskQuestionAnswer
|
||||
{
|
||||
ReadingQuestionTrialId = x.ReadingQuestionId,
|
||||
ReadingQuestionCriterionTrialId = taskInfo.TrialReadingCriterionId,
|
||||
TrialId = taskInfo.TrialId,
|
||||
SubjectId = taskInfo.SubjectId,
|
||||
VisitTaskId = inDto.VisitTaskId,
|
||||
Answer = x.Answer,
|
||||
}).ToList());
|
||||
}
|
||||
|
||||
return ResponseOutput.Result(await _readingTaskQuestionAnswerRepository.SaveChangesAsync());
|
||||
}
|
||||
|
||||
private async Task<List<ReadingQuestionTrial>> GetJudgeDisplayQuestions(Guid trialReadingCriterionId, decimal visitNum, JudgeRule judgeRule)
|
||||
{
|
||||
var questionList = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == trialReadingCriterionId && x.IsJudgeQuestion).OrderBy(x => x.ShowOrder).ToListAsync();
|
||||
var questionIds = questionList.Select(x => x.Id).ToList();
|
||||
var visitJudgeRules = judgeRule == JudgeRule.Difference
|
||||
? await _readingQuestionVisitJudgeRuleRepository.Where(x => questionIds.Contains(x.ReadingQuestionId) && (x.VisitNum == visitNum || x.VisitNum == -1)).ToListAsync()
|
||||
: new List<ReadingQuestionVisitJudgeRule>();
|
||||
|
||||
return questionList.Where(x => !x.ExcludeShowVisitList.Contains(visitNum))
|
||||
.Where(x => judgeRule == JudgeRule.Consistent
|
||||
? x.JudgeType != JudgeTypeEnum.NotApplicable
|
||||
: (visitJudgeRules.FirstOrDefault(rule => rule.ReadingQuestionId == x.Id && rule.VisitNum == visitNum)
|
||||
?? visitJudgeRules.FirstOrDefault(rule => rule.ReadingQuestionId == x.Id && rule.VisitNum == -1))?.JudgeType != JudgeTypeEnum.NotApplicable)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取裁判阅片任务信息
|
||||
/// </summary>
|
||||
|
|
|
|||
Loading…
Reference in New Issue