diff --git a/src/main/kotlin/com/swm_standard/phote/controller/ExamController.kt b/src/main/kotlin/com/swm_standard/phote/controller/ExamController.kt index 54ec8d5..af45288 100644 --- a/src/main/kotlin/com/swm_standard/phote/controller/ExamController.kt +++ b/src/main/kotlin/com/swm_standard/phote/controller/ExamController.kt @@ -10,6 +10,7 @@ import com.swm_standard.phote.dto.RegradeExamRequest import com.swm_standard.phote.dto.RegradeExamResponse import com.swm_standard.phote.dto.ReadExamHistoryDetailResponse import com.swm_standard.phote.dto.ReadExamHistoryListResponse +import com.swm_standard.phote.dto.ReadExamResultsResponse import com.swm_standard.phote.service.ExamService import io.swagger.v3.oas.annotations.Operation import io.swagger.v3.oas.annotations.Parameter @@ -50,6 +51,16 @@ class ExamController( ): BaseResponse> = BaseResponse(msg = "문제풀이 기록 리스트 조회 성공", data = examService.readExamHistoryList(workbookId)) + @Operation(summary = "readExamResults", description = "(강사가) 학생들의 시험 결과 목록을 조회") + @SecurityRequirement(name = "bearer Auth") + @GetMapping("/exams/result/{examId}") + fun readExamResults( + @PathVariable( + required = true, + ) examId: UUID, + ): BaseResponse = + BaseResponse(msg = "학생 시험 결과 조회 성공", data = examService.readExamResults(examId)) + @Operation(summary = "gradeExam", description = "문제풀이 제출 및 채점") @SecurityRequirement(name = "bearer Auth") @PostMapping("/exam/{workbookId}") diff --git a/src/main/kotlin/com/swm_standard/phote/dto/ExamDtos.kt b/src/main/kotlin/com/swm_standard/phote/dto/ExamDtos.kt index 958d003..52ce78d 100644 --- a/src/main/kotlin/com/swm_standard/phote/dto/ExamDtos.kt +++ b/src/main/kotlin/com/swm_standard/phote/dto/ExamDtos.kt @@ -34,6 +34,19 @@ data class ReadExamHistoryListResponse( val sequence: Int, ) +data class ReadExamStudentResult( + val userId: UUID, + val name: String, + val score: Int, + val time: Int, +) + +data class ReadExamResultsResponse( + val examId: UUID, + val totalQuestionCount: Int, + val students: List, +) + data class GradeExamRequest( val time: Int, val answers: List, diff --git a/src/main/kotlin/com/swm_standard/phote/repository/ExamResultRepository.kt b/src/main/kotlin/com/swm_standard/phote/repository/ExamResultRepository.kt index b48754b..2101698 100644 --- a/src/main/kotlin/com/swm_standard/phote/repository/ExamResultRepository.kt +++ b/src/main/kotlin/com/swm_standard/phote/repository/ExamResultRepository.kt @@ -7,4 +7,5 @@ import java.util.UUID interface ExamResultRepository : JpaRepository { fun findByExamId(examId: UUID): ExamResult? fun findByExamIdAndMemberId(examId: UUID, memberId: UUID): ExamResult + fun findAllByExamId(examId: UUID): List } diff --git a/src/main/kotlin/com/swm_standard/phote/service/ExamService.kt b/src/main/kotlin/com/swm_standard/phote/service/ExamService.kt index 2edddcb..718b8a7 100644 --- a/src/main/kotlin/com/swm_standard/phote/service/ExamService.kt +++ b/src/main/kotlin/com/swm_standard/phote/service/ExamService.kt @@ -12,6 +12,8 @@ import com.swm_standard.phote.dto.RegradeExamResponse import com.swm_standard.phote.dto.ReadExamHistoryDetail import com.swm_standard.phote.dto.ReadExamHistoryDetailResponse import com.swm_standard.phote.dto.ReadExamHistoryListResponse +import com.swm_standard.phote.dto.ReadExamStudentResult +import com.swm_standard.phote.dto.ReadExamResultsResponse import com.swm_standard.phote.dto.SubmittedAnswerRequest import com.swm_standard.phote.entity.Answer import com.swm_standard.phote.entity.Category @@ -106,6 +108,22 @@ class ExamService( } } + fun readExamResults(examId: UUID): ReadExamResultsResponse { + val exam = examRepository.findById(examId).orElseThrow { NotFoundException(fieldName = "examId") } + val examResults = examResultRepository.findAllByExamId(examId) + + val responses = examResults.map { examResult -> + ReadExamStudentResult( + examResult.member.id, + examResult.member.name, + examResult.totalCorrect, + examResult.time, + ) + } + + return ReadExamResultsResponse(examId, exam.workbook.quantity, responses) + } + @Transactional fun gradeExam( workbookId: UUID,