| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- package com.seecoder.dataanalysis.data.entity.eval;
- import com.seecoder.dataanalysis.data.entity.competency.KSScore;
- import com.seecoder.dataanalysis.vo.question.CompleteQuestionVO;
- import lombok.AllArgsConstructor;
- import lombok.Data;
- import lombok.NoArgsConstructor;
- import lombok.experimental.Accessors;
- import org.jetbrains.annotations.NotNull;
- import org.springframework.data.annotation.Id;
- import org.springframework.data.mongodb.core.mapping.Document;
- import org.springframework.data.mongodb.core.mapping.Field;
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.Collections;
- import java.util.List;
- /**
- * @author Peng Yiyan
- */
- @NoArgsConstructor
- @AllArgsConstructor
- @Accessors(chain = true)
- @Data
- public class Question {
- /**
- * 题目id
- */
- private String questionId;
- // /**
- // * 题目总分值
- // */
- // private Double questionScore;
- /**
- * 题目难度,用于Skills
- */
- private Integer weight;
- /**
- * 题目考察的能力,可能考察多种不同能力,所以用list存储
- */
- private List<String> competencies;
- // /**
- // * 题目考察的K-S对,和competencies中的下标一一对应
- // */
- // private List<KSScore> ksScores;
- /**
- * 解析CompleteQuestionVO的内容,并放入Question中
- * @param completeQuestionVO
- */
- public Question(CompleteQuestionVO completeQuestionVO){
- this.setQuestionId(completeQuestionVO.getId());
- this.setWeight(completeQuestionVO.getWeight());
- List<String> knowledgeList = completeQuestionVO.getKnowledgeId();
- // String[] testArray = new String[]{"SR.RV.RT","SR.RV","SR.RC.INRP","SC","SC.RT","SR","SSR"};
- // List<String> knowledgeList = Arrays.asList(testArray);
- // Collections.sort(knowledgeList,(a,b) -> b.split(".").length - a.split(".").length);
- Collections.sort(knowledgeList,(a,b) -> countPoint(b) - countPoint(a));
- // for(String str : knowledgeList)
- // System.out.println(str);
- //处理重复知识点后的结果数组
- List<String> after = new ArrayList<>();
- after.add(knowledgeList.get(0));
- int index = 1;
- for(;index<knowledgeList.size();index++){
- if(countPoint(knowledgeList.get(index)) == countPoint(knowledgeList.get(index-1))){
- after.add(knowledgeList.get(index));
- }else {
- break;
- }
- }
- for(;index<knowledgeList.size();index++){
- boolean overlap = false;
- for(String have : after){
- if(have.contains(knowledgeList.get(index))){
- overlap = true;
- break;
- }
- }
- if(!overlap){
- after.add(knowledgeList.get(index));
- }
- }
- this.setCompetencies(after);
- }
- //计算字符串中.(分隔符)的数目
- int countPoint(String s){
- int count = 0;
- for(int i=0;i<s.length();i++){
- if(s.charAt(i) == '.'){
- count++;
- }
- }
- return count;
- }
- }
|