diff --git a/src/main/java/fr/univ_lille/gitlab/classrooms/classrooms/ClassroomStudentController.java b/src/main/java/fr/univ_lille/gitlab/classrooms/classrooms/ClassroomStudentController.java new file mode 100644 index 0000000..9b96e93 --- /dev/null +++ b/src/main/java/fr/univ_lille/gitlab/classrooms/classrooms/ClassroomStudentController.java @@ -0,0 +1,47 @@ +package fr.univ_lille.gitlab.classrooms.classrooms; + +import fr.univ_lille.gitlab.classrooms.assignments.AssignmentService; +import fr.univ_lille.gitlab.classrooms.users.ClassroomUserService; +import jakarta.annotation.security.RolesAllowed; +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.server.ResponseStatusException; +import org.springframework.web.servlet.ModelAndView; + +import java.util.UUID; + +@Controller +@RolesAllowed("TEACHER") +class ClassroomStudentController { + + private final ClassroomService classroomService; + + private final AssignmentService assignmentService; + + private final ClassroomUserService classroomUserService; + + ClassroomStudentController(ClassroomService classroomService, AssignmentService assignmentService, ClassroomUserService classroomUserService) { + this.classroomService = classroomService; + this.assignmentService = assignmentService; + this.classroomUserService = classroomUserService; + } + + @GetMapping("/classrooms/{classroomId}/students/{studentName}") + ModelAndView showClassroomStudent(@PathVariable UUID classroomId, @PathVariable String studentName) { + var classroom = this.classroomService.getClassroom(classroomId).orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND, "Classroom with id %s does not exists".formatted(classroomId))); + + var student = this.classroomUserService.getClassroomUser(studentName); + + var studentAssignments = this.assignmentService.getAllStudentAssignmentsForAClassroom(classroom, student); + + var model = new ModelAndView("classrooms/student"); + + model.addObject("classroom", classroom); + model.addObject("student", student); + model.addObject("assignments", studentAssignments); + + return model; + } +} diff --git a/src/main/resources/templates/classrooms/student.html b/src/main/resources/templates/classrooms/student.html new file mode 100644 index 0000000..7e6ac33 --- /dev/null +++ b/src/main/resources/templates/classrooms/student.html @@ -0,0 +1,106 @@ + + + + + +
+
+
+

Classroom + Name

+

Accepted assignments of the classroom Classroom Name.

+
+
+ + +
+ + diff --git a/src/main/resources/templates/classrooms/view.html b/src/main/resources/templates/classrooms/view.html index 11c19ab..0b951f5 100644 --- a/src/main/resources/templates/classrooms/view.html +++ b/src/main/resources/templates/classrooms/view.html @@ -81,10 +81,10 @@
- +