Browse Source

统计需要生成题目总数

master
luogw 4 weeks ago
parent
commit
1012e34a52
  1. 51
      src/main/java/com/project/question/domain/service/impl/QuestionInventoryDomainServiceImpl.java

51
src/main/java/com/project/question/domain/service/impl/QuestionInventoryDomainServiceImpl.java

@ -47,7 +47,7 @@ public class QuestionInventoryDomainServiceImpl implements QuestionInventoryDoma
return; return;
} }
int watermark = getWatermark(task); int watermark = getWatermark(task);
int targetLine = (int) Math.ceil(1.2 * getUnpassedCount(task)); int targetLine = getTargetLine(task);
Map<String, Double> questionTypeMap = questionTypeProportion(task); Map<String, Double> questionTypeMap = questionTypeProportion(task);
@ -84,13 +84,16 @@ public class QuestionInventoryDomainServiceImpl implements QuestionInventoryDoma
@Override @Override
public Result<String> checkAndReplenishBoolean(Long taskId) { public Result<String> checkAndReplenishBoolean(Long taskId) {
Boolean flage = false;
Integer total = 0;
TaskEntity task = taskMapper.selectById(taskId); TaskEntity task = taskMapper.selectById(taskId);
if (task == null || task.getEndTime().before(new Date())) { if (task == null || task.getEndTime().before(new Date())) {
return Result.success("题目生成完成"); return Result.success("考试任务不存在");
} }
int unpassed = getUnpassedCount(task); int unpassed = getUnpassedCount(task);
if (unpassed <= 0) { if (unpassed <= 0) {
return Result.success("题目生成完成"); return Result.success("考试任务未发现未通过人数");
} }
List<TaskKnowledgePointEntity> kpList = taskKpMapper.selectList( List<TaskKnowledgePointEntity> kpList = taskKpMapper.selectList(
new LambdaQueryWrapper<TaskKnowledgePointEntity>().eq(TaskKnowledgePointEntity::getTaskId , taskId)); new LambdaQueryWrapper<TaskKnowledgePointEntity>().eq(TaskKnowledgePointEntity::getTaskId , taskId));
@ -99,8 +102,12 @@ public class QuestionInventoryDomainServiceImpl implements QuestionInventoryDoma
if (QuestionTypeEnum.MULTIPLE_CHOICE.equals(questionType)) { if (QuestionTypeEnum.MULTIPLE_CHOICE.equals(questionType)) {
continue; continue;
} }
if(!checkKp(task,kp.getId(),questionType)){ Map<String, Double> questionTypeMap = questionTypeProportion(task);
return Result.success("题目未生成完成"); int targetLine = getTargetLine(task);
int targetNum = (int) Math.ceil(targetLine * questionTypeMap.get(questionType.name()));
total = total + targetNum;
if (!checkKpInventory(kp.getId(), questionType, targetNum)) {
flage = true;
} }
} }
} }
@ -111,11 +118,20 @@ public class QuestionInventoryDomainServiceImpl implements QuestionInventoryDoma
if (cluster.getClusterSize() < 2) { if (cluster.getClusterSize() < 2) {
continue; continue;
} }
if (!checkCluster(task, cluster)) {
return Result.success("题目未生成完成"); Map<String, Double> questionTypeMap = questionTypeProportion(task);
int targetLine = getTargetLine(task);
int clusterWatermark = targetLine * cluster.getClusterSize();
int targetNum = (int) Math.ceil(clusterWatermark * questionTypeMap.get(QuestionTypeEnum.MULTIPLE_CHOICE.name()));
total = total + targetNum;
if (!checkClusterInventory(cluster.getId(), targetNum)) {
flage = true;
} }
} }
return Result.success("题目生成完成"); if (flage){
return Result.success("题目未生成完成,目标题量:"+total);
}
return Result.success("题目生成完成,目标题量:"+total);
} }
/** /**
@ -177,6 +193,13 @@ public class QuestionInventoryDomainServiceImpl implements QuestionInventoryDoma
return (int) Math.ceil(1.0 * getUnpassedCount(task)); return (int) Math.ceil(1.0 * getUnpassedCount(task));
} }
/**
* 计算目标线 (targetLine = ceil(1.2 * u))
*/
private int getTargetLine(TaskEntity task) {
return (int) Math.ceil(1.2 * getUnpassedCount(task));
}
/** /**
* 获取题目题型占比系数 * 获取题目题型占比系数
*/ */
@ -196,19 +219,17 @@ public class QuestionInventoryDomainServiceImpl implements QuestionInventoryDoma
public Boolean checkKp(TaskEntity task, Long kpId, QuestionTypeEnum questionType){ public Boolean checkKp(TaskEntity task, Long kpId, QuestionTypeEnum questionType){
Map<String, Double> questionTypeMap = questionTypeProportion(task); Map<String, Double> questionTypeMap = questionTypeProportion(task);
int watermark = getWatermark(task); int targetLine = getTargetLine(task);
if (!checkKpInventory(kpId, questionType, (int) Math.ceil(watermark * questionTypeMap.get(questionType.name())))) {
return false; return checkKpInventory(kpId, questionType, (int) Math.ceil(targetLine * questionTypeMap.get(questionType.name())));
}
return true;
} }
@Override @Override
public Boolean checkCluster(TaskEntity task, TaskKnowledgeClusterEntity cluster) { public Boolean checkCluster(TaskEntity task, TaskKnowledgeClusterEntity cluster) {
Map<String, Double> questionTypeMap = questionTypeProportion(task); Map<String, Double> questionTypeMap = questionTypeProportion(task);
int watermark = getWatermark(task); int targetLine = getTargetLine(task);
int clusterWatermark = watermark * cluster.getClusterSize(); int clusterWatermark = targetLine * cluster.getClusterSize();
return checkClusterInventory(cluster.getId(), (int) Math.ceil(clusterWatermark * questionTypeMap.get(QuestionTypeEnum.MULTIPLE_CHOICE.name()))); return checkClusterInventory(cluster.getId(), (int) Math.ceil(clusterWatermark * questionTypeMap.get(QuestionTypeEnum.MULTIPLE_CHOICE.name())));
} }

Loading…
Cancel
Save