|
@@ -2,6 +2,7 @@ package com.example.civilizedcity.service.impl;
|
2
|
2
|
|
3
|
3
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
4
|
4
|
import com.example.civilizedcity.common.Constants;
|
|
5
|
+import com.example.civilizedcity.common.NumberUtil;
|
5
|
6
|
import com.example.civilizedcity.common.StringUtils;
|
6
|
7
|
import com.example.civilizedcity.entity.*;
|
7
|
8
|
import com.example.civilizedcity.mapper.*;
|
|
@@ -145,24 +146,15 @@ public class TaCheckItemServiceImpl extends BaseServiceImpl<TaCheckItemMapper, T
|
145
|
146
|
TaCheckItemQu qu = getQu(quList, item.getQuId());
|
146
|
147
|
// 如果是选择题, 对应的答案
|
147
|
148
|
TaCheckItemAn standAn = null;
|
|
149
|
+ // 是否扣分题
|
|
150
|
+ String computeType = qu.getComputeType();
|
148
|
151
|
|
149
|
152
|
if (Constants.QU_OF_FILL.equals(qu.getQuType())) {
|
150
|
153
|
// 如果是填空题, 用户填的应该是数字, 没填就是 0
|
151
|
154
|
Double fillNum = StringUtils.isEmpty(item.getAnswer()) ? 0.0 : Double.parseDouble(item.getAnswer());
|
152
|
155
|
|
153
|
156
|
// 填空得分 = 填空的数字 * 每个数字的分数
|
154
|
|
- Double fillScore = fillNum * qu.getAnScore();
|
155
|
|
-
|
156
|
|
- // 如果是扣分项, 那么得分 = 总分 - 扣分
|
157
|
|
- if (fillScore < 0) {
|
158
|
|
- score = qu.getMaxScore() + fillScore;
|
159
|
|
- if (score < 0) {
|
160
|
|
- score = 0;
|
161
|
|
- }
|
162
|
|
- } else {
|
163
|
|
- // 如果是得分项, 那么 分数 = 得分
|
164
|
|
- score = fillScore;
|
165
|
|
- }
|
|
157
|
+ score = fillNum * qu.getAnScore();
|
166
|
158
|
} else if (Constants.QU_OF_RADIO.equals(qu.getQuType())) {
|
167
|
159
|
// 如果是选择题, 找到对应的答案
|
168
|
160
|
standAn = taCheckItemAnMapper.getOneBy(qu.getQuId(), item.getAnswerCode());
|
|
@@ -174,6 +166,14 @@ public class TaCheckItemServiceImpl extends BaseServiceImpl<TaCheckItemMapper, T
|
174
|
166
|
score = qu.getMaxScore();
|
175
|
167
|
}
|
176
|
168
|
|
|
169
|
+ // 如果是扣分项
|
|
170
|
+ if ("-".equals(computeType)) {
|
|
171
|
+ score = qu.getMaxScore() + score;
|
|
172
|
+ if (score < 0) {
|
|
173
|
+ score = 0;
|
|
174
|
+ }
|
|
175
|
+ }
|
|
176
|
+
|
177
|
177
|
// 判断是否需要生成问题单
|
178
|
178
|
boolean isIssue = false;
|
179
|
179
|
if (score < qu.getMaxScore()) {
|