|
|
@@ -12,6 +12,8 @@ import com.seecoder.dataanalysis.data.entity.eval.EvalExamRecord;
|
|
|
import com.seecoder.dataanalysis.data.entity.eval.Question;
|
|
|
import com.seecoder.dataanalysis.data.entity.eval.display.FormatQuestion;
|
|
|
import com.seecoder.dataanalysis.logic.question.QuestionService;
|
|
|
+import com.seecoder.dataanalysis.vo.AnswerDTO;
|
|
|
+import com.seecoder.dataanalysis.vo.EvalExamRecordDTO;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
@@ -108,6 +110,12 @@ public class EvalDataAnalysisServiceImpl implements EvalDataAnalysisService {
|
|
|
EvalExamInfo evalExamInfo = evalExamInfoDao.findById(evalExamRecord.getExamId()).get();
|
|
|
CompetencyTree competencyTree;
|
|
|
|
|
|
+ //如果record中没有学生id信息
|
|
|
+ if(evalExamRecord.getUserId()==null){
|
|
|
+ System.out.println("找不到学生id");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
Optional<CompetencyTree> result2 = competencyTreeDao.findById(evalExamRecord.getUserId());
|
|
|
if (!result2.isPresent()) {
|
|
|
//若查找不到能力树就新建一棵
|
|
|
@@ -177,6 +185,97 @@ public class EvalDataAnalysisServiceImpl implements EvalDataAnalysisService {
|
|
|
return competencyTree;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public CompetencyTree updateCompetencyTreeType2(EvalExamRecordDTO evalExamRecordDTO){
|
|
|
+
|
|
|
+ Optional<EvalExamInfo> result1 = evalExamInfoDao.findById(evalExamRecordDTO.getExamId());
|
|
|
+ if (!result1.isPresent()) {
|
|
|
+ System.out.println("考试信息不存在");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ EvalExamInfo evalExamInfo = evalExamInfoDao.findById(evalExamRecordDTO.getExamId()).get();
|
|
|
+ CompetencyTree competencyTree;
|
|
|
+
|
|
|
+ //如果record中没有学生id信息
|
|
|
+ if(evalExamRecordDTO.getUserId()==null){
|
|
|
+ System.out.println("找不到学生id");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ Optional<CompetencyTree> result2 = competencyTreeDao.findById(evalExamRecordDTO.getUserId());
|
|
|
+ if (!result2.isPresent()) {
|
|
|
+ //若查找不到能力树就新建一棵
|
|
|
+ competencyTree = new CompetencyTree(evalExamRecordDTO.getUserId());
|
|
|
+ } else {
|
|
|
+ competencyTree = competencyTreeDao.findById(evalExamRecordDTO.getUserId()).get();
|
|
|
+ }
|
|
|
+
|
|
|
+ //数据取完,开始进行KSD分析和入库
|
|
|
+ List<KSDScore> subTree = competencyTree.getSubCompetencyTree();
|
|
|
+ //难度由1-5,分别对应1.0, 1.25, 1.5, 1.75, 2.0的得分系数
|
|
|
+ Integer difficulty = evalExamInfo.getDifficulty();
|
|
|
+ String disposition = evalExamInfo.getDisposition();
|
|
|
+ Double tree_Score = competencyTree.getTreeScore();
|
|
|
+ double[] difficulty_percent = new double[]{1.0, 1.25, 1.5, 1.75, 2.0};
|
|
|
+ //得到学生所有题目的得分
|
|
|
+ List<AnswerDTO> answers = evalExamRecordDTO.getErrorQuestions();
|
|
|
+ Map<String, Double> studentScores = new HashMap<>();
|
|
|
+ if (answers != null) {
|
|
|
+ for (AnswerDTO answer : answers) {
|
|
|
+ studentScores.put(answer.getQuestionId(), answer.getQuestionScore());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Map<String, Double> questionAndScore = evalExamInfo.getQuestionAndScore();
|
|
|
+ //修改成不初始化,而是逐条添加的模式,对每一题进行分析入库
|
|
|
+ for (Map.Entry<String, Double> entry : studentScores.entrySet()) {
|
|
|
+ String questionId = entry.getKey();
|
|
|
+ Question question = questionService.getQuestionByIdForAnalysis(questionId);
|
|
|
+ List<String> knowledgeList = question.getCompetencies();
|
|
|
+ Integer weight = question.getWeight();
|
|
|
+
|
|
|
+ //能力树中的加分 = 学生得分 * 试卷难度
|
|
|
+ Double addScore = difficulty_percent[difficulty - 1] * studentScores.get(questionId);
|
|
|
+ //增加能力树总分,注意,每个competency都会加分
|
|
|
+ tree_Score += (addScore * knowledgeList.size());
|
|
|
+
|
|
|
+ for(int i=0;i<knowledgeList.size();i++){
|
|
|
+ String[] coms = knowledgeList.get(i).split("\\.");
|
|
|
+ String com1 = coms[0];
|
|
|
+ dfs(subTree,disposition,weight,addScore,"",com1);
|
|
|
+ int index1 = 0;
|
|
|
+ if(coms.length > 1){
|
|
|
+ String com2 = coms[1];
|
|
|
+ for(;index1<subTree.size();index1++){
|
|
|
+ if(subTree.get(index1).getCompetency().equals(com1)){
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dfs(subTree.get(index1).getChildren(),disposition,weight,addScore,com1+".",com2);
|
|
|
+ }
|
|
|
+ if(coms.length > 2){
|
|
|
+ String com2 = coms[1];
|
|
|
+ String com3 = coms[2];
|
|
|
+ int index2 = 0;
|
|
|
+ for(;index2<subTree.get(index1).getChildren().size();index2++){
|
|
|
+ if(subTree.get(index1).getChildren().get(index2).getCompetency().split("\\.")[1].equals(com2)){
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dfs(subTree.get(index1).getChildren().get(index2).getChildren(),disposition,weight,addScore,com1+"."+com2+".",com3);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //处理完考试中的每个问题后,更新能力树
|
|
|
+ competencyTree.setTreeScore(tree_Score);
|
|
|
+ competencyTree.setSubCompetencyTree(subTree);
|
|
|
+ competencyTreeDao.save(competencyTree);
|
|
|
+
|
|
|
+ return competencyTree;
|
|
|
+ }
|
|
|
+
|
|
|
void dfs(List<KSDScore> sub,String disposition,Integer weight,Double addScore,String pre,String com){
|
|
|
// System.out.println("start: "+com);
|
|
|
boolean existCom = false;
|