Browse Source

Merge branch 'test' of http://110.188.24.182:10023/Fengwo/hotline into test

tangjiang 2 tuần trước cách đây
mục cha
commit
86752bbe00

+ 6 - 15
src/Hotline.Application/Exam/Service/Practices/PracticeService.cs

@@ -40,6 +40,7 @@ using Hotline.Repository.SqlSugar.Exam.Service;
 using Hotline.Repository.SqlSugar.Exam.Extensions;
 using Exam.Infrastructure.Extensions;
 using Consul;
+using J2N.Collections.Generic.Extensions;
 
 namespace Hotline.Application.Exam.Service.Practices
 {
@@ -222,19 +223,7 @@ namespace Hotline.Application.Exam.Service.Practices
 
             if (viewPracticeQuestionDto != null)
             {
-                var practiceResultItemTable = _practiceResultItemRepository.Queryable();
-                var practiceResultTable = _practiceResultRepository.Queryable().Where(x => x.PracticeQuestionId == practiceQuestionRequest.PracticeQuestionId);
-
-                var practiceResultItems = await practiceResultTable.InnerJoin(practiceResultItemTable, (r, i) => r.Id == i.PracticeResultId).Select((r, i) => i).ToListAsync();
-
-                var practiceAnswers = await _practiceAnswerRepository.Queryable().Where(x => x.PracticeQuestionId == practiceQuestionRequest.PracticeQuestionId).ToListAsync();
-
-                viewPracticeQuestionDto.PracticeQuestionOptionsDtos.ForEach(item =>
-                {
-                    item.IsSelected = practiceResultItems.Any(x => x.QuestionOptionId == item.QuestionOptionId);
-
-                    item.IsAnswer = practiceAnswers.Any(x => x.PracticeOptionId == item.QuestionOptionId);
-                });
+               
 
                 viewPracticeQuestionDto.Answer = string.Join(",", viewPracticeQuestionDto.PracticeQuestionOptionsDtos.Where(x => x.IsAnswer).Select(m => m.Label));
             }
@@ -336,7 +325,7 @@ namespace Hotline.Application.Exam.Service.Practices
             if (practiceResultItems != null)
             {
                 practiceQuestionDto.PracticeQuestionOptionsDtos.ForEach(item =>
-                {
+                {        
                     item.IsSelected = practiceResultItems.Any(x => x.QuestionOptionId == item.QuestionOptionId);
                 });
             }
@@ -411,12 +400,14 @@ namespace Hotline.Application.Exam.Service.Practices
             var practiceQuestionOptionTable = _practiceQuestionOptionsRepository.Queryable();
 
             var queryResult = practiceQuestionTable.InnerJoin(practiceQuestionOptionTable, (p, o) => p.QuestionId == o.QuestionId && p.Id == o.PracticeQuestionId)
+                .OrderBy((p,o)=>o.Label)
                 .Select((p, o) => new PracticeQuestionOptionsDto
                 {
                     Content = o.Content,
                     Label = o.Label,
                     PracticeQuestionId = o.PracticeQuestionId,
-                    QuestionOptionId = o.QuestionOptionId
+                    QuestionOptionId = o.QuestionOptionId,
+                    IsAnswer = o.IsAnswer
                 });
 
             return await queryResult.Distinct().ToListAsync();

+ 4 - 10
src/Hotline.Share/Dtos/Practices/PracticeQuestionOptionsDto.cs

@@ -35,27 +35,21 @@ namespace Hotline.Share.Dtos.Practices
         /// </summary>
         [Description("是否选中")]
         public bool IsSelected { get; set; }
-    }
 
-    public class GradingPracticeQuestionOptionsDto : PracticeQuestionOptionsDto, IActionRequest
-    {
-     
         /// <summary>
         /// 是否答案
         /// </summary>
         [Description("是否答案")]
         public bool IsAnswer { get; set; }
+    }
+
+    public class GradingPracticeQuestionOptionsDto : PracticeQuestionOptionsDto, IActionRequest
+    {
 
         /// <summary>
         /// 主键
         /// </summary>
         [Description("主键")]
         public string Id { get; set; }
-
-        /// <summary>
-        /// 是否选中
-        /// </summary>
-        [Description("是否选中")]
-        public bool IsSelected { get; set; }
     }
 }