|
|
|
@ -170,11 +170,15 @@ public class TheoryTestServiceImpl implements TheoryTestService {
|
|
|
|
|
if (record.getAverageScore() == null) {
|
|
|
|
|
record.setAverageScore(score);
|
|
|
|
|
} else {
|
|
|
|
|
Integer examCount = record.getExamCount();
|
|
|
|
|
BigDecimal averageScore = record.getAverageScore();
|
|
|
|
|
BigDecimal multiply = averageScore.multiply(BigDecimal.valueOf(examCount));
|
|
|
|
|
BigDecimal newAvg = multiply.add(score).divide(BigDecimal.valueOf(examCount), 2, RoundingMode.HALF_UP);
|
|
|
|
|
record.setAverageScore(newAvg);
|
|
|
|
|
StuTheoryExamExample example = new StuTheoryExamExample();
|
|
|
|
|
example.createCriteria().andUserIdEqualTo(userId).andAnsweredEqualTo(true);
|
|
|
|
|
List<StuTheoryExamWithBLOBs> stuTheoryExamWithBLOBs = theoryExamMapper.selectByExampleWithBLOBs(example);
|
|
|
|
|
BigDecimal totalScore = stuTheoryExamWithBLOBs.stream()
|
|
|
|
|
.map(StuTheoryExamWithBLOBs::getScore)
|
|
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add)
|
|
|
|
|
.add(score);
|
|
|
|
|
BigDecimal avgScore = totalScore.divide(BigDecimal.valueOf(stuTheoryExamWithBLOBs.size()+1), 2, RoundingMode.HALF_UP);
|
|
|
|
|
record.setAverageScore(avgScore);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
theoryRecordMapper.updateByPrimaryKey(record);
|
|
|
|
@ -532,6 +536,7 @@ public class TheoryTestServiceImpl implements TheoryTestService {
|
|
|
|
|
System.out.println(s);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<StuTheoryExamDetailDto> getTheoryTestDetail(String theoryExamId, Integer index, Integer size) throws IOException {
|
|
|
|
|
ArrayList<String> idsList = new ArrayList<>();
|
|
|
|
|