Merge branch 'BE/userinfo' into 'backend'

feat: report 제출 및 채점 기능

See merge request s11-webmobile1-sub2/S11P12A701!71
This commit is contained in:
박정민 2024-08-06 17:08:25 +09:00
commit 9c673ade17
3 changed files with 10 additions and 9 deletions

View File

@ -10,7 +10,7 @@ import java.util.List;
public class ReportRequset {
List<AnswerInput> answerInputList;
List<String> answer;
// [1,2,,3]
// List<answerDto> a

View File

@ -23,13 +23,13 @@ public class Report {
private int allCount;
private int correctCount;
private Date testAt;
private Long lectureId;
@ManyToOne
@JoinColumn(name= "user_id")
@JoinColumn(name = "user_id")
private User user;
@ManyToOne
@JoinColumn(name= "quizset_id")
@JoinColumn(name = "quizset_id")
private QuizSet quizSet;
}

View File

@ -45,7 +45,7 @@ public class ReportServiceImpl implements ReportService {
QuizSet quizSet = quizSetService.findQuizSet(quizsetId);
List<Quiz> quizList = quizSet.getQuizzes();
List<AnswerInput> answerInputList = reportRequset.getAnswerInputList();
List<String> answerInputList = reportRequset.getAnswer();
List<Answer> answerList = new ArrayList<>();
@ -56,19 +56,20 @@ public class ReportServiceImpl implements ReportService {
for (int idx = 0; idx < answerInputList.size(); idx++) {
Quiz quiz = quizList.get(idx);
AnswerInput inputAnswer = answerInputList.get(idx);
String inputAnswer = answerInputList.get(idx);
Answer answer;
if (quiz.getAnswer().equals(inputAnswer.getAnswer())) {
//
if (quiz.getAnswer().equals(inputAnswer)) {
correctCount++;
answer = Answer.builder()
.userAnswer(inputAnswer.getAnswer())
.userAnswer(inputAnswer)
.isCorrect(true)
.report(null)
.quiz(quiz)
.build();
} else {
answer = Answer.builder()
.userAnswer(inputAnswer.getAnswer())
.userAnswer(inputAnswer)
.isCorrect(false)
.report(null)
.quiz(quiz)