成长路径图,考试计数

This commit is contained in:
yang
2024-07-08 14:49:31 +08:00
parent 13b5e6ab4c
commit 5594e07264

View File

@@ -93,10 +93,13 @@ public class AloneExamServiceImpl implements IAloneExamService{
//更新状态,状态是未完成的,这里会有问题
if(scoreType!=null && scoreType==2) {
AloneExam ae=aeDao.findOne(FieldFilters.eq("aid", aea.getAid()),FieldFilters.eq("testId", aea.getTestId()));
long currentTimes = ae.getTimes() != null ? ae.getTimes() : 0;
//最后一次的分数为准
aeDao.update(UpdateBuilder.from(AloneExam.class)
.addUpdateField("status", aea.getStatus())
.addUpdateField("score", aea.getScore())
.addUpdateField("times", currentTimes+1)
.addFilter(FieldFilters.eq("aid", aea.getAid()))
.addFilter(FieldFilters.eq("testId", aea.getTestId()))
.builder());
@@ -111,6 +114,8 @@ public class AloneExamServiceImpl implements IAloneExamService{
}else {
aeDao.updateMultiFieldById(ae.getId(), UpdateBuilder.create("status", aea.getStatus()),UpdateBuilder.create("score", aea.getScore()));
}
long currentTimes = ae.getTimes() != null ? ae.getTimes() : 0;
aeDao.updateFieldById(ae.getId(), "times", currentTimes+1);
}
// else {
// //这种情况汶是不存在的
@@ -501,7 +506,7 @@ public class AloneExamServiceImpl implements IAloneExamService{
aloneExamAnswer.setAid(userId);
aloneExamAnswer.setName(examScoreDto.getUserName());
aloneExamAnswer.setUcode(examScoreDto.getWorkNum());
aloneExamAnswer.setUseSecond(examScoreDto.getUseMinute()*60);
// aloneExamAnswer.setUseSecond(examScoreDto.getUseMinute()*60);
ExamTest examTest = examTestDao.get(examScoreDto.getTestId());
aloneExamAnswer.setPassLine(examTest.getPassLine());
@@ -509,34 +514,29 @@ public class AloneExamServiceImpl implements IAloneExamService{
aloneExamAnswer.setTestDuration(examTest.getTestDuration());
// 获取考试任务ID
String aloneExamId = (String) aeDao.findField("id",
FieldFilters.eq("aid", userId),
FieldFilters.eq("testId", examScoreDto.getTestId())
);
aloneExamAnswer.setAloneId(aloneExamId);
AloneExam aloneExam=aeDao.findOne(FieldFilters.eq("aid", userId),FieldFilters.eq("testId", examScoreDto.getTestId()));
aloneExamAnswer.setAloneId(aloneExam.getId());
// 添加答卷
dao.save(aloneExamAnswer);
// 更新状态,状态是未完成的,这里会有问题
long currentTimes = aloneExam.getTimes() != null ? aloneExam.getTimes() : 0;
if(examTest.getScoringType()!=null && examTest.getScoringType()==2) {
//最后一次的分数为准
aeDao.update(UpdateBuilder.from(AloneExam.class)
.addUpdateField("status", examScoreDto.getStatus())
.addUpdateField("score", examScoreDto.getScore())
.addUpdateField("times", currentTimes+1)
.addFilter(FieldFilters.eq("aid", userId))
.addFilter(FieldFilters.eq("testId", examScoreDto.getTestId()))
.builder());
} else {
//更新状态
AloneExam ae=aeDao.findOne(FieldFilters.eq("aid", userId),FieldFilters.eq("testId", examScoreDto.getTestId()));
if(ae!=null) {
if(ae.getStatus()==AloneExam.STATUS_FINISH) {
if(ae.getScore()<examScoreDto.getScore()) {
aeDao.updateFieldById(ae.getId(), "score", examScoreDto.getScore());
if (aloneExam.getStatus() == AloneExam.STATUS_FINISH) {
if (aloneExam.getScore() < examScoreDto.getScore()) {
aeDao.updateMultiFieldById(aloneExam.getId(), UpdateBuilder.create("score", examScoreDto.getScore()), UpdateBuilder.create("times", currentTimes+1));
}
} else {
aeDao.updateMultiFieldById(ae.getId(), UpdateBuilder.create("status", examScoreDto.getStatus()),UpdateBuilder.create("score", examScoreDto.getScore()));
}
aeDao.updateMultiFieldById(aloneExam.getId(), UpdateBuilder.create("status", examScoreDto.getStatus()), UpdateBuilder.create("score", examScoreDto.getScore()), UpdateBuilder.create("times", currentTimes+1));
}
}