Skip to content

Commit

Permalink
시험의 시작, 종료 시간을 지정한 출제 방식을 제거한다. (#20)
Browse files Browse the repository at this point in the history
* refactor: 사용하지 않는 vercel analytics, speed-insights 제거

* docs: 프로젝트 개요 주소 링크로 변경

* refactor: 시험 제출 시startAt, endAt 필드 제거

* refactor: 제출된 시험 문제 중 지문이 있는 경우에만 보여준다.

* refactor: 시험 제출 요청 시 startAt, endAt 필드를 지운다.

* refactor: exam 테이블에 startAt, endAt 컬럼을 지운다.

* refactor: startAt, endAt 필드를 지운 후 테스트를 성공시킨다.
  • Loading branch information
alstn113 authored Jan 10, 2025
1 parent 07f6af1 commit 014bf9e
Show file tree
Hide file tree
Showing 23 changed files with 72 additions and 362 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

## 프로젝트 개요

- 서버 주소: https://api.fluppy.run
- API 명세서: https://api.fluffy.run/docs/index.html
- 웹 프론트엔드 주소: https://fluppy.run
- 서비스 개발 블로그: https://alstn113.tistory.com/tag/플러피
- [서버 주소](https://api.fluffy.run)
- [API 명세서](https://api.fluffy.run/docs/index.html)
- [웹 프론트엔드 주소](https://fluffy.run)
- [서비스 개발 블로그](https://alstn113.tistory.com/tag/플러피)

## 서버

Expand Down
13 changes: 6 additions & 7 deletions server/src/main/java/com/fluffy/DataInitializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import com.fluffy.exam.domain.ExamRepository;
import com.fluffy.exam.domain.Question;
import com.fluffy.exam.domain.QuestionOption;
import java.time.LocalDateTime;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.boot.ApplicationArguments;
Expand Down Expand Up @@ -89,7 +88,7 @@ private void init() {
)),
Question.trueOrFalse("펭귄은 날 수 있는 새이다.", "", false)
));
exam1.publish(null, null);
exam1.publish();
examRepository.save(exam1);

Exam exam2 = Exam.create("역사 시험", member1.getId());
Expand Down Expand Up @@ -128,7 +127,7 @@ private void init() {
Question.shortAnswer("로제타 스톤의 중요성은 무엇인가요?", "", "고대 이집트 문자의 해독"),
Question.longAnswer("콜럼버스의 발견과 그 영향에 대해 설명하세요.", "")
));
exam2.publish(null, LocalDateTime.now().plusDays(3));
exam2.publish();
examRepository.save(exam2);

Exam exam3 = Exam.create("영어 시험", member2.getId());
Expand Down Expand Up @@ -172,7 +171,7 @@ private void init() {
Question.shortAnswer("‘beneficial’의 의미는 무엇인가요?", "", "유익한"),
Question.longAnswer("‘I wish I had studied harder’ 문장의 의미를 설명하세요.", "")
));
exam3.publish(LocalDateTime.now().plusDays(1), LocalDateTime.now().plusDays(2));
exam3.publish();
examRepository.save(exam3);

Exam exam4 = Exam.create("과학 시험", member2.getId());
Expand Down Expand Up @@ -209,7 +208,7 @@ private void init() {
Question.trueOrFalse("빛은 물질을 통과할 수 없다.", "", false),
Question.longAnswer("지구의 내부 구조에 대해 설명하세요.", "")
));
exam4.publish(LocalDateTime.now().plusDays(2), LocalDateTime.now().plusDays(4));
exam4.publish();
examRepository.save(exam4);

Exam exam5 = Exam.create("문화 시험", member2.getId());
Expand Down Expand Up @@ -248,7 +247,7 @@ private void init() {
Question.shortAnswer("‘매트릭스’ 영화의 주제는 무엇인가요?", "", "가상 현실과 인간의 자유 의지"),
Question.longAnswer("세계 각국의 전통 축제에 대해 설명하세요.", "")
));
exam5.publish(LocalDateTime.now().plusDays(1), LocalDateTime.now().plusDays(3));
exam5.publish();
examRepository.save(exam5);

Exam exam6 = Exam.create("컴퓨터 시험", member3.getId());
Expand Down Expand Up @@ -287,7 +286,7 @@ private void init() {
Question.shortAnswer("오픈 소스 소프트웨어의 장점은 무엇인가요?", "", "자유로운 사용, 수정 가능"),
Question.longAnswer("기술 발전이 사회에 미친 영향에 대해 설명하세요.", "")
));
exam6.publish(LocalDateTime.now().plusDays(2), LocalDateTime.now().plusDays(4));
exam6.publish();
examRepository.save(exam6);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,10 @@
import com.fluffy.exam.application.request.PublishExamAppRequest;
import com.fluffy.exam.application.request.question.QuestionAppRequest;
import com.fluffy.global.web.Accessor;
import java.time.LocalDateTime;
import java.util.List;

