浏览代码

调整阅卷接口

guqiang 14 小时之前
父节点
当前提交
a4fade49f2

+ 12 - 0
src/Hotline.Api/Controllers/Exam/UserExamController.cs

@@ -33,6 +33,18 @@ namespace Hotline.Api.Controllers.Exam
             return await _userExamService.GetPagedListAsync(userExamPagedRequest) as UserExamResultPageViewResponse;
         }
 
+        /// <summary>
+        /// 阅卷列表
+        /// </summary>
+        /// <param name="gradingPagedRequest"></param>
+        /// <returns></returns>
+        [HttpPost(UserExamApiRoute.GetGradingPagedList)]
+        public async Task<GradingResultPageViewResponse> GetGradingPagedList([FromBody] GradingPagedRequest gradingPagedRequest)
+        {
+            return await _userExamService.GetGradingResultPagedList(gradingPagedRequest);
+        }
+
+
         /// <summary>
         /// 开始考试
         /// </summary>

+ 2 - 0
src/Hotline.Application/Exam/Constants/ApiRoutes/UserExamApiRoute.cs

@@ -36,5 +36,7 @@ namespace Hotline.Application.Exam.Constants.ApiRoutes
         public const string GetUnExamUsers = "GetUnExamUsers";
 
         public const string GetUserExamResults = "GetUserExamResults";
+
+        public const string GetGradingPagedList = "GetGradingPagedList";
     }
 }

+ 2 - 0
src/Hotline.Application/Exam/Interface/ExamManages/IUserExamService.cs

@@ -100,5 +100,7 @@ namespace Hotline.Application.Exam.Interface.ExamManages
         /// <param name="userExamResultReportPagedRequest"></param>
         /// <returns></returns>
         Task<UserExamResultPageViewResponse> GetUserExamResults(UserExamResultReportPagedRequest userExamResultReportPagedRequest);
+
+        Task<GradingResultPageViewResponse> GetGradingResultPagedList(GradingPagedRequest gradingPagedRequest);
     }
 }

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

@@ -75,6 +75,18 @@ namespace Hotline.Application.Exam.Service.ExamManages
                 extractRuleDto.RuleTagDtos = await GetRuleTagDtos(entityQueryRequest);
 
                 extractRuleDto.TagQuestionDtos = await GetTagQuestions(entityQueryRequest);
+
+                var tagQuestionCounts = await GetTagQuestionCountAsync(new TagQuestionRequest
+                {
+                    TagIds = extractRuleDto.RuleTagDtos.Select(x=>x.TagId).ToList()
+                });
+
+                extractRuleDto.TagQuestionDtos.ForEach(item =>
+                {
+                    var tagQuestionCount = tagQuestionCounts.FirstOrDefault(m => m.TagId == item.TagId);
+
+                    item.TotalCount = tagQuestionCount?.TotalCount ?? 0;
+                });
             }
 
 
@@ -207,21 +219,7 @@ namespace Hotline.Application.Exam.Service.ExamManages
         public async Task<List<TagQuestionViewResponse>> GetTagQuestionCount(TagQuestionRequest tagQuestionRequest)
         {
             if (tagQuestionRequest.TagIds.IsNullOrEmpty()) return new List<TagQuestionViewResponse>();
-
-            var expression = tagQuestionRequest.GetExpression();
-            var questionTagTable = new ExamRepository<ExamQuestionTag>(_uow, _dataPermissionFilterBuilder, _serviceProvider).Queryable().Where(expression);
-            var questionTable = new ExamRepository<ExamQuestion>(_uow, _dataPermissionFilterBuilder, _serviceProvider).Queryable();
-            var queryable = questionTagTable.LeftJoin(questionTable, (t, q) => t.QuestionId == q.Id)
-                .GroupBy((t, q) => new { t.TagId, q.QuestionType })
-                .OrderBy((t, q) => t.TagId)
-                .Select((t, q) => new TagQuestionViewResponse
-                {
-                    TagId = t.TagId,
-                    QuestionType = q.QuestionType,
-                    TotalCount = SqlFunc.AggregateCount(q.Id!=null)
-                });
-
-            return await queryable.ToListAsync();
+            return await GetTagQuestionCountAsync(tagQuestionRequest);
         }
         #endregion
 
@@ -528,6 +526,24 @@ namespace Hotline.Application.Exam.Service.ExamManages
 
             actionRequest.RuleTagDtos.ForEach(x => x.RuleId = id);
         }
+
+        private async Task<List<TagQuestionViewResponse>> GetTagQuestionCountAsync(TagQuestionRequest tagQuestionRequest)
+        {
+            var expression = tagQuestionRequest.GetExpression();
+            var questionTagTable = new ExamRepository<ExamQuestionTag>(_uow, _dataPermissionFilterBuilder, _serviceProvider).Queryable().Where(expression);
+            var questionTable = new ExamRepository<ExamQuestion>(_uow, _dataPermissionFilterBuilder, _serviceProvider).Queryable();
+            var queryable = questionTagTable.LeftJoin(questionTable, (t, q) => t.QuestionId == q.Id)
+                .GroupBy((t, q) => new { t.TagId, q.QuestionType })
+                .OrderBy((t, q) => t.TagId)
+                .Select((t, q) => new TagQuestionViewResponse
+                {
+                    TagId = t.TagId,
+                    QuestionType = q.QuestionType,
+                    TotalCount = SqlFunc.AggregateCount(q.Id != null)
+                });
+
+            return await queryable.ToListAsync();
+        }
         #endregion
     }
 }

+ 43 - 0
src/Hotline.Application/Exam/Service/ExamManages/UserExamService.cs

