@eliceio/cdk-cli 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -107,20 +107,20 @@ Claude에게 만들고 싶은 자료를 말하면 설계 · 화면 코드 · 검
107
107
  마지막에 확인 문제 3개. 어두운 화면으로.
108
108
  ```
109
109
 
110
- | 하고 싶은 것 | 요청 예 |
111
- | ------------------------ | -------------------------------------------------------------------------------- |
112
- | 퀴즈 (한 페이지 한 문항) | "퍼셉트론 확인 퀴즈. 단일 선택, 해설 포함" (여러 문항은 퀴즈 페이지를 여러 개로) |
113
- | 시뮬레이션 · 시각화 | "정렬 알고리즘이 한 단계씩 움직이는 걸 보여 주는 자료. 속도 조절 가능하게" |
114
- | 플래시카드 | "파이썬 내장 함수 20개 플래시카드. 교육자가 편집 화면에서 카드를 고칠 수 있게" |
115
- | 읽기 자료 + 자기점검 | "HTTP 상태 코드 설명 자료, 끝에 이해도 자기점검(제출하면 완료)" |
116
- | 문제 설명 | "실습 문제 설명으로 쓸 엘리스 자료. 문제는 …" |
117
- | 기존 HTML 옮기기 | "이 폴더의 HTML을 엘리스 Custom HTML 자료로 올릴 수 있게 바꿔줘" |
118
- | 오류 고치기 | "ecdk build가 실패해. 고쳐줘" |
110
+ | 하고 싶은 것 | 요청 예 |
111
+ | -------------------- | ------------------------------------------------------------------------------ |
112
+ | 퀴즈 (문항 20개까지) | "퍼셉트론 확인 퀴즈. 단일 선택 3문항, 해설 포함" |
113
+ | 시뮬레이션 · 시각화 | "정렬 알고리즘이 한 단계씩 움직이는 걸 보여 주는 자료. 속도 조절 가능하게" |
114
+ | 플래시카드 | "파이썬 내장 함수 20개 플래시카드. 교육자가 편집 화면에서 카드를 고칠 수 있게" |
115
+ | 읽기 자료 + 자기점검 | "HTTP 상태 코드 설명 자료, 끝에 이해도 자기점검(제출하면 완료)" |
116
+ | 문제 설명 | "실습 문제 설명으로 쓸 엘리스 자료. 문제는 …" |
117
+ | 기존 HTML 옮기기 | "이 폴더의 HTML을 엘리스 Custom HTML 자료로 올릴 수 있게 바꿔줘" |
118
+ | 오류 고치기 | "ecdk build가 실패해. 고쳐줘" |
119
119
 
120
120
  #### 방법 B: 직접 만들기
121
121
 
122
122
  ```bash
123
- ecdk create my-quiz # 퀴즈 (기본): 문항 하나를 편집 화면에서 만듦
123
+ ecdk create my-quiz # 퀴즈 (기본): 문항(20개까지)을 편집 화면에서 만듦
124
124
  ecdk create my-page --template blank # 퀴즈가 아닌 자료(시뮬레이션 · 활동 · 설명 · 플래시카드 · 설문): 예제 · 내용 JSON 편집기로 시작
125
125
  ecdk create my-quiz --theme dark # 어두운 화면
126
126
  ecdk create --list # 템플릿 목록 · 버전 · 설명
@@ -153,10 +153,10 @@ ecdk dev # http://localhost:4170
153
153
 
154
154
  엘리스 학습 화면을 흉내 낸 페이지가 열립니다. 콘텐츠는 운영과 같은 조건(다른 출처, sandbox, 콘텐츠 CSP)에서 열리므로 여기서 되면 운영에서도 됩니다.
155
155
 
156
- 1. **내용 편집**에서 견본 내용과 정답을 조금 넣어 저장합니다 (화면 안 저장, 템플릿은 "편집 완료"). 저장 전에는 학생 화면에 "아직 내용이 없습니다"가 보입니다.
156
+ 1. **내용 편집**에서 견본 내용과 정답을 조금 넣어 저장합니다 (화면 안 저장, 퀴즈 템플릿은 "초안에 반영"). 저장 전에는 학생 화면에 "아직 내용이 없습니다"가 보입니다.
157
157
  1. **학생**에서 활동을 끝까지 해 봅니다. 제출이 있으면 점수 · 결과가 나와야 합니다 (정답은 내용 편집에서 저장한 것).
