|
|
|
@ -15,10 +15,12 @@ namespace Tiobon.Core.Services |
|
|
|
|
public class Ghre_QuestionServices : BaseServices<Ghre_Question, Ghre_QuestionDto, InsertGhre_QuestionInput, EditGhre_QuestionInput>, IGhre_QuestionServices |
|
|
|
|
{ |
|
|
|
|
private readonly IBaseRepository<Ghre_Question> _dal; |
|
|
|
|
public Ghre_QuestionServices(IBaseRepository<Ghre_Question> dal) |
|
|
|
|
private IGhre_QuestionAnswerServices _ghre_QuestionAnswerServices; |
|
|
|
|
public Ghre_QuestionServices(IBaseRepository<Ghre_Question> dal, IGhre_QuestionAnswerServices ghre_QuestionAnswerServices) |
|
|
|
|
{ |
|
|
|
|
this._dal = dal; |
|
|
|
|
base.BaseDal = dal; |
|
|
|
|
_ghre_QuestionAnswerServices = ghre_QuestionAnswerServices; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
@ -92,7 +94,28 @@ namespace Tiobon.Core.Services |
|
|
|
|
|
|
|
|
|
if (Id != 0) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
var question = await base.QueryById(Id); |
|
|
|
|
data.PageData.questionType.ForEach(x => x.isActive = 0); |
|
|
|
|
var questionType = data.PageData.questionType.Where(x => x.type == question.QuestionType).FirstOrDefault(); |
|
|
|
|
if (questionType != null) |
|
|
|
|
{ |
|
|
|
|
var answers = await _ghre_QuestionAnswerServices.Query(x => x.QuestionId == Id, "TaxisNo ASC"); |
|
|
|
|
questionType.isActive = 1; |
|
|
|
|
questionType.detail.difficulty = question.DifficultyLevel; |
|
|
|
|
questionType.detail.answer = answers.Where(x => x.IsCorrect == true).FirstOrDefault()?.QuestionNo; |
|
|
|
|
questionType.detail.answer1 = answers.Where(x => x.IsCorrect == true).Select(x => x.QuestionNo).ToList(); |
|
|
|
|
questionType.detail.answer1 = answers.Where(x => x.IsCorrect == true).Select(x => x.QuestionNo).ToList(); |
|
|
|
|
questionType.detail.content = question.QuestionContent; |
|
|
|
|
questionType.detail.RemarkSz = question.QuestionAnalysis; |
|
|
|
|
questionType.detail.answerList = answers.Select(x => new FromGhre_QuestionQuestionAnswerList() |
|
|
|
|
{ |
|
|
|
|
No = x.QuestionNo, |
|
|
|
|
label = x.AnswerContent, |
|
|
|
|
imageUrl = x.ImageUrl, |
|
|
|
|
imgWidthPc = x.ImageWidthPc, |
|
|
|
|
imgWidthApp = x.ImageWidthApp, |
|
|
|
|
}).ToList(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|