diff --git a/01-planning/_registry/policies/POL-0012-club-cohort.md b/01-planning/_registry/policies/POL-0012-club-cohort.md index 6619f427f..26b203c0d 100644 --- a/01-planning/_registry/policies/POL-0012-club-cohort.md +++ b/01-planning/_registry/policies/POL-0012-club-cohort.md @@ -52,7 +52,7 @@ ## 출석 — 날짜 판, 캡틴이 입력한다 - 출석부는 **멤버 × 그 달의 날짜**다. 지금 구글 시트와 같다 - - 줄: 멤버(닉네임) · 신청 폼에서 「명단에 보이기」를 켠 질문의 답(얼리버드: 목표 시간) + - 줄: 멤버(닉네임) · 신청 폼에서 「출석부 표시」를 고른 질문(2개까지)의 답(얼리버드: 목표 시간) - 열: 1일~말일 · 사람별 출석률 · 맨 아래 날마다 출석 수 - 값은 **스터디와 같은 네 가지** — 출석 · 지각 · 결석 · 휴가. 지각은 0.5일. 휴가 제한 없음 - **출석은 캡틴이 입력한다** — 디스코드 인증을 보고. 크루가 직접 남기는 길은 없다. 휴가가 필요하면 캡틴에게 말한다 diff --git a/01-planning/stories/captain-application-form/PRD.md b/01-planning/stories/captain-application-form/PRD.md index 653fd7f5a..6df7829c5 100644 --- a/01-planning/stories/captain-application-form/PRD.md +++ b/01-planning/stories/captain-application-form/PRD.md @@ -32,6 +32,7 @@ flowchart LR 11. 불러오기·저장 실패와 권한 없음 안내. 조회 완료 전 저장 차단 12. 권한 — 담당 캡틴만 수정, 다른 캡틴은 조회. 네비게이터·크루는 백오피스 진입 불가 13. 바꾼 질문은 이후 신청부터 적용 — 먼저 낸 신청은 신청 당시 질문과 답 유지 +14. 클럽 기수는 질문 2개까지 「출석부 표시」 — 그 답이 출석부 닉네임 옆 열에, 신청 창에는 공개 안내 14. 답 모양이 바뀌는 유형 변경은 새 질문으로 저장 ## 2. 화면명세 @@ -225,7 +226,23 @@ erDiagram - 질문 설명에는 설문지 헤더와 같은 마크다운(#~###### 제목·**굵게**·*기울임*·~~취소선~~·`코드`·[링크](url)·순서/비순서 목록·펜스 코드 블록)을 쓸 수 있다 — 지원자 화면에도 그대로 렌더링된다 - 저장된 질문을 단답·장문과 선택형(객관식·체크박스·드롭다운) 사이로 바꾸면 저장할 때 새 질문으로 저장한다 — 옛 답이 새 유형의 결과 집계와 섞이지 않게 - 선택형끼리 바꾸면 같은 질문으로 둔다 -- **데이터**: ApplicationQuestion[] — id/label/type/required/options/allowOther/placeholder/description +- **데이터**: ApplicationQuestion[] — id/label/type/required/options/allowOther/placeholder/description/showInRoster + +#### 3-3 — 출석부 표시 + +- **조건**: 클럽 기수일 때 +- **내용**: 편집 중인 질문 카드 아래 줄, 「필수 응답」 옆 체크박스 「출석부 표시」 +- **동작**: 2개를 고르면 나머지 질문의 체크박스는 막힌다 — 하나를 풀면 다시 고를 수 있다 +- **정책** + - 클럽 기수에만 둔다 — 서버가 클럽 기수 출석부에만 답을 붙인다 + - 폼에 2개까지 고를 수 있다. 3개 이상이면 저장이 400 이다 + - 고른 질문의 답은 출석부(운영 콘솔 · 사용자 사이트) 닉네임 옆 열에 폼 질문 순서대로 보이고, 열 이름은 질문 제목이다 +- **데이터**: questions[].showInRoster (STUDY.APPLICATION_FORM JSON) — 출석 API 응답 participants[].rosterAnswers (질문 순서대로) + +#### 3-4 — 출석부 표시 안내 + +- **조건**: 클럽 기수이고 출석부 표시를 고른 질문일 때 +- **내용**: 접힌 카드 아래 「출석부에 표시」 ### 4 — 저장 @@ -250,9 +267,12 @@ erDiagram | 구분 | 대상 | 지금 | 할 일 | |---|---|---|---| -| FE | back-office-front 신청 폼 탭 (`ApplicationFormTab`) | 있음 — 조회 · 저장 API 연결 | 없음 | +| FE | back-office-front 신청 폼 탭 (`ApplicationFormTab`) | 있음 — 조회 · 저장 API 연결 · 「출석부 표시」 체크박스(클럽 기수, 2개까지) | 없음 | +| FE | core-front 신청 창 공개 안내 · 스터디 일정 출석 탭의 답 열 (`ApplyDialog` · `AttendanceTabContent`) | 있음 — 폼 · 출석 API 의 `showInRoster` · `rosterAnswers` 연결(답 열 2개까지) | 없음 | +| FE | back-office-front 클럽 기수 출석부의 답 열 | 없음 — 클럽 날짜 판이 아직 없다 | 클럽 출석부(ST-043)와 함께 | | BE | `GET` · `PUT /api/admin/studies/{studyId}/application-form` | 구현완료 | 없음 | | BE | 모집 뒤 폼 수정 · 신청 질문 사본(`STUDY_APPLICATION.QUESTIONS_SNAPSHOT`) · 질문 버전 (ZAPP #165) | 구현완료 | 없음 | +| BE | 질문 `showInRoster` (폼에 2개까지) · 클럽 기수 출석 응답 `rosterAnswers` ([club-cohort](../../../specs/club-cohort/spec.md)) | 구현완료 (#588 하나 → 이 브랜치에서 2개 · 목록으로) | 없음 | | BE | 옛 사이트 경로 `PUT /api/studies/{studyId}/application-form` | 폐기 — 스펙에서는 지웠고 컨트롤러는 남아 있다 | 지운다 ([share 10-07](../../../docs/share/2026-10-07-captain-owner-by-created-by.md)) | ### 데이터 diff --git a/01-planning/stories/captain-application-form/screens/apply-roster-notice.png b/01-planning/stories/captain-application-form/screens/apply-roster-notice.png new file mode 100644 index 000000000..aca843d34 Binary files /dev/null and b/01-planning/stories/captain-application-form/screens/apply-roster-notice.png differ diff --git a/01-planning/stories/captain-application-form/screens/form-roster-checkbox.png b/01-planning/stories/captain-application-form/screens/form-roster-checkbox.png new file mode 100644 index 000000000..be8ee92ac Binary files /dev/null and b/01-planning/stories/captain-application-form/screens/form-roster-checkbox.png differ diff --git a/01-planning/stories/captain-application-form/screens/form-roster-limit.png b/01-planning/stories/captain-application-form/screens/form-roster-limit.png new file mode 100644 index 000000000..c058f87d0 Binary files /dev/null and b/01-planning/stories/captain-application-form/screens/form-roster-limit.png differ diff --git a/01-planning/stories/captain-application-form/screens/shots.json b/01-planning/stories/captain-application-form/screens/shots.json index e556c370f..f4a034207 100644 --- a/01-planning/stories/captain-application-form/screens/shots.json +++ b/01-planning/stories/captain-application-form/screens/shots.json @@ -7,6 +7,40 @@ "path": "/proto/console/studies/1?tab=form", "viewport": "desktop", "scrollTo": "[data-anno~=\"form:3\"]" + }, + { + "story": "captain-application-form", + "name": "form-roster-checkbox", + "title": "신청 폼 탭(클럽 기수) — 질문 편집 중 「출석부 표시」 체크박스, 접힌 카드의 「출석부에 표시」", + "path": "/proto/console/studies/4?tab=form", + "click": [ + "질문 1 수정" + ], + "scrollTo": "[data-anno=\"form:3-3\"]" + }, + { + "story": "captain-application-form", + "name": "form-roster-limit", + "title": "신청 폼 탭(클럽 기수) — 2개를 고르면 나머지 질문의 체크박스는 막힌다", + "path": "/proto/console/studies/4?tab=form", + "click": [ + "질문 2 수정", + "출석부 표시", + "신청 폼", + "질문 3 수정" + ], + "scrollTo": "[data-anno=\"form:3-3\"]" + }, + { + "story": "captain-application-form", + "name": "apply-roster-notice", + "title": "신청 창(클럽 기수) — 출석부 표시 질문 아래 공개 안내", + "path": "/proto/core/ko/studies/5?apply=1", + "storage": { + "sc_discord": "crew_example", + "sc_discord_nickname": "crew_example" + }, + "scrollTo": "[data-anno=\"apply:5-1\"]" } ] } diff --git a/01-planning/stories/captain-club-monthly-attendance/PRD.md b/01-planning/stories/captain-club-monthly-attendance/PRD.md index f5316a045..59bae490d 100644 --- a/01-planning/stories/captain-club-monthly-attendance/PRD.md +++ b/01-planning/stories/captain-club-monthly-attendance/PRD.md @@ -92,7 +92,7 @@ flowchart LR - **조건**: 클럽 기수(STUDY_PROGRAM.KIND = CLUB) - **내용**: 줄은 멤버, 열은 그 달의 날짜 - **정책**: 참여 중단한 사람은 맨 아래 -- **데이터**: `GET /api/admin/studies/{studyId}/attendances` — 기존 출석 명부. 클럽 기수는 회차가 날마다 하나라 열이 곧 날짜다. 줄마다 `rosterAnswer` +- **데이터**: `GET /api/admin/studies/{studyId}/attendances` — 기존 출석 명부. 클럽 기수는 회차가 날마다 하나라 열이 곧 날짜다. 줄마다 `rosterAnswers`(「출석부 표시」 질문 2개까지의 답) #### 3-1 — 닉네임 @@ -101,7 +101,7 @@ flowchart LR #### 3-2 — 신청 답 열 -- **조건**: 신청 폼에 「명단에 보이기」 질문이 있을 때 +- **조건**: 신청 폼에 「출석부 표시」 질문이 있을 때 - **내용**: 그 질문의 답 — 얼리버드는 목표 시간. 인증 시각을 확인할 때 대조한다 #### 3-3 — 날짜 머리 @@ -191,7 +191,7 @@ flowchart LR |---|---|---|---| | FE | back-office-front 스터디 상세 › 출석 탭 — 클럽 기수면 날짜 판 | 회차 출석부만 | 프로토대로 만든다 — 판은 core-front 출석 판(ST-044)과 같은 부품으로 | | FE | core-front 스터디 일정(클럽) › 출석 — 캡틴이면 같은 편집 판 | 없음 | 프로토대로 — 저장은 같은 `POST /api/admin/studies/{studyId}/attendances` | -| BE | `GET · POST /api/admin/studies/{studyId}/attendances` | 구현완료 | [club-cohort](../../../specs/club-cohort/spec.md) 「출석」의 클럽 차이 — 회차 `date` · `rosterAnswer` · 오늘 뒤 400 | +| BE | `GET · POST /api/admin/studies/{studyId}/attendances` | 구현완료 | [club-cohort](../../../specs/club-cohort/spec.md) 「출석」의 클럽 차이 — 회차 `date` · `rosterAnswers` · 오늘 뒤 400 | | BE | 같은 API 의 `undoWithdrawals[]` (참여 중단 취소) | 스펙작성중 | 추가 | | BE | 클럽 회차를 회차 상태 판정(`MISSED`) · 회차 알림에서 빼기 | 스펙작성중 | 추가 | diff --git a/01-planning/stories/captain-reregister-cohort/PRD.md b/01-planning/stories/captain-reregister-cohort/PRD.md index e89558aa1..2d66a1df0 100644 --- a/01-planning/stories/captain-reregister-cohort/PRD.md +++ b/01-planning/stories/captain-reregister-cohort/PRD.md @@ -113,7 +113,7 @@ flowchart LR |---|---|---|---| | FE | back-office-front 스터디 상세 머리 「다음 달 기수 만들기」 버튼 · 창 | 없음 | 프로토대로 만든다 | | BE | `POST /api/admin/studies/{studyId}/next-cohort` | 스펙작성중 | [club-cohort](../../../specs/club-cohort/spec.md) — 복사 · 날마다 회차 · 이어서 참여를 한 트랜잭션으로 | -| BE | `STUDY.COHORT_MONTH` · `STUDY_PARTICIPANT.CARRIED_FROM_ID` · 신청 질문 `SHOW_IN_ROSTER` | 스펙작성중 | 마이그레이션 | +| BE | `STUDY.COHORT_MONTH` · `STUDY_PARTICIPANT.CARRIED_FROM_ID` | 스펙작성중 | 마이그레이션 (신청 질문 `showInRoster` 는 폼 JSON 이라 마이그레이션 없음 · #588 구현완료) | | BE | 클럽 기수 상태 — 1일 진행 중 · 말일 뒤 종료 (매일 0시) | 스펙작성중 | 기존 상태 배치에 클럽 분기 | | BE | `POST /api/admin/studies` 가 기존 클럽의 새 기수를 받지 않기 | 구현완료 · 변경 예정 | [study](../../../specs/study/spec.md) AC-7 | diff --git a/01-planning/stories/crew-my-club/PRD.md b/01-planning/stories/crew-my-club/PRD.md index 4417bcc5c..dbb1cc921 100644 --- a/01-planning/stories/crew-my-club/PRD.md +++ b/01-planning/stories/crew-my-club/PRD.md @@ -93,7 +93,7 @@ flowchart LR #### 3-2 — 신청 답 열 -- **조건**: 신청 폼에 「명단에 보이기」 질문이 있을 때 +- **조건**: 신청 폼에 「출석부 표시」 질문이 있을 때 - **내용**: 얼리버드 목표 시간 #### 3-3 — 날짜 머리 @@ -126,7 +126,7 @@ flowchart LR | 구분 | 대상 | 지금 | 할 일 | |---|---|---|---| | FE | core-front 스터디 일정 — 클럽 기수면 탭 「출석 · 공지」, 첫 탭이 출석 판 | 스터디 탭만 | 프로토대로 — 판은 back-office-front 클럽 출석부(ST-043)와 같은 부품 | -| BE | `GET /api/me/studies/{studyId}/attendances` | 구현완료 | [club-cohort](../../../specs/club-cohort/spec.md) 「출석」의 크루 조회 — 클럽 기수는 멤버 전원 · `date` · `rosterAnswer` | +| BE | `GET /api/me/studies/{studyId}/attendances` | 구현완료 | [club-cohort](../../../specs/club-cohort/spec.md) 「출석」의 크루 조회 — 클럽 기수는 멤버 전원 · `date` · `rosterAnswers` | --- diff --git a/backend/api/src/main/java/com/studyclub/api/application/StudyApplicationFormRequests.java b/backend/api/src/main/java/com/studyclub/api/application/StudyApplicationFormRequests.java index e8d943903..695982a20 100644 --- a/backend/api/src/main/java/com/studyclub/api/application/StudyApplicationFormRequests.java +++ b/backend/api/src/main/java/com/studyclub/api/application/StudyApplicationFormRequests.java @@ -39,6 +39,6 @@ public record ApplicationFormQuestionRequest( @Schema(description = "RADIO/CHECKBOX/SELECT 전용 선택지") List<@NotBlank(message = "questions[].options[] 값을 입력해 주세요.") String> options, @Schema(description = "RADIO/CHECKBOX 전용 기타 직접 입력 허용 여부") Boolean allowOther, - @Schema(description = "클럽 출석부 명단에 이 질문의 답을 보여줄지 — 클럽 기수 전용, 질문 하나만 true 가능") + @Schema(description = "클럽 출석부 명단에 이 질문의 답을 보여줄지 — 클럽 기수 전용, 질문 2개까지 true 가능") Boolean showInRoster) {} } diff --git a/backend/api/src/main/java/com/studyclub/api/application/StudyApplicationFormService.java b/backend/api/src/main/java/com/studyclub/api/application/StudyApplicationFormService.java index 7e2f741f1..377657599 100644 --- a/backend/api/src/main/java/com/studyclub/api/application/StudyApplicationFormService.java +++ b/backend/api/src/main/java/com/studyclub/api/application/StudyApplicationFormService.java @@ -37,6 +37,10 @@ public class StudyApplicationFormService { private static final int DESCRIPTION_MAX = 5_000; private static final int PLACEHOLDER_MAX = 200; private static final int OPTION_MAX = 200; + + /** 「출석부에 표시」를 켤 수 있는 질문 수 (specs/club-cohort) */ + private static final int MAX_ROSTER_QUESTIONS = 2; + private static final String DISCORD_QUESTION_ID = "discord"; private final StudyRepository studyRepository; @@ -138,9 +142,10 @@ private List normalizeQuestions( questions.stream().map(question -> normalizeQuestion(question, ids)).toList(); long rosterCount = normalized.stream().filter(q -> Boolean.TRUE.equals(q.showInRoster())).count(); - if (rosterCount > 1) { + if (rosterCount > MAX_ROSTER_QUESTIONS) { throw new BusinessException( - ErrorCode.INVALID_INPUT, "명단에 보이기(showInRoster)는 질문 하나만 설정할 수 있습니다."); + ErrorCode.INVALID_INPUT, + "출석부에 표시(showInRoster)는 질문 " + MAX_ROSTER_QUESTIONS + "개까지 설정할 수 있습니다."); } return normalized; } diff --git a/backend/api/src/main/java/com/studyclub/api/attendance/AttendanceResponse.java b/backend/api/src/main/java/com/studyclub/api/attendance/AttendanceResponse.java index 649d324d1..927193ebf 100644 --- a/backend/api/src/main/java/com/studyclub/api/attendance/AttendanceResponse.java +++ b/backend/api/src/main/java/com/studyclub/api/attendance/AttendanceResponse.java @@ -33,8 +33,11 @@ public record ParticipantAttendance( Instant leftAt, List attendances, Double attendanceRate, - /** 클럽 기수 전용 — showInRoster=true 질문의 답. 없으면 null. */ - String rosterAnswer) {} + /** + * 클럽 기수 전용 — showInRoster=true 질문(최대 2개)의 답. 폼의 질문 순서대로, 답이 없으면 그 자리는 null. 일반 스터디 · 켠 + * 질문이 없으면 빈 목록. + */ + List rosterAnswers) {} public record AttendanceEntry(long meetingId, String status) {} } diff --git a/backend/api/src/main/java/com/studyclub/api/attendance/AttendanceService.java b/backend/api/src/main/java/com/studyclub/api/attendance/AttendanceService.java index 685d89cf9..69952c616 100644 --- a/backend/api/src/main/java/com/studyclub/api/attendance/AttendanceService.java +++ b/backend/api/src/main/java/com/studyclub/api/attendance/AttendanceService.java @@ -148,14 +148,16 @@ public AttendanceResponse getAttendances( .filter(a -> a.getDiscordNickname() != null) .collect(Collectors.toMap(Account::getId, Account::getDiscordNickname)); - // 클럽 기수 여부 — rosterAnswer · 회차 date 를 붙이기 위해 판정 + // 클럽 기수 여부 — rosterAnswers · 회차 date 를 붙이기 위해 판정 boolean isClub = study.getProgramId() != null && studyProgramRepository .findById(study.getProgramId()) .map(p -> p.getStudyKind() == StudyKind.CLUB) .orElse(false); - Map rosterAnswers = isClub ? rosterAnswersOf(study, accountIds) : Map.of(); + List rosterQuestionIds = isClub ? rosterQuestionIdsOf(study) : List.of(); + Map> rosterAnswers = + rosterAnswersOf(study, rosterQuestionIds, accountIds); Instant now = Instant.now(); double totalNumerator = 0; @@ -197,7 +199,8 @@ public AttendanceResponse getAttendances( p.getLeftAt(), participantAttendancePerMeeting, AttendanceRateCalculator.rate(numeratorDenominatorPair), - rosterAnswers.get(p.getAccountId()))); + rosterAnswers.getOrDefault( + p.getAccountId(), emptyAnswers(rosterQuestionIds.size())))); } Double avgRate = totalDenominator == 0 ? null : totalNumerator / totalDenominator; @@ -230,33 +233,41 @@ public AttendanceResponse getAttendances( participantAttendances); } + /** 클럽 기수 전용 — 「출석부에 표시」를 켠 질문 ID, 폼의 질문 순서대로(최대 2개). */ + private List rosterQuestionIdsOf(Study study) { + return formQuestionReader.questionsOf(study).stream() + .filter(q -> Boolean.TRUE.equals(q.showInRoster())) + .map(ApplicationFormQuestion::id) + .toList(); + } + + private static List emptyAnswers(int size) { + return size == 0 ? List.of() : Collections.nCopies(size, null); + } + /** - * 클럽 기수 전용 — 계정 ID 별 rosterAnswer(명단에 보이기 질문의 답). showInRoster 질문이 없거나 답이 없으면 해당 계정은 맵에 없다. + * 클럽 기수 전용 — 계정 ID 별 rosterAnswers(질문 순서대로, 답이 없으면 null). 신청이 없는 계정은 맵에 없다. * *

