Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 01-planning/_registry/policies/POL-0012-club-cohort.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
## 출석 — 날짜 판, 캡틴이 입력한다

- 출석부는 **멤버 × 그 달의 날짜**다. 지금 구글 시트와 같다
- 줄: 멤버(닉네임) · 신청 폼에서 「명단에 보이기」를 켠 질문의 답(얼리버드: 목표 시간)
- 줄: 멤버(닉네임) · 신청 폼에서 「출석부 표시」를 고른 질문(2개까지)의 답(얼리버드: 목표 시간)
- 열: 1일~말일 · 사람별 출석률 · 맨 아래 날마다 출석 수
- 값은 **스터디와 같은 네 가지** — 출석 · 지각 · 결석 · 휴가. 지각은 0.5일. 휴가 제한 없음
- **출석은 캡틴이 입력한다** — 디스코드 인증을 보고. 크루가 직접 남기는 길은 없다. 휴가가 필요하면 캡틴에게 말한다
Expand Down
24 changes: 22 additions & 2 deletions 01-planning/stories/captain-application-form/PRD.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ flowchart LR
11. 불러오기·저장 실패와 권한 없음 안내. 조회 완료 전 저장 차단
12. 권한 — 담당 캡틴만 수정, 다른 캡틴은 조회. 네비게이터·크루는 백오피스 진입 불가
13. 바꾼 질문은 이후 신청부터 적용 — 먼저 낸 신청은 신청 당시 질문과 답 유지
14. 클럽 기수는 질문 2개까지 「출석부 표시」 — 그 답이 출석부 닉네임 옆 열에, 신청 창에는 공개 안내
14. 답 모양이 바뀌는 유형 변경은 새 질문으로 저장

## 2. 화면명세
Expand Down Expand Up @@ -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 — 저장

Expand All @@ -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)) |

### 데이터
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions 01-planning/stories/captain-application-form/screens/shots.json
Original file line number Diff line number Diff line change
Expand Up @@ -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\"]"
}
]
}
6 changes: 3 additions & 3 deletions 01-planning/stories/captain-club-monthly-attendance/PRD.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 — 닉네임

Expand All @@ -101,7 +101,7 @@ flowchart LR

#### 3-2 — 신청 답 열

- **조건**: 신청 폼에 「명단에 보이기」 질문이 있을 때
- **조건**: 신청 폼에 「출석부 표시」 질문이 있을 때
- **내용**: 그 질문의 답 — 얼리버드는 목표 시간. 인증 시각을 확인할 때 대조한다

#### 3-3 — 날짜 머리
Expand Down Expand Up @@ -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`) · 회차 알림에서 빼기 | 스펙작성중 | 추가 |

Expand Down
2 changes: 1 addition & 1 deletion 01-planning/stories/captain-reregister-cohort/PRD.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |

Expand Down
4 changes: 2 additions & 2 deletions 01-planning/stories/crew-my-club/PRD.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ flowchart LR

#### 3-2 — 신청 답 열

- **조건**: 신청 폼에 「명단에 보이기」 질문이 있을 때
- **조건**: 신청 폼에 「출석부 표시」 질문이 있을 때
- **내용**: 얼리버드 목표 시간

#### 3-3 — 날짜 머리
Expand Down Expand Up @@ -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` |

---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -138,9 +142,10 @@ private List<NormalizedApplicationQuestion> 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@ public record ParticipantAttendance(
Instant leftAt,
List<AttendanceEntry> attendances,
Double attendanceRate,
/** 클럽 기수 전용 — showInRoster=true 질문의 답. 없으면 null. */
String rosterAnswer) {}
/**
* 클럽 기수 전용 — showInRoster=true 질문(최대 2개)의 답. 폼의 질문 순서대로, 답이 없으면 그 자리는 null. 일반 스터디 · 켠
* 질문이 없으면 빈 목록.
*/
List<String> rosterAnswers) {}

public record AttendanceEntry(long meetingId, String status) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<Long, String> rosterAnswers = isClub ? rosterAnswersOf(study, accountIds) : Map.of();
List<String> rosterQuestionIds = isClub ? rosterQuestionIdsOf(study) : List.of();
Map<Long, List<String>> rosterAnswers =
rosterAnswersOf(study, rosterQuestionIds, accountIds);

Instant now = Instant.now();
double totalNumerator = 0;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -230,33 +233,41 @@ public AttendanceResponse getAttendances(
participantAttendances);
}

/** 클럽 기수 전용 — 「출석부에 표시」를 켠 질문 ID, 폼의 질문 순서대로(최대 2개). */
private List<String> rosterQuestionIdsOf(Study study) {
return formQuestionReader.questionsOf(study).stream()
.filter(q -> Boolean.TRUE.equals(q.showInRoster()))
.map(ApplicationFormQuestion::id)
.toList();
}

private static List<String> emptyAnswers(int size) {
return size == 0 ? List.of() : Collections.nCopies(size, null);
}

/**
* 클럽 기수 전용 — 계정 ID 별 rosterAnswer(명단에 보이기 질문의 답). showInRoster 질문이 없거나 답이 없으면 해당 계정은 맵에 없다.
* 클럽 기수 전용 — 계정 ID 별 rosterAnswers(질문 순서대로, 답이 없으면 null). 신청이 없는 계정은 맵에 없다.
*
* <p>같은 studyId 에 신청이 여럿이면 ID 가 큰(나중) 행의 답을 쓴다 — 이어서 참여로 복사된 최신 답이 앞에 온다.
*/
private Map<Long, String> rosterAnswersOf(Study study, Set<Long> 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<Long, List<String>> rosterAnswersOf(
Study study, List<String> questionIds, Set<Long> accountIds) {
if (questionIds.isEmpty() || accountIds.isEmpty()) {
return Map.of();
}
List<StudyApplication> applications =
studyApplicationRepository.findByStudyIdAndAccountIdInOrderByIdDesc(
study.getId(), accountIds);
Map<Long, String> result = new HashMap<>();
Map<Long, List<String>> 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<String> answers = new ArrayList<>(questionIds.size());
for (String questionId : questionIds) {
answers.add(extractAnswer(app.getFormAnswer(), questionId));
}
result.put(app.getAccountId(), answers);
}
return result;
}
Expand All @@ -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;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<String, Object> rosterRequest(int rosterCount) {
List<Map<String, Object>> 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<String, Object> validRequest() {
return Map.of(
"title",
Expand Down
Loading
Loading