|
|
@@ -10,6 +10,7 @@ import com.seecoder.dataanalysis.data.entity.competency.*;
|
|
|
import com.seecoder.dataanalysis.data.entity.eval.EvalExamInfo;
|
|
|
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 org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -275,4 +276,87 @@ public class EvalDataAnalysisServiceImpl implements EvalDataAnalysisService {
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<FormatQuestion> getStudentQuestionsList(int userId, List<String> types){
|
|
|
+ List<FormatQuestion> questionList = new ArrayList<>();
|
|
|
+ List<EvalExamRecord> evalExamRecordList = evalExamRecordDao.findByUserId(userId);
|
|
|
+ Map<String,Double> res = new HashMap<>();
|
|
|
+
|
|
|
+ for(EvalExamRecord evalExamRecord : evalExamRecordList){
|
|
|
+ Optional<EvalExamInfo> result = evalExamInfoDao.findById(evalExamRecord.getExamId());
|
|
|
+ if(!result.isPresent()){
|
|
|
+ System.out.println("找不到对应考试信息");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ EvalExamInfo evalExamInfo = evalExamInfoDao.findById(evalExamRecord.getExamId()).get();
|
|
|
+
|
|
|
+
|
|
|
+ //获得题目ID和题目分数的对应关系
|
|
|
+ Map<String,Double> questionAndScore = evalExamInfo.getQuestionAndScore();
|
|
|
+ Map<String,Double> errorQuestions = evalExamRecord.getErrorQuestions();
|
|
|
+ for(String questionId : errorQuestions.keySet()){
|
|
|
+ QuestionVO questionVO = questionService.getQuestionById(questionId);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ Boolean isType = false;
|
|
|
+ //当Types为空的时候默认全选
|
|
|
+ if(types==null||types.size()==0){
|
|
|
+ isType = true;
|
|
|
+ }else {
|
|
|
+ for(String type : types){
|
|
|
+ for(String know : questionVO.getKnowledgeId()){
|
|
|
+ //包含,说明是要查找的type,则继续
|
|
|
+ if(know.contains(type)){
|
|
|
+ isType = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //如果该题不是要求返回的type,则跳过不做分析
|
|
|
+ if(isType == false){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //如果题目分数为0,则跳过不做分析
|
|
|
+ if(questionAndScore.get(questionId) == 0){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+// System.out.println(errorQuestions.get(questionId));
|
|
|
+// System.out.println(question.getQuestionScore());
|
|
|
+ //如果做过相同的题目,则取最高分
|
|
|
+ DecimalFormat df = new DecimalFormat("#.00");
|
|
|
+ //当前题目的得分比值
|
|
|
+ Double scorePercent = errorQuestions.get(questionId)/questionAndScore.get(questionId);
|
|
|
+ //如果res里已经有当前的questionId,说明这道题已经做过了,判断是否需要更新信息
|
|
|
+ if(res.containsKey(questionId)){
|
|
|
+ scorePercent = Math.max(scorePercent,res.get(questionId));
|
|
|
+ //只有当得分/总分比当前值更大的时候才需要更新
|
|
|
+ if(scorePercent > res.get(questionId)){
|
|
|
+ for(FormatQuestion formatQuestion : questionList){
|
|
|
+ if(formatQuestion.getQuestionId().equals(questionId)){
|
|
|
+ formatQuestion.setScore(errorQuestions.get(questionId));
|
|
|
+ formatQuestion.setTotalScore(questionAndScore.get(questionId));
|
|
|
+ formatQuestion.setExamId(evalExamRecord.getExamId());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else {//如果没有做过,则新建一个FormatQuestion
|
|
|
+ FormatQuestion formatQuestion = new FormatQuestion();
|
|
|
+ formatQuestion.setQuestionId(questionId);
|
|
|
+ formatQuestion.setQuestionVO(questionVO);
|
|
|
+ formatQuestion.setKnows(questionVO.getKnowledgeId());
|
|
|
+ formatQuestion.setScore(errorQuestions.get(questionId));
|
|
|
+ formatQuestion.setTotalScore(questionAndScore.get(questionId));
|
|
|
+ formatQuestion.setExamId(evalExamRecord.getExamId());
|
|
|
+ questionList.add(formatQuestion);
|
|
|
+ }
|
|
|
+ res.put(questionId,Double.valueOf(df.format(scorePercent)));
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return questionList;
|
|
|
+ }
|
|
|
+
|
|
|
}
|