|
@@ -213,49 +213,18 @@ public class PaperResultService {
|
|
|
* }
|
|
|
*/
|
|
|
public String abilityScore(PaperResult result, Paper paper) {
|
|
|
-
|
|
|
- Map<String, String> abilityCodes = subjectAbilityService.map(paper.getSubjectId());
|
|
|
- List<Integer> collectQuestion = convertQuestion(result.getCollectQuestion());
|
|
|
- //各能力分数 Map<code,Set<number>> 能力与题目编号
|
|
|
-// Map<String, Set<Integer>> codeNumber = new HashMap<>();
|
|
|
-
|
|
|
- //Map<code,score> 各能力分数
|
|
|
- Map<String, Double> codeScore = new LinkedHashMap<>();
|
|
|
- //初始化能力分数
|
|
|
- abilityCodes.keySet().forEach(e -> codeScore.put(e, 0d));
|
|
|
-
|
|
|
- for (Question q : paper.getQuestions()) {
|
|
|
- if (!collectQuestion.contains(q.getNumber())) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- String jsonScore = q.getJsonScore();
|
|
|
- Map<String, Double> scores = ObjectUtil.json2Map(jsonScore);
|
|
|
-// scores.forEach((code, score) -> {
|
|
|
-// if (score > 0) {
|
|
|
-// Set<Integer> number = codeNumber.getOrDefault(code, new HashSet<>());
|
|
|
-// number.add(q.getNumber());
|
|
|
-// codeNumber.put(code, number);
|
|
|
-// }
|
|
|
-// });
|
|
|
- //如果这题做对了 分数累加
|
|
|
- for (Map.Entry<String, Double> e : codeScore.entrySet()) {
|
|
|
- e.setValue(e.getValue() + scores.get(e.getKey()));
|
|
|
- }
|
|
|
+ String jsonScore = result.getJsonScore();
|
|
|
+ Map<String, Double> scores = ObjectUtil.json2Map(jsonScore);
|
|
|
+ Map<String, String> ability = subjectAbilityService.map(paper.getSubjectId());
|
|
|
+ Map<String, Double> abilityScores = ObjectUtil.json2Map(paper.getJsonScore());
|
|
|
+ Map<String, Double> ret = new LinkedHashMap<>();
|
|
|
+ //将成绩转化为10分
|
|
|
+ for (Map.Entry<String, Double> entry : scores.entrySet()) {
|
|
|
+ Double score = abilityScores.getOrDefault(entry.getKey(), 0d);
|
|
|
+ double s = score == 0 ? 0 : NumberUtil.format(10.0 * entry.getValue() / score);
|
|
|
+ ret.put(ability.get(entry.getKey()), s);
|
|
|
}
|
|
|
- ;
|
|
|
-
|
|
|
- //获取试卷的分数
|
|
|
- Map<String, Double> paperJsonScore = ObjectUtil.json2Map(paper.getJsonScore());
|
|
|
- Map<String, Double> d = new HashMap<>();
|
|
|
- //将分数转化为最大值为10
|
|
|
- for (Map.Entry<String, Double> e : codeScore.entrySet()) {
|
|
|
- double s = e.getValue();
|
|
|
- //改成10分制
|
|
|
- double score = NumberUtil.format(10 * s * 100.0 / paperJsonScore.get(e.getKey()));
|
|
|
- d.put(abilityCodes.get(e.getKey()), score);
|
|
|
- }
|
|
|
- return ObjectUtil.object2Json(d);
|
|
|
-
|
|
|
+ return ObjectUtil.object2Json(ret);
|
|
|
}
|
|
|
|
|
|
/**
|