Skip to content

Commit

Permalink
feat: 학생의 모든 워크북과 답안 기록 출력
Browse files Browse the repository at this point in the history
  • Loading branch information
yoursin0330 committed Nov 27, 2024
1 parent bf4b866 commit bafda25
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.hangeulbada.domain.assignment.dto.ScoreDTO;
import com.hangeulbada.domain.assignment.dto.SpecificAssignmentDTO;
import com.hangeulbada.domain.assignment.service.AssignmentService;
import com.hangeulbada.domain.group.dto.GroupAssignmentDTO;
import com.hangeulbada.domain.ocr.dto.OCRRequest;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
Expand Down Expand Up @@ -46,4 +47,13 @@ public ResponseEntity<SpecificAssignmentDTO> getAssignment(
SpecificAssignmentDTO assignmentDTO = assignmentService.getAssignment(studentId, workbookId);
return ResponseEntity.ok(assignmentDTO);
}

@StudentTag
@GetMapping("/student/all")
@Operation(summary = "학생이 푼 문제집", description = "학생이 푼 모든 문제집을 조회합니다.")
@ApiResponse(responseCode = "200", description = "클래스 문제집 조회 성공", content = @io.swagger.v3.oas.annotations.media.Content(schema = @io.swagger.v3.oas.annotations.media.Schema(implementation = GroupAssignmentDTO.class)))
public ResponseEntity<List<GroupAssignmentDTO>> getAssignment(Principal principal){
List<GroupAssignmentDTO> assignment = assignmentService.getUserAssignments(principal.getName());
return ResponseEntity.ok(assignment);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.hangeulbada.domain.assignment.entity.Assignment;
import com.hangeulbada.domain.assignment.repository.AssignmentRepository;
import com.hangeulbada.domain.externalapi.service.ApiService;
import com.hangeulbada.domain.group.dto.GroupAssignmentDTO;
import com.hangeulbada.domain.ocr.dto.OCRRequest;
import com.hangeulbada.domain.user.service.UserService;
import com.hangeulbada.domain.workbookset.dto.QuestionResponseDto;
Expand Down Expand Up @@ -117,4 +118,8 @@ public void saveIncorrectTag(AssignmentScoreResponseDTO assignmentDto, Map<Integ
}
}
}

public List<GroupAssignmentDTO> getUserAssignments(String studentId){
return assignmentRepository.findGroupAssignmentsByStudentId(studentId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,4 @@ public ResponseEntity<List<GroupAttendResponse>> getAttendGroup(Principal princi
return ResponseEntity.ok(group);
}

@StudentTag
@GetMapping("/student/group/{groupId}/assignment")
@Operation(summary = "학생이 클래스에서 푼 문제집", description = "학생이 클래스에서 푼 문제집을 조회합니다.")
@ApiResponse(responseCode = "200", description = "클래스 문제집 조회 성공", content = @io.swagger.v3.oas.annotations.media.Content(schema = @io.swagger.v3.oas.annotations.media.Schema(implementation = GroupAssignmentDTO.class)))
public ResponseEntity<List<GroupAssignmentDTO>> getAssignment(@PathVariable(name="groupId") String groupId, Principal principal){
List<GroupAssignmentDTO> assignment = userService.getGroupAssignment(groupId, principal.getName());
return ResponseEntity.ok(assignment);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@
import com.hangeulbada.domain.assignment.repository.AssignmentRepository;
import com.hangeulbada.domain.auth.dto.UserDTO;
import com.hangeulbada.domain.auth.repository.UserRepository;
import com.hangeulbada.domain.group.dto.GroupAssignmentDTO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.modelmapper.ModelMapper;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
@RequiredArgsConstructor
Expand All @@ -21,9 +18,6 @@ public class UserService {
public void deleteUser(String id){
UserRepository.deleteById(id);
}
public List<GroupAssignmentDTO> getGroupAssignment(String groupId, String studentId){
return assignmentRepository.findGroupAssignmentsByStudentId(studentId);
}
public UserDTO getUserById(String id){
return mapper.map(UserRepository.findById(id).orElse(null), UserDTO.class);
}
Expand Down

0 comments on commit bafda25

Please sign in to comment.