|
|
|
@ -7,6 +7,7 @@ import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
|
|
import com.ruoyi.wgz.bo.req.WgzAppSubmitATestPaperReq;
|
|
|
|
|
import com.ruoyi.wgz.bo.res.WgzAppSubmitATestPaperRes;
|
|
|
|
|
import com.ruoyi.wgz.bo.res.WgzAppUserScoreQuery;
|
|
|
|
|
import com.ruoyi.wgz.bo.rests.WgzAppSubmitATestPaperTwo;
|
|
|
|
|
import com.ruoyi.wgz.domain.WgzQuestionBank;
|
|
|
|
|
import com.ruoyi.wgz.domain.WgzQuestionsConfiguration;
|
|
|
|
|
import com.ruoyi.wgz.service.IWgzQuestionBankService;
|
|
|
|
@ -125,10 +126,11 @@ public class WgzQuestionSaveServiceImpl extends ServicePlusImpl<WgzQuestionSaveM
|
|
|
|
|
WgzQuestionsConfiguration configuration = iWgzQuestionsConfigurationService.appQueryLimitOne();
|
|
|
|
|
//3、计算这次用户提交的试卷信息所得到的分数
|
|
|
|
|
List<WgzQuestionSave> bqs = new ArrayList<>();
|
|
|
|
|
AtomicReference<Double> fenshu = new AtomicReference<>(0.0);
|
|
|
|
|
AtomicInteger number = new AtomicInteger(0);
|
|
|
|
|
AtomicInteger index = new AtomicInteger(0);
|
|
|
|
|
req.getList().forEach(data -> {
|
|
|
|
|
Double fenshu = 0.0;
|
|
|
|
|
Integer number = 0;
|
|
|
|
|
Integer index = 0;
|
|
|
|
|
List<WgzAppSubmitATestPaperTwo> list = req.getList();
|
|
|
|
|
for (WgzAppSubmitATestPaperTwo data : list) {
|
|
|
|
|
String correct = "";
|
|
|
|
|
String pass = "";
|
|
|
|
|
// 获取题库的正确答案,然后和用户的答案作对比
|
|
|
|
@ -141,8 +143,8 @@ public class WgzQuestionSaveServiceImpl extends ServicePlusImpl<WgzQuestionSaveM
|
|
|
|
|
}
|
|
|
|
|
if (bqb.getCorrectAnswer().toLowerCase().contains(data.getAnswer().toLowerCase())) {
|
|
|
|
|
correct = "1";
|
|
|
|
|
fenshu.updateAndGet(v -> v + data.getScore());
|
|
|
|
|
number.incrementAndGet();
|
|
|
|
|
fenshu = fenshu+data.getScore();
|
|
|
|
|
number = number+1;
|
|
|
|
|
} else {
|
|
|
|
|
correct = "2";
|
|
|
|
|
}
|
|
|
|
@ -156,27 +158,72 @@ public class WgzQuestionSaveServiceImpl extends ServicePlusImpl<WgzQuestionSaveM
|
|
|
|
|
bqsTwo.setCorrect(correct);
|
|
|
|
|
bqsTwo.setScore(data.getScore());
|
|
|
|
|
//这几条数据只在每张试卷的第一条数据中存储(重复的没必要每条都存储)
|
|
|
|
|
if (index.get() == 0) {
|
|
|
|
|
if (index == 0) {
|
|
|
|
|
bqsTwo.setTakeTime(req.getTakeTime());
|
|
|
|
|
bqsTwo.setTimeOut(configuration.getAnswerTime());
|
|
|
|
|
bqsTwo.setPass(pass);
|
|
|
|
|
}
|
|
|
|
|
bqs.add(bqsTwo);
|
|
|
|
|
index.incrementAndGet();
|
|
|
|
|
});
|
|
|
|
|
index = index+1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// AtomicReference<Double> fenshu = new AtomicReference<>(0.0);
|
|
|
|
|
// AtomicInteger number = new AtomicInteger(0);
|
|
|
|
|
// AtomicInteger index = new AtomicInteger(0);
|
|
|
|
|
// req.getList().forEach(data -> {
|
|
|
|
|
// String correct = "";
|
|
|
|
|
// String pass = "";
|
|
|
|
|
// // 获取题库的正确答案,然后和用户的答案作对比
|
|
|
|
|
// WgzQuestionBank bqb = iWgzQuestionBankService.selectById(data.getBankId());
|
|
|
|
|
// if (bqb == null) {
|
|
|
|
|
// throw new RuntimeException("您的试卷被外星人卷走了!");
|
|
|
|
|
// } else {
|
|
|
|
|
// if (StringUtils.isEmpty(data.getAnswer())) {
|
|
|
|
|
// throw new RuntimeException("您还有题未答完!");
|
|
|
|
|
// }
|
|
|
|
|
// if (bqb.getCorrectAnswer().toLowerCase().contains(data.getAnswer().toLowerCase())) {
|
|
|
|
|
// correct = "1";
|
|
|
|
|
// fenshu.updateAndGet(v -> v + data.getScore());
|
|
|
|
|
// number.incrementAndGet();
|
|
|
|
|
// } else {
|
|
|
|
|
// correct = "2";
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// // 记录这次的及格线和总分
|
|
|
|
|
// pass = configuration.getPassingScore().toString() + "," + configuration.getFullMark().toString();
|
|
|
|
|
// WgzQuestionSave bqsTwo = new WgzQuestionSave();
|
|
|
|
|
// bqsTwo.setUserId(req.getUserId());
|
|
|
|
|
// bqsTwo.setBankId(data.getBankId());
|
|
|
|
|
// bqsTwo.setAnswer(data.getAnswer());
|
|
|
|
|
// bqsTwo.setCorrect(correct);
|
|
|
|
|
// bqsTwo.setScore(data.getScore());
|
|
|
|
|
// //这几条数据只在每张试卷的第一条数据中存储(重复的没必要每条都存储)
|
|
|
|
|
// if (index.get() == 0) {
|
|
|
|
|
// bqsTwo.setTakeTime(req.getTakeTime());
|
|
|
|
|
// bqsTwo.setTimeOut(configuration.getAnswerTime());
|
|
|
|
|
// bqsTwo.setPass(pass);
|
|
|
|
|
// }
|
|
|
|
|
// bqs.add(bqsTwo);
|
|
|
|
|
// index.incrementAndGet();
|
|
|
|
|
// });
|
|
|
|
|
Double fullMark = configuration.getFullMark();
|
|
|
|
|
scoreTwo = 100.00 / fullMark * fenshu.get();
|
|
|
|
|
scoreTwo = 100.00 / fullMark * fenshu;
|
|
|
|
|
WgzAppSubmitATestPaperRes res = new WgzAppSubmitATestPaperRes();
|
|
|
|
|
res.setAnswerTime(configuration.getAnswerTime());
|
|
|
|
|
res.setTakeTime(req.getTakeTime());
|
|
|
|
|
res.setFullMark(fullMark);
|
|
|
|
|
res.setPassingScore(configuration.getPassingScore());
|
|
|
|
|
res.setScore(fenshu.get());
|
|
|
|
|
res.setNumber(number.get());
|
|
|
|
|
res.setScore(fenshu);
|
|
|
|
|
res.setNumber(number);
|
|
|
|
|
//4、两次卷子的分数对比,第一次的分数比第二次大那么第二次只返回结果;第二次的分数比第一次大那么删除第一次的数据再重新插入
|
|
|
|
|
if (scoreOne > scoreTwo) {
|
|
|
|
|
return res;
|
|
|
|
|
} else {
|
|
|
|
|
if (scoreOne == 0){
|
|
|
|
|
// 插入新数据
|
|
|
|
|
super.saveBatch(bqs);
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
// 先查询当前用户是否有答题,有就把之前的删除(真删)
|
|
|
|
|
int deleteResult = baseMapper.delete(new LambdaQueryWrapper<WgzQuestionSave>().eq(WgzQuestionSave::getUserId, req.getUserId()));
|
|
|
|
|
if (deleteResult >0){
|
|
|
|
|