@RequestMapping(value = "/classmates", method = RequestMethod.GET) public String getClassmates(Model model) { User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); model.addAttribute("current_user", user); Student currentStudent = studentService.getOne(user.getId()); if (user.getRole().equals(Role.ROLE_STUDENT)) model.addAttribute("homework", currentStudent.getGroup().getHomeworks()); TreeMap<Double, String> studentsMap = new TreeMap<>(Collections.reverseOrder()); currentStudent .getGroup() .getStudents() .forEach( student -> studentsMap.put( studentService.getAverageScore(student.getId()), student.getFullName())); LinkedHashMap<String, String> studentsMapForFreemarker = new LinkedHashMap<>(); studentsMap .entrySet() .forEach( entry -> studentsMapForFreemarker.put(String.valueOf(entry.getKey()), entry.getValue())); model.addAttribute("studentsMap", studentsMapForFreemarker); return "student/classmates"; }
@RequestMapping(value = "/marks", method = RequestMethod.GET) public String getMarks(Model model) { User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); model.addAttribute("current_user", user); Student currentStudent = studentService.getOne(user.getId()); if (user.getRole().equals(Role.ROLE_STUDENT)) model.addAttribute("homework", currentStudent.getGroup().getHomeworks()); model.addAttribute("marks", firstTenMarks(currentStudent.getMarks())); return "student/marks"; }
@RequestMapping(value = "/schedule", method = RequestMethod.GET) public String getSchedule(Model model) { User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); model.addAttribute("current_user", user); Student currentStudent = studentService.getOne(user.getId()); if (user.getRole().equals(Role.ROLE_STUDENT)) model.addAttribute("homework", currentStudent.getGroup().getHomeworks()); List<SchoolDay> schoolDays = new ArrayList<>(studentService.getSchedule(currentStudent).getSchoolDays()); Collections.sort(schoolDays); model.addAttribute("schoolDays", schoolDays); return "student/schedule"; }