같은 studyId 에 신청이 여럿이면 ID 가 큰(나중) 행의 답을 쓴다 — 이어서 참여로 복사된 최신 답이 앞에 온다. */ - private Map rosterAnswersOf(Study study, Set accountIds) { - String rosterQuestionId = - formQuestionReader.questionsOf(study).stream() - .filter(q -> Boolean.TRUE.equals(q.showInRoster())) - .map(ApplicationFormQuestion::id) - .findFirst() - .orElse(null); - if (rosterQuestionId == null || accountIds.isEmpty()) { + private Map> rosterAnswersOf( + Study study, List questionIds, Set accountIds) { + if (questionIds.isEmpty() || accountIds.isEmpty()) { return Map.of(); } List applications = studyApplicationRepository.findByStudyIdAndAccountIdInOrderByIdDesc( study.getId(), accountIds); - Map result = new HashMap<>(); + Map> result = new HashMap<>(); for (StudyApplication app : applications) { if (result.containsKey(app.getAccountId())) { continue; // ID 가 큰(나중) 행을 이미 저장했다 } - String answer = extractAnswer(app.getFormAnswer(), rosterQuestionId); - if (answer != null) { - result.put(app.getAccountId(), answer); + List answers = new ArrayList<>(questionIds.size()); + for (String questionId : questionIds) { + answers.add(extractAnswer(app.getFormAnswer(), questionId)); } + result.put(app.getAccountId(), answers); } return result; } @@ -278,7 +289,7 @@ private String extractAnswer(String formAnswerJson, String questionId) { } return value.asText(); } catch (JacksonException e) { - log.warn("rosterAnswer 추출 실패 — questionId={}", questionId, e); + log.warn("rosterAnswers 추출 실패 — questionId={}", questionId, e); return null; } } diff --git a/backend/api/src/test/java/com/studyclub/api/application/StudyApplicationFormIntegrationTest.java b/backend/api/src/test/java/com/studyclub/api/application/StudyApplicationFormIntegrationTest.java index 716ab111b..adc49dfac 100644 --- a/backend/api/src/test/java/com/studyclub/api/application/StudyApplicationFormIntegrationTest.java +++ b/backend/api/src/test/java/com/studyclub/api/application/StudyApplicationFormIntegrationTest.java @@ -7,6 +7,7 @@ import com.studyclub.domain.account.SystemRole; import java.sql.Timestamp; import java.time.Instant; +import java.util.ArrayList; import java.util.List; import java.util.Map; import org.junit.jupiter.api.BeforeEach; @@ -381,6 +382,52 @@ void rejectsAllowOtherOnUnsupportedType() { assertThat(response.getBody()).containsEntry("errorCode", "INVALID_INPUT"); } + @Test + @DisplayName("성공 - 출석부에 표시는 질문 2개까지 켤 수 있다") + void acceptsTwoRosterQuestions() { + var response = + rest.exchange( + "/api/admin/studies/" + EDITABLE_STUDY_ID + "/application-form", + HttpMethod.PUT, + authenticatedJsonRequest(CAPTAIN_ID, rosterRequest(2)), + Map.class); + + assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); + } + + @Test + @DisplayName("실패 - 출석부에 표시를 질문 3개에 켜면 INVALID_INPUT이다") + void rejectsThreeRosterQuestions() { + var response = + rest.exchange( + "/api/admin/studies/" + EDITABLE_STUDY_ID + "/application-form", + HttpMethod.PUT, + authenticatedJsonRequest(CAPTAIN_ID, rosterRequest(3)), + Map.class); + + assertThat(response.getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST); + assertThat(response.getBody()).containsEntry("errorCode", "INVALID_INPUT"); + } + + private Map rosterRequest(int rosterCount) { + List> questions = new ArrayList<>(); + for (int i = 0; i < 3; i++) { + questions.add( + Map.of( + "id", + "goal" + i, + "label", + "목표 " + i, + "type", + "TEXT", + "required", + true, + "showInRoster", + i < rosterCount)); + } + return Map.of("questions", questions); + } + private Map validRequest() { return Map.of( "title", diff --git a/frontend/apps/back-office-front/src/features/application-form/ApplicationFormEditor.test.tsx b/frontend/apps/back-office-front/src/features/application-form/ApplicationFormEditor.test.tsx index cc58b376c..98d655fb7 100644 --- a/frontend/apps/back-office-front/src/features/application-form/ApplicationFormEditor.test.tsx +++ b/frontend/apps/back-office-front/src/features/application-form/ApplicationFormEditor.test.tsx @@ -113,3 +113,48 @@ it('저장된 단답 질문을 객관식으로 바꿔 저장하면 새 질문 id await waitFor(() => expect(onSave).toHaveBeenCalledTimes(2)); expect(onSave.mock.calls[1][0].questions[0].id).toBe(first.id); }); + +function renderRosterEditor(club: boolean, onSave = vi.fn().mockResolvedValue(undefined)) { + render( + , + ); + return onSave; +} + +it('클럽 기수는 출석부 표시를 질문 2개까지 고른다 — 2개를 고르면 나머지 체크박스는 막힌다', async () => { + const onSave = renderRosterEditor(true); + expect(screen.getByText('출석부에 표시')).toBeTruthy(); + await userEvent.click(screen.getByRole('button', { name: '질문 2 수정' })); + await userEvent.click(screen.getByRole('checkbox', { name: '출석부 표시' })); + await userEvent.click(screen.getByRole('button', { name: '질문 3 수정' })); + expect((screen.getByRole('checkbox', { name: '출석부 표시' }) as HTMLInputElement).disabled).toBe(true); + await userEvent.click(screen.getByRole('button', { name: '저장' })); + await waitFor(() => expect(onSave).toHaveBeenCalledTimes(1)); + const [first, second, third] = onSave.mock.calls[0][0].questions; + expect(first.showInRoster).toBe(true); + expect(second.showInRoster).toBe(true); + expect(third.showInRoster).toBeUndefined(); +}); + +it('클럽이 아니면 출석부 표시 체크박스를 두지 않는다', async () => { + renderRosterEditor(false); + await userEvent.click(screen.getByRole('button', { name: '질문 2 수정' })); + expect(screen.queryByRole('checkbox', { name: '출석부 표시' })).toBeNull(); +}); diff --git a/frontend/apps/back-office-front/src/features/application-form/ApplicationFormEditor.tsx b/frontend/apps/back-office-front/src/features/application-form/ApplicationFormEditor.tsx index 2ba003b69..48f43cfd0 100644 --- a/frontend/apps/back-office-front/src/features/application-form/ApplicationFormEditor.tsx +++ b/frontend/apps/back-office-front/src/features/application-form/ApplicationFormEditor.tsx @@ -22,7 +22,11 @@ import { reassignIdsOnAnswerShapeChange, TYPE_LABEL, } from '@/features/application-form/question'; -import { applicationFormSchema, type ApplicationFormValues } from '@/features/application-form/schema'; +import { + applicationFormSchema, + MAX_ROSTER_QUESTIONS, + type ApplicationFormValues, +} from '@/features/application-form/schema'; const HEADER_ID = '__form-header__'; const DISCORD_QUESTION: ApplicationQuestion = { @@ -48,6 +52,7 @@ export function ApplicationFormEditor({ saving, saved, message, + club = false, onSave, }: { initialValues: ApplicationFormValues; @@ -57,6 +62,8 @@ export function ApplicationFormEditor({ saving: boolean; saved: boolean; message?: string; + /** 클럽 기수면 질문마다 「출석부 표시」 체크박스를 둔다 — 서버가 클럽 기수 출석부에만 답을 붙인다 (specs/club-cohort) */ + club?: boolean; onSave: (values: ApplicationFormValues) => Promise; }) { const { @@ -94,6 +101,9 @@ export function ApplicationFormEditor({ setValue(`questions.${index}`, { ...question, ...patch }, { shouldDirty: true }); } + /** 「출석부 표시」는 질문 2개까지 — 다 골랐으면 나머지 질문의 체크박스를 막는다 (서버 규칙과 같다) */ + const rosterFull = values.questions.filter((question) => question.showInRoster).length >= MAX_ROSTER_QUESTIONS; + function reorder(from: number, to: number) { if (disabled || selectedId || to < 0 || to >= fields.length) return; move(from, to); @@ -284,11 +294,26 @@ export function ApplicationFormEditor({

)}
- update(index, { required: event.target.checked })} - /> +
+ update(index, { required: event.target.checked })} + /> + {club && ( + update(index, { showInRoster: event.target.checked })} + /> + )} +
- {questions.map((q) => { + {questions.map((q, qi) => { const selected = selectedId === q.id; const dragging = dragId === q.id; const dragOver = !selected && dragOverId === q.id && dragId !== q.id; @@ -306,11 +324,27 @@ export function ApplicationFormTab({ study, onSave }: { study: Study; onSave?: ( )}
- update(q.id, { required: ev.target.checked })} - /> +
+ update(q.id, { required: ev.target.checked })} + /> + {club && ( + update(q.id, { showInRoster: ev.target.checked })} + /> + )} +
)} - {tab === 'form' && } + {tab === 'form' && ( + + )} {tab === 'results' && requestTab('crew')} />} {tab === 'info' && } diff --git a/frontend/apps/playground/src/proto/console/lib/clubs.ts b/frontend/apps/playground/src/proto/console/lib/clubs.ts index 8cc97cf1d..332c9d1da 100644 --- a/frontend/apps/playground/src/proto/console/lib/clubs.ts +++ b/frontend/apps/playground/src/proto/console/lib/clubs.ts @@ -20,7 +20,7 @@ export type ClubConfig = { key: ClubKey; /** STUDY_PROGRAM.TITLE — 기수 제목(STUDY.TITLE)도 이 이름 그대로다 */ title: string; - /** 신청 폼에서 「명단에 보이기」를 켠 질문 — 그 답을 출석부 이름 옆에 보인다 (시트의 「목표 시간」 열) */ + /** 신청 폼에서 「출석부 표시」를 고른 질문 — 그 답을 출석부 이름 옆에 보인다 (시트의 「목표 시간」 열) */ rosterQuestion?: { label: string }; /** STUDY_RECRUITMENT.CAPACITY — 다음 달 기수가 복사한다. 없으면 제한 없음 */ capacity?: number; @@ -109,7 +109,7 @@ export type ClubMember = { id: string; /** 닉네임 — 시트에서 붙여넣을 때 이 이름으로 찾는다 */ name: string; - /** 「명단에 보이기」 질문의 답 */ + /** 「출석부 표시」 질문의 답 */ extra?: string; /** 참여 중단 날짜 (이번 기수 안). 없으면 참여 중 */ leftOn?: string; diff --git a/frontend/apps/playground/src/proto/core/components/ApplyDialog.tsx b/frontend/apps/playground/src/proto/core/components/ApplyDialog.tsx index 1ea6c15b0..ba01eb176 100644 --- a/frontend/apps/playground/src/proto/core/components/ApplyDialog.tsx +++ b/frontend/apps/playground/src/proto/core/components/ApplyDialog.tsx @@ -4,6 +4,7 @@ import { useEffect, useRef, useState } from 'react'; +import { clubOfStudy } from '@console/lib/clubs'; import { formCardClass, FormHeaderCard, QuestionFillView } from '@core/components/ApplicationFormUi'; import { DiscordNicknameField } from '@core/components/DiscordNicknameField'; import { @@ -111,6 +112,8 @@ export function ApplyDialog({ // 클럽은 요일 · 일정 확인을 묻지 않는다 — 진행 방식 글(「매일 아침 인증」)은 모임 시각이 아니다 const asksDays = kindRules(study).asksDays; const fixedSchedule = asksDays && study.schedule ? t(study.schedule, locale) : null; + // 클럽 기수 — 「출석부 표시」를 고른 질문. 프로토 mock 폼에는 그 값이 없어 클럽 설정의 명단 질문 제목으로 찾는다 + const rosterLabel = clubOfStudy(study)?.rosterQuestion?.label; const [myRegion, setMyRegion] = useState('KR'); // 지역은 브라우저에 저장돼 있어 서버 렌더 시점에는 알 수 없다. 마운트 후 읽는다. useEffect(() => setMyRegion(getRegion()), [open]); @@ -455,6 +458,17 @@ export function ApplyDialog({ }); }} /> + {(q.showInRoster ?? (!!rosterLabel && q.label.startsWith(rosterLabel))) && ( +

+ {t( + { + ko: '이 답변은 모든 참여 크루가 출석부에서 볼 수 있어요.', + en: 'Every crew member in this cohort can see this answer on the attendance board.', + }, + locale, + )} +

+ )} ))} diff --git a/frontend/apps/playground/src/proto/specs/club-cohort.ts b/frontend/apps/playground/src/proto/specs/club-cohort.ts index 801cc6584..6fffb95f2 100644 --- a/frontend/apps/playground/src/proto/specs/club-cohort.ts +++ b/frontend/apps/playground/src/proto/specs/club-cohort.ts @@ -132,14 +132,14 @@ export const CLUBBOOK_SPEC: ScreenSpec = { display: ['줄은 멤버, 열은 그 달의 날짜'], policy: ['참여 중단한 사람은 맨 아래'], data: [ - '`GET /api/admin/studies/{studyId}/attendances` — 기존 출석 명부. 클럽 기수는 회차가 날마다 하나라 열이 곧 날짜다. 줄마다 `rosterAnswer`', + '`GET /api/admin/studies/{studyId}/attendances` — 기존 출석 명부. 클럽 기수는 회차가 날마다 하나라 열이 곧 날짜다. 줄마다 `rosterAnswers`(「출석부 표시」 질문 2개까지의 답)', ], }, { n: '3-1', title: '닉네임', when: CLUB_ONLY, display: ['멤버 이름 — 시트의 이름 열과 같다'] }, { n: '3-2', title: '신청 답 열', - when: '신청 폼에 「명단에 보이기」 질문이 있을 때', + when: '신청 폼에 「출석부 표시」 질문이 있을 때', display: ['그 질문의 답 — 얼리버드는 목표 시간. 인증 시각을 확인할 때 대조한다'], }, { @@ -265,7 +265,7 @@ export const CLUB_BOARD_SPEC: ScreenSpec = { { n: '3-2', title: '신청 답 열', - when: '신청 폼에 「명단에 보이기」 질문이 있을 때', + when: '신청 폼에 「출석부 표시」 질문이 있을 때', display: ['얼리버드 목표 시간'], }, { n: '3-3', title: '날짜 머리', display: ['날짜 · 요일. 오늘은 「오늘」'] }, diff --git a/frontend/apps/playground/src/proto/specs/study-apply.ts b/frontend/apps/playground/src/proto/specs/study-apply.ts index 65e773069..07c082bda 100644 --- a/frontend/apps/playground/src/proto/specs/study-apply.ts +++ b/frontend/apps/playground/src/proto/specs/study-apply.ts @@ -94,6 +94,14 @@ export const APPLY_SPEC: ScreenSpec = { data: ['study.applicationForm 중 id 가 discord 가 아닌 질문 전부 — DEMO_APPLICATION_FORM (백오피스 신청 폼과 동일)'], when: '캡틴이 설계한 추가 질문이 있을 때', }, + { + n: '5-1', + title: '출석부 공개 안내', + display: ['「이 답변은 모든 참여 크루가 출석부에서 볼 수 있어요.」'], + policy: ['캡틴이 신청 폼에서 「출석부 표시」를 고른 질문(2개까지) 아래에만 보인다 — 답을 적기 전에 누가 보는지 알린다'], + data: ['GET /api/studies/{studyId}/application-form 의 questions[].showInRoster'], + when: '클럽 기수이고 「출석부 표시」를 고른 질문일 때', + }, { n: '7', title: '오류 메시지', diff --git a/frontend/packages/mock/src/msw/data.ts b/frontend/packages/mock/src/msw/data.ts index 02a11f493..e852b13a6 100644 --- a/frontend/packages/mock/src/msw/data.ts +++ b/frontend/packages/mock/src/msw/data.ts @@ -167,6 +167,8 @@ export type ApiApplicationFormQuestion = { description?: string; options?: string[]; allowOther?: boolean; + /** 클럽 기수 — 이 답을 출석부에서 모든 참여 크루가 본다 (폼에 2개까지) */ + showInRoster?: boolean; }; export type ApiStudyApplicationForm = { diff --git a/frontend/packages/types/src/study.ts b/frontend/packages/types/src/study.ts index 05f810310..1b40eaba3 100644 --- a/frontend/packages/types/src/study.ts +++ b/frontend/packages/types/src/study.ts @@ -43,6 +43,8 @@ export type ApplicationQuestion = { allowOther?: boolean; placeholder?: string; description?: string; + /** 클럽 기수 전용 — 이 질문의 답을 출석부 닉네임 옆에 보인다. 폼에 2개까지 고를 수 있다 (specs/club-cohort) */ + showInRoster?: boolean; }; export type StudyWeek = { label: L10n; title: L10n }; diff --git a/specs/club-cohort/spec.md b/specs/club-cohort/spec.md index 42bfd3577..f9058aeef 100644 --- a/specs/club-cohort/spec.md +++ b/specs/club-cohort/spec.md @@ -34,8 +34,8 @@ |---|---|---| | `STUDY.COHORT_MONTH` | DATE NULL 추가 · `UNIQUE(PROGRAM_ID, COHORT_MONTH)` | 클럽 기수의 달(1일). 스터디는 NULL. 같은 달 기수가 둘 생기지 않게 막는다 | | `STUDY_PARTICIPANT.CARRIED_FROM_ID` | BIGINT NULL 추가 | 이어서 참여로 만든 행의 이전 기수 참여 ID. 재참여율을 이것으로 센다 | -| 신청 폼 질문 `SHOW_IN_ROSTER` | BOOLEAN NOT NULL DEFAULT FALSE 추가 | 켠 질문의 답을 출석부 응답의 `rosterAnswer` 로 준다(얼리버드 목표 시간). 다음 달 기수가 폼과 함께 복사한다 | -| 이어서 참여의 신청 답 | 이전 기수 신청 답을 **스냅샷(질문 문구 · 답 · `SHOW_IN_ROSTER`)** 으로 복사 | 질문 ID 로 짝짓지 않는다 — 다음 기수 폼이 바뀌어도 답이 남는다 | +| 신청 폼 질문 `showInRoster` | `STUDY.APPLICATION_FORM` JSON 의 질문마다 boolean (새 칼럼 없음 · 없으면 false) | 폼에 **2개까지** — 3개 이상이면 저장 400. 고른 질문의 답을 클럽 기수 출석부 응답의 `rosterAnswers`(폼 질문 순서대로) 로 준다(얼리버드 목표 시간). 다음 달 기수가 폼과 함께 복사한다. 화면: 운영 콘솔 신청 폼 탭의 「출석부 표시」 체크박스(클럽 기수만) · 신청 창의 공개 안내 · 출석부 닉네임 옆 열(질문마다 한 열, 열 이름 = 질문 제목) | +| 이어서 참여의 신청 답 | 이전 기수 신청 답을 **스냅샷(질문 문구 · 답 · `showInRoster`)** 으로 복사 | 질문 ID 로 짝짓지 않는다 — 다음 기수 폼이 바뀌어도 답이 남는다 | | `STUDY_MEETING` | 클럽 기수는 날마다 1행 · `SCHEDULED_AT` = 그 날 0시(KST) | 회차는 「그 달의 몇째 날」을 가리키는 칸이다. 하루를 세는 기준은 스터디 규칙 글에 적는다 | ## 기수 상태 — 날짜로 바뀐다 (매일 0시) @@ -73,7 +73,7 @@ 1. 같은 프로그램에 `COHORT_MONTH = 다음 달` 기수가 있으면 409 2. `STUDY`(`STATUS = DRAFT`, 제목은 프로그램 제목 그대로, `COHORT_MONTH` 다음 달 1일, `START_AT` 다음 달 1일, `END_AT` 그다음 달 1일 0시(KST) — 기수의 말일이 끝나는 순간, 위 「기수 상태」) · `STUDY_RECRUITMENT`(`RECRUIT_DEADLINE_AT` 이번 달 말일 23:59, `START_AT` NULL, `CAPACITY`) · 기본 반 · 날마다 회차 -3. 이번 기수의 소개 · 상세 설명 · 카테고리 · 디스코드 채널 · 드라이브 · 신청 폼(`SHOW_IN_ROSTER` 포함)을 복사한다 +3. 이번 기수의 소개 · 상세 설명 · 카테고리 · 디스코드 채널 · 드라이브 · 신청 폼(`showInRoster` 포함)을 복사한다 4. 이번 기수의 `ACTIVE` · `COMPLETED` 참여자마다 다음 기수 `STUDY_PARTICIPANT`(`ACTIVE`, 기본 반, `CARRIED_FROM_ID`) — 신청 답 스냅샷 복사 ### Response @@ -95,7 +95,7 @@ [attendance](../attendance/spec.md) 그대로이고 아래만 다르다. - 클럽 기수의 회차는 날마다 하나라 출석부의 열이 곧 날짜다. 응답에 회차 `date` 를 함께 준다 -- 참여자 줄에 `rosterAnswer`(「명단에 보이기」 질문의 답 — 없으면 null)를 더한다 +- 참여자 줄에 `rosterAnswers`(「출석부 표시」 질문 2개까지의 답 — 폼 질문 순서대로, 답이 없으면 그 자리는 null · 고른 질문이 없으면 빈 목록)를 더한다 - 허용 값 · 출석률은 스터디와 같다 — `PRESENT` · `LATE` · `ABSENT` · `EXCUSED`, 출석률 산식 그대로. 킥오프 회차가 없다 - 오늘(KST) 뒤의 회차 · 참여 중단 뒤의 회차면 400 - 끝난 기수도 `updates[]` 를 받는다. `withdrawals[]` 는 진행 중 기수만 — 끝난 기수면 409