use of ai.elimu.model.enums.content.NumeracySkill in project webapp by elimu-ai.
the class ApplicationListController method handleRequest.
@RequestMapping(method = RequestMethod.GET)
public String handleRequest(Model model, HttpSession session) {
logger.info("handleRequest");
Contributor contributor = (Contributor) session.getAttribute("contributor");
logger.info("contributor.getLocale(): " + contributor.getLocale());
// List count of active Android applications for each EGRA/EGMA skill
List<Application> activeApplications = applicationDao.readAllByStatus(contributor.getLocale(), ApplicationStatus.ACTIVE);
logger.info("activeApplications.size(): " + activeApplications.size());
Map<LiteracySkill, Integer> literacySkillCountMap = new LinkedHashMap<>();
for (LiteracySkill literacySkill : LiteracySkill.values()) {
literacySkillCountMap.put(literacySkill, 0);
}
for (Application application : activeApplications) {
for (LiteracySkill literacySkill : application.getLiteracySkills()) {
int count = literacySkillCountMap.get(literacySkill);
literacySkillCountMap.put(literacySkill, count + 1);
}
}
model.addAttribute("literacySkillCountMap", literacySkillCountMap);
int maxLiteracySkillCount = 0;
Collection<Integer> literacySkillCountCollection = literacySkillCountMap.values();
for (int count : literacySkillCountCollection) {
if (count > maxLiteracySkillCount) {
maxLiteracySkillCount = count;
}
}
model.addAttribute("maxLiteracySkillCount", maxLiteracySkillCount);
Map<NumeracySkill, Integer> numeracySkillCountMap = new LinkedHashMap<>();
for (NumeracySkill numeracySkill : NumeracySkill.values()) {
numeracySkillCountMap.put(numeracySkill, 0);
}
for (Application application : activeApplications) {
for (NumeracySkill numeracySkill : application.getNumeracySkills()) {
int count = numeracySkillCountMap.get(numeracySkill);
numeracySkillCountMap.put(numeracySkill, count + 1);
}
}
model.addAttribute("numeracySkillCountMap", numeracySkillCountMap);
int maxNumeracySkillCount = 0;
Collection<Integer> numeracySkillCountCollection = numeracySkillCountMap.values();
for (int count : numeracySkillCountCollection) {
if (count > maxNumeracySkillCount) {
maxNumeracySkillCount = count;
}
}
model.addAttribute("maxNumeracySkillCount", maxNumeracySkillCount);
List<Application> applications = applicationDao.readAll(contributor.getLocale());
model.addAttribute("applications", applications);
return "admin/application/list";
}
Aggregations