Parcourir la source

Merge branch 'feature/exam' into test
合并冲突

guqiang il y a 3 semaines
Parent
commit
03766bba37

+ 1 - 1
src/Hotline.Application/Exam/Service/ExamManages/ExtractRuleService.cs

@@ -83,7 +83,7 @@ namespace Hotline.Application.Exam.Service.ExamManages
 
                 extractRuleDto.TagQuestionDtos.ForEach(item =>
                 {
-                    var tagQuestionCount = tagQuestionCounts.FirstOrDefault(m => m.TagId == item.TagId);
+                    var tagQuestionCount = tagQuestionCounts.FirstOrDefault(m => m.TagId == item.TagId && m.QuestionType == item.QuestionType);
 
                     item.TotalCount = tagQuestionCount?.TotalCount ?? 0;
                 });

+ 1 - 1
src/Hotline.Application/Exam/Service/Questions/QuestionService.cs

@@ -627,7 +627,7 @@ namespace Hotline.Application.Exam.Service.Questions
 
             actionRequest.QuestionKnowladgeDtos.ResolveOperationStatus();
 
-            var questionKnowladgeDtos = actionRequest.QuestionKnowladgeDtos.Where(x => x.OperationStatus == EEOperationStatus.Add).ToList();
+            var questionKnowladgeDtos = actionRequest.QuestionKnowladgeDtos.Where(x => x.OperationStatus == EEOperationStatus.Update).ToList();
 
             var ids = questionKnowladgeDtos.Select(x => x.Id);
 

+ 5 - 5
src/Hotline.Application/Exam/Service/TestPapers/TestPaperService.cs

@@ -825,14 +825,14 @@ namespace Hotline.Application.Exam.Service.TestPapers
             var tagQuestionTable = tagQuestionRepository.Queryable();
 
 
-            var testPaperRules = await exatractTable.InnerJoin(ruleTagTable,(e,rt)=>e.Id == rt.RuleId)
-                .InnerJoin(tagQuestionTable,(e,rt,tq)=>rt.RuleId == tq.RuleId && rt.TagId == tq.TagId)
-                .GroupBy((e, rt, tq)=> tq.QuestionType)
-                .Select((e,rt,tq)=> new ExamTagQuestion
+            var testPaperRules = await exatractTable.InnerJoin(ruleTagTable, (e, rt) => e.Id == rt.RuleId)
+                .InnerJoin(tagQuestionTable, (e, rt, tq) => rt.RuleId == tq.RuleId && rt.TagId == tq.TagId)
+                .GroupBy((e, rt, tq) => tq.QuestionType)
+                .Select((e, rt, tq) => new ExamTagQuestion
                 {
                     QuestionType = tq.QuestionType,
                     Count = SqlFunc.AggregateSum(tq.Count)
-                })
+                }).MergeTable().Where(m => m.Count > 0)
                 .ToListAsync();
 
             if (testPaperRules != null)

+ 2 - 1
src/Hotline.Repository.SqlSugar/Exam/Validators/ExamManages/ExamManageValidator.cs

@@ -45,7 +45,7 @@ namespace Exam.Application
 
             RuleFor(m => m.Name).NotEmpty().WithMessage(x=>string.Format(ExamErrorMessage.IsRequired,x.GetType().GetDescription(nameof(ExamManage.Name))));
             RuleFor(m => m.Code).NotEmpty().WithMessage(x => string.Format(ExamErrorMessage.IsRequired, x.GetType().GetDescription(nameof(ExamManage.Code))));
-            RuleFor(m => m.CutoffScore).NotNull().WithMessage(x => string.Format(ExamErrorMessage.IsRequired, x.GetType().GetDescription(nameof(ExamManage.CutoffScore))));
+            RuleFor(m => m.CutoffScore).NotEmpty().WithMessage(x => string.Format(ExamErrorMessage.IsRequired, x.GetType().GetDescription(nameof(ExamManage.CutoffScore))));
             RuleFor(m => m.ExamType).NotNull().WithMessage(x => string.Format(ExamErrorMessage.IsRequired, x.GetType().GetDescription(nameof(ExamManage.ExamType))));
             RuleFor(m => m.Method).NotNull().WithMessage(x => string.Format(ExamErrorMessage.IsRequired, x.GetType().GetDescription(nameof(ExamManage.Method))));
             //RuleFor(m => m.TestPaperId).NotEmpty().WithMessage(x => string.Format(ExamErrorMessage.IsRequired, typeof(ExamTestPaper).GetDescription()));
@@ -55,6 +55,7 @@ namespace Exam.Application
             RuleFor(m => m.EndTime).NotNull().WithMessage(x => string.Format(ExamErrorMessage.IsRequired, x.GetType().GetDescription(nameof(ExamManage.EndTime))));
             RuleFor(m => m.EndTime).Must((e, v) => e.ExamType == EExamType.Simulate || e.StartTime < v).WithMessage(x => string.Format(ExamErrorMessage.Greater, x.GetType().GetDescription(nameof(ExamManage.EndTime)), x.GetType().GetDescription(nameof(ExamManage.StartTime))));
             RuleFor(m => m.TotalScore).NotNull().WithMessage(x => string.Format(ExamErrorMessage.IsRequired, x.GetType().GetDescription(nameof(ExamManage.TotalScore))));
+            RuleFor(m => m.CutoffScore).Must((e, v)=> e.TotalScore > v).WithMessage(x => string.Format(ExamErrorMessage.Greater, x.GetType().GetDescription(nameof(ExamManage.CutoffScore)), x.GetType().GetDescription(nameof(ExamManage.TotalScore))));
         }
 
         protected override void ValidateRuleWithAdd()