|
|
@ -313,15 +313,83 @@ public class StudentManager { |
|
|
|
return managerTool.getStudent(id); |
|
|
|
return managerTool.getStudent(id); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
public HashMap<String, Integer[]> generateSubjectAnalysis(String subject) { |
|
|
|
* 获取某科目成绩分析HashMap |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param subject 欲分析的科目 |
|
|
|
|
|
|
|
* @return 成绩等级人数 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private int[] getSubjectAnalysis(String subject) { |
|
|
|
ArrayList<Integer> scores = new ArrayList<>(managerTool.getSubjectScores(subject).values()); |
|
|
|
ArrayList<Integer> scores = new ArrayList<>(managerTool.getSubjectScores(subject).values()); |
|
|
|
int[] scoreAnalysis = new int[5]; |
|
|
|
int[] scoreAnalysis = new int[5]; |
|
|
|
HashMap<String, Integer[]> analysis = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int score : scores) { |
|
|
|
for (int score : scores) { |
|
|
|
|
|
|
|
scoreAnalysis[getScoreLevel(score)]++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return scoreAnalysis; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 获取所有成绩分析HashMap |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return 成绩等级人数 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public HashMap<String, int[]> getAllSubjectAnalysis() { |
|
|
|
|
|
|
|
ArrayList<String> subjects = managerTool.getAllSubjects(); |
|
|
|
|
|
|
|
HashMap<String, int[]> analysis = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (String subject : subjects) { |
|
|
|
|
|
|
|
analysis.put(subject, this.getSubjectAnalysis(subject)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return analysis; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 生成每科成绩层次分析(按百分制)的ArrayList |
|
|
|
|
|
|
|
* @return 包含成绩层次分析记录的ArrayList。每个层次等级数据为:人数/百分比 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public ArrayList<String> generateSubjectAnalysis() { |
|
|
|
|
|
|
|
HashMap<String, int[]> analysis = getAllSubjectAnalysis(); |
|
|
|
|
|
|
|
ArrayList<String> subjects = new ArrayList<>(analysis.keySet()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ArrayList<String> records = new ArrayList<>(); |
|
|
|
|
|
|
|
int studentAmount = managerTool.getStudentAmount(); |
|
|
|
|
|
|
|
for (String subject : subjects) { |
|
|
|
|
|
|
|
int[] scoreLevelInfo = analysis.get(subject); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
StringBuilder stringBuilder = new StringBuilder().append(subject).append(":\n\t"); |
|
|
|
|
|
|
|
stringBuilder |
|
|
|
|
|
|
|
.append(String.format("Level A: %d/%.2f", scoreLevelInfo[SCORE_LEVEL_A], (float) scoreLevelInfo[SCORE_LEVEL_A] / studentAmount)).append(" | ") |
|
|
|
|
|
|
|
.append(String.format("Level B: %d/%.2f", scoreLevelInfo[SCORE_LEVEL_B], (float) scoreLevelInfo[SCORE_LEVEL_B] / studentAmount)).append(" | ") |
|
|
|
|
|
|
|
.append(String.format("Level C: %d/%.2f", scoreLevelInfo[SCORE_LEVEL_C], (float) scoreLevelInfo[SCORE_LEVEL_C] / studentAmount)).append(" | ") |
|
|
|
|
|
|
|
.append(String.format("Level D: %d/%.2f", scoreLevelInfo[SCORE_LEVEL_D], (float) scoreLevelInfo[SCORE_LEVEL_D] / studentAmount)).append(" | ") |
|
|
|
|
|
|
|
.append(String.format("Level E: %d/%.2f", scoreLevelInfo[SCORE_LEVEL_E], (float) scoreLevelInfo[SCORE_LEVEL_E] / studentAmount)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
records.add(stringBuilder.toString()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return records; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private int getScoreLevel(int score) { |
|
|
|
|
|
|
|
if (score >= 90) { |
|
|
|
|
|
|
|
return SCORE_LEVEL_A; |
|
|
|
|
|
|
|
} else if (score >= 80) { |
|
|
|
|
|
|
|
return SCORE_LEVEL_B; |
|
|
|
|
|
|
|
} else if (score >= 70) { |
|
|
|
|
|
|
|
return SCORE_LEVEL_C; |
|
|
|
|
|
|
|
} else if (score >= 60) { |
|
|
|
|
|
|
|
return SCORE_LEVEL_D; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return SCORE_LEVEL_E; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static final int SCORE_LEVEL_A = 0; |
|
|
|
|
|
|
|
public static final int SCORE_LEVEL_B = 1; |
|
|
|
|
|
|
|
public static final int SCORE_LEVEL_C = 2; |
|
|
|
|
|
|
|
public static final int SCORE_LEVEL_D = 3; |
|
|
|
|
|
|
|
public static final int SCORE_LEVEL_E = 4; |
|
|
|
} |
|
|
|
} |