|
@@ -153,8 +153,11 @@ public class ExamStatisticsServiceImpl extends ServiceImpl<ExamStatisticsMapper,
|
|
|
* @param userExamQuestionList
|
|
|
* @return
|
|
|
*/
|
|
|
- public double calcExamAccuracy(List<UserExamQuestion> userExamQuestionList) {
|
|
|
- long rightNum = userExamQuestionList.stream().filter(o -> o.getIsRight() == true).count();
|
|
|
+ public Double calcExamAccuracy(List<UserExamQuestion> userExamQuestionList) {
|
|
|
+ if (CollectionUtils.isEmpty(userExamQuestionList)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ long rightNum = userExamQuestionList.stream().filter(o -> !Objects.isNull(o.getIsRight()) && o.getIsRight() == true).count();
|
|
|
return NumberUtil.div(multi(rightNum), userExamQuestionList.size(), 2);
|
|
|
}
|
|
|
|
|
@@ -166,7 +169,7 @@ public class ExamStatisticsServiceImpl extends ServiceImpl<ExamStatisticsMapper,
|
|
|
public Double calcUserAccuracy(Map<String, List<UserExamQuestion>> ueqMap, ExamStatisticsDTO dto) {
|
|
|
List<UserExamQuestion> questions = ueqMap.get(dto.getUserExamId());
|
|
|
if (!CollectionUtils.isEmpty(questions)) {
|
|
|
- long rightNum = questions.stream().filter(o -> o.getIsRight() == true).count();
|
|
|
+ long rightNum = questions.stream().filter(o -> !Objects.isNull(o.getIsRight()) && o.getIsRight() == true).count();
|
|
|
return NumberUtil.div(multi(rightNum), questions.size(), 2);
|
|
|
}
|
|
|
return null;
|
|
@@ -180,7 +183,8 @@ public class ExamStatisticsServiceImpl extends ServiceImpl<ExamStatisticsMapper,
|
|
|
public Double calcScoreRate(Map<String, List<UserExamQuestion>> ueqMap, ExamStatisticsDTO dto) {
|
|
|
List<UserExamQuestion> questions = ueqMap.get(dto.getUserExamId());
|
|
|
if (!CollectionUtils.isEmpty(questions)) {
|
|
|
- int userScoreTotal = questions.stream().filter(o -> o.getIsRight() == true).mapToInt(UserExamQuestion::getQuestionScore).sum();
|
|
|
+ int userScoreTotal = questions.stream().filter(o -> !Objects.isNull(o.getIsRight()) && o.getIsRight() == true)
|
|
|
+ .mapToInt(UserExamQuestion::getQuestionScore).sum();
|
|
|
int scoreTotal = questions.stream().mapToInt(UserExamQuestion::getQuestionScore).sum();
|
|
|
return NumberUtil.div(multi(userScoreTotal), scoreTotal, 2);
|
|
|
}
|