Skip to content

Commit

Permalink
Merge pull request #25 from DigiLabChallengeHackathon/fix/quizzes
Browse files Browse the repository at this point in the history
release: fix quiz db
  • Loading branch information
andrewkimswe authored Nov 30, 2024
2 parents 53aa4af + 3db5d4a commit 119508b
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 6 deletions.
43 changes: 43 additions & 0 deletions ChoiceQuiz.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
@Data
@AllArgsConstructor
public static class ChoiceQuiz {

/**
* 4지선다형 퀴즈 고유 ID.
*/
@NotBlank(message = "ChoiceId is required.")
private String choiceId;

/**
* 4지 선다 질문.
* 예: "___는 노란색이고 너무 달콤한 과일이야."
*/
@NotBlank(message = "Question is required.")
private String question;

/**
* 정답 선택지 배열.
* 예: ["바나나", "사과", "키위", "포도"]
*/
@NotNull(message = "Options are required.")
private String[] options;

/**
* 정답 제주어 단어.
* 예: "바나나"
*/
@NotBlank(message = "Correct answer is required.")
private String correctAnswer;

/**
* 정답 설명.
* 예: "바나나는 제주어로 A입니다."
*/
private String explanation;

/**
* 음성 파일 경로.
* 예: "link_to_voice_file"
*/
private String voice;
}
2 changes: 0 additions & 2 deletions src/main/java/com/mosabulgyeo/bewavoca/dto/QuizResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,12 @@ public static class ChoiceQuiz {
* 정답 설명.
* 예: "바나나는 제주어로 A입니다."
*/
@NotBlank(message = "Explanation is required.")
private String explanation;

/**
* 음성 파일 경로.
* 예: "link_to_voice_file"
*/
@NotBlank(message = "Voice file path is required.")
private String voice;
}
}
48 changes: 46 additions & 2 deletions src/main/java/com/mosabulgyeo/bewavoca/entity/Quiz.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,82 @@ public class Quiz {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

/**
* 퀴즈가 속한 지역 (Region)
*/
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "region_id", nullable = false)
private Region region;

/**
* 스테이지 유형 (ox, match, choice)
*/
@Column(nullable = false)
private String stageType;

/**
* 퀴즈 질문
*/
@Column(nullable = true)
private String question;

/**
* 표준어 (match 유형에 사용)
*/
@Column(nullable = true)
private String standard;

/**
* 제주어 (정답 또는 매칭 단어)
*/
@Column(nullable = true)
private String jeju;

/**
* 4지선다 선택지 (쉼표로 구분된 문자열)
* 예: "바나나,사과,키위,포도"
*/
@Column(nullable = true)
private String options;

/**
* 정답 설명
*/
@Column(nullable = true)
private String explanation;

/**
* 음성 파일 경로
*/
@Column(nullable = true)
private String voice;

/**
* OX 유형의 정답 (true: O, false: X)
*/
@Column(nullable = true)
private boolean correctAnswer;
private Boolean correctAnswer;

/**
* Quiz 생성자
* @param region 지역
* @param stageType 스테이지 유형
* @param question 질문
* @param standard 표준어
* @param jeju 제주어 (정답)
* @param options 선택지 (쉼표로 구분된 문자열)
* @param explanation 정답 설명
* @param voice 음성 파일 경로
* @param correctAnswer OX 정답
*/
public Quiz(Region region, String stageType, String question, String standard, String jeju,
String explanation, String voice, boolean correctAnswer) {
String options, String explanation, String voice, Boolean correctAnswer) {
this.region = region;
this.stageType = stageType;
this.question = question;
this.standard = standard;
this.jeju = jeju;
this.options = options;
this.explanation = explanation;
this.voice = voice;
this.correctAnswer = correctAnswer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public Object mapQuizToResponse(String type, Quiz quiz) {
return new QuizResponse.OXQuiz(
quiz.getId(),
quiz.getQuestion(),
quiz.isCorrectAnswer(),
quiz.getCorrectAnswer(),
quiz.getExplanation(),
quiz.getVoice()
);
Expand All @@ -34,7 +34,9 @@ public Object mapQuizToResponse(String type, Quiz quiz) {
);
case "choice":
return new QuizResponse.ChoiceQuiz(
quiz.getStandard(),
quiz.getId().toString(),
quiz.getQuestion(),
quiz.getOptions().split(","),
quiz.getJeju(),
quiz.getExplanation(),
quiz.getVoice()
Expand Down

0 comments on commit 119508b

Please sign in to comment.