Skip to content

Commit

Permalink
시험 문제에 지문을 넣을 수 있다. (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
alstn113 committed Jan 8, 2025
1 parent 2e497c0 commit 40cfa71
Show file tree
Hide file tree
Showing 48 changed files with 1,095 additions and 2,741 deletions.
8 changes: 4 additions & 4 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ body:
- type: markdown
attributes:
value: |
버그 신고를 작성해주셔서 감사합니다! 🙏
버그 신고를 작성해주셔서 감사합니다!
- type: textarea
id: what-happened
attributes:
label: 어떤 일이 발생했나요? 🤔
label: 어떤 일이 발생했나요?
description: 또한, 어떤 결과를 기대했었는지 알려주세요.
placeholder: 예상치 못한 버그가 발생했습니다...
validations:
Expand All @@ -31,8 +31,8 @@ body:
- type: checkboxes
id: terms
attributes:
label: 동의 👍
label: 동의
description: 아래 항목을 모두 확인하고 체크해주세요.
options:
- label: 다른 이슈가 있는지 확인했습니다.
- label: 다른 이슈가 있는지 확인했습니다.
required: true
14 changes: 7 additions & 7 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@ body:
- type: markdown
attributes:
value: |
새로운 기능을 제안해주셔서 감사합니다! 🙏
새로운 기능을 제안해주셔서 감사합니다!
- type: textarea
id: new-feature
attributes:
label: 어떤 기능을 제안하시나요? 🤔
description: 이 새로운 기능으로 어떤 효과를 기대하시나요? 🚀
label: 어떤 기능을 제안하시나요?
description: 이 새로운 기능으로 어떤 효과를 기대하시나요?
placeholder: 이 기능이 있으면 좋겠다면, 이유를 적어주세요...
validations:
required: true
- type: textarea
id: how
attributes:
label: 이 기능은 어떻게 구현할 수 있을까요? 🛠️
description: 필요한 기술 스택이나 구현 방법 등을 알려주세요. 💻
label: 이 기능은 어떻게 구현할 수 있을까요?
description: 필요한 기술 스택이나 구현 방법 등을 알려주세요.
placeholder: 이러한 방법으로 구현할 수 있습니다...
- type: checkboxes
id: terms
attributes:
label: 동의 👍
label: 동의
description: 아래 항목을 모두 확인하고 체크해주세요.
options:
- label: 다른 이슈가 있는지 확인했습니다.
- label: 다른 이슈가 있는지 확인했습니다.
required: true
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# 플러피, 온라인 시험 문제 제작 및 관리 서비스
# 플러피(Fluffy), 온라인 시험 문제 제작 및 관리 서비스

**▷ 개발 기간 : 2024.11 ~ 현재</br>**
**▷ 개발 인원 : 1명**

서버 주소: https://api.fluppy.run
API 명세서: https://api.fluffy.run/docs/index.html
웹 프론트엔드 주소: https://fluppy.run

## Server

### 기술 스택
Expand Down
135 changes: 68 additions & 67 deletions server/src/main/java/com/fluffy/DataInitializer.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -47,28 +47,29 @@ public Question toQuestion(QuestionAppRequest request) {
private Question toQuestion(ShortAnswerQuestionAppRequest request) {
return Question.shortAnswer(
request.text(),
request.passage(),
request.correctAnswer()
);
}

private Question toQuestion(LongAnswerQuestionAppRequest request) {
return Question.longAnswer(request.text());
return Question.longAnswer(request.text(), request.passage());
}

private Question toQuestion(SingleChoiceQuestionAppRequest request) {
List<QuestionOption> questionOptions = toQuestionOptions(request.options());

return Question.singleChoice(request.text(), questionOptions);
return Question.singleChoice(request.text(), request.passage(), questionOptions);
}

private Question toQuestion(MultipleChoiceAppRequest request) {
List<QuestionOption> questionOptions = toQuestionOptions(request.options());

return Question.multipleChoice(request.text(), questionOptions);
return Question.multipleChoice(request.text(), request.passage(), questionOptions);
}

private Question toQuestion(TrueOrFalseQuestionAppRequest request) {
return Question.trueOrFalse(request.text(), request.trueOrFalse());
return Question.trueOrFalse(request.text(), request.passage(), request.trueOrFalse());
}

private List<QuestionOption> toQuestionOptions(List<QuestionOptionRequest> requests) {
Expand Down Expand Up @@ -99,6 +100,7 @@ private QuestionResponse toAnswerResponse(Question question) {
return new AnswerQuestionResponse(
question.getId(),
question.getText(),
question.getPassage(),
question.getType().name()
);
}
Expand All @@ -107,6 +109,7 @@ private QuestionResponse toChoiceResponse(Question question) {
return new ChoiceQuestionResponse(
question.getId(),
question.getText(),
question.getPassage(),
question.getType().name(),
questionOptionMapper.toResponses(question.getOptionGroup().toList())
);
Expand All @@ -130,6 +133,7 @@ private QuestionWithAnswersResponse toAnswerWithAnswersResponse(Question questio
return new AnswerQuestionWithAnswersResponse(
question.getId(),
question.getText(),
question.getPassage(),
question.getType().name(),
question.getCorrectAnswer()
);
Expand All @@ -139,6 +143,7 @@ private QuestionWithAnswersResponse toChoiceWithAnswersResponse(Question questio
return new ChoiceQuestionWithAnswersResponse(
question.getId(),
question.getText(),
question.getPassage(),
question.getType().name(),
questionOptionMapper.toWithAnswersResponses(question.getOptionGroup().toList())
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

public record LongAnswerQuestionAppRequest(
String text,
String passage,
String type
) implements QuestionAppRequest {
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

public record MultipleChoiceAppRequest(
String text,
String passage,
String type,
List<QuestionOptionRequest> options
) implements QuestionAppRequest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ public interface QuestionAppRequest {
String text();

String type();

String passage();
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

public record ShortAnswerQuestionAppRequest(
String text,
String passage,
String type,
String correctAnswer
) implements QuestionAppRequest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

public record SingleChoiceQuestionAppRequest(
String text,
String passage,
String type,
List<QuestionOptionRequest> options
) implements QuestionAppRequest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

public record TrueOrFalseQuestionAppRequest(
String text,
String passage,
String type,
boolean trueOrFalse
) implements QuestionAppRequest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,23 @@ public interface QuestionResponse {

String text();

String passage();

String type();
}

public record AnswerQuestionResponse(
Long id,
String text,
String passage,
String type
) implements QuestionResponse {
}

public record ChoiceQuestionResponse(
Long id,
String text,
String passage,
String type,
List<QuestionOptionResponse> options
) implements QuestionResponse {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@ public interface QuestionWithAnswersResponse {

String text();

String passage();

String type();
}

public record AnswerQuestionWithAnswersResponse(
Long id,
String text,
String passage,
String type,
String correctAnswer
) implements QuestionWithAnswersResponse {
Expand All @@ -32,6 +35,7 @@ public record AnswerQuestionWithAnswersResponse(
public record ChoiceQuestionWithAnswersResponse(
Long id,
String text,
String passage,
String type,
List<QuestionOptionWithAnswersResponse> options
) implements QuestionWithAnswersResponse {
Expand Down
38 changes: 22 additions & 16 deletions server/src/main/java/com/fluffy/exam/domain/Question.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@ public class Question {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(nullable = false)
@Column(nullable = false, columnDefinition = "VARCHAR(2000)")
private String text;

@Column(nullable = false, columnDefinition = "TEXT")
private String passage;

@Column(nullable = false, columnDefinition = "VARCHAR(50)")
@Enumerated(EnumType.STRING)
private QuestionType type;
Expand All @@ -46,57 +49,59 @@ public class Question {
@Embedded
private final QuestionOptionGroup optionGroup = new QuestionOptionGroup();

public static Question shortAnswer(String text, String correctAnswer) {
public static Question shortAnswer(String text, String passage, String correctAnswer) {
if (correctAnswer == null || correctAnswer.isBlank() || correctAnswer.length() > MAX_TEXT_LENGTH) {
throw new BadRequestException("정답의 길이는 1자 이상 %d자 이하여야 합니다.".formatted(MAX_TEXT_LENGTH));
}

return answer(text, QuestionType.SHORT_ANSWER, correctAnswer);
return answer(text, passage, QuestionType.SHORT_ANSWER, correctAnswer);
}

public static Question longAnswer(String text) {
return answer(text, QuestionType.LONG_ANSWER, null);
public static Question longAnswer(String text, String passage) {
return answer(text, passage, QuestionType.LONG_ANSWER, null);
}

public static Question singleChoice(String text, List<QuestionOption> options) {
public static Question singleChoice(String text, String passage, List<QuestionOption> options) {
if (options.stream().filter(QuestionOption::isCorrect).count() != 1) {
throw new BadRequestException("객관식 단일 선택은 정답이 1개여야 합니다.");
}

return choice(text, QuestionType.SINGLE_CHOICE, options);
return choice(text, passage, QuestionType.SINGLE_CHOICE, options);
}

public static Question multipleChoice(String text, List<QuestionOption> options) {
return choice(text, QuestionType.MULTIPLE_CHOICE, options);
public static Question multipleChoice(String text, String passage, List<QuestionOption> options) {
return choice(text, passage, QuestionType.MULTIPLE_CHOICE, options);
}

public static Question trueOrFalse(String text, boolean trueOrFalse) {
return choice(text, QuestionType.TRUE_OR_FALSE, List.of(
public static Question trueOrFalse(String text, String passage, boolean trueOrFalse) {
return choice(text, passage, QuestionType.TRUE_OR_FALSE, List.of(
new QuestionOption("TRUE", trueOrFalse),
new QuestionOption("FALSE", !trueOrFalse)
));
}

private static Question answer(String text, QuestionType type, String correctAnswer) {
return new Question(text, type, correctAnswer, new ArrayList<>());
private static Question answer(String text, String passage, QuestionType type, String correctAnswer) {
return new Question(text, passage, type, correctAnswer, new ArrayList<>());
}

private static Question choice(String text, QuestionType type, List<QuestionOption> options) {
return new Question(text, type, null, options);
private static Question choice(String text, String passage, QuestionType type, List<QuestionOption> options) {
return new Question(text, passage, type, null, options);
}

private Question(
String text,
String passage,
QuestionType type,
String correctAnswer,
List<QuestionOption> options
) {
this(null, text, type, correctAnswer, options);
this(null, text, passage, type, correctAnswer, options);
}

private Question(
Long id,
String text,
String passage,
QuestionType type,
String correctAnswer,
List<QuestionOption> options
Expand All @@ -105,6 +110,7 @@ private Question(

this.id = id;
this.text = text;
this.passage = passage;
this.type = type;
this.correctAnswer = correctAnswer;
addOptions(options);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE question
ADD COLUMN passage TEXT NOT NULL DEFAULT '';
Loading

0 comments on commit 40cfa71

Please sign in to comment.