|
@@ -183,9 +183,9 @@ namespace Hotline.Application.Exam.Service.ExamManages
|
|
|
var result = queryable.GroupBy(x => x.QuestionType).Select(m => new ExamQuestionViewResponse
|
|
|
{
|
|
|
QuestionType = m.Key,
|
|
|
- Questions = m.Select(n => new SimpleViewResponse
|
|
|
+ Questions = m.GroupBy(g=>g.QuestionId).Select(n => new SimpleViewResponse
|
|
|
{
|
|
|
- Id = n.QuestionId
|
|
|
+ Id = n.Key
|
|
|
}).ToList()
|
|
|
}).ToList();
|
|
|
|
|
@@ -304,6 +304,8 @@ namespace Hotline.Application.Exam.Service.ExamManages
|
|
|
|
|
|
if (!startExamViewResponse.CheckValidate())
|
|
|
{
|
|
|
+ await SetExamStatus(userExam, startExamViewResponse, cancellationToken);
|
|
|
+
|
|
|
return startExamViewResponse;
|
|
|
}
|
|
|
|
|
@@ -322,6 +324,16 @@ namespace Hotline.Application.Exam.Service.ExamManages
|
|
|
|
|
|
return startExamViewResponse;
|
|
|
}
|
|
|
+
|
|
|
+ private async Task SetExamStatus(ExamUserExam userExam, StartExamViewResponse startExamViewResponse, CancellationToken cancellationToken)
|
|
|
+ {
|
|
|
+ userExam.ExamStatus = startExamViewResponse.IsCompleted ? EExamStatus.Complete : EExamStatus.NoStart;
|
|
|
+
|
|
|
+ userExam.ToUpdate(_sessionContext);
|
|
|
+
|
|
|
+ await _repository.UpdateWithValidateAsync(userExam, cancellationToken);
|
|
|
+ }
|
|
|
+
|
|
|
public async Task<StartExamViewResponse> StartUserExamAsync(StartUserExamDto startUserExamDto, CancellationToken cancellationToken)
|
|
|
{
|
|
|
var userExam = await _repository.GetAsync(x => x.Id == startUserExamDto.Id);
|
|
@@ -338,6 +350,8 @@ namespace Hotline.Application.Exam.Service.ExamManages
|
|
|
|
|
|
if (!startExamViewResponse.CheckValidate())
|
|
|
{
|
|
|
+ await SetExamStatus(userExam, startExamViewResponse, cancellationToken);
|
|
|
+
|
|
|
return startExamViewResponse;
|
|
|
}
|
|
|
|
|
@@ -382,8 +396,11 @@ namespace Hotline.Application.Exam.Service.ExamManages
|
|
|
startExamViewResponse = AddCheckValidateTimeStrategy(examUserExam, examManage, startExamViewResponse, examStrategys);
|
|
|
startExamViewResponse = AddCheckValidateCountStrategy(examUserExam, examManage, startExamViewResponse, examStrategys);
|
|
|
|
|
|
+ examStrategyProxy.Initial(examStrategys);
|
|
|
+
|
|
|
if (!examStrategyProxy.Validate())
|
|
|
{
|
|
|
+ startExamViewResponse = (StartExamViewResponse)examStrategyProxy.GetResult();
|
|
|
return startExamViewResponse;
|
|
|
}
|
|
|
}
|
|
@@ -417,12 +434,16 @@ namespace Hotline.Application.Exam.Service.ExamManages
|
|
|
{
|
|
|
CallBack = () =>
|
|
|
{
|
|
|
- startExamViewResponse = new StartExamViewResponse
|
|
|
+ var response = new StartExamViewResponse
|
|
|
{
|
|
|
IsJoin = false,
|
|
|
IsStart = false,
|
|
|
- IsCompleted = true
|
|
|
+ IsCompleted = true,
|
|
|
+ StartTime = examUserExam.StartTime,
|
|
|
+ TimeSpan = examManage.TimeSpan
|
|
|
};
|
|
|
+
|
|
|
+ return response;
|
|
|
}
|
|
|
};
|
|
|
examStrategys.Add(checkStartTime);
|
|
@@ -436,12 +457,16 @@ namespace Hotline.Application.Exam.Service.ExamManages
|
|
|
{
|
|
|
CallBack = () =>
|
|
|
{
|
|
|
- startExamViewResponse = new StartExamViewResponse
|
|
|
+ var response = new StartExamViewResponse
|
|
|
{
|
|
|
IsJoin = false,
|
|
|
IsStart = false,
|
|
|
- IsCompleted = true
|
|
|
+ IsCompleted = true,
|
|
|
+ StartTime = examUserExam.StartTime,
|
|
|
+ TimeSpan = examManage.TimeSpan
|
|
|
};
|
|
|
+
|
|
|
+ return response;
|
|
|
}
|
|
|
};
|
|
|
examStrategys.Add(checkStartTime);
|
|
@@ -458,12 +483,16 @@ namespace Hotline.Application.Exam.Service.ExamManages
|
|
|
{
|
|
|
CallBack = () =>
|
|
|
{
|
|
|
- startExamViewResponse = new StartExamViewResponse
|
|
|
+ var response = new StartExamViewResponse
|
|
|
{
|
|
|
IsJoin = false,
|
|
|
IsStart = false,
|
|
|
- IsCompleted = true
|
|
|
+ IsCompleted = true,
|
|
|
+ StartTime = examUserExam.StartTime,
|
|
|
+ TimeSpan = examManage.TimeSpan
|
|
|
};
|
|
|
+
|
|
|
+ return response;
|
|
|
}
|
|
|
};
|
|
|
examStrategys.Add(checkStartTime);
|
|
@@ -478,12 +507,16 @@ namespace Hotline.Application.Exam.Service.ExamManages
|
|
|
{
|
|
|
CallBack = () =>
|
|
|
{
|
|
|
- startExamViewResponse = new StartExamViewResponse
|
|
|
+ var response = new StartExamViewResponse
|
|
|
{
|
|
|
IsJoin = false,
|
|
|
IsStart = false,
|
|
|
- IsCompleted = true
|
|
|
+ IsCompleted = true,
|
|
|
+ StartTime = examUserExam.StartTime,
|
|
|
+ TimeSpan = examManage.TimeSpan
|
|
|
};
|
|
|
+
|
|
|
+ return response;
|
|
|
}
|
|
|
};
|
|
|
examStrategys.Add(checkStartTime);
|
|
@@ -498,12 +531,16 @@ namespace Hotline.Application.Exam.Service.ExamManages
|
|
|
{
|
|
|
CallBack = () =>
|
|
|
{
|
|
|
- startExamViewResponse = new StartExamViewResponse
|
|
|
+ var response = new StartExamViewResponse
|
|
|
{
|
|
|
IsJoin = false,
|
|
|
IsStart = false,
|
|
|
- IsCompleted = false
|
|
|
+ IsCompleted = false,
|
|
|
+ StartTime = examUserExam.StartTime,
|
|
|
+ TimeSpan = examManage.TimeSpan
|
|
|
};
|
|
|
+
|
|
|
+ return response;
|
|
|
}
|
|
|
};
|
|
|
examStrategys.Add(checkStartTime);
|