From 523de5aed64ef979f9470bc8bcc2a990238865a0 Mon Sep 17 00:00:00 2001 From: "hhb@hotmail.com" Date: Wed, 12 Mar 2025 16:28:03 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E6=9B=B4=E6=96=B0=E5=88=86=E6=95=B0?= =?UTF-8?q?=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/LaborEducationServiceImpl.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/java/cn/teammodel/controller/admin/service/impl/LaborEducationServiceImpl.java b/src/main/java/cn/teammodel/controller/admin/service/impl/LaborEducationServiceImpl.java index f499c4f..c96c454 100644 --- a/src/main/java/cn/teammodel/controller/admin/service/impl/LaborEducationServiceImpl.java +++ b/src/main/java/cn/teammodel/controller/admin/service/impl/LaborEducationServiceImpl.java @@ -283,6 +283,7 @@ public class LaborEducationServiceImpl implements LaborEducationService { // 更新主观成绩,计算主观总分和客观总分 Map combinedScores = new HashMap<>(); for (Map.Entry entry : subjectiveScores.entrySet()) { + double score = 0; String knowledgeBlock = entry.getKey(); int count = entry.getValue(); // 次数 // 确保 count 不小于0 @@ -292,21 +293,29 @@ public class LaborEducationServiceImpl implements LaborEducationService { double maxCount = 50.0; // 最大次数(可根据实际情况调整) // 将次数转换为 0-100 的分数 - double convertedScore = (count / maxCount) * 100; + double convertedScore; + if (count > maxCount) { + convertedScore = 100.0; // 如果次数超过最大次数,设置为满分 + } else { + convertedScore = (count / maxCount) * 100; + } subjectiveTotal += convertedScore; // 获取对应知识块的客观成绩 double objectiveScore = knowledgeBlockScores.get(knowledgeBlock); objectiveTotal += objectiveScore; - + score = convertedScore * 0.6 + objectiveScore * 0.4; /* 形成 次数/客观分数 的格式 String combinedScore = count + "/" + objectiveScore; */ - int finalCount = count; + double finalCount = convertedScore; + double finalScore = score / knowledgeBlockCount; combinedScores.put(knowledgeBlock, new HashMap() {{ put("count", finalCount); put("objectiveScore", objectiveScore); + put("compositeScore", finalScore); + }}); //combinedScores.put(knowledgeBlock, objectiveScore);