|
@@ -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();
|