Some checks failed
ci / build (push) Failing after 5s
- 핵심 규칙 6: 완료의 정의는 게이트 통과. 사용자를 QA로 쓰지 않는다 - 5단계 기계 검사 4번째: design-gate 실행 의무화 - references/audit-gate.md: 사고-검사 매핑, SEO/meta 체크리스트, OS/브라우저 특성, 하니스 규칙 - tools/design-gate.mjs: 범용 게이트(메타/SEO·대비·수축·리듬·트랙·스케일×폭 + 옵션 L0/L3/L4, checks 깊은 병합) - 리듬·트랙 불변식: 숫자 라벨 등폭·빈 셀 트랙 균일·등간격 — 시간표 자동배치 결함 재현 픽스처 검출, 앱 15뷰 통과(오탐 0) feat(site): 관리 앱 2종 프로덕션 콘솔(v6→v18) - 가온 학적부 9뷰·두레 수강신청 6뷰: shadcn 문법, Pretendard/Noto Serif/IBM Plex 폰트 전략, 볼드 금지(400/500/600), WCAG AA 대비 전면 교정, 한글 keep-all 조판 - LMS 필수 요소(알림 센터·공지·진도·평가 유형·출결 사유·학점 경고), 12명 기준 데이터 정합, SEO 구조(h1 유일·OG/twitter·og.png) - 시간표 자동배치 결함 수리(명시적 격자 좌표) - QA 게이트: L0 stylelint/html-validate · L1 단위 30 · L2 감사 61+불변식 · L3 시각회귀 30화면 · L4 WebKit · L5 키보드 탐색 — npm run verify 실패 시 배포 금지 체인
57 lines
2.1 KiB
JavaScript
57 lines
2.1 KiB
JavaScript
/* 가온 학적부 — 순수 계산 로직. 브라우저와 Node 테스트가 같은 함수를 공유한다. */
|
|
(function (global) {
|
|
"use strict";
|
|
|
|
const attSummary = (row) => {
|
|
const days = (row || []).filter((v) => v !== null && v !== undefined);
|
|
if (!days.length) return "휴학";
|
|
const att = days.filter((v) => v === 2).length;
|
|
return `${Math.round((att / days.length) * 100)}%`;
|
|
};
|
|
|
|
// 일별 합계 — marks 는 '행 배열'의 목록이다. v11 사고(행 자체를 세어 0/3) 방지가 이 함수의 존재 이유.
|
|
const dayTotal = (marks, d) =>
|
|
marks.filter((row) => row && row[d] !== null && row[d] !== undefined).length;
|
|
const dayPresent = (marks, d) =>
|
|
marks.filter((row) => row && row[d] === 2).length;
|
|
|
|
const counts = (marks) => {
|
|
const flat = (marks || []).filter(Boolean).flat();
|
|
const att = flat.filter((v) => v === 2).length;
|
|
const late = flat.filter((v) => v === 1).length;
|
|
const abs = flat.filter((v) => v === 0).length;
|
|
return {
|
|
att, late, abs, total: flat.length,
|
|
rate: flat.length ? Math.round((att / flat.length) * 100) : 0,
|
|
};
|
|
};
|
|
|
|
// 명단 통계 — 0명 나눗셈 가드 포함
|
|
const rosterStats = (students) => {
|
|
const list = students || [];
|
|
const active = list.filter((s) => s.status === "재학");
|
|
const avgAtt = active.length
|
|
? Math.round(active.reduce((a, s) => a + (s.att || 0), 0) / active.length)
|
|
: 0;
|
|
const hw = active.reduce(
|
|
(a, s) => {
|
|
const [done, total] = String(s.hw || "0/0").split("/").map(Number);
|
|
return { done: a.done + (done || 0), total: a.total + (total || 0) };
|
|
},
|
|
{ done: 0, total: 0 }
|
|
);
|
|
return {
|
|
total: list.length,
|
|
active: active.length,
|
|
off: list.length - active.length,
|
|
avgAtt,
|
|
hwDone: hw.done,
|
|
hwTotal: hw.total,
|
|
hwRate: hw.total ? Math.round((hw.done / hw.total) * 100) : 0,
|
|
};
|
|
};
|
|
|
|
const api = { attSummary, dayTotal, dayPresent, counts, rosterStats };
|
|
global.GAON = api;
|
|
if (typeof module !== "undefined") module.exports = api;
|
|
})(typeof window !== "undefined" ? window : globalThis);
|