package com.example.classroomattendance.controller; import com.example.classroomattendance.model.Student; import com.example.classroomattendance.service.StudentService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.*; @Controller public class StudentController { @Autowired private StudentService studentService; @PostMapping("/pick") public String pickRandomStudent(Model model) { Student pickedStudent = studentService.pickRandomStudent(); model.addAttribute("pickedStudent", pickedStudent); model.addAttribute("students", studentService.getAllStudents()); return "index"; } @PostMapping("/updatePoints") public String updateStudentPoints(@RequestParam Long studentId, @RequestParam double points, Model model) { studentService.updateStudentPoints(studentId, points); model.addAttribute("pickedStudent", studentService.pickRandomStudent()); model.addAttribute("students", studentService.getAllStudents()); return "index"; } @GetMapping("/") public String listStudents(Model model) { model.addAttribute("students", studentService.getAllStudents()); return "index"; } }