public record PublishExamWebRequest(
List<QuestionAppRequest> questions,
LocalDateTime startAt,
LocalDateTime endAt
) {
public record PublishExamWebRequest(List<QuestionAppRequest> questions) {
public PublishExamAppRequest toAppRequest(Long examId, Accessor accessor) {
return new PublishExamAppRequest(examId, questions, startAt, endAt, accessor);
return new PublishExamAppRequest(examId, questions, accessor);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void publish(PublishExamAppRequest request) {
List<Question> questions = questionMapper.toQuestions(request.questions());
exam.updateQuestions(questions);

exam.publish(request.startAt(), request.endAt());
exam.publish();
}

private Exam validateExamAuthor(Long examId, Accessor accessor) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@

import com.fluffy.exam.application.request.question.QuestionAppRequest;
import com.fluffy.global.web.Accessor;
import java.time.LocalDateTime;
import java.util.List;

public record PublishExamAppRequest(
Long examId,
List<QuestionAppRequest> questions,
LocalDateTime startAt,
LocalDateTime endAt,
Accessor accessor
) {
}
7 changes: 1 addition & 6 deletions server/src/main/java/com/fluffy/exam/domain/Exam.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import java.time.LocalDateTime;
import java.util.List;
import lombok.AccessLevel;
import lombok.Getter;
Expand Down Expand Up @@ -41,9 +40,6 @@ public class Exam extends AuditableEntity {
@Embedded
private final QuestionGroup questionGroup = new QuestionGroup();

@Embedded
private ExamPeriod examPeriod;

@Column(nullable = false, columnDefinition = "BOOLEAN DEFAULT FALSE")
private boolean isSingleAttempt = false;

Expand All @@ -57,7 +53,7 @@ public static Exam create(String title, Long memberId) {
return exam;
}

public void publish(LocalDateTime startAt, LocalDateTime endAt) {
public void publish() {
if (status.isPublished()) {
throw new BadRequestException("시험은 이미 출시되었습니다.");
}
Expand All @@ -66,7 +62,6 @@ public void publish(LocalDateTime startAt, LocalDateTime endAt) {
throw new BadRequestException("시험을 출시하기 위해서는 최소 1개 이상의 문제를 추가해야 합니다.");
}

this.examPeriod = ExamPeriod.create(startAt, endAt);
this.status = ExamStatus.PUBLISHED;
}

Expand Down
64 changes: 0 additions & 64 deletions server/src/main/java/com/fluffy/exam/domain/ExamPeriod.java

This file was deleted.

20 changes: 10 additions & 10 deletions server/src/main/resources/db/migration/V1__init.sql
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
CREATE TABLE IF NOT EXISTS member
(
id BIGINT GENERATED BY DEFAULT AS IDENTITY,
name VARCHAR(255) NOT NULL,
email VARCHAR(255),
avatar_url VARCHAR(255) NOT NULL,
social_id VARCHAR(255) NOT NULL,
provider VARCHAR(20) NOT NULL,
created_at TIMESTAMP(6) NOT NULL,
updated_at TIMESTAMP(6) NOT NULL,
id BIGINT GENERATED BY DEFAULT AS IDENTITY,
name VARCHAR(255) NOT NULL,
email VARCHAR(255),
avatar_url VARCHAR(255) NOT NULL,
social_id VARCHAR(255) NOT NULL,
provider VARCHAR(20) NOT NULL,
created_at TIMESTAMP(6) NOT NULL,
updated_at TIMESTAMP(6) NOT NULL,
PRIMARY KEY (id)
);

Expand All @@ -16,7 +16,7 @@ CREATE TABLE IF NOT EXISTS exam
id BIGINT GENERATED BY DEFAULT AS IDENTITY,
member_id BIGINT NOT NULL,
title VARCHAR(255) NOT NULL,
description TEXT NOT NULL,
description TEXT NOT NULL,
status VARCHAR(20) NOT NULL,
created_at TIMESTAMP(6) NOT NULL,
start_at TIMESTAMP(6),
Expand Down Expand Up @@ -45,7 +45,7 @@ CREATE TABLE IF NOT EXISTS question
id BIGINT GENERATED BY DEFAULT AS IDENTITY,
exam_id BIGINT,
text VARCHAR(255) NOT NULL,
correct_answer VARCHAR(255),
correct_answer VARCHAR(255),
type VARCHAR(50) NOT NULL,
PRIMARY KEY (id)
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ALTER TABLE exam
DROP COLUMN start_at,
DROP COLUMN end_at;
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,7 @@ void publish() throws Exception {
List.of(new QuestionOptionRequest("선택1", true),
new QuestionOptionRequest("선택2", true))),
new TrueOrFalseQuestionAppRequest("질문5", "지문", "TRUE_OR_FALSE", true)
),
LocalDateTime.now(),
LocalDateTime.now().plusDays(1)
)
);

doNothing().when(examService).publish(any());
Expand Down Expand Up @@ -381,9 +379,7 @@ void publish() throws Exception {
fieldWithPath("questions[].trueOrFalse").description("true or false 정답").optional(),
fieldWithPath("questions[].options").description("선택지 목록").optional(),
fieldWithPath("questions[].options[].text").description("선택지 내용").optional(),
fieldWithPath("questions[].options[].isCorrect").description("정답 여부").optional(),
fieldWithPath("startAt").description("시작 시간").optional(),
fieldWithPath("endAt").description("종료 시간").optional()
fieldWithPath("questions[].options[].isCorrect").description("정답 여부").optional()
)
));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,17 @@ void getPublishedExamSummaries() {

Exam exam1 = Exam.create("시험 제목1", author.getId());
exam1.updateQuestions(List.of(Question.shortAnswer("질문1", "지문", "답1")));
exam1.publish(null, null);
exam1.publish();
examRepository.save(exam1);

Exam exam2 = Exam.create("시험 제목2", author.getId());
exam2.updateQuestions(List.of(Question.shortAnswer("질문2", "지문", "답2")));
exam2.publish(null, null);
exam2.publish();
examRepository.save(exam2);

Exam exam3 = Exam.create("시험 제목3", author.getId());
exam3.updateQuestions(List.of(Question.shortAnswer("질문3", "지문", "답3")));
exam3.publish(null, null);
exam3.publish();
examRepository.save(exam3);

// when
Expand Down Expand Up @@ -86,12 +86,12 @@ void getMyExamSummaries() {

Exam exam1 = Exam.create("시험 제목1", author.getId());
exam1.updateQuestions(List.of(Question.shortAnswer("질문1", "지문", "답1")));
exam1.publish(null, null);
exam1.publish();
examRepository.save(exam1);

Exam exam2 = Exam.create("시험 제목2", author.getId());
exam2.updateQuestions(List.of(Question.shortAnswer("질문2", "지문", "답2")));
exam2.publish(null, null);
exam2.publish();
examRepository.save(exam2);

Exam otherExam1 = Exam.create("시험 제목3", author.getId());
Expand All @@ -100,12 +100,12 @@ void getMyExamSummaries() {

Exam exam4 = Exam.create("시험 제목4", another.getId());
exam4.updateQuestions(List.of(Question.shortAnswer("질문4", "지문", "답4")));
exam4.publish(null, null);
exam4.publish();
examRepository.save(exam4);

Exam exam5 = Exam.create("시험 제목5", author.getId());
exam5.updateQuestions(List.of(Question.shortAnswer("질문5", "지문", "답5")));
exam5.publish(null, null);
exam5.publish();
examRepository.save(exam5);

// when
Expand All @@ -131,7 +131,7 @@ void getExamDetail() {

Exam exam = Exam.create("시험 제목", member.getId());
exam.updateQuestions(List.of(Question.shortAnswer("질문", "지문", "답")));
exam.publish(null, null);
exam.publish();
examRepository.save(exam);

// when
Expand All @@ -157,7 +157,7 @@ void getExamWithAnswers() {

Exam exam = Exam.create("시험 제목", member.getId());
exam.updateQuestions(List.of(Question.shortAnswer("질문", "지문", "답")));
exam.publish(null, null);
exam.publish();
examRepository.save(exam);

// when
Expand Down Expand Up @@ -187,7 +187,7 @@ void getExamWithAnswersFailWhenNotWrittenBy() {

Exam exam = Exam.create("시험 제목", member.getId());
exam.updateQuestions(List.of(Question.shortAnswer("질문", "지문", "답")));
exam.publish(null, null);
exam.publish();
examRepository.save(exam);

// when
Expand Down
Loading

0 comments on commit 014bf9e

Please sign in to comment.