@@ -33,6 +33,10 @@ using XF.Domain.Repository;
 using ExamQuestion = Hotline.Exams.Questions.ExamQuestion;
 using Hotline.Repository.SqlSugar.Exam.Service;
 using Hotline.Repository.SqlSugar.Exam.Extensions;
+using Exam.Infrastructure.Data.Interface;
+using Hotline.Repository.SqlSugar.Exam.Interface;
+using DocumentFormat.OpenXml.Drawing.Charts;
+using SqlSugar;
 
 namespace Hotline.Application.Exam.Service.ExamManages
 {
@@ -621,6 +625,45 @@ namespace Hotline.Application.Exam.Service.ExamManages
                 Pagination = new Pagination(userExamResultReportPagedRequest.PageIndex, userExamResultReportPagedRequest.PageSize, total)
             };
         }
+
+
+
+        public async Task<GradingResultPageViewResponse> GetGradingResultPagedList(GradingPagedRequest gradingPagedRequest)
+        {
+            // 只要有阅卷记录就在已阅卷列表中,已阅卷和未阅卷会有重复数据,只有所有记录都已阅卷才会从未阅卷列表中排除
+            var userExamTable =  _repository.Queryable().Where(x => x.IsCheck == gradingPagedRequest.IsCheck);
+
+            var examManageTable = new ExamRepository<ExamManage>(_uow, _dataPermissionFilterBuilder, _serviceProvider).Queryable();
+
+            var queryable = userExamTable.InnerJoin(examManageTable, (u, e) => u.ExamId == e.Id).GroupBy((u, e) => new
+            {
+                ExamName = e.Name,
+                ExamCode = e.Code,
+                CutoffScore = e.CutoffScore,
+                TotalScore = e.TotalScore,
+                Id = e.Id,
+                Status = e.Status,
+            }).Select((u, e) => new GradingResultViewResponse
+            {
+                CutoffScore = e.CutoffScore,
+                TotalScore = e.TotalScore,
+                ExamName = e.Name,
+                ExamCode = e.Code,
+                IsCheck = SqlFunc.Subqueryable<ExamUserExam>().Where(x=>x.ExamId == e.Id && x.IsCheck).Any(),
+                Id = e.Id
+            });
+
+            var list = await queryable.ToPageListAsync(gradingPagedRequest.PageIndex, gradingPagedRequest.PageSize);
+            var total = await queryable.CountAsync();
+
+            var result = new GradingResultPageViewResponse
+            {
+                Items = list,
+                Pagination = new Pagination(gradingPagedRequest.PageIndex, gradingPagedRequest.PageSize, total)
+            };
+
+            return result;
+        }
         #endregion
 
         #region private method

+ 6 - 0
src/Hotline.Share/Dtos/TestPapers/TagQuestionDto.cs

@@ -31,6 +31,12 @@ namespace Hotline.Share.Dtos.TestPapers
             }
         }
 
+        /// <summary>
+        /// 总数
+        /// </summary>
+        [Description("总数")]
+        public int TotalCount { get; set; }
+
     }
 
     /// <summary>

+ 1 - 1
src/Hotline.Share/Requests/Exam/GradingPagedRequest.cs

@@ -4,6 +4,6 @@ namespace Hotline.Share.Requests.Exam
 {
     public record GradingPagedRequest:PagedRequest,IQueryRequest
     {
-        public bool IsCheck { get; set; } 
+        public bool? IsCheck { get; set; }
     }
 }

+ 5 - 0
src/Hotline.Share/ViewResponses/Exam/UserExamResultPageViewResponse.cs

@@ -5,4 +5,9 @@ namespace Exam.Share.ViewResponses.Exam
     public class UserExamResultPageViewResponse:PageViewResponse<UserExamResultViewResponse>
     {
     }
+
+    public class GradingResultPageViewResponse : PageViewResponse<GradingResultViewResponse>
+    {
+
+    }
 }

+ 65 - 0
src/Hotline.Share/ViewResponses/Exam/UserExamResultViewResponse.cs

@@ -116,4 +116,69 @@ namespace Exam.Share.ViewResponses.Exam
         [Description("考试ID")]
         public string ExamId { get; set; }
     }
+
+    public class GradingResultViewResponse : IViewResponse
+    {
+
+        /// <summary>
+        /// 考试标题
+        /// </summary>
+        [Description("考试标题")]
+        public string ExamName { get; set; }
+
+        /// <summary>
+        /// 考试编号
+        /// </summary>
+        [Description("考试编号")]
+        public string ExamCode { get; set; }
+
+        /// <summary>
+        /// 总分
+        /// </summary>
+        [Description("总分")]
+        public int TotalScore { get; set; }
+
+        /// <summary>
+        /// 分数线
+        /// </summary>
+        [Description("分数线")]
+        public int CutoffScore { get; set; }
+
+        /// <summary>
+        /// 考试分数
+        /// </summary>
+        [Description("考试分数")]
+        public int Score { get; set; }
+
+        /// <summary>
+        /// 是否已阅卷
+        /// </summary>
+        [Description("是否已阅卷")]
+        public bool IsCheck { get; set; }
+
+        /// <summary>
+        /// 状态
+        /// </summary>
+        [Description("状态")]
+        public EPublicStatus Status { get; set; }
+
+        /// <summary>
+        /// 排序
+        /// </summary>
+        [Description("排序")]
+        public int SortIndex { get; set; }
+
+        /// <summary>
+        /// 主键
+        /// </summary>
+        [Description("主键")]
+
+        public string Id { get; set; }
+
+        /// <summary>
+        /// 考试状态
+        /// </summary>
+        [Description("考试状态")]
+        public EExamStatus ExamStatus { get; set; }
+    }
 }