Skip to content

Commit

Permalink
style: 코딩 컨벤션 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
starwook committed Jan 13, 2025
1 parent 675cca9 commit 777a6df
Show file tree
Hide file tree
Showing 13 changed files with 151 additions and 148 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@

@Service
public interface QuestionClassifyByCategoryService {
Map<QuestionCategory, List<Question>> classifyQuestionByCategoryOrdered(List<? extends Question> questions);
Map<QuestionCategory, List<Question>> classifyQuestionByCategoryOrdered(List<? extends Question> questions);
}

Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@

@Service
public interface LicenseQuestionGetService {
Map<QuestionCategory, List<Question>> getClassifiedLicenseMultipleChoiceQuestion(
Long sessionId);
Map<QuestionCategory, List<Question>> getClassifiedLicenseMultipleChoiceQuestion(
Long sessionId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@
@RequiredArgsConstructor
public class AdminLicenseQuestionGetService implements LicenseQuestionGetService {

private final LicenseMultipleChoiceQuestionDslRepository licenseMultipleChoiceQuestionDslRepository;
private final QuestionClassifyByCategoryService questionClassifyByCategoryService;
private final LicenseMultipleChoiceQuestionDslRepository licenseMultipleChoiceQuestionDslRepository;
private final QuestionClassifyByCategoryService questionClassifyByCategoryService;

/**
* 관리자 조회시 허용 여부와 관련 없이 모든 문제를 가져온다.
* 문제지도 섞지 않는다.
* 허용 여부 순대로 섞는다
*/
@Override
public Map<QuestionCategory, List<Question>> getClassifiedLicenseMultipleChoiceQuestion(
Long sessionId) {
List<LicenseMultipleChoiceQuestion> licenseMultipleChoiceQuestions = licenseMultipleChoiceQuestionDslRepository
.findAllWhereLicenseSessionId(sessionId);
return questionClassifyByCategoryService.classifyQuestionByCategoryOrdered(licenseMultipleChoiceQuestions);
}
/**
* 관리자 조회시 허용 여부와 관련 없이 모든 문제를 가져온다.
* 문제지도 섞지 않는다.
* 허용 여부 순대로 섞는다
*/
@Override
public Map<QuestionCategory, List<Question>> getClassifiedLicenseMultipleChoiceQuestion(
Long sessionId) {
List<LicenseMultipleChoiceQuestion> licenseMultipleChoiceQuestions = licenseMultipleChoiceQuestionDslRepository
.findAllWhereLicenseSessionId(sessionId);
return questionClassifyByCategoryService.classifyQuestionByCategoryOrdered(licenseMultipleChoiceQuestions);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import java.util.Map;

public interface AdminMajorQuestionClassifiedGetService {
Map<QuestionCategory, List<Question>> getClassifiedAllMajorMultipleChoiceQuestions();
Map<QuestionCategory, List<Question>> getClassifiedAllMajorMultipleChoiceQuestions();

Map<QuestionCategory, List<Question>> getClassifiedAllMajorDescriptiveQuestions();
Map<QuestionCategory, List<Question>> getClassifiedAllMajorDescriptiveQuestions();
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@

@Service
public interface MajorQuestionClassifiedGetService<T extends Question> {
/**
* 분류별로 나누어 문제를 반환
*/
Map<QuestionCategory, List<T>> getApprovedClassifiedMajorMultipleChoiceQuestions(
RequestGetQuestionByCategoryAndLevelDto requestGetQuestionByCategoryAndLevelDto);
/**
* 분류별로 나누어 문제를 반환
*/
Map<QuestionCategory, List<T>> getApprovedClassifiedMajorMultipleChoiceQuestions(
RequestGetQuestionByCategoryAndLevelDto requestGetQuestionByCategoryAndLevelDto);


Map<QuestionCategory, List<T>> getApprovedClassifiedDescriptiveQuestions(
RequestGetQuestionByCategoryAndLevelDto requestGetQuestionByCategoryAndLevelDto
);
Map<QuestionCategory, List<T>> getApprovedClassifiedDescriptiveQuestions(
RequestGetQuestionByCategoryAndLevelDto requestGetQuestionByCategoryAndLevelDto
);

}

Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,27 @@
@RequiredArgsConstructor
@Transactional
public class BasicAdminMajorQuestionClassifiedGetService implements AdminMajorQuestionClassifiedGetService {
private final QuestionClassifyByCategoryService questionClassifyByCategoryService;
private final MajorDescriptiveDslRepository majorDescriptiveQuestionChooseRepository;
private final MajorMultipleChoiceQuestionDslRepository majorMultipleChoiceQuestionDslRepository;
private final QuestionClassifyByCategoryService questionClassifyByCategoryService;
private final MajorDescriptiveDslRepository majorDescriptiveQuestionChooseRepository;
private final MajorMultipleChoiceQuestionDslRepository majorMultipleChoiceQuestionDslRepository;

/**
* 관리자가 조회시 Approve됐는지 기준으로 정렬되며(false인 것부터),
* 이후엔 객관식 -> 주관식으로 정렬된다.
*
* @return
*/
@Override
public Map<QuestionCategory, List<Question>> getClassifiedAllMajorMultipleChoiceQuestions() {
List<MajorMultipleChoiceQuestion> majorMultipleChoiceQuestions = majorMultipleChoiceQuestionDslRepository
.findAllOrderByIfApprovedAsc();
return questionClassifyByCategoryService.classifyQuestionByCategoryOrdered(majorMultipleChoiceQuestions);
}
/**
* 관리자가 조회시 Approve됐는지 기준으로 정렬되며(false인 것부터),
* 이후엔 객관식 -> 주관식으로 정렬된다.
*
* @return
*/
@Override
public Map<QuestionCategory, List<Question>> getClassifiedAllMajorMultipleChoiceQuestions() {
List<MajorMultipleChoiceQuestion> majorMultipleChoiceQuestions = majorMultipleChoiceQuestionDslRepository
.findAllOrderByIfApprovedAsc();
return questionClassifyByCategoryService.classifyQuestionByCategoryOrdered(majorMultipleChoiceQuestions);
}

@Override
public Map<QuestionCategory, List<Question>> getClassifiedAllMajorDescriptiveQuestions() {
List<MajorDescriptiveQuestion> majorDescriptiveQuestions =
majorDescriptiveQuestionChooseRepository.findAllOrderByIfApprovedAsc();
return questionClassifyByCategoryService.classifyQuestionByCategoryOrdered(majorDescriptiveQuestions);
}
@Override
public Map<QuestionCategory, List<Question>> getClassifiedAllMajorDescriptiveQuestions() {
List<MajorDescriptiveQuestion> majorDescriptiveQuestions =
majorDescriptiveQuestionChooseRepository.findAllOrderByIfApprovedAsc();
return questionClassifyByCategoryService.classifyQuestionByCategoryOrdered(majorDescriptiveQuestions);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,74 +22,74 @@
@Transactional
public class BasicAdminMajorQuestionMakeService implements AdminMajorQuestionMakeService {

private final QuestionRepository questionRepository;
private final MajorMultipleChoiceQuestionRepository majorMultipleChoiceQuestionRepository;
private final QuestionChoiceService questionChoiceService;
private final DuplicateQuestionDetector duplicateQuestionDetector;
private final QuestionRepository questionRepository;
private final MajorMultipleChoiceQuestionRepository majorMultipleChoiceQuestionRepository;
private final QuestionChoiceService questionChoiceService;
private final DuplicateQuestionDetector duplicateQuestionDetector;

/**
* 리스트로 생성
*/
@Override
public List<MajorMultipleChoiceQuestion> makeMultipleChoiceQuestions(
List<RequestMakeMultipleChoiceQuestionDto> requestDtos) {
// 중복되지 않은 질문을 필터링하여 저장
return requestDtos.stream()
.filter(this::isNotDuplicateQuestion)
.map(this::saveMajorMultipleChoiceQuestion)
.collect(Collectors.toList());
}
/**
* 리스트로 생성
*/
@Override
public List<MajorMultipleChoiceQuestion> makeMultipleChoiceQuestions(
List<RequestMakeMultipleChoiceQuestionDto> requestDtos) {
// 중복되지 않은 질문을 필터링하여 저장
return requestDtos.stream()
.filter(this::isNotDuplicateQuestion)
.map(this::saveMajorMultipleChoiceQuestion)
.collect(Collectors.toList());
}

/**
* 단일 생성
*/
@Override
public MajorMultipleChoiceQuestion makeMultipleChoiceQuestion(
RequestMakeMultipleChoiceQuestionDto requestDto) throws DuplicateQuestionContentException {
if (!isNotDuplicateQuestion(requestDto)) {
throw new DuplicateQuestionContentException();
}
return saveMajorMultipleChoiceQuestion(requestDto);
}
/**
* 단일 생성
*/
@Override
public MajorMultipleChoiceQuestion makeMultipleChoiceQuestion(
RequestMakeMultipleChoiceQuestionDto requestDto) throws DuplicateQuestionContentException {
if (!isNotDuplicateQuestion(requestDto)) {
throw new DuplicateQuestionContentException();
}
return saveMajorMultipleChoiceQuestion(requestDto);
}

@Override
public List<MajorDescriptiveQuestion> makeDescriptiveQuestions(
List<RequestMakeMajorDescriptiveQuestionDto> requestNormalQuestionDto) {
@Override
public List<MajorDescriptiveQuestion> makeDescriptiveQuestions(
List<RequestMakeMajorDescriptiveQuestionDto> requestNormalQuestionDto) {

return requestNormalQuestionDto.stream()
.map(this::saveMajorDescriptiveQuestion)
.collect(Collectors.toList());
}
return requestNormalQuestionDto.stream()
.map(this::saveMajorDescriptiveQuestion)
.collect(Collectors.toList());
}

/**
* 중복되지 않은 질문인지 확인하는 메서드
* 매번 DB에서 새롭게 조회 후 검증한다.(DTO 자체의 중복된 데이터)
*/
private boolean isNotDuplicateQuestion(RequestMakeMultipleChoiceQuestionDto requestDto) {
return majorMultipleChoiceQuestionRepository.findAll().stream()
.noneMatch(existingQuestion -> duplicateQuestionDetector.isQuestionDuplicate(
existingQuestion.getContent(), requestDto.getContent()));
}
/**
* 중복되지 않은 질문인지 확인하는 메서드
* 매번 DB에서 새롭게 조회 후 검증한다.(DTO 자체의 중복된 데이터)
*/
private boolean isNotDuplicateQuestion(RequestMakeMultipleChoiceQuestionDto requestDto) {
return majorMultipleChoiceQuestionRepository.findAll().stream()
.noneMatch(existingQuestion -> duplicateQuestionDetector.isQuestionDuplicate(
existingQuestion.getContent(), requestDto.getContent()));
}

/**
* 새로운 질문을 저장하고 선택지를 저장하는 메서드
*/
private MajorMultipleChoiceQuestion saveMajorMultipleChoiceQuestion(
RequestMakeMultipleChoiceQuestionDto requestDto) {
MajorMultipleChoiceQuestion question = MajorMultipleChoiceQuestion.makeWithDto(requestDto);
questionRepository.save(question);
questionChoiceService.saveWith(requestDto, question);
return question;
}
/**
* 새로운 질문을 저장하고 선택지를 저장하는 메서드
*/
private MajorMultipleChoiceQuestion saveMajorMultipleChoiceQuestion(
RequestMakeMultipleChoiceQuestionDto requestDto) {
MajorMultipleChoiceQuestion question = MajorMultipleChoiceQuestion.makeWithDto(requestDto);
questionRepository.save(question);
questionChoiceService.saveWith(requestDto, question);
return question;
}

private MajorDescriptiveQuestion saveMajorDescriptiveQuestion(
RequestMakeMajorDescriptiveQuestionDto requestDto
) {
MajorDescriptiveQuestion question = MajorDescriptiveQuestion.makeWithDto(
requestDto
);
questionRepository.save(question);
return question;
}
private MajorDescriptiveQuestion saveMajorDescriptiveQuestion(
RequestMakeMajorDescriptiveQuestionDto requestDto
) {
MajorDescriptiveQuestion question = MajorDescriptiveQuestion.makeWithDto(
requestDto
);
questionRepository.save(question);
return question;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -20,41 +20,41 @@
@Service
@RequiredArgsConstructor
public class UserMajorQuestionClassifiedGetService implements MajorQuestionClassifiedGetService<Question> {
private final MajorMultipleChoiceQuestionDslRepository majorMultipleChoiceQuestionDslRepository;
private final QuestionClassifyByCategoryService questionClassifyByCategoryService;
private final MajorDescriptiveDslRepository majorDescriptiveQuestionDslRepository;
private final MajorMultipleChoiceQuestionDslRepository majorMultipleChoiceQuestionDslRepository;
private final QuestionClassifyByCategoryService questionClassifyByCategoryService;
private final MajorDescriptiveDslRepository majorDescriptiveQuestionDslRepository;

/**
* 분야, 난이도 파라미터로 문제를 조회하는 경우 - 객관식.
* 문제 선택지들을 섞어준다.
*/
@Override
public Map<QuestionCategory, List<Question>> getApprovedClassifiedMajorMultipleChoiceQuestions(
RequestGetQuestionByCategoryAndLevelDto requestGetQuestionByCategoryAndLevelDto) {
List<MajorMultipleChoiceQuestion> majorMultipleChoiceQuestions = majorMultipleChoiceQuestionDslRepository
.findAllCategoriesAndLevelsAndIfApproved(
requestGetQuestionByCategoryAndLevelDto.getQuestionCategories(),
requestGetQuestionByCategoryAndLevelDto.getQuestionLevels(),
true);
for (MajorMultipleChoiceQuestion question : majorMultipleChoiceQuestions) {
Collections.shuffle(question.getQuestionChoices());
}
return questionClassifyByCategoryService.classifyQuestionByCategoryOrdered(majorMultipleChoiceQuestions);
}
/**
* 분야, 난이도 파라미터로 문제를 조회하는 경우 - 객관식.
* 문제 선택지들을 섞어준다.
*/
@Override
public Map<QuestionCategory, List<Question>> getApprovedClassifiedMajorMultipleChoiceQuestions(
RequestGetQuestionByCategoryAndLevelDto requestGetQuestionByCategoryAndLevelDto) {
List<MajorMultipleChoiceQuestion> majorMultipleChoiceQuestions = majorMultipleChoiceQuestionDslRepository
.findAllCategoriesAndLevelsAndIfApproved(
requestGetQuestionByCategoryAndLevelDto.getQuestionCategories(),
requestGetQuestionByCategoryAndLevelDto.getQuestionLevels(),
true);
for (MajorMultipleChoiceQuestion question : majorMultipleChoiceQuestions) {
Collections.shuffle(question.getQuestionChoices());
}
return questionClassifyByCategoryService.classifyQuestionByCategoryOrdered(majorMultipleChoiceQuestions);
}


/**
* 분야, 난이도 파라미터로 문제를 조회하는 경우 - 서술형
*/
@Override
public Map<QuestionCategory, List<Question>> getApprovedClassifiedDescriptiveQuestions(
RequestGetQuestionByCategoryAndLevelDto dto) {
List<MajorDescriptiveQuestion> majorDescriptiveQuestions = majorDescriptiveQuestionDslRepository
.findAllCategoriesAndLevelsAndIfApproved(
dto.getQuestionCategories(),
dto.getQuestionLevels(),
true
);
return questionClassifyByCategoryService.classifyQuestionByCategoryOrdered(majorDescriptiveQuestions);
}
/**
* 분야, 난이도 파라미터로 문제를 조회하는 경우 - 서술형
*/
@Override
public Map<QuestionCategory, List<Question>> getApprovedClassifiedDescriptiveQuestions(
RequestGetQuestionByCategoryAndLevelDto dto) {
List<MajorDescriptiveQuestion> majorDescriptiveQuestions = majorDescriptiveQuestionDslRepository
.findAllCategoriesAndLevelsAndIfApproved(
dto.getQuestionCategories(),
dto.getQuestionLevels(),
true
);
return questionClassifyByCategoryService.classifyQuestionByCategoryOrdered(majorDescriptiveQuestions);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public void forLicenseQuestion(LicenseSession licenseSession, Model model) {
public void forMajor(Set<QuestionCategory> questionCategories, boolean isMultipleChoice, Model model) {
if (isMultipleChoice) {
addTagToModel(forMajorMultiple(questionCategories), model);
return;
}
addTagToModel(forMajorDescriptive(questionCategories), model);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
border-radius: 5px;
font-size: 1rem;
line-height: 1.6;
color: #999;
/*color: #999;*/
}

/* 버튼 그룹 스타일 */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ document.addEventListener('DOMContentLoaded', () => {
eventSource.onmessage = (event) => {
// JSON 문자열을 JavaScript 객체로 파싱
const parsedData = JSON.parse(event.data);

const deltaContent = parsedData.firstChoiceDelta;

// 출력 및 포맷팅
Expand Down
4 changes: 2 additions & 2 deletions application/src/main/resources/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@ <h2 class="standard">난이도</h2>
</div>
<div class="start-button-container">
<button class="start-left-box" onclick="makeMultipleChoice(true)" type="submit">
<span class="start-button-text">객관식</span>
<span class="start-button-text">객관식 문제 풀기</span>
</button>
<button class="start-right-box" onclick="makeMultipleChoice(false)" type="submit">
<span class="start-button-text">면접식</span>
<span class="start-button-text">기술 면접 연습하기</span>
</button>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class DescriptiveQuestionService(
"2. 사용자가 틀린 내용을 말한다면 틀렸다고 말씀해주세요." +
"채점 기준에 사용자의 답변이 부합하지 않더라도, 채점 기준이 무조건 적인 정답이 되어선 안됩니다." +
"그러니 지적할 때, ~이렇게 대답하셔야합니다. 보단 ~ 이런 내용을 보충하시면 더 좋을 거같습니다. 이런 식으로 지적해주세요." +
"다만 당신의 답변도 Too Much Information을 담아선 안 됩니다. 예를 들어 JVM의 컴파일 과정에 대해 물어보았는데, " +
"당신의 답변에 JIT 컴파일러 내용이 들어가있으면 좋지 않습니다. 관련성은 있지만, 물어본 질문에 대해서만 답변을 해주세요." +
"문제 채점 기준은 다음과 같습니다. 주어진 채점 기준이 없다면 당신이 임의로 판단해서 채점해주세요. " +
""
}

0 comments on commit 777a6df

Please sign in to comment.