158
158
  1. **튜터링**에서 방금 낸 답이 보이고 제출 버튼이 없어야 합니다.
159
- 1. **내용 편집**에서 화면 안 저장(템플릿은 "편집 완료")을 누른 뒤 **학생**에 반영되는지 봅니다. 편집 화면은 LXP처럼 edit 토큰으로 열리고, 화면 안 저장이 자료의 draft에 저장합니다(`PATCH /materials/{id}/draft`). 흉내 서버는 발행 단계가 없어 바로 학생에 보이지만, LXP에서는 편집 페이지 위쪽 '수업 자료에 반영'(새 버전)을 눌러야 학생에게 보입니다. 저장 전 업로드의 편집 화면(저장 거절)은 **SDK 기능 › 저장 전 편집 화면**으로 엽니다.
159
+ 1. **내용 편집**에서 화면 안 저장(퀴즈 템플릿은 "초안에 반영")을 누른 뒤 **학생**에 반영되는지 봅니다. 편집 화면은 LXP처럼 edit 토큰으로 열리고, 화면 안 저장이 자료의 draft에 저장합니다(`PATCH /materials/{id}/draft`). 흉내 서버는 발행 단계가 없어 바로 학생에 보이지만, LXP에서는 편집 페이지 위쪽 '수업 자료에 반영'(새 버전)을 눌러야 학생에게 보입니다. 저장 전 업로드의 편집 화면(저장 거절)은 **SDK 기능 › 저장 전 편집 화면**으로 엽니다.
160
160
  1. 위쪽 **모바일**로 좁은 화면도 확인합니다.
161
161
 
162
162
  화면마다 브라우저로 한 번씩 열어 보는 것은 `ecdk dev --check`가 대신합니다 (서버를 띄워 화면 × 폭마다 헤드리스 브라우저로 열고, 결과와 그림을 남긴 뒤 끝냄). AI 도구가 화면을 확인할 때도 이것을 씁니다.
@@ -219,7 +219,7 @@ ecdk build # [ok] dist/content.zip · 파일 6개 · 149.4KB (엔진 vite, 규
219
219
  > **TODO(LXP)**: 업로드 화면이 나오면 화면 이름 · 순서를 맞춥니다.
220
220
 
221
221
  1. LXP 레슨 편집에서 **Custom HTML** 자료를 만들고 `dist/content.zip`을 올립니다.
