@eliceio/cdk-cli 1.2.1 → 1.3.0-contenttypes.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.
Files changed (169) hide show
  1. package/README.md +63 -53
  2. package/es/cli.js +11 -2
  3. package/es/commands/build/index.js +12 -0
  4. package/es/commands/create/index.js +2 -0
  5. package/es/commands/create/scaffold.d.ts +2 -2
  6. package/es/commands/create/scaffold.js +3 -3
  7. package/es/commands/dev/index.d.ts +10 -1
  8. package/es/commands/dev/index.js +47 -7
  9. package/es/commands/doctor/index.js +6 -2
  10. package/es/core/config.d.ts +42 -9
  11. package/es/core/config.js +217 -12
  12. package/es/core/project-check.d.ts +3 -2
  13. package/es/core/project-check.js +14 -3
  14. package/es/core/regex.d.ts +11 -0
  15. package/es/core/regex.js +41 -0
  16. package/es/core/sandbox.d.ts +26 -0
  17. package/es/core/sandbox.js +240 -30
  18. package/es/dev/assets.d.ts +80 -0
  19. package/es/dev/assets.js +240 -0
  20. package/es/dev/check.d.ts +30 -0
  21. package/es/dev/check.js +224 -34
  22. package/es/dev/grading.d.ts +49 -14
  23. package/es/dev/grading.js +109 -29
  24. package/es/dev/host-page.js +27 -3
  25. package/es/dev/inject.d.ts +2 -1
  26. package/es/dev/inject.js +10 -2
  27. package/es/dev/mock-api.d.ts +26 -3
  28. package/es/dev/mock-api.js +219 -40
  29. package/es/dev/server.d.ts +12 -1
  30. package/es/dev/server.js +115 -9
  31. package/es/engines/vite/index.js +1 -1
  32. package/es/engines/vite/plugin.d.ts +2 -0
  33. package/es/engines/vite/plugin.js +33 -5
  34. package/es/rules/answers.d.ts +13 -0
  35. package/es/rules/answers.js +94 -0
  36. package/es/rules/check.js +70 -1
  37. package/es/rules/index.d.ts +1 -0
  38. package/es/rules/index.js +1 -0
  39. package/es/rules/size.d.ts +31 -0
  40. package/es/rules/size.js +58 -0
  41. package/es/rules/types.d.ts +12 -0
  42. package/es/rules.json.js +2 -2
  43. package/package.json +2 -2
  44. package/rules.json +34 -5
  45. package/skills/_shared/always.md +3 -3
  46. package/skills/_shared/references/00-what-the-person-decides.md +1 -1
  47. package/skills/_shared/references/02-design-the-material.md +10 -7
  48. package/skills/_shared/references/03-create-the-project.md +10 -8
  49. package/skills/_shared/references/04-rules.md +1 -1
  50. package/skills/_shared/references/05-screen-code.md +52 -23
  51. package/skills/_shared/references/06-using-the-quiz-template.md +7 -6
  52. package/skills/_shared/references/08-fix-check-errors.md +23 -22
  53. package/skills/_shared/references/09-check.md +8 -6
  54. package/skills/_shared/references/12-upload-with-the-material-mcp.md +13 -13
  55. package/skills/_shared/references/13-edit-screen-design.md +122 -0
  56. package/skills/_shared/references/14-layouts.md +96 -0
  57. package/skills/elice-content-check/SKILL.md +2 -2
  58. package/skills/elice-content-create/SKILL.md +1 -1
  59. package/skills/elice-content-migrate/SKILL.md +1 -1
  60. package/skills/elice-content-publish/SKILL.md +1 -1
  61. package/templates/_shared/lib/cdk-mock.d.ts +47 -3
  62. package/templates/_shared/lib/cdk-mock.js +293 -15
  63. package/templates/_shared/lib/elice-content-editor.js +89 -58
  64. package/templates/_shared/lib/elice-content.css +1313 -126
  65. package/templates/_shared/lib/elice-content.d.ts +222 -23
  66. package/templates/_shared/lib/elice-content.js +1176 -88
  67. package/templates/_shared/lib/icons/empty-content.d.ts +2 -0
  68. package/templates/_shared/lib/icons/empty-content.js +11 -0
  69. package/templates/_shared/lib/icons/file-video.d.ts +2 -0
  70. package/templates/_shared/lib/icons/file-video.js +11 -0
  71. package/templates/_shared/lib/icons/file.d.ts +2 -0
  72. package/templates/_shared/lib/icons/file.js +11 -0
  73. package/templates/blank/README.md +6 -4
  74. package/templates/blank/edit.html +8 -2
  75. package/templates/blank/index.html +6 -1
  76. package/templates/blank/instructor.html +6 -1
  77. package/templates/blank/screens/instructor.js +8 -2
  78. package/templates/blank/screens/learn.js +1 -1
  79. package/templates/blank/template.json +1 -1
  80. package/templates/document/README.md +92 -0
  81. package/templates/document/commentary.txt +2 -0
  82. package/templates/document/core/dom.d.ts +13 -0
  83. package/templates/document/core/dom.js +83 -0
  84. package/templates/document/core/file-type.d.ts +21 -0
  85. package/templates/document/core/file-type.js +85 -0
  86. package/templates/document/core/group-3d.d.ts +20 -0
  87. package/templates/document/core/group-3d.js +256 -0
  88. package/templates/document/core/inline-edit.d.ts +15 -0
  89. package/templates/document/core/inline-edit.js +377 -0
  90. package/templates/document/core/load.d.ts +13 -0
  91. package/templates/document/core/load.js +40 -0
  92. package/templates/document/core/pdf-options.d.ts +9 -0
  93. package/templates/document/core/pdf-options.js +36 -0
  94. package/templates/document/core/pdf-worker.d.ts +24 -0
  95. package/templates/document/core/pdf-worker.js +122 -0
  96. package/templates/document/core/pdf.d.ts +12 -0
  97. package/templates/document/core/pdf.js +190 -0
  98. package/templates/document/core/pptx-edit.d.ts +14 -0
  99. package/templates/document/core/pptx-edit.js +137 -0
  100. package/templates/document/core/pptx-fonts.d.ts +5 -0
  101. package/templates/document/core/pptx-fonts.js +115 -0
  102. package/templates/document/core/pptx-media.d.ts +18 -0
  103. package/templates/document/core/pptx-media.js +83 -0
  104. package/templates/document/core/pptx-view.d.ts +5 -0
  105. package/templates/document/core/pptx-view.js +185 -0
  106. package/templates/document/core/settings.d.ts +25 -0
  107. package/templates/document/core/settings.js +86 -0
  108. package/templates/document/core/slide-edges.d.ts +3 -0
  109. package/templates/document/core/slide-edges.js +82 -0
  110. package/templates/document/core/viewer.d.ts +28 -0
  111. package/templates/document/core/viewer.js +159 -0
  112. package/templates/document/edit.html +17 -0
  113. package/templates/document/gitignore +4 -0
  114. package/templates/document/index.html +18 -0
  115. package/templates/document/metadata.json +9 -0
  116. package/templates/document/package.json +17 -0
  117. package/templates/document/public/fonts/OFL-Caladea.txt +93 -0
  118. package/templates/document/public/fonts/OFL-Carlito.txt +93 -0
  119. package/templates/document/public/fonts/caladea-latin-400-normal.woff2 +0 -0
  120. package/templates/document/public/fonts/caladea-latin-700-normal.woff2 +0 -0
  121. package/templates/document/public/fonts/carlito-latin-400-normal.woff2 +0 -0
  122. package/templates/document/public/fonts/carlito-latin-700-normal.woff2 +0 -0
  123. package/templates/document/screens/edit.js +574 -0
  124. package/templates/document/screens/learn.js +61 -0
  125. package/templates/document/styles.css +644 -0
  126. package/templates/document/template.json +6 -0
  127. package/templates/document/ui/templates/edit.js +82 -0
  128. package/templates/document/ui/templates/page.js +11 -0
  129. package/templates/document/ui/templates/viewer.js +41 -0
  130. package/templates/document/ui/texts.d.ts +3 -0
  131. package/templates/document/ui/texts.js +62 -0
  132. package/templates/document/ui/theme.css +69 -0
  133. package/templates/quiz/README.md +32 -14
  134. package/templates/quiz/core/behaviors.d.ts +17 -7
  135. package/templates/quiz/core/behaviors.js +40 -53
  136. package/templates/quiz/core/editor.d.ts +27 -2
  137. package/templates/quiz/core/editor.js +412 -11
  138. package/templates/quiz/core/markdown.d.ts +19 -0
  139. package/templates/quiz/core/markdown.js +225 -11
  140. package/templates/quiz/core/model.d.ts +40 -3
  141. package/templates/quiz/core/model.js +112 -5
  142. package/templates/quiz/core/rich-text.d.ts +18 -0
  143. package/templates/quiz/core/rich-text.js +469 -0
  144. package/templates/quiz/edit.html +12 -3
  145. package/templates/quiz/index.html +12 -3
  146. package/templates/quiz/public/img/mascot-half.webp +0 -0
  147. package/templates/quiz/screens/edit.js +331 -49
  148. package/templates/quiz/screens/learn.js +147 -15
  149. package/templates/quiz/styles.css +1244 -622
  150. package/templates/quiz/template.json +9 -2
  151. package/templates/quiz/ui/templates/edit.d.ts +19 -5
  152. package/templates/quiz/ui/templates/edit.js +371 -77
  153. package/templates/quiz/ui/templates/group.js +19 -8
  154. package/templates/quiz/ui/templates/order.js +25 -24
  155. package/templates/quiz/ui/templates/page.js +33 -8
  156. package/templates/quiz/ui/templates/question.js +6 -4
  157. package/templates/quiz/ui/texts.js +91 -26
  158. package/templates/quiz/ui/theme.css +8 -9
  159. package/templates/steps/README.md +77 -0
  160. package/templates/steps/commentary.txt +7 -0
  161. package/templates/steps/edit.html +21 -0
  162. package/templates/steps/gitignore +4 -0
  163. package/templates/steps/index.html +69 -0
  164. package/templates/steps/metadata.json +9 -0
  165. package/templates/steps/package.json +13 -0
  166. package/templates/steps/screens/edit.js +32 -0
  167. package/templates/steps/screens/learn.js +108 -0
  168. package/templates/steps/styles.css +54 -0
  169. package/templates/steps/template.json +6 -0
package/rules.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.12.0",
2
+ "version": "0.18.0",
3
3
  "manifest": {
4
4
  "file": "metadata.json",
5
5
  "kinds": ["material", "description"],
@@ -10,7 +10,7 @@
10
10
  "material": ["learn", "instructor", "edit"],
11
11
  "description": ["learn"]
12
12
  },
13
- "graderTypes": ["pattern", "rubric"],
13
+ "graderTypes": ["pattern", "partial_pattern", "rubric"],
14
14
  "commentaryFile": "commentary.txt",
15
15
  "defaultEntry": "index.html"
16
16
  },
@@ -21,13 +21,18 @@
21
21
  "minVersions": {
22
22
  "sdk": "1.0.0-alpha.4"
23
23
  },
24
+ "layouts": {
25
+ "content": ["single", "split", "stage", "media"],
26
+ "regions": ["main", "aside", "stage", "controls", "readout", "actions"]
27
+ },
24
28
  "limits": {
25
29
  "maxZipBytes": 20971520,
26
30
  "maxUnpackedBytes": 209715200,
27
31
  "maxFiles": 300,
28
32
  "maxEntries": 3000,
29
33
  "warnRatio": 0.8,
30
- "maxImageBytes": 1048576
34
+ "maxImageBytes": 1048576,
35
+ "maxScreenBytes": 1572864
31
36
  },
32
37
  "allowedExtensions": [
33
38
  "html",
@@ -118,7 +123,7 @@
118
123
  },
119
124
  {
120
125
  "id": "api.external-send",
121
- "pattern": "\\b(?:fetch|sendBeacon|EventSource|WebSocket)\\s*\\(\\s*['\"`](?:https?|wss?):\\/\\/|\\.open\\(\\s*['\"`][A-Za-z]+['\"`]\\s*,\\s*['\"`]https?:\\/\\/",
126
+ "pattern": "(?<!\\bmlapi\\??\\.)\\b(?:fetch|sendBeacon|EventSource|WebSocket)\\s*\\(\\s*['\"`](?:https?|wss?):\\/\\/|\\.open\\(\\s*['\"`][A-Za-z]+['\"`]\\s*,\\s*['\"`]https?:\\/\\/",
122
127
  "title": "외부 주소로 요청을 보냄 (학생 정보 유출 위험)"
123
128
  },
124
129
  {
@@ -138,7 +143,7 @@
138
143
  },
139
144
  {
140
145
  "id": "sandbox.fetch-local",
141
- "pattern": "\\bfetch\\(\\s*(['\"`])(?![a-z][a-z0-9+.-]*:|//)[^'\"`]*(?<!\\.json)\\1|\\bimport\\(\\s*(?!['\"`])[A-Za-z_$]|\\bnew\\s+(?:Shared)?Worker\\(\\s*['\"`](?![a-z][a-z0-9+.-]*:|//)",
146
+ "pattern": "(?<!\\bmlapi\\??\\.)\\bfetch\\(\\s*(['\"`])(?![a-z][a-z0-9+.-]*:|//)[^'\"`]*(?<!\\.json)\\1|\\bimport\\(\\s*(?!['\"`])[A-Za-z_$]|\\bnew\\s+(?:Shared)?Worker\\(\\s*['\"`](?![a-z][a-z0-9+.-]*:|//)",
142
147
  "title": "zip 안 파일을 fetch · 변수 import() · Worker로 읽음 (콘텐츠 서버의 sandbox 헤더에 allow-same-origin이 없으면 CORS로 막힘)"
143
148
  }
144
149
  ],
@@ -419,6 +424,12 @@
419
424
  "scope": "client",
420
425
  "title": "한도에 가까움"
421
426
  },
427
+ {
428
+ "id": "limit.screen-size",
429
+ "level": "warn",
430
+ "scope": "client",
431
+ "title": "화면 하나를 열 때 받는 JS · CSS가 큼 (기준 limits.maxScreenBytes, 큰 라이브러리는 import()로)"
432
+ },
422
433
  {
423
434
  "id": "path.unsafe",
424
435
  "level": "error",
@@ -509,6 +520,18 @@
509
520
  "scope": "client",
510
521
  "title": "metadata.json build.template이 이 ecdk가 모르는 템플릿이거나 더 새 템플릿 버전"
511
522
  },
523
+ {
524
+ "id": "layout.unknown",
525
+ "level": "warn",
526
+ "scope": "client",
527
+ "title": "data-ec-layout · data-ec-region에 키트가 모르는 값 (single · split · stage · media, main · aside · stage · controls · readout · actions)"
528
+ },
529
+ {
530
+ "id": "layout.own-step-nav",
531
+ "level": "warn",
532
+ "scope": "client",
533
+ "title": "화면 코드가 이전 · 다음 버튼을 직접 그림 (LXP 이전 · 다음 막대와 헷갈림, 키트 app.useStepper)"
534
+ },
512
535
  {
513
536
  "id": "ref.missing",
514
537
  "level": "error",
@@ -641,6 +664,12 @@
641
664
  "scope": "server",
642
665
  "title": "비밀 값 (키 · 토큰 · 비밀번호)"
643
666
  },
667
+ {
668
+ "id": "sec.answer-in-bundle",
669
+ "level": "warn",
670
+ "scope": "client",
671
+ "title": "편집 화면에 저장한 정답(.ecdk/settings.json 채점 설정)과 같은 글이 zip에 들어갈 파일에 있음 (프로젝트 검사만)"
672
+ },
644
673
  {
645
674
  "id": "sec.html-injection",
646
675
  "level": "warn",
@@ -1,18 +1,18 @@
1
1
  ## Always
2
2
 
3
- - Answer the person in their language. The reference files are in English: `references/` next to this SKILL.md, read only the ones you need with the Read tool: 00 what the person decides · 01 environment · 02 design · 03 create the project · 04 sandbox rules · 05 screen code and kit API · 06 quiz template · 07 move existing HTML · 08 error ids · 09 check · 10 build and report · 11 more · 12 upload.
3
+ - Answer the person in their language. The reference files are in English: `references/` next to this SKILL.md, read only the ones you need with the Read tool: 00 what the person decides · 01 environment · 02 design · 03 create the project · 04 sandbox rules · 05 screen code and kit API · 06 quiz template · 07 move existing HTML · 08 error ids · 09 check · 10 build and report · 11 more · 12 upload · 13 edit screen design · 14 layouts and stepper.
4
4
  - Never put correct answers in the content zip. The edit screen saves them to `settings.grading` (locally `.ecdk/settings.json` from `ecdk dev`, which stays local unless the person agrees to send it with the upload, `references/12-upload-with-the-material-mcp.md`).
5
5
  - The completion policy is not in the project or the zip: it is a setting of the LXP page. Say which one fits (`references/02-design-the-material.md` ②); the elice-content-publish skill sets it with the upload after the person agrees (`on_graded` only with grading saved), otherwise the instructor picks it in the '설정' panel at the top of the LXP edit page. Only `on_graded` grades: `on_submit` completes on any submission without grading (`is_correct: null`, the kit shows "제출했어요."), `on_access` completes on open.
6
6
  - The content runs in a sandboxed iframe on its own origin: use the SDK (`app.useSubmit`, `app.useSave`) for anything that must be kept (storage and cookies stay only in that browser), and in-page UI instead of `alert`/`confirm`, new windows, the parent window or external requests.
7
7
  - The content CSP blocks external images, fonts, video, CSS, `<iframe>` and external APIs: put everything in the zip (fonts as files or data URIs). If a library calls outside hosts while running, that is blocked too → check the `ecdk dev` log for "막힌 외부 요청".
8
8
  - Fix every `ecdk validate` / `ecdk build` error before you report. Do not edit `lib/` (the screen kit). The SDK comes from npm through `package.json` (`npm update @eliceio/cdk`); the kit imports it and `ecdk build` (Vite) bundles it into the screens. Never copy SDK code into the project.
9
9
  - Ask the person before you settle correct answers (they confirm them before answers go with an upload), install anything globally, or upload or save to LXP (a saved version is visible to learners at once). Before uploading, confirm the exact target page (기관 · 과목 · 수업 · 페이지) with the person.
10
- - LXP draws its own 이전 · 다음 bar under the material to move between lecture pages. For steps inside a material use the kit's `app.usePaging` (side chevrons, `n / N`; `references/02-design-the-material.md`), never a look-alike bottom 이전 · 다음 bar.
10
+ - Lay out screens with the kit, not your own frame: a content layout `data-ec-layout` (`single` · `split` · `stage` · `media`) with content in `data-ec-region` boxes, and for steps inside a material the kit stepper `app.useStepper()` with `<section data-ec-step>` (`references/14-layouts.md`). LXP draws its own 이전 · 다음 bar under the material, so never build your own Back/Next buttons, `n / N` or a bottom bar.
11
11
 
12
12
  ## Progress and live preview
13
13
 
14
14
  - At the start, show a short numbered plan (for example `1 설계 → 2 프로젝트 → 3 학생 화면 → 4 편집 화면 → 5 확인 → 6 zip`). Before and after each step write one line: `[3/6] 학생 화면 만드는 중: …` and `[3/6] 끝: … · 다음: …`.
15
15
  - Right after `ecdk create` (or when you start on an existing project), start `ecdk dev <folder>` in the background and give the person the URL it prints (`http://localhost:4170` unless that port is taken), so they watch the screens change while you write code. Claude Code: run it as a background command. Helpy Code: the tool's background option, or `zsh -ilc 'ecdk dev <folder> > /tmp/ecdk-dev.log 2>&1 &'` and read the URL from that log. Do not wait for the person.
16
- - Check screens only with `ecdk dev [folder] --check [--screens learn,tutoring,instructor,edit] [--viewport desktop,mobile] [--json]`. Never write your own browser-automation script (Playwright, Puppeteer, …). After each screen, run it (`--screens <that screen>`), tell the person the result lines, the screenshots `.ecdk/screens/<screen>-<viewport>.png` (Claude Code: Read the PNG to see it; otherwise give the path) and what to try in the browser (it checks only the first state, no clicks or submits). First make sure `ecdk dev --help` lists `--check` (an older ecdk does not have it). To see the student screen with content, write sample content to `.ecdk/settings.json` first (`references/09-check.md`). Exit 1: fix and run again (at most twice). Exit 3 (no browser), an unknown option (an older ecdk) or a problem you cannot fix: stop checking and ask the person to look at the dev URL (`references/09-check.md`).
16
+ - Check screens only with `ecdk dev [folder] --check [--screens learn,tutoring,instructor,edit] [--viewport desktop,mobile] [--step all] [--theme all] [--json]`. Never write your own browser-automation script (Playwright, Puppeteer, …). After each screen, run it (`--screens <that screen>`), tell the person the result lines, the screenshots `.ecdk/screens/<screen>-<viewport>.png` (Claude Code: Read the PNG to see it; otherwise give the path) and what to try in the browser (it checks only the first state, no clicks or submits). First make sure `ecdk dev --help` lists `--check` (an older ecdk does not have it). To see the student screen with content, write sample content to `.ecdk/settings.json` first (`references/09-check.md`). Exit 1: fix and run again (at most twice). Exit 3 (no browser), an unknown option (an older ecdk) or a problem you cannot fix: stop checking and ask the person to look at the dev URL (`references/09-check.md`).
17
17
  - While `ecdk dev` runs, do not run `ecdk validate` again and again: dev checks again on every change and `--check` prints the validation summary. Run `ecdk validate` once before building (or let `ecdk build` check).
18
18
  - If `ecdk`, `node` or `npm` is "command not found", the app started without the person's shell PATH (macOS desktop apps such as Helpy Code Desktop). Find the paths once with `"$SHELL" -ilc 'command -v ecdk node npm'` (`zsh -ilc` when `$SHELL` is empty), then run commands with absolute paths and node's folder first on PATH: `PATH="/opt/homebrew/bin:$PATH" /opt/homebrew/bin/ecdk build --json`. If that fails, run the command through the login shell (`"$SHELL" -ilc 'ecdk build --json'`; with `--json` read only the last JSON block). If that also fails, ask the person how Node was installed.
@@ -4,7 +4,7 @@ The person (the instructor or author) is responsible for the content and its ans
4
4
 
5
5
  1. **The learning goal, when it is unclear.** Decide the rest of the design to fit the goal and tell the person briefly what you decided.
6
6
  2. **Correct answers.** You may draft answers and rubrics, but the person confirms that they are right, before they go with an upload.
7
- 3. **How it is graded**: whether the student submits, and the grader (`pattern` or `rubric`) set on the edit screen. Propose what fits the material and get a confirmation. **The completion policy**: propose the one that fits (the table in 2 ②) and get a yes before the upload sets it (2026-11-12: the publish skill can set it with the save; otherwise the instructor picks it in the '설정' panel at the top of the LXP edit page). Only `on_graded` grades: `on_submit` completes on any submission without grading (`is_correct: null`, the kit shows "제출했어요."), `on_access` completes on open.
7
+ 3. **How it is graded**: whether the student submits, and the grader (`pattern`, `partial_pattern` for a score per question, or `rubric`) set on the edit screen. Propose what fits the material and get a confirmation. **The completion policy**: propose the one that fits (the table in 2 ②) and get a yes before the upload sets it (2026-11-12: the publish skill can set it with the save; otherwise the instructor picks it in the '설정' panel at the top of the LXP edit page). Only `on_graded` grades: `on_submit` completes on any submission without grading (`is_correct: null`, the kit shows "제출했어요."), `on_access` completes on open.
8
8
  4. **What the learning notes say** (`commentary.txt`). A material needs them (LXP rejects the upload without them); once they are filled in, AI Helpy answers only questions about this material, so let the person check the wording.
9
9
  5. **Checking the screens.** The person looks at the student, tutoring, instructor, edit and mobile views in the preview. When they cannot, tell them what to check and in which order.
10
10
  6. **Uploading to LXP.** A saved version is **visible to learners at once** (when the page is open). Before uploading, show what changes and get approval. The same goes for changing a material that is already open, changing answers, and restoring an older version.
@@ -20,27 +20,30 @@ Read or watch / change values and observe (simulation, visualization) / follow s
20
20
  | Something to read or watch, such as a simulation | `on_access` (done on open) | - | No submission |
21
21
  | Done when the activity ends (results, self-check, survey) | `on_submit` (done on submit) | - | Submit the result with `useSubmit` |
22
22
  | One correct answer or one set of answers | `on_graded` (done when it passes) | `pattern` (one regex) | `useSubmit` |
23
+ | Several questions with a score per question (partial score) | `on_graded` | `partial_pattern` | `useSubmit` with a string array |
23
24
  | Writing or assignments graded against a rubric (AI grading) | `on_graded` | `rubric` (the criteria) | `useSubmit`, the score comes back at once |
24
25
 
25
26
  - **The grader and the answers are set on the edit screen** and saved to `settings.grading` with the edit token (`useSave` with `getGrading`): `{ "type": "pattern", "answer_key": "^…$" }` or `{ "type": "rubric", "rubric": "…" }`. The kit's default block `app.useGradingBlock()` uses LXP's wording (기준 답안 (정규표현식), 작성 예시 보기, 평가 기준). When the answers depend on the content's structure (questions, choices, steps), set them where the content is edited, for example in each question card. The answer to `pattern` is **one regular expression** that must match the whole submitted answer string (trimmed), so submit one string and build the regex from the instructor's choices.
27
+ - **`partial_pattern` (partial score per question)**: `{ "type": "partial_pattern", "answer_key": ["^…$", "^…$"], "scores": [50, 50] }`. The student submits a **string array** in question order and `answer[i]` is matched against `answer_key[i]` the same way as `pattern` (trimmed, full match). The score is the sum of `scores[i]` of the matched questions, capped at 100. Rules the server enforces on save (422 otherwise): both arrays 1–50 long and the same length, each score an integer 0–100, the sum at least 100 (a lower sum could never complete). Only 100 is `is_correct: true` and completes `on_graded`; a missing item scores 0, extra items are ignored, and an answer that is not an array of strings is rejected (422). The response also carries `answer_correctness` (per question, `answer_key` order; `[]` for `pattern` · `rubric`), in the submit response and the submission lists, so a screen can mark each question right or wrong (SDK `answerCorrectness`). Kit helpers: `validatePartialGrading` (the same rules, for `getGrading`) and `splitScores(n)` (equal integer split summing to 100, e.g. 3 → [33, 33, 34]). The quiz template supports both (6).
28
+ - **Choosing between `pattern` and `partial_pattern` is the person's call.** For a material with several questions, ask: "모두 맞혀야 100점" (`pattern`) or "문항별 부분 점수" (`partial_pattern`). For partial scores, take the per-question scores from the person or from the planning material; if neither gives them, use an equal score and say so in the summary (the quiz template's automatic score is `ceil(100 / questions)` each, 3 → 34 · 34 · 34; the kit's `splitScores` sums to exactly 100, 3 → 33 · 33 · 34). In the quiz template the author can also change the grader and the scores on the edit screen. Scores are integers 0–100 summing to at least 100 (usually exactly 100). Students must answer every question before they submit (the quiz blocks an unanswered question), so a skipped question cannot score 0 by design.
29
+ - **Regexes run on the server in Python `re`**, not JavaScript: for a case-insensitive match put `(?i)` at the very start (`(?i)^(paris|파리)$`); the kit, `ecdk dev` and the local mock turn a leading `(?i)` · `(?s)` · `(?m)` into the JS flag. Avoid what the two engines read differently: `\w` · `\d` · `\b` match Unicode (Korean letters, full-width digits) in Python but only ASCII in JS, so write the characters out (`[0-9]`, `[가-힣A-Za-z]`); named groups are `(?P<name>…)` in Python and `(?<name>…)` in JS (do not use them); lookbehind must be fixed-width in Python; inline flags anywhere but the start fail in both. The generated keys (escaped literals, `(?:…|…)`, `^…$`) mean the same in both.
26
30
  - **The completion policy is picked in LXP**, not in the project: the publish skill proposes it from this table and sets it with the upload after the person agrees (graded: the quiz template or settings with `grading` → `on_graded`; submits without grading → `on_submit`; no submission → `on_access`), or the instructor chooses it in the '설정' panel at the top of the LXP edit page, which applies at once (ADR 0012). `on_graded` needs `settings.grading` saved first, so it goes in the same save as settings with `grading`, or later. Do not write it in `metadata.json` (the old `completionPolicies` and `screens.completionPolicy` are ignored with the warning `manifest.completion-policies-ignored`, and `ecdk build` leaves them out of the zip). The content can read the current policy (SDK `material.completionPolicy`) but never sets it. Build what the suggested policy needs: a submission (`useSubmit`) for `on_submit` · `on_graded`, and the grading saved on the edit screen for `on_graded`. The server rejects `on_graded` without `settings.grading` (`MATERIAL_GRADING_REQUIRED`). The edit screen never sends a policy.
27
31
  - **Only `on_graded` grades.** `on_submit` completes on any submission and does not grade, even with saved answers: the submission comes back `is_correct: null`, `score: 100`, and the kit shows "제출했어요.". `on_access` completes on open. A quiz with `on_submit` shows no score; that is the policy, not broken grading.
28
- - Custom HTML does not use manual grading (`manual`) or no grading (`none`). There is no per-question grading: every question must be right for 100. Changing the answers does not regrade past submissions.
32
+ - Custom HTML does not use manual grading (`manual`) or no grading (`none`). With `pattern` there is no per-question grading: every question must be right for 100 (use `partial_pattern` for a score per question). Changing the answers does not regrade past submissions.
29
33
  - Answers never go in the zip (`metadata.json` · data JSON · code), and there is no answer file in the project: answers exist only in `settings.grading`, saved on the edit screen. The old `gradingTypes` field is gone (2026-11-10): `ecdk build` warns when it is still in `metadata.json` or an old `elice.config.json`. A grading with the 11-10 policy and grader fields is rejected with how to rewrite it.
30
34
 
31
35
  **②-1 Learning notes**: write the key concepts, the activity, and the intent of the questions in `commentary.txt` (plain text) at the top of the project. `build` puts it in the zip and writes `"commentary": "commentary.txt"` in `metadata.json`; LXP's AI Helpy and AI quiz generation read it. It is inside the zip, so students can read it: **never put answers in it.** A material needs it: LXP rejects an upload without learning notes, and `ecdk validate` reports `manifest.commentary-missing` (a problem description, `kind: description`, does not need it). Once it is filled in, AI Helpy answers only questions about this material.
32
36
 
33
37
  **③ Does it need an instructor screen?** Make one when there are explanations, a summary of the answer conditions, or teaching tips. Turn it off when it would equal the student screen.
34
38
 
35
- **④ Does it need a content edit screen?** When instructors may want to rewrite text, numbers or lists (for example a simulation's initial values, a card list, step descriptions), keep them in the content the edit screen saves (`app.content`, the material's `settings`) and let the edit screen change them. There is no default content file: until the edit screen saves, `app.content` is `{}`, `app.hasContent` is false, and the student and instructor screens show `app.emptyState()` ("아직 내용이 없습니다 …"). Turn the edit screen off only when the material needs no content at all (everything is in the code).
39
+ **④ Does it need a content edit screen?** When instructors may want to rewrite text, numbers or lists (for example a simulation's initial values, a card list, step descriptions), keep them in the content the edit screen saves (`app.content`, the material's `settings`) and let the edit screen change them. There is no default content file: until the edit screen saves, `app.content` is `{}`, `app.hasContent` is false, and the student and instructor screens show `app.emptyState()` (illustration + "학습 자료를 준비하고 있어요"). **Whenever a learning screen has nothing to show, always use `app.emptyState()`**; never design your own empty-state markup, illustration or text (5, "Nothing to show"). Turn the edit screen off only when the material needs no content at all (everything is in the code).
36
40
 
37
41
  **④-1 Design the content JSON shape** before the screens: the keys the student screen reads (for example `{ "title": "…", "unit": "km", "items": [{ "name": "수성", "value": 4879 }] }`), which are required, number ranges and list sizes. That shape becomes the schema of the kit's content editor (`useContentEditor`, see 5), so the edit screen needs no hand-written fields. Keep it small and flat, and keep graded answers out of it.
38
42
 
39
43
  **⑤ Purpose**: the material itself (`kind: material`, the default), or the **problem description** of another material such as a practice (`kind: description`: student screen only, no grading).
40
44
 
41
- **Steps inside one material (paging)**: LXP already draws a bar **under every material** with `< 이전 · 3/6 · 다음 >` that moves between **lecture pages** of the course. Inside the material, never draw a bottom bar with 이전 · 다음 (or "◀ 이전 · 2 / 6 · 다음 ▶") that looks like it: the student cannot tell which one moves the step and which one leaves the material. For a material with several steps (slides, STEP 1~5), use the kit's `app.usePaging` (see 5):
45
+ **⑥ Choose navigation and content layout** ([14](14-layouts.md)): LXP already draws a bar **under every material** with `< 이전 · 3/6 · 다음 >` that moves between **lecture pages**, so never draw your own bottom 이전 · 다음 bar or `n / N` inside the material.
42
46
 
43
- - Between steps: **round chevron buttons on the left and right edges** of the content, vertically centered, and a small **`n / N` indicator inside the content**.
44
- - On the **first step the left button, on the last step the right button go to the previous / next lecture page** in LXP (SDK `app.navigation.previous()` · `next()`). They look different on purpose (a labeled pill "‹ 이전 자료" · "다음 자료 ›" instead of a bare chevron), so the student knows they are leaving this material. When there is no lecture page on that side, or the material is not in LXP (editor preview, local), they are hidden.
45
- - If the last step has its own action (submit, "결과 보기"), keep it in the content; the right pill still leads on to the next material.
46
- - On a phone (narrower than 512px) the kit puts the buttons under the content instead of over its edges.
47
+ - **Navigation**: one screen (the default), or the kit **stepper** for several steps (slides, STEP 1~5, intro → experiment → summary): `app.useStepper()` with one `<section data-ec-step>` per step. Back/Next sit in the side gutters, `n / N` bottom-left; the first step's Back and the last step's Next go to the previous / next LXP material. Options, off by default: `canNext` (block Next until the step is done) and `remember` (reopen at the last step in this browser).
48
+ - **Content layout** per screen or step: `single` (text, a question, a survey) · `split` (explanation | practice) · `stage` (simulation: stage, live readout, controls in the first screen) · `media` (video, PDF). Mark it with `data-ec-layout` and put content in `data-ec-region` boxes.
49
+ - Tell the person the choice in one line, for example "단계 3개: 1 도입 single · 2 실험 stage · 3 정리 split".
@@ -1,14 +1,16 @@
1
1
  # 3. Create the project
2
2
 
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).
3
+ Run `ecdk create --list` first: it prints each template with its own version (`quiz@1.5.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
- | Case | Start with |
6
- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
7
- | A quiz (one question per quiz material; several questions mean several quiz materials) | `ecdk create <folder>` (quiz template: starts with no question; the edit screen adds one question of any of the five types with "문항 추가"; answers set on the edit screen; `pattern` grading, `on_graded` picked in LXP) |
8
- | Any other material | `ecdk create <folder> --template blank` (three screens with a small example to replace, "예측하고 확인하기", and the kit content editor on the edit screen: see 5) |
9
- | A dark screen | Add `--theme dark` to the above |
10
- | A problem description | Create with blank, set `metadata.json` to `{ "kind": "description", "screens": { "learn": { "enabled": true, "entry": "index.html" } }, "commentary": "commentary.txt" }`, delete the other screen files |
11
- | An existing HTML page | [7. Move existing HTML](07-move-existing-html.md) |
5
+ | Case | Start with |
6
+ | -------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
7
+ | A quiz (one question per quiz material; several questions mean several quiz materials) | `ecdk create <folder>` (quiz template: starts with no question; the edit screen adds one question of any of the five types with "문항 추가"; answers set on the edit screen; `pattern` grading, `on_graded` picked in LXP) |
8
+ | Any other material | `ecdk create <folder> --template blank` (three screens with a small example to replace, "예측하고 확인하기", and the kit content editor on the edit screen: see 5) |
9
+ | A material in several steps (intro → experiment → summary, slides) | `ecdk create <folder> --template steps` (kit stepper `app.useStepper` and a different content layout per step, example "진자의 주기", content editor on the edit screen: see [14](14-layouts.md)) |
10
+ | One document to read (PDF or PPTX, completion on opening) | `ecdk create <folder> --template document` (the edit screen uploads a `.pdf` or `.pptx` and edits PPTX slide text in place; the student screen pages through it; `on_access` picked in LXP; `.ppt` · `.pps` · `.ppsx` must be saved as `.pptx` or `.pdf` first; uploads work in `ecdk dev` only until the server upload API ships) |
11
+ | A dark screen | Add `--theme dark` to the above |
12
+ | A problem description | Create with blank, set `metadata.json` to `{ "kind": "description", "screens": { "learn": { "enabled": true, "entry": "index.html" } }, "commentary": "commentary.txt" }`, delete the other screen files |
13
+ | An existing HTML page | [7. Move existing HTML](07-move-existing-html.md) |
12
14
 
13
15
  `create` refuses a folder that is not empty. Use a new subfolder. It then runs `npm install` in the project (the SDK `@eliceio/cdk` comes from npm through `package.json`; `--no-install` skips it). When the install fails, the project stays: run `npm install` in it (network or proxy problem; tell the user).
14
16
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  1. **Never put correct answers in the content**: not in a data JSON file, the screen code, or comments. They reach the student's browser. Answers go only in `settings.grading` through the edit screen (the server never sends it to students; `ecdk dev` keeps it in `.ecdk/settings.json`, left out of the zip).
4
4
  2. **Screen code calls only `lib/elice-content.js` (the kit).** Do not edit `lib/`. Do not call the SDK (`@eliceio/cdk`, imported by the kit and bundled by `ecdk build`) directly.
5
- 3. **Do not use blocked features**: `alert`/`confirm`/`prompt` · `window.open` · `<form>` submission · access to `window.parent`/`top` · `fetch`/`WebSocket` to external addresses · external `<script src>`. `localStorage` · `sessionStorage` · `indexedDB` · `document.cookie` work, but they stay only in that browser and device and are not the learner's record: to keep progress, submit it (`useSubmit`); to keep content, save it from the edit screen.
5
+ 3. **Do not use blocked features**: `alert`/`confirm`/`prompt` · `window.open` · `<form>` submission · access to `window.parent`/`top` · `fetch`/`WebSocket` to external addresses (an AI call to mlapi goes through `sdk.mlapi.fetch`, which the check allows) · external `<script src>`. `localStorage` · `sessionStorage` · `indexedDB` · `document.cookie` work, but they stay only in that browser and device and are not the learner's record: to keep progress, submit it (`useSubmit`); to keep content, save it from the edit screen.
6
6
  4. **Libraries and media go inside the zip.** Download libraries for charts, visualization or physics (for example Chart.js, D3, p5.js) into `vendor/` and load them by relative path instead of a CDN. Fonts, images and sounds also go in the zip. Limits: zip 20 MB, 300 files. Upload long videos separately as Elice video materials.
7
7
  - The content CSP (same as LXP) blocks every external image, font, video, CSS file, `<iframe src>`/`<object>`/`<embed>` and `fetch` (errors `ref.external-request` · `html.iframe`; an `<iframe>` filled with `srcdoc` for a code preview is fine). Fonts go in the zip as files or data URIs: external fonts (Google Fonts too) are blocked for now; they open once the server allowlist is settled.
8
8
  - A library may call outside hosts while it runs (web fonts, wasm, map tiles, APIs) and the CSP blocks them. `ref.vendor-external-url` warns about outside addresses in library files; open `ecdk dev` and look for "막힌 외부 요청" in the log, then put those files in the zip and point the library at them by relative path.
@@ -4,19 +4,27 @@
4
4
 
5
5
  Do not open `lib/` to learn the API: this table is the API (from `lib/elice-content.d.ts`, `lib/elice-content-editor.d.ts`, `lib/elice-content.css`). Start from the template's example screens (`screens/*.js`) and change them. Never edit `lib/`.
6
6
 
7
- | `lib/elice-content.js` | What it is |
8
- | --------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
9
- | `await start({ screen })` → `app` | `screen`: `'learn'` · `'instructor'` · `'edit'`. Optional `onError(err)` (`ContentError` with `code`) |
10
- | `app.content` · `app.hasContent` · `app.emptyState()` | What the edit screen saved (`{}` until saved) · whether it saved · the "아직 내용이 없습니다" element to show when `hasContent` is false (student and instructor screens) |
11
- | `app.screen` · `app.viewer` · `app.readOnly` · `app.isDraft` | `'learn'`… · `'student'` · `'instructor'` · `'tutor'` · tutoring (read-only, the kit locks the screen) · draft preview (submissions not recorded) |
12
- | `app.account` · `app.result` | `{ anonymousId, fullname }` or null (e.g. `anonymousId` as a per-person random seed) · `{ score, submitCount, completedAt }` or null |
13
- | `app.useSubmit({ getAnswer, setAnswer?, validate?, onResult?, root?, label? })` | Student screen submit bar → `{ element, result, restored }`. `getAnswer()` small JSON · `setAnswer(a)` on reopen and in tutoring · `validate(a)` → `true` or a message · `onResult({ isCorrect, score, answer? }, { restored })`. Locking, restoring and messages are the kit's |
14
- | `app.useSave({ getContent, validate?, getGrading?, root?, label? })` | Edit screen save bar → `{ element, markDirty(), dirty }`. Watches `root` (default `#app`) for changes, except inside `[data-ec-quiet]`. `getGrading()` → `Grading`, a message (blocks saving) or `undefined` (keep) |
15
- | `app.useGradingBlock({ graders?, examples?, root? })` | Edit screen grader block (LXP's "기준 답안 (정규표현식)" · "평가 기준") → `{ element, grader, getGrading() }`; pass `getGrading` to `useSave` |
16
- | `app.usePaging({ count, onChange(step, { content }), start?, root? })` | Steps inside one material: side chevrons and `n / N` → `{ element, content, go(i), step, ready }`. Draw only into `content` |
17
- | `app.grading` | Saved grading on the edit screen only: `{ type: 'pattern', answer_key }` · `{ type: 'rubric', rubric }` or null |
18
- | `app.submit(answer)` · `app.lastAnswer()` · `app.lastSubmission()` · `app.saveContent(content, grading?)` | Low-level calls under `useSubmit` · `useSave` (rarely needed) |
19
- | `validateAnswerRegex(regex, samples?)` | Exported: checks an answer regex (non-empty, length ≤ `ANSWER_KEY_MAX`, compiles, `^…$`, run time) → `null` or a message. Also `GRADER_TYPES`, `GRADING_EXAMPLES`, `normalizeGrading` |
7
+ | `lib/elice-content.js` | What it is |
8
+ | --------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
9
+ | `await start({ screen })` → `app` | `screen`: `'learn'` · `'instructor'` · `'edit'`. Optional `onError(err)` (`ContentError` with `code`) |
10
+ | `app.content` · `app.hasContent` · `app.emptyState({ title?, description?, theme? })` | What the edit screen saved (`{}` until saved) · whether it saved · the empty-state element to show when `hasContent` is false (student and instructor screens): illustration + "학습 자료를 준비하고 있어요" + "준비가 완료되면 이곳에서 볼 수 있어요", centred. Call it with no arguments; `theme: 'dark'` only on a dark area of a light page (the dark theme already gets dark colours). `title` · `description` (`''` hides it) only when the person asks for other words. Never your own empty-state markup (see "Nothing to show") |
11
+ | `app.screen` · `app.viewer` · `app.readOnly` · `app.isDraft` | `'learn'`… · `'student'` · `'instructor'` · `'tutor'` · tutoring (read-only, the kit locks the screen) · draft preview (submissions not recorded) |
12
+ | `app.account` · `app.result` | `{ anonymousId, fullname }` or null (e.g. `anonymousId` as a per-person random seed) · `{ score, submitCount, completedAt }` or null |
13
+ | `app.useSubmit({ getAnswer, setAnswer?, validate?, onResult?, root?, label? })` | Student screen submit bar → `{ element, result, restored }`. `getAnswer()` small JSON · `setAnswer(a)` on reopen and in tutoring · `validate(a)` → `true` or a message · `onResult({ isCorrect, score, answerCorrectness?, answer? }, { restored })` · `resultText(r)` → own result line or `undefined` · `allowUnchanged` · `scrollOnResult` (`'result'` default, `'bottom'` scrolls to the end of the screen after every server answer, success or error; the quiz uses `'bottom'`). After a submit the kit scrolls the result into view and disables the button with "답을 고치면 다시 제출할 수 있어요." until the answer changes (`allowUnchanged: true` turns that off). Locking, restoring and messages are the kit's |
14
+ | `app.useSave({ getContent, validate?, getGrading?, root?, label? })` | Edit screen save bar → `{ element, markDirty(), dirty }`. Watches `root` (default `#app`) for changes, except inside `[data-ec-quiet]`. `getGrading()` → `Grading`, a message (blocks saving) or `undefined` (keep) |
15
+ | `app.useGradingBlock({ graders?, examples?, root? })` | Edit screen grader block (LXP's "기준 답안 (정규표현식)" · "평가 기준") → `{ element, grader, getGrading() }`; pass `getGrading` to `useSave` |
16
+ | `app.useStepper({ canNext?, remember?, count?, onChange?, start?, root? })` | Steps inside one material: one `<section data-ec-step>` per step (or `{ count, onChange(step, { content, section }) }` for code-drawn steps); Back/Next and `n / N` → `{ element, content, nav, go(i), refresh(), step, count, ready }`. `canNext(step)` → `true` or a reason (blocks Next). `remember` keeps the last step in this browser. Old name `app.usePaging` (same) |
17
+ | `app.assets.uploadFile(file, { onProgress?, signal? })` · `await app.assets.url(asset_key)` | Material files (PDF · PPTX up to 95MB, images up to 10MB; SDK `assets.post` · `assets.get`). `uploadFile` (edit screen only) asks the server for an upload URL and PUTs the file → `{ asset_key }` (the SDK's `id`, the server's file key `assets/{material_id}/{id}.{ext}`, as is); save it in the content. The SDK picks the kind from the file's MIME type, else its extension, so pass a `File` with its name. Aborting `signal` rejects with an `AbortError`; `file_invalid_size` → `ContentError` `upload_bad_file`, `file_invalid_type` → `upload_bad_type`. `url` → a Promise of the signed address, or null: the version's `asset_base_url` (ends at the signature, `https://{api}/s/{sig}/`) + that key; the SDK builds it, so pass the saved `asset_key` unchanged. The signed address lasts 6 hours (published version, student screen) and 1 hour (draft, edit screen): fetch what you need early on the edit screen, and on the student screen show a "reload" notice when a later request fails with 403 (the document template does both). Needs an SDK with `assets.post` (else `ContentError` `upload_not_supported`); `ecdk dev` imitates the server (`.ecdk/assets/`, not in the zip) |
18
+ | `app.assets.uploadImage(file, { onProgress?, signal? })` · `optimizeImage(file)` · `IMAGE_RULES` | Images in the content (PNG · JPEG · WebP · GIF, up to 10MB; no SVG). `uploadImage` (edit screen only) shrinks the image once in the browser with the exported `optimizeImage`, then uploads it like `uploadFile` → `{ asset_key, size, original_size, width, height, type }`. `optimizeImage`: PNG · JPEG · WebP are drawn upright (EXIF orientation), scaled to a longest side of 2048px and re-encoded as WebP quality 0.85 (JPEG if the browser cannot make WebP, PNG for a PNG · WebP that may be transparent); re-encoding drops EXIF · GPS. The original is kept when the result is larger, unless it needed scaling or carries EXIF · XMP. GIF is uploaded as is. Errors are `ContentError` `upload_bad_type` · `upload_bad_file` (image wording) · `image_unreadable`. To show it, `fetch` the address from `await app.assets.url(asset_key)` and put `URL.createObjectURL(blob)` in the `<img>`: the content CSP allows images only from the content origin, `data:` and `blob:`, and the file origin only in `connect-src` (the quiz template does this in `core/markdown.js`). Show a "reload" notice when the fetch fails (the signed address expires) |
19
+ | `app.grading` | Saved grading on the edit screen only: `{ type: 'pattern', answer_key }` · `{ type: 'partial_pattern', answer_key: [], scores: [] }` · `{ type: 'rubric', rubric }` or null |
20
+ | `app.submit(answer)` · `app.lastAnswer()` · `app.lastSubmission()` · `app.saveContent(content, grading?)` | Low-level calls under `useSubmit` · `useSave` (rarely needed) |
21
+ | `skeleton(layout?, { parts?, label? })` | Exported: loading placeholder (`.ec-sk`, shimmer, "불러오는 중…" for screen readers only). Put it in `#app` before `await start()`. `'learn'` = one block that fills the screen, `'edit'` = `parts` from the top (default `['bar', 'media']`: file bar + 16:9 preview). Use the same markup in the HTML so it shows before the script runs |
22
+ | `showSnackbar({ text, onAction?, action?, onClose?, focus? })` | Exported: edit screen "되돌리기" message at the bottom (`.ec-snackbar`, 6 s, one at a time, outside `#app`) → `{ element, close() }`. See [13](13-edit-screen-design.md) |
23
+ | `fileBar({ icon?, name, meta?, onChange?, changeLabel?, disabled? })` · `formatFileMeta` · `infoList` | Exported: edit screen uploaded-file row (`.ec-file-bar`, button "다른 파일로 변경") · "120MB, 08:30" · ⓘ list. `icon`: `fileVideoIcon()` (`lib/icons/file-video.js`) or `fileIcon()` (`lib/icons/file.js`); import only the icon you use, so the zip carries only that icon and its license comment |
24
+ | `fitCanvas(canvas, onResize?)` | Exported: sizes a canvas drawing buffer to its shown size × `devicePixelRatio` and again on every resize; `onResize({ ctx, width, height, dpr })` runs at once and on resize: redraw there with that `ctx`, in CSS px → `{ ctx, size, stop() }`. See [14](14-layouts.md) |
25
+ | `validateAnswerRegex(regex, samples?)` | Exported: checks an answer regex (non-empty, length ≤ `ANSWER_KEY_MAX`, compiles, `^…$`, run time; a leading `(?i)` is the case-insensitive flag) → `null` or a message. Also `GRADER_TYPES`, `GRADING_EXAMPLES`, `normalizeGrading` |
26
+ | `validatePartialGrading({ answer_key, scores })` · `splitScores(n)` | Exported: checks `partial_pattern` like the server (1–`PARTIAL_ITEMS_MAX` items, same lengths, integer scores 0–100, sum ≥ 100, each regex with `validateAnswerRegex`) → `null` or a message · equal integer scores summing to 100 (3 → `[33, 33, 34]`) |
27
+ | `toJsRegex(regex)` · `matchesAnswer(regex, answer)` | Exported: the server's Python regex as JS `{ source, flags }` (leading `(?i)` · `(?s)` · `(?m)` → flag) · whether the trimmed answer fully matches (the server's judgment) |
20
28
 
21
29
  | `lib/elice-content-editor.js` (edit screen only) | What it is |
22
30
  | ---------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
@@ -26,11 +34,13 @@ Do not open `lib/` to learn the API: this table is the API (from `lib/elice-cont
26
34
  | `lib/elice-content.css` (EDS, light and dark) | Use |
27
35
  | --------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
28
36
  | Elements | `main` (720px column, 20px gap), `h1`, `p`, `button`, `input` · `textarea` · `select` (full width, 16px text) are styled already |
37
+ | Content layouts | `data-ec-layout="single \| split \| stage \| media"` with regions `data-ec-region="main \| aside \| stage \| controls \| readout \| actions"`, CSS only. Tokens `--ec-layout-max` `--ec-layout-wide` `--ec-layout-gap` `--ec-panel-width` `--ec-stage-height` `--ec-nav-gutter` `--ec-fab-safe`. See [14](14-layouts.md) |
29
38
  | Layout · boxes | `.ec-card` (bordered box, column) · `.ec-row` (wrapping row, 8px gap) · `.ec-col` (column, 12px gap) · `.ec-option` (one choice row with its input) · `.ec-badge` (small tag) |
30
39
  | Buttons | `button.ec-primary` (main action) · `button.ec-text-button` · `button.ec-icon-button` (borderless icon, needs `aria-label`) · `button.ec-icon-button.ec-danger` (red ✕) |
31
40
  | Messages | `.ec-result` (info) · `.ec-result.ok` · `.ec-result.no` · `.ec-error` · `.ec-notice` (message + one action) · `.ec-muted` · `.ec-empty` (from `emptyState()`) · `.ec-visually-hidden` |
32
41
  | Student targets | `.ec-dropzone` + `.ec-dropzone-title` (empty drop target) |
33
- | Drawn by the kit | `.ec-submitbar` · `.ec-paging` · `.ec-step-nav` · `.ec-step-count` · `.ec-grading*` · `.ec-json*` (do not build these yourself) |
42
+ | Edit screens | `body.ec-edit-page` · `.ec-edit-card` · `.ec-field` · `.ec-reveal` · `.ec-list` · `.ec-toggle` · `.ec-file-bar` · `.ec-info-line` and more: rules and example in [13](13-edit-screen-design.md) |
43
+ | Drawn by the kit | `.ec-submitbar` · `.ec-stepper` (with `<ec-stepper-nav>`, Shadow DOM) · `.ec-grading*` · `.ec-json*` (do not build these yourself) |
34
44
  | Tokens | `--ec-bg` `--ec-surface` `--ec-fg` `--ec-muted` `--ec-line` `--ec-border` `--ec-accent` `--ec-accent-dark` `--ec-accent-bg` `--ec-ok` `--ec-ok-bg` `--ec-no` `--ec-no-bg` `--ec-warn-bg` `--ec-info` `--ec-info-bg` `--ec-radius` `--ec-shadow`; type: `--eds-font-family` `--eds-fs-h1`…`--eds-fs-h6` `--eds-fs-body1` `--eds-fs-body2` `--eds-fs-caption` `--eds-fw-medium` `--eds-fw-semibold` `--eds-fw-bold` `--eds-fw-extrabold`. Dark theme: `<html data-eds-theme="dark">` |
35
45
 
36
46
  Your own styles go in `styles.css` with these tokens, so both themes work.
@@ -73,22 +83,30 @@ const grading = app.useGradingBlock();
73
83
  app.useSave({ getContent: () => app.content, getGrading: () => grading.getGrading() });
74
84
  ```
75
85
 
76
- - `getGrading` returns the grading settings (`{ type: 'pattern', answer_key }` or `{ type: 'rubric', rubric }`) or an error message that blocks saving. `app.grading` is the saved grading (only on the edit screen).
86
+ - `getGrading` returns the grading settings (`{ type: 'pattern', answer_key }`, `{ type: 'partial_pattern', answer_key, scores }` or `{ type: 'rubric', rubric }`) or an error message that blocks saving. `useGradingBlock` offers `pattern` and `rubric` only; a screen that grades per question builds `partial_pattern` itself and checks it with `validatePartialGrading`. `useSave` · `saveContent` save it unchanged (arrays included). `app.grading` is the saved grading (only on the edit screen).
77
87
  - When the edit screen saves the grading, the student screen must submit (`grading.no-submit` warns when the edit screen uses `useGradingBlock` · `getGrading` · `grading:` but no code calls `useSubmit` · `submit(`).
78
- - Saving on the edit screen (`useSave`) **saves to the material's draft** (SDK `saveSettings`, with the edit token LXP opens the edit screen with). LXP's previews show the draft right away; learners see it only after the person presses '수업 자료에 반영' at the top of the LXP edit page, which publishes the draft as a new version. In `ecdk dev` there is no publish step, so the student view changes at once. The kit shows the result and the failure messages (the upload is not saved yet, the upload is still processing, session expired), so the screen code does not announce "saved" itself.
88
+ - Saving on the edit screen (`useSave`) **saves to the material's draft** (SDK `saveSettings`, with the edit token LXP opens the edit screen with). LXP's previews show the draft right away; learners see it only after the person presses '수업 자료에 반영' at the top of the LXP edit page, which publishes the draft as a new version. In `ecdk dev` there is no publish step, so the student view changes at once. The kit shows the result and the failure messages (the upload is not saved yet, the upload is still processing, session expired, and for a server 422 `VALIDATION_ERROR` a message by the server's error type: "배점 합계는 100점 이상이어야 합니다." · "문항별 정답과 점수의 개수가 맞지 않아요." · "정답 형식이 올바르지 않아요.", otherwise "저장할 내용의 형식이 올바르지 않아요."), so the screen code does not announce "saved" itself. A submission the server rejects with 422 (the saved grading and the answer shape do not match, for example `partial_pattern` with a string answer) shows "이 자료의 채점 설정과 답 모양이 맞지 않아 제출하지 못했어요. 교육자에게 알려 주세요." in every template.
79
89
  - Materials without a submission do not call `useSubmit` (only `on_access` fits them in LXP).
80
90
  - Use `app.viewer` (`student` · `instructor` · `tutor`), `app.readOnly` (tutoring) and `app.account.anonymousId` (for example a per-person fixed random seed) only when needed. The kit handles per-viewer behavior such as the tutoring lock, so the screen code does not branch on the viewer.
81
- - Steps inside one material (see "Steps inside one material" in 2): let the kit draw the side buttons and the `n / N` indicator. Never draw an LXP-like bottom 이전 · 다음 bar.
91
+ - Steps inside one material: turn on the kit's stepper and give each step a layout ([14](14-layouts.md)). Never draw an LXP-like bottom 이전 · 다음 bar or your own `n / N`.
92
+
93
+ ```html
94
+ <main id="app">
95
+ <section data-ec-step data-ec-layout="single">…</section>
96
+ <section data-ec-step data-ec-layout="stage">…</section>
97
+ </main>
98
+ ```
82
99
 
83
100
  ```js
84
- app.usePaging({
85
- count: steps.length,
86
- // also called once at start. Draw only into `content` (#app by default); the kit keeps its buttons outside it
87
- onChange: (i, { content }) => content.replaceChildren(renderStep(steps[i])),
101
+ const stepper = app.useStepper({
102
+ // optional: block Next until the step is done; call stepper.refresh() when that changes
103
+ canNext: i => i !== 1 || tried || '실험을 한 번 해 보세요.',
104
+ // stop timers, sound and video of the step you leave
105
+ onChange: (i, { section }) => pauseOthers(section),
88
106
  });
89
107
  ```
90
108
 
91
- The kit wraps the content area (`root`, default `#app`) in its own frame and puts the side buttons and `n / N` in the frame, so redrawing `#app` (`replaceChildren`, `innerHTML`) does not remove them. Toggling `hidden` on prepared step elements works too. `usePaging({ count, onChange, start, root })` returns `{ element, content, go(i), step, ready }`. Use `go(i)` to jump (for example "다시 배분하기" back to step 3). Gating a step (for example "submit before moving on") is the screen's job: show a message in the step, the kit does not lock the arrows.
109
+ For steps drawn by code, pass `{ count, onChange: (i, { content }) => content.replaceChildren(renderStep(steps[i])) }` (also called once at start; draw only into `content`). The kit wraps the content area (`root`, default `#app`) in its frame, so redrawing `#app` does not remove the buttons. Use `go(i)` to jump. The last step's Next goes on to the next LXP material.
92
110
 
93
111
  - Run simulations and animations with `requestAnimationFrame` and stop them while the view is hidden. Split heavy computation into small pieces.
94
112
 
@@ -124,14 +142,25 @@ app.useSave({ getContent: editor.getContent, validate: editor.validate });
124
142
  - Only the edit screen imports `lib/elice-content-editor.js`; `ecdk build` bundles code per screen, so the student screen does not carry it.
125
143
  - Use the editor when the content is data (lists, numbers, short texts). Write a custom edit screen when editing needs its own UI (placing points on an image, a per-question answer UI like the quiz template). The content is visible to students: values the student screen reveals (like "정답 보기" of a self-check) may be in it, answers that are graded never are (`settings.grading`).
126
144
 
145
+ ### Nothing to show: `app.emptyState()`
146
+
147
+ **When a student or instructor screen has nothing to show, always use `app.emptyState()`. Never build your own empty-state markup, illustration or text.** With no arguments it is the shared design every template uses: the illustration, "학습 자료를 준비하고 있어요" and "준비가 완료되면 이곳에서 볼 수 있어요", centred, in light colours (dark colours in the dark theme). Do not pass text or add styles. The only option a screen normally needs is `theme: 'dark'`, when the notice sits on a dark area of a light page (for example a dark document stage).
148
+
149
+ ```js
150
+ const app = await start({ screen: 'learn' });
151
+ if (app.hasContent) render(app.content);
152
+ else root.replaceChildren(app.emptyState()); // on a dark stage: app.emptyState({ theme: 'dark' })
153
+ ```
154
+
127
155
  ### UI patterns
128
156
 
129
- Build screens from the kit's classes in `lib/elice-content.css` (EDS values, both themes) so every material looks and behaves the same. The quiz template follows these patterns; copy its markup from `ui/templates/`.
157
+ Build screens from the kit's classes in `lib/elice-content.css` (EDS values, both themes) so every material looks and behaves the same. The quiz template follows these patterns; copy its markup from `ui/templates/`. Edit screens: [13](13-edit-screen-design.md) (cards, underline fields, "+ 추가" reveal, answer on the option row, snackbar undo).
130
158
 
131
159
  | Where | Pattern |
132
160
  | ------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
133
161
  | Edit screen, a card for one item (question, step) | Title on the left, then a type `<select>` in regular weight. On the right, borderless icon buttons `button.ec-icon-button`: ↑ · ↓ · delete with a **trash** icon. Hide ↑ · ↓ when there is only one card. |
134
162
  | Edit screen, one row in a list (choice, group) | `⠿` drag handle → the answer control (radio or checkbox) → number → text input → remove with `button.ec-icon-button.ec-danger` (a red **✕**, no border). A wide answer control (a `<select>`) goes after the input instead. Disable remove at the minimum count. |
163
+ | Student · instructor screen, nothing to show yet | Always `app.emptyState()` (above), never your own empty-state markup, illustration or text. |
135
164
  | Student screen, an empty drop target | `.ec-dropzone`: a dashed box with an icon, a bold line `.ec-dropzone-title` (for example "보기를 여기로 끌어 놓으세요") and a hint `<p>` ("또는 보기를 누른 뒤 이곳을 눌러 주세요."). It also takes clicks, not only drops. |
136
165
  | Student screen, undo actions ("답안 초기화") | Show only when there is something to undo (for example at least one item placed), hide on read-only screens, and keep the row height fixed so nothing below jumps. Keep it away from the submit button. |
137
166
  | Any Korean text in a narrow box | `word-break: keep-all` so lines do not break inside a word. |
@@ -1,10 +1,11 @@
1
1
  # 6. Using the quiz template
2
2
 
3
3
  - The quiz has **no instructor screen** (`metadata.json` `screens.instructor.enabled: false`): an instructor who opens it in LXP gets the student screen and can solve and submit it (graded, not recorded). Add `instructor.html` and turn it on only when the person asks for one.
4
- - The template starts with **no questions**: the student screen shows "아직 내용이 없습니다" until the edit screen saves. The question and answer are added on the edit screen ("문항 추가", any of the five types, the answer in the same card): in `ecdk dev`, so the upload can carry them (`.ecdk/settings.json`, sent after the person agrees), or on the LXP edit screen after upload. **One quiz material holds one question**, like the legacy LXP quiz: once there is a question the edit screen shows a hint instead of "문항 추가", and several questions mean several quiz materials (pages). A quiz already saved with more questions still shows and saves. For a requested question set, put the first question in the edit view in `ecdk dev` (answers confirmed by the person) and give the others as draft text, one question per quiz material.
5
- - Question types: `select_one` · `select_multiple` · `order` · `text` · `group`. Question, choice and group ids (`q1`, `a`, `g1`) are lower-case letters and digits; once set, do not change them.
6
- - Student answer: **one string**, `id=answer` per question joined by `;` in question order: `q1=b;q2=a,d;q3=c,a,b;q4=weight;q5=g1:a|g2:b,c`. Multiple choice lists choice ids **sorted**, order lists them in slot order, group lists `group:choices(sorted)` in group order joined by `|`, and a text answer is trimmed and `encodeURIComponent`-encoded.
7
- - Answers: the instructor picks the answer in each question card of the edit screen. Single and multiple choice mark it in the option rows (a "정답" radio or checkbox per option), group sorting picks each option's group in its row, order uses a separate "정답" section, and text questions take one allowed answer per line. Saving builds one regex and checks it, and blocks the save with the question number when an answer is missing, points at a deleted choice, or the regex does not match the answers back or still matches a changed answer. The quiz grades with `pattern` (no hand-written regex); its completion policy is `on_graded` (set by the publish skill with the answers, or picked in the '설정' panel at the top of the LXP edit page); with `on_submit` the server does not grade (`is_correct: null`, the kit shows "제출했어요."). `pattern` compares the whole answer at once, so **everything must match for 100** (no partial score per question).
4
+ - The template starts with **no questions**: the student screen shows "학습 자료를 준비하고 있어요" until the edit screen saves. The questions and answers are added on the edit screen ("+ 문제 추가", any of the five types picked from the type button's list, the answer in the same card; up to 20 questions): in `ecdk dev`, so the upload can carry them (`.ecdk/settings.json`, sent after the person agrees), or on the LXP edit screen after upload. There is no quiz title or description field (the student screen starts with the questions); a `title` · `description` saved earlier is kept as is.
5
+ - Question types: `select_one` · `select_multiple` · `order` · `text` · `group`. For `order` the student taps the choices in the right order and each gets a number 1 · 2 · 3 (tap again to remove, "답안 초기화" to clear); the answer string is the same as before. Question, choice and group ids (`q1`, `a`, `g1`) are lower-case letters and digits; once set, do not change them.
6
+ - Student answer (`pattern`, the default): **one string**, `id=answer` per question joined by `;` in question order: `q1=b;q2=a,d;q3=c,a,b;q4=weight;q5=g1:a|g2:b,c`. Multiple choice lists choice ids **sorted**, order lists them in slot order, group lists `group:choices(sorted)` in group order joined by `|`, and a text answer is trimmed and `encodeURIComponent`-encoded.
7
+ - Answers: the instructor picks the answer in each question card of the edit screen. Single and multiple choice mark it in the option rows (a "정답" radio or checkbox per option), group sorting picks each option's group in its row, order uses a separate "정답" section, and text questions take one allowed answer per line. Saving builds one regex and checks it, and blocks the save with the question number when an answer is missing, points at a deleted choice, or the regex does not match the answers back or still matches a changed answer. The quiz grades with `pattern` or `partial_pattern` (no hand-written regex; the author picks the type on the edit screen with the "부분 채점 허용" switch shown from two questions, a new quiz is `pattern`); its completion policy is `on_graded` (set by the publish skill with the answers, or picked in the '설정' panel at the top of the LXP edit page); with `on_submit` the server does not grade (`is_correct: null`, the kit shows "제출했어요."). `pattern` compares the whole answer at once, so **everything must match for 100**.
8
+ - **Partial score per question (`partial_pattern`, 2 ②)**: ask the person which one they want ("모두 맞혀야 100점" or "문항별 부분 점수"). For partial scores, write into `.ecdk/settings.json` both the public `"gradingType": "partial_pattern"` (the student screen cannot see `grading`, so this tells it to submit an array) and `grading` `{ "type": "partial_pattern", "answer_key": ["^q1=b$", "^q2=a,d$", …], "scores": [60, 40, …] }`, one regex per question in question order, each the same as one `id=answer` piece of the `pattern` regex wrapped in `^…$`. Scores come from the person or the planning material, otherwise the automatic score: every question gets `ceil(100 / questions)` (3 questions → 34 · 34 · 34, the server caps the student's score at 100). Also write `"pointsMode": "custom"` with each question's `"points"` (same values as `scores`), or `"pointsMode": "equal"` for the automatic score. Then have the person open the edit view and save once ("초안으로 저장") so the edit screen checks every answer. The author can change both on the edit screen: the "부분 채점 허용" switch picks `pattern` or `partial_pattern`, the row under it shows "자동 배점" or "직접 배점" with the total, and each question card has a score field (custom scores must be integers 0–100 summing to at least 100; "동일 점수로 적용하기" goes back to automatic). A quiz saved before keeps its type and scores unless the author changes them. The student answer is then an array `["q1=b", "q2=a,d", …]`, and the student screen marks each question ✓ · ✕ from `answer_correctness` (right after submitting and when reopened); below 100 it shows a box with the score, "아쉬워요!" and a mascot above the submit bar, and with custom scores each question title shows "N점". With `pattern` the score line is hidden: one question shows "오답입니다." in its card, and several questions with any wrong show "틀린 문제가 있습니다. 다시 한번 풀어보세요." above the submit bar. Every question must still be answered before submitting.
8
9
 
9
10
  ```json
10
11
  {
@@ -16,8 +17,8 @@
16
17
  - File split: **`ui/` is the look** (edit freely), **`screens/` is the layout** (which blocks in which order), **`core/` is behavior and the grading contract** (do not edit).
17
18
  - Colors, spacing, corners, choice cards: the `--qz-*` variables in `ui/theme.css` (they point at EDS tokens, so `--theme dark` also fits)
18
19
  - Text: `ui/texts.js` (tab title, loading, student, edit, and validation messages)
19
- - Markup: the `` html`…` `` snippets in `ui/templates/*.js` (`choice` card, `question` frame, `order`, `group`, `text`, `page` header, `edit` fields). Inserted values are escaped. Classes and tags are free; **keep the `data-role` attributes** (`result` · `explanation` · `choice` · `input` · `pool` · `slots` · `items` and so on, listed at the top of each file) and selecting, dragging and the answer strings keep working.
20
+ - Markup: the `` html`…` `` snippets in `ui/templates/*.js` (`choice` card, `question` frame, `order`, `group`, `text`, `page` header, `edit` fields). Inserted values are escaped. Classes and tags are free; **keep the `data-role` attributes** (`result` · `explanation` · `choice` · `input` · `options` · `pool` · `items` and so on, listed at the top of each file) and selecting, tapping, dragging and the answer strings keep working.
20
21
  - Behavior adds state as attributes: `data-result="correct|wrong"` · `data-dragging` · `data-ghost`. Style them in CSS.
21
- - After a change, solve all five types in `ecdk dev` by clicking and dragging, submit, and check that the answer string (local grading) is unchanged.
22
+ - After a change, solve all five types in `ecdk dev` by tapping and dragging, submit, and check that the answer string (local grading) is unchanged.
22
23
 
23
24
  To mix a visualization or simulation into a quiz, edit the quiz template, or write the question data in the same shape on top of blank.