|
@@ -124,18 +124,18 @@ public class ExamServiceImpl implements ExamService {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public List<String> startExam(Exam exam, User user) {
|
|
public List<String> startExam(Exam exam, User user) {
|
|
- ExamHistory examHistoryInDb = examHistoryRepository.findByUserIdAndExamId(user.getUserName(), exam.getId());
|
|
|
|
- if (examHistoryInDb != null) {
|
|
|
|
- if (examHistoryInDb.getEndTime() != null) {
|
|
|
|
- return null; // exam has been finished.
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
|
|
+// ExamHistory examHistoryInDb = examHistoryRepository.findByUserIdAndExamId(user.getUserName(), exam.getId());
|
|
|
|
+// if (examHistoryInDb != null) {
|
|
|
|
+// if (examHistoryInDb.getEndTime() != null) {
|
|
|
|
+// return null; // exam has been finished.
|
|
|
|
+// }
|
|
|
|
+// } else {
|
|
ExamHistory examHistory = new ExamHistory();
|
|
ExamHistory examHistory = new ExamHistory();
|
|
examHistory.setExamId(exam.getId());
|
|
examHistory.setExamId(exam.getId());
|
|
examHistory.setStartTime(LocalDateTime.now(CHINA_ZONE));
|
|
examHistory.setStartTime(LocalDateTime.now(CHINA_ZONE));
|
|
examHistory.setUserId(user.getUserName());
|
|
examHistory.setUserId(user.getUserName());
|
|
examHistoryRepository.insert(examHistory);
|
|
examHistoryRepository.insert(examHistory);
|
|
- }
|
|
|
|
|
|
+// }
|
|
return examToQuestionRepository
|
|
return examToQuestionRepository
|
|
.findAllByExamId(exam.getId()).stream()
|
|
.findAllByExamId(exam.getId()).stream()
|
|
.map(x -> x.getQuestionId())
|
|
.map(x -> x.getQuestionId())
|