222
- 2. **편집** 화면에서 내용(문항 · 텍스트)과 정답을 입력해 화면 안 저장(퀴즈는 "편집 완료")을 누릅니다. 이것은 draft에 저장하고, 학생에게는 편집 페이지 위쪽 **'수업 자료에 반영'**을 눌러야 보입니다. 올리기 전에는 내용이 없어 학생 화면에 "아직 내용이 없습니다"가 보입니다. 완료 정책은 LXP 편집 페이지 위쪽에서 여는 **'설정'** 패널에서 교육자가 고르고, 고르면 바로 적용됩니다 (publish 스킬은 동의를 받아 업로드 때 정함, [정답과 채점](#정답과-채점)). 정답은 zip에 넣지 않습니다. `ecdk dev`에서 저장한 내용 · 정답(`.ecdk/settings.json`)은 손으로 올릴 때는 쓰이지 않고, publish 스킬은 동의를 받아 함께 보낼 수 있습니다.
222
+ 2. **편집** 화면에서 내용(문항 · 텍스트)과 정답을 입력해 화면 안 저장(퀴즈는 "초안에 반영")을 누릅니다. 이것은 draft에 저장하고, 학생에게는 편집 페이지 위쪽 **'수업 자료에 반영'**을 눌러야 보입니다. 올리기 전에는 내용이 없어 학생 화면에 "아직 내용이 없습니다"가 보입니다. 완료 정책은 LXP 편집 페이지 위쪽에서 여는 **'설정'** 패널에서 교육자가 고르고, 고르면 바로 적용됩니다 (publish 스킬은 동의를 받아 업로드 때 정함, [정답과 채점](#정답과-채점)). 정답은 zip에 넣지 않습니다. `ecdk dev`에서 저장한 내용 · 정답(`.ecdk/settings.json`)은 손으로 올릴 때는 쓰이지 않고, publish 스킬은 동의를 받아 함께 보낼 수 있습니다.
223
223
  3. 학생 화면 · 교육자 화면을 열어 확인합니다.
224
224
 
225
225
  코드를 고치면 `ecdk build`로 다시 만들어 올립니다 (이미 올린 페이지는 편집 페이지의 ⋮ › '다른 파일로 변경'으로 zip을 고른 뒤 '수업 자료에 반영'). 문항 · 텍스트 같은 **내용**은 zip을 다시 올리지 않고 LXP 안의 내용 편집 화면에서 고칠 수 있습니다.
@@ -282,7 +282,7 @@ content.zip
282
282
  "rules": "0.2.0",
283
283
  "protocol": 1,
284
284
  "engine": "vite",
285
- "template": "quiz@1.3.2",
285
+ "template": "quiz@1.4.0",
286
286
  "sdk": "2.0.0",
287
287
  "minify": true,
288
288
  "digest": "sha256-4E598jFubNa9BAOp3WH+kb2xBRxnM6uARnRMpp6bY6I=",
@@ -305,7 +305,7 @@ SDK 버전과 빌드 옵션입니다. **zip에 들어가지 않습니다.** `ecd
305
305
  // SDK. 키트가 import하고 ecdk build가 화면 코드와 함께 번들로 묶음 (파일로 넣지 않음). 올리기: npm update @eliceio/cdk
306
306
  "dependencies": { "@eliceio/cdk": "^1.0.0-alpha.4" },
307
307
  // 빌드 옵션 (아래 표). 화면 · 학습 참고 내용은 여기가 아니라 metadata.json
308
- "ecdk": { "template": "quiz@1.3.2" },
308
+ "ecdk": { "template": "quiz@1.4.0" },
309
309
  }
310
310
  ```
311
311
 
@@ -322,7 +322,7 @@ ecdk 플러그인이 맡는 것: 입력(원본의 모든 HTML) · 상대 경로
322
322
  | `minify` | `true` | 묶은 JS · CSS를 줄여(주석 빼고) 넣음. `false`면 끔 |
323
323
  | `sourcemap` | `false` | 묶은 스크립트에 inline map을 붙여 운영에서도 원본 위치로 오류를 봄 (`minify`를 끄면 못 씀) |
324
324
  | `root` · `outDir` · `exclude` | `.` · `dist` · `[]` | 원본 폴더, 결과 폴더(프로젝트 안만), 더 뺄 파일 |
325
- | `template` | `ecdk create`가 적음 | 만든 템플릿과 그 템플릿의 버전 (`quiz@1.3.2`, 템플릿마다 따로. `ecdk create --list`) |
325
+ | `template` | `ecdk create`가 적음 | 만든 템플릿과 그 템플릿의 버전 (`quiz@1.4.0`, 템플릿마다 따로. `ecdk create --list`) |
326
326
 
327
327
  `kind` · `screens` · `commentary`를 `"ecdk"`에 적으면 사용 오류(종료 코드 2)로 `metadata.json`에 적으라고 알립니다.
328
328
 
@@ -8,7 +8,7 @@ const usage = `사용법: ecdk create <폴더> [--template ${TEMPLATES.join('|')
8
8
 
9
9
  학생 화면 · 교육자 화면 · 내용 편집(CMS) 화면, 화면 키트(lib/), metadata.json, package.json이 든 프로젝트를 만들고
10
10
  npm install을 실행한다. SDK(@eliceio/cdk)는 package.json 의존성이다 (node_modules에 설치, 네트워크 필요).
11
- quiz: 한 문항 퀴즈(여러 문항은 페이지를 여러 개로, 선택 · 순서 · 주관식 · 그룹 분류, 편집 화면 포함, 기본)
11
+ quiz: 퀴즈(문항 20개까지, 모두 맞혀야 100점, 선택 · 순서 · 주관식 · 그룹 분류, 편집 화면 포함, 기본)
12
12
  blank: 퀴즈가 아닌 모든 자료(시뮬레이션 · 시각화 · 활동 · 설명 · 플래시카드 · 설문)를 직접 만들 때. 화면 3개 골격
13
13
  --list: 템플릿 목록과 버전 · 설명 (템플릿마다 버전이 따로 있음)
14
14
  --theme dark: Elice Design System 어두운 화면 (기본 light)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eliceio/cdk-cli",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "교육자용 Custom HTML 콘텐츠 CLI",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
@@ -46,7 +46,7 @@
46
46
  "rollup": "^4.0.0",
47
47
  "tslib": "^2.6.1",
48
48
  "typescript": "~5.9.3",
49
- "@eliceio/cdk": "^1.2.0"
49
+ "@eliceio/cdk": "^1.2.1"
50
50
  },
51
51
  "scripts": {
52
52
  "prebuild": "del-cli \"buildcache/*\" \"es/*\"",
@@ -1,6 +1,6 @@
1
1
  # 3. Create the project
2
2
 
3
- Run `ecdk create --list` first: it prints each template with its own version (`quiz@1.3.2`), what it is for and its screens. Pick the template from that list. `ecdk create` records the template and version in `package.json` `"ecdk"` (`template`), `ecdk build` copies it to `metadata.json` `build.template`, and `ecdk doctor` says when the installed ecdk ships a newer version of that template (nothing changes on its own).
3
+ Run `ecdk create --list` first: it prints each template with its own version (`quiz@1.4.0`), what it is for and its screens. Pick the template from that list. `ecdk create` records the template and version in `package.json` `"ecdk"` (`template`), `ecdk build` copies it to `metadata.json` `build.template`, and `ecdk doctor` says when the installed ecdk ships a newer version of that template (nothing changes on its own).
4
4
 
5
5
  | Case | Start with |
6
6
  | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
@@ -37,13 +37,13 @@ Next time, read it, confirm the page with the person as above (기관 · 과목
37
37
 
38
38
  1. **Does the server take it?** Look at the input schema of `save_draft` (and `update_material`): use `settings` only when the schema lists it as a key of `payload` (or, on an older server, as a top-level parameter). The same holds for `completion_policy`, `title` and `icon`. If no tool has it, use the fallback below. Never guess another argument or tool name.
39
39
  2. **Only this project's file.** Use `<project>/.ecdk/settings.json` of the project you just built, never a file from another project or copied for another material. If the person changed the target page or project since, ask again.
40
- 3. **Checked by the edit screen.** It must be what the edit screen saved, so its own validation ran (the quiz edit screen checks every answer and builds the regex): the person opens the edit view in `ecdk dev`, checks the content and saves with the edit screen's button (the quiz template: "편집 완료"); the dev log prints "내용을 .ecdk/settings.json에 저장했습니다". If you wrote or changed the file by hand (`references/09-check.md`), that save must happen before the upload. Then check the shape: a JSON object, content keys at the top level (not wrapped in `content`), `grading` only when graded. The quiz: `{ "title": …, "questions": [ … ] }` with `grading` `{ "type": "pattern", "answer_key": "^…$" }`.
40
+ 3. **Checked by the edit screen.** It must be what the edit screen saved, so its own validation ran (the quiz edit screen checks every answer and builds the regex): the person opens the edit view in `ecdk dev`, checks the content and saves with the edit screen's button (the quiz template: "초안에 반영"); the dev log prints "내용을 .ecdk/settings.json에 저장했습니다". If you wrote or changed the file by hand (`references/09-check.md`), that save must happen before the upload. Then check the shape: a JSON object, content keys at the top level (not wrapped in `content`), `grading` only when graded. The quiz: `{ "title": …, "questions": [ … ] }` with `grading` `{ "type": "pattern", "answer_key": "^…$" }`.
41
41
  4. **Whole replace: compare first.** `settings` replaces the page's settings as a whole (the content keys and `grading`); nothing is merged. On a page that already has a version, read its settings with `get_material` and compare them with the local file. If keys would disappear, or the content saved in LXP differs from the file (an instructor edited it in LXP after the last upload), show a short summary of the difference (which keys or items, the title, the number of questions; never answer values) and ask before overwriting. The person may prefer to keep LXP's content: then send no `settings`. A first upload to a new page needs no comparison.
42
42
  5. **Summary and an explicit yes.** Before the upload, show what goes with it: the title, the number of questions or items, and whether answers are included (`grading.type`, `pattern` or `rubric`), but never the answer values (`answer_key`, `rubric`). The answers must be ones the person confirmed (Always: ask before you settle correct answers). Send it only after an explicit yes; a no means the fallback.
43
43
  6. **Send** it as `payload.settings` with the save (`save_draft` above), with the completion policy the person agreed to (below). Then check it with `get_material` (or `get_draft` when the draft shows it before saving) as in the table.
44
44
  7. **No settings file?** Suggest filling the edit view in `ecdk dev` first and saving, so the upload carries it, or skip it (the person enters the content in the LXP edit screen later).
45
45
 
46
- **Fallback (the server has no `settings`, the person said no, or there is no file)**: upload the zip only, without content or `grading`, and without `on_graded` (see "Completion policy"). After saving, tell the person to open the LXP edit page, enter the content and answers on the edit screen (`settings`, with `settings.grading` for `on_graded`) and save with the edit screen's own button (the quiz template: "편집 완료"). That saves to the draft; learners see it only after '수업 자료에 반영' at the top of the LXP edit page.
46
+ **Fallback (the server has no `settings`, the person said no, or there is no file)**: upload the zip only, without content or `grading`, and without `on_graded` (see "Completion policy"). After saving, tell the person to open the LXP edit page, enter the content and answers on the edit screen (`settings`, with `settings.grading` for `on_graded`) and save with the edit screen's own button (the quiz template: "초안에 반영"). That saves to the draft; learners see it only after '수업 자료에 반영' at the top of the LXP edit page.
47
47
 
48
48
  **Uploading a zip by hand in LXP**: on the LXP edit page, ⋮ › '다른 파일로 변경', pick the zip, then '수업 자료에 반영'.
49
49
 
@@ -797,8 +797,8 @@ const GRADING_TEXT = {
797
797
  emptyRubric: '평가 기준을 입력해 주세요.',
798
798
  };
799
799
 
800
- /** 정답 정규식 길이 상한 (서버에 보내는 값, 너무 긴 정규식은 막는다) */
801
- export const ANSWER_KEY_MAX = 5000;
800
+ /** 정답 정규식 길이 상한. 서버(elice-material grading.py _REGEX_MAX_LENGTH)와 같게: 넘으면 서버가 저장을 거절한다 */
801
+ export const ANSWER_KEY_MAX = 500;
802
802
  /** 정답 정규식 한 번 맞춰 보는 시간 상한(ms). 넘으면 ReDoS 위험으로 막는다 */
803
803
  const REGEX_TIME_LIMIT_MS = 50;
804
804
 
@@ -26,7 +26,7 @@ core/ 동작 — 고치지 않습니다 (답 문자열 · 채점 약속,
26
26
  | 바꾸고 싶은 것 | 고치는 곳 |
27
27
  | -------------------------------------------- | ------------------------------------------------------------------------- |
28
28
  | 색 · 간격 · 모서리 | `ui/theme.css`의 `--qz-*` 변수 (예: `--qz-accent`, `--qz-option-padding`) |
29
- | 문구 ("정답", "편집 완료", 탭 제목 등) | `ui/texts.js` (HTML의 제목 · "불러오는 중"은 스크립트가 돌기 전 대비용) |
29
+ | 문구 ("정답", "초안에 반영", 탭 제목 등) | `ui/texts.js` (HTML의 제목 · "불러오는 중"은 스크립트가 돌기 전 대비용) |
30
30
  | 보기 카드 마크업 | `ui/templates/choice.js` (모양은 `styles.css`의 `.qz-option`) |
31
31
  | 문항 겉모양 · 결과 · 해설 자리 | `ui/templates/question.js` |
32
32
  | 순서 맞추기 · 그룹 분류 배치 | `ui/templates/order.js` · `ui/templates/group.js` |
@@ -93,7 +93,7 @@ app.useSave({ getContent, validate });
93
93
  ## 퀴즈 데이터와 정답
94
94
 
95
95
  - 문항은 편집 화면에서 만들어 저장한 내용(`settings`)뿐입니다. 처음에는 문항이 없어 편집 화면은 **문항 추가**로 시작하고, 저장하기 전 학생 화면은 "아직 내용이 없습니다" 안내를 보입니다. 형식은 ecdk 문서 ADR 0006.
96
- - 퀴즈 하나에 문항은 **하나**입니다 (기존 LXP 퀴즈처럼). 문항이 있으면 "문항 추가" 대신 안내가 보이고, 여러 문항은 퀴즈 페이지를 여러 개 만듭니다. 이미 여러 문항으로 저장된 퀴즈도 그대로 보이고 저장됩니다.
96
+ - 퀴즈 하나에 문항은 **20개까지** 넣습니다. **모든 문항을 맞혀야 100점**이고 부분 점수는 없습니다 (정답 하나가 `^q1=…;q2=…$` 정규식 하나라서). 20개가 차면 "문항 추가" 대신 안내가 보입니다. 정답 정규식은 퀴즈 전체가 500자(서버 한도)까지라, 한글 주관식은 한 글자가 9자로 늘어 정답 · 유사 정답이 많으면 4~5문항에서 한도에 닿습니다. 넘으면 저장할 때 가장 긴 문항에 "정답이 너무 깁니다"가 보입니다.
97
97
  - 문항 유형: 단일 선택 · 복수 선택 · 순서 맞추기 · 주관식 · 그룹 분류
98
98
  - 학생 답은 문자열 하나로 제출합니다: 문항 순서대로 `문항id=답`을 `;`로 잇고 주관식은 URL 인코딩 (`q1=b;q2=a,d;q4=%EA%B0%80…`).
99
99
  - 퀴즈는 채점 방식 **기준 답안(pattern)** 고정이고, 모든 문항을 맞혀야 100점입니다 (문항별 점수 없음, ADR 0009). 편집 화면은 답(`settings.grading`)만 저장합니다. 완료 정책은 LXP 페이지 설정입니다 (ADR 0012): publish 스킬이 동의를 받아 업로드 때 정하거나 교육자가 LXP 편집 페이지 위쪽 '설정' 패널에서 고릅니다. 퀴즈는 **채점해 통과하면 완료(on_graded)**여야 채점합니다. 제출하면 완료(on_submit)면 서버가 채점하지 않고 제출만으로 완료되어 점수 없이 "제출했어요."가 보입니다.
@@ -28,6 +28,34 @@ export function createEditor({ rerender, root, templates, labels }) {
28
28
  );
29
29
  }
30
30
 
31
+ /**
32
+ * 라벨 없는 바로 쓰는 칸 (ui.inlineField). field와 같이 값을 넣고 고치면 onInput(값).
33
+ * 여러 줄 칸은 글에 맞춰 높이가 늘고, 필수 칸은 글을 쓰면 오류 표시(aria-invalid)를 지운다
34
+ * @param {{ placeholder: string, size?: 'title' | 'question' | 'body', required?: boolean, max?: number, multiline?: boolean }} opts
35
+ */
36
+ function inlineField(label, value, onInput, opts) {
37
+ const node = bindField(ui.inlineField({ label, ...opts }), value, onInput, opts.max);
38
+ const input = part(node, 'input');
39
+ input.addEventListener('input', () => input.removeAttribute('aria-invalid'));
40
+ if (opts.multiline) {
41
+ const fit = () => {
42
+ input.style.height = 'auto';
43
+ input.style.height = `${input.scrollHeight}px`;
44
+ };
45
+ input.addEventListener('input', fit);
46
+ // 화면에 붙은 뒤에야 높이를 잴 수 있다
47
+ requestAnimationFrame(fit);
48
+ }
49
+ return node;
50
+ }
51
+
52
+ /** 비어 있는 필수 바로 쓰는 칸에 오류 표시를 붙이고 첫 칸을 돌려준다 (저장 전 검증에 걸렸을 때) */
53
+ function markEmptyRequired() {
54
+ const empty = [...root.querySelectorAll('[data-required]')].filter((i) => !i.value.trim());
55
+ for (const input of empty) input.setAttribute('aria-invalid', 'true');
56
+ return empty[0] ?? null;
57
+ }
58
+
31
59
  function bindField(node, value, onInput, max) {
32
60
  const input = part(node, 'input');
33
61
  const count = part(node, 'count');
@@ -52,15 +80,66 @@ export function createEditor({ rerender, root, templates, labels }) {
52
80
  return node;
53
81
  }
54
82
 
55
- /** 켜고 끄기 */
56
- function toggle(label, checked, onChange) {
57
- const node = ui.toggle({ label });
83
+ /** 켜고 끄기. title: 마우스를 올리면 보이는 보충 설명 */
84
+ function toggle(label, checked, onChange, title, icon) {
85
+ const node = ui.toggle({ label, title, icon });
58
86
  const input = part(node, 'input');
59
87
  input.checked = Boolean(checked);
60
88
  input.addEventListener('change', () => onChange(input.checked));
61
89
  return node;
62
90
  }
63
91
 
92
+ /**
93
+ * 필요할 때만 여는 칸. open이 아니면 "+ …" 버튼만 보이고, 누르면 칸이 열려 초점이 간다.
94
+ * 비운 채 칸을 벗어나면 다시 닫는다. 여닫는 것만으로는 다시 그리거나 "변경" 표시를 만들지 않는다
95
+ * @param {string} label 열기 버튼 글
96
+ * @param {Element} node 칸 (inlineField가 만든 요소)
97
+ * @param {{ open?: boolean, onOpen?: () => void, onClose?: () => void, title?: string, icon?: string, hint?: string }} [opts]
98
+ * title가 있으면 열린 칸을 머리줄(아이콘 · 제목 · 지우기)이 있는 카드로 보인다
99
+ */
100
+ function revealable(label, node, { open = false, onOpen, onClose, title, icon, hint } = {}) {
101
+ const wrap = ui.reveal({ label, field: node, title, icon, hint });
102
+ const button = part(wrap, 'reveal');
103
+ const body = part(wrap, 'reveal-body');
104
+ const input = part(node, 'input');
105
+ const fit = () => {
106
+ if (input.tagName !== 'TEXTAREA') return;
107
+ input.style.height = 'auto';
108
+ input.style.height = `${input.scrollHeight}px`;
109
+ };
110
+ const show = () => {
111
+ button.hidden = true;
112
+ body.hidden = false;
113
+ fit();
114
+ };
115
+ const hide = () => {
116
+ body.hidden = true;
117
+ button.hidden = false;
118
+ };
119
+ button.addEventListener('click', () => {
120
+ show();
121
+ onOpen?.();
122
+ input.focus();
123
+ });
124
+ input.addEventListener('blur', () => {
125
+ // 창을 옮겨 초점을 잃은 경우(초점 요소가 그대로)는 닫지 않는다
126
+ if (input.value.trim() || document.activeElement === input) return;
127
+ hide();
128
+ onClose?.();
129
+ });
130
+ // 내용이 있어도 지우고 닫는다 (비우는 입력을 흘려 보내 데이터에도 반영)
131
+ part(wrap, 'reveal-close').addEventListener('click', () => {
132
+ input.value = '';
133
+ input.dispatchEvent(new Event('input', { bubbles: true }));
134
+ hide();
135
+ onClose?.();
136
+ button.focus();
137
+ });
138
+ if (open) button.hidden = true;
139
+ else body.hidden = true;
140
+ return wrap;
141
+ }
142
+
64
143
  /**
65
144
  * 보기 · 그룹 목록 (단일 · 복수 · 순서 · 그룹 공통). 손잡이를 끌어 순서 바꾸기
66
145
  * answer가 있으면 줄마다 정답 칸(data-role="answer")을 둔다: radio(단일) · checkbox(복수) · select(그룹 고르기).
@@ -75,7 +154,7 @@ export function createEditor({ rerender, root, templates, labels }) {
75
154
  * onAdd: 추가한 뒤 할 일 (예: 순서 맞추기 칸 수 늘리기) ·
76
155
  * onDelete: 지운 뒤 할 일 (예: 순서 맞추기 칸 수 줄이기, 정답에서 빼기) · onInput: 글을 고친 뒤 할 일
77
156
  */
78
- function itemList(kind, items, key, { onAdd, onDelete, onInput, answer } = {}) {
157
+ function itemList(kind, items, key, { onAdd, onDelete, onInput, answer, numbered = true } = {}) {
79
158
  const isGroup = kind === 'group';
80
159
  const text = isGroup ? 'name' : 'text';
81
160
  const min = isGroup ? LIMITS.groupsMin : LIMITS.optionsMin;
@@ -86,6 +165,7 @@ export function createEditor({ rerender, root, templates, labels }) {
86
165
  index: i,
87
166
  canDelete: items.length > min,
88
167
  min,
168
+ numbered,
89
169
  answer: answer && { type: answer.type, name: answer.name, choices: answer.choices },
90
170
  });
91
171
  row.dataset.role = 'row';
@@ -193,6 +273,59 @@ export function createEditor({ rerender, root, templates, labels }) {
193
273
  });
194
274
  }
195
275
 
276
+ /**
277
+ * 상자 사이로 끌어 옮기는 손잡이 (마우스 · 터치 공용 Pointer Events). 끄는 동안 놓을 수 있는 상자에 data-over가 붙고,
278
+ * 놓으면 onDrop(상자, 그 앞에 둘 행 또는 null). 키보드: 손잡이에서 ↑ · ↓ → onKey(-1 | 1)
279
+ * @param {Element} handle 끌기 손잡이
280
+ * @param {Element} row 옮기는 행 (끄는 동안 data-dragging)
281
+ * @param {{ boxSelector: string, onDrop: (box: Element, before: Element | null) => void, onKey: (dir: -1 | 1) => void }} on
282
+ */
283
+ function dragAcross(handle, row, { boxSelector, onDrop, onKey }) {
284
+ handle.addEventListener('keydown', (e) => {
285
+ const d = { ArrowUp: -1, ArrowDown: 1 }[e.key];
286
+ if (!d) return;
287
+ e.preventDefault();
288
+ onKey(d);
289
+ });
290
+ handle.addEventListener('pointerdown', (down) => {
291
+ if (down.button !== 0) return;
292
+ down.preventDefault();
293
+ handle.setPointerCapture(down.pointerId);
294
+ row.dataset.dragging = '';
295
+ let over = null;
296
+ const boxAt = (e) => {
297
+ const hit = document.elementsFromPoint(e.clientX, e.clientY).find((el) => !row.contains(el));
298
+ return hit?.closest(boxSelector) ?? null;
299
+ };
300
+ const onMove = (e) => {
301
+ row.style.transform = `translate(${e.clientX - down.clientX}px, ${e.clientY - down.clientY}px)`;
302
+ const box = boxAt(e);
303
+ if (box === over) return;
304
+ over?.removeAttribute('data-over');
305
+ over = box;
306
+ over?.setAttribute('data-over', '');
307
+ };
308
+ const end = (e) => {
309
+ handle.removeEventListener('pointermove', onMove);
310
+ handle.removeEventListener('pointerup', end);
311
+ handle.removeEventListener('pointercancel', end);
312
+ delete row.dataset.dragging;
313
+ row.style.transform = '';
314
+ over?.removeAttribute('data-over');
315
+ if (e.type !== 'pointerup' || !over) return;
316
+ const rows = [...over.querySelectorAll('[data-role="row"]')].filter((r) => r !== row);
317
+ const before = rows.find((r) => {
318
+ const b = r.getBoundingClientRect();
319
+ return e.clientY < b.top + b.height / 2;
320
+ });
321
+ onDrop(over, before ?? null);
322
+ };
323
+ handle.addEventListener('pointermove', onMove);
324
+ handle.addEventListener('pointerup', end);
325
+ handle.addEventListener('pointercancel', end);
326
+ });
327
+ }
328
+
196
329
  /**
197
330
  * 문항 카드: 유형 바꾸기 · 위로 · 아래로 · 삭제를 붙인다. on: { type(값), up(), down(), remove() }
198
331
  */
@@ -218,9 +351,13 @@ export function createEditor({ rerender, root, templates, labels }) {
218
351
  return {
219
352
  ui,
220
353
  field,
354
+ inlineField,
355
+ markEmptyRequired,
221
356
  numberField,
222
357
  toggle,
358
+ revealable,
223
359
  itemList,
360
+ dragAcross,
224
361
  card,
225
362
  addQuestion,
226
363
  /** 검증에 걸린 문항 카드 */
@@ -19,8 +19,8 @@ export const LIMITS = {
19
19
  optionsMax: 20,
20
20
  groupsMin: 2,
21
21
  groupsMax: 6,
22
- // 퀴즈 하나에 문항 하나 (기존 LXP처럼). 여러 문항은 퀴즈 페이지를 여러 개로 → 부분 점수가 필요 없음
23
- questionsMax: 1,
22
+ // 여러 문항 퀴즈: 문항 20개까지. 모든 문항을 맞혀야 100점 (부분 점수 없음)
23
+ questionsMax: 20,
24
24
  };
25
25
 
26
26
  /** 편집 화면에서 문항을 더 넣을 수 있는지. 이미 여러 문항으로 저장된 퀴즈도 그대로 보이고 저장되며, 더 넣는 것만 막는다 */
@@ -65,7 +65,8 @@ export function convertType(q, type, names) {
65
65
  text: names.option(options.length + 1),
66
66
  });
67
67
  next.options = options;
68
- next.shuffle = Boolean(q.shuffle);
68
+ // 순서 맞추기는 정답 순서대로 적으므로 학생에게는 섞어 보이는 게 기본 (이미 정한 값이 있으면 그대로)
69
+ next.shuffle = q.shuffle === undefined ? type === 'order' : Boolean(q.shuffle);
69
70
  } else {
70
71
  delete next.options;
71
72
  delete next.shuffle;