@eliceio/cdk-cli 0.1.0-alpha.3 → 0.1.0-alpha.4

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 (82) hide show
  1. package/README.md +196 -144
  2. package/es/cli.js +6 -1
  3. package/es/commands/build/index.d.ts +1 -1
  4. package/es/commands/build/index.js +11 -12
  5. package/es/commands/check/index.d.ts +5 -2
  6. package/es/commands/check/index.js +15 -9
  7. package/es/commands/create/index.d.ts +4 -0
  8. package/es/commands/create/index.js +30 -7
  9. package/es/commands/create/install.d.ts +17 -0
  10. package/es/commands/create/install.js +53 -0
  11. package/es/commands/create/scaffold.d.ts +4 -1
  12. package/es/commands/create/scaffold.js +19 -13
  13. package/es/commands/dev/index.d.ts +1 -1
  14. package/es/commands/dev/index.js +4 -4
  15. package/es/commands/doctor/index.d.ts +11 -1
  16. package/es/commands/doctor/index.js +124 -36
  17. package/es/core/collect.d.ts +5 -2
  18. package/es/core/config.d.ts +95 -29
  19. package/es/core/config.js +253 -47
  20. package/es/core/manifest.d.ts +2 -1
  21. package/es/core/manifest.js +2 -1
  22. package/es/core/minify.js +2 -2
  23. package/es/core/prepare.d.ts +18 -2
  24. package/es/core/prepare.js +46 -15
  25. package/es/core/project-check.d.ts +18 -7
  26. package/es/core/project-check.js +35 -8
  27. package/es/core/sandbox.js +2 -2
  28. package/es/core/sdk.d.ts +39 -0
  29. package/es/core/sdk.js +95 -0
  30. package/es/core/templates.d.ts +3 -3
  31. package/es/core/templates.js +4 -4
  32. package/es/dev/grading.d.ts +1 -1
  33. package/es/dev/grading.js +1 -1
  34. package/es/dev/host-page.js +2 -2
  35. package/es/dev/mock-api.d.ts +7 -8
  36. package/es/dev/mock-api.js +18 -13
  37. package/es/dev/server.js +62 -43
  38. package/es/rules/check.js +45 -9
  39. package/es/rules/manifest.d.ts +1 -1
  40. package/es/rules/manifest.js +1 -1
  41. package/es/rules/types.d.ts +18 -8
  42. package/es/rules.json.js +2 -2
  43. package/es/test-packages.d.ts +7 -0
  44. package/guides/content-development.md +63 -55
  45. package/package.json +2 -2
  46. package/rules.json +18 -3
  47. package/skills/_shared/always.md +2 -2
  48. package/skills/elice-content-check/SKILL.md +3 -1
  49. package/skills/elice-content-create/SKILL.md +5 -4
  50. package/skills/elice-content-migrate/SKILL.md +2 -2
  51. package/skills/elice-content-publish/SKILL.md +4 -3
  52. package/templates/_shared/lib/cdk-mock.js +17 -17
  53. package/templates/_shared/lib/elice-content.css +8 -0
  54. package/templates/_shared/lib/elice-content.d.ts +5 -1
  55. package/templates/_shared/lib/elice-content.js +20 -12
  56. package/templates/blank/README.md +11 -8
  57. package/templates/blank/metadata.json +11 -0
  58. package/templates/blank/package.json +13 -0
  59. package/templates/blank/screens/completion.js +2 -2
  60. package/templates/blank/screens/instructor.js +12 -5
  61. package/templates/blank/screens/learn.js +16 -11
  62. package/templates/quiz/README.md +14 -11
  63. package/templates/quiz/core/editor.d.ts +12 -1
  64. package/templates/quiz/core/editor.js +28 -5
  65. package/templates/quiz/core/model.d.ts +14 -0
  66. package/templates/quiz/core/model.js +73 -1
  67. package/templates/quiz/metadata.json +11 -0
  68. package/templates/quiz/package.json +13 -0
  69. package/templates/quiz/screens/edit.js +85 -29
  70. package/templates/quiz/screens/instructor.js +18 -12
  71. package/templates/quiz/screens/learn.js +42 -36
  72. package/templates/quiz/styles.css +47 -0
  73. package/templates/quiz/template.json +2 -2
  74. package/templates/quiz/ui/templates/edit.d.ts +1 -0
  75. package/templates/quiz/ui/templates/edit.js +37 -5
  76. package/templates/quiz/ui/texts.js +9 -7
  77. package/templates/_shared/lib/cdk.js +0 -3
  78. package/templates/blank/content.json +0 -4
  79. package/templates/blank/elice.config.json +0 -10
  80. package/templates/quiz/content.json +0 -35
  81. package/templates/quiz/elice.config.json +0 -9
  82. package/templates/quiz/grading.json +0 -4
package/rules.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.5.0",
2
+ "version": "0.7.0",
3
3
  "manifest": {
4
4
  "file": "metadata.json",
5
5
  "kinds": ["material", "description"],
@@ -15,6 +15,9 @@
15
15
  "commentaryFile": "commentary.txt",
16
16
  "defaultEntry": "index.html"
17
17
  },
18
+ "minVersions": {
19
+ "sdk": "1.0.0-alpha.3"
20
+ },
18
21
  "limits": {
19
22
  "maxZipBytes": 20971520,
20
23
  "maxUnpackedBytes": 209715200,
@@ -522,10 +525,10 @@
522
525
  "title": "채점(on_graded)으로 완료하는데 편집 화면 코드가 채점 설정(getGrading · useGradingBlock)을 저장하지 않음"
523
526
  },
524
527
  {
525
- "id": "grading.missing",
528
+ "id": "project.legacy-file",
526
529
  "level": "warn",
527
530
  "scope": "client",
528
- "title": "채점(on_graded)으로 완료하는데 프로젝트에 grading.json이 없음 (ecdk dev가 채점을 흉내 내지 못함, 프로젝트 검사만)"
531
+ "title": "더 쓰지 않는 프로젝트 파일(elice.config.json · content.json · grading.json)이 남아 있음 (프로젝트 검사만, ADR 0011)"
529
532
  },
530
533
  {
531
534
  "id": "build.template-unknown",
@@ -658,6 +661,18 @@
658
661
  "level": "warn",
659
662
  "scope": "client",
660
663
  "title": "postMessage 대상 *"
664
+ },
665
+ {
666
+ "id": "sdk.outdated",
667
+ "level": "error",
668
+ "scope": "client",
669
+ "title": "SDK가 최소 버전보다 낮음 (metadata.json build.sdk < rules.json minVersions.sdk, npm update @eliceio/cdk)"
670
+ },
671
+ {
672
+ "id": "sdk.lib-copy",
673
+ "level": "warn",
674
+ "scope": "client",
675
+ "title": "옛 lib/cdk.js 복사본 (package.json에 @eliceio/cdk가 없음, 프로젝트 검사만. SDK를 package.json 의존성으로 옮기기)"
661
676
  }
662
677
  ]
663
678
  }
@@ -1,9 +1,9 @@
1
1
  ## Always
2
2
 
3
- - Never put correct answers in the content zip. The edit screen saves them to `settings.grading` (locally `grading.json`).
3
+ - Never put correct answers in the content zip. The edit screen saves them to `settings.grading` (locally `.ecdk/settings.json` from `ecdk dev`).
4
4
  - The content runs in a sandboxed iframe on another origin: use the SDK (`app.useSubmit`, `app.useSave`) instead of storage, cookies, `alert`/`confirm`, new windows, the parent window or external requests.
5
5
  - 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). Run each command through their login shell instead: `"$SHELL" -ilc 'ecdk build --json'` (use `zsh -ilc` when `$SHELL` is empty). With `--json`, read only the last JSON block of the output (a login shell may print other text first). If that also fails, ask the person how Node was installed.
6
- - Fix every `ecdk check` / `ecdk build` error before you report. Do not edit `lib/` (the SDK kit).
6
+ - Fix every `ecdk check` / `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`); `ecdk build` adds it to the zip as `lib/cdk.js`.
7
7
  - Ask the person before you settle correct answers, install anything globally, or upload or save to LXP (a saved version is visible to learners at once).
8
8
  - 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`; on the first and last step they become "이전 자료" · "다음 자료" to the previous / next lecture page, `ecdk guide 2`), never a look-alike bottom 이전 · 다음 bar.
9
9
  - Answer the person in their language. The guide is in English.
@@ -16,7 +16,9 @@ The full guide ships with the CLI: `ecdk guide 8` (fix check errors), `ecdk guid
16
16
  3. **Problems that show only in LXP.**
17
17
  - Stays on "Loading" or shows nothing: rebuild with the current `ecdk build` (it adapts the pages to the LXP sandbox) and check the built zip with `ecdk check dist/content.zip`. Ask the person for the browser console error.
18
18
  - Upload rejected: check `ecdk check dist/content.zip`; a material needs `commentary.txt` and every file named in `metadata.json`.
19
- - Answers or grading wrong: check the answers on the edit screen (saving in the `ecdk dev` content edit view writes `grading.json`) and `completionPolicies` (its first value is the default; the completion policy view writes `.ecdk/completion.json`) and that the submitted answer string matches the regex (`ecdk guide 2`, `ecdk guide 6`).
19
+ - Screens show "아직 내용이 없습니다": nothing is saved yet; create the content in the edit screen (there is no default content file). `project.legacy-file`: an old `content.json` · `grading.json`; re-enter it in the edit screen and delete the file. An old `elice.config.json`, or `sdk.lib-copy` (an old `lib/cdk.js` copy): `ecdk doctor --fix`, then `npm install`.
20
+ - Answers or grading wrong: check the answers on the edit screen (saving in the `ecdk dev` content edit view writes `.ecdk/settings.json`) and `completionPolicies` (its first value is the default; the completion policy view writes `.ecdk/completion.json`) and that the submitted answer string matches the regex (`ecdk guide 2`, `ecdk guide 6`).
21
+ - `@eliceio/cdk 패키지를 찾지 못했습니다` or doctor `project.deps` fails: run `npm install` in the project. `sdk.outdated`: `npm update @eliceio/cdk` (on an old `lib/cdk.js` copy: `ecdk doctor --fix && npm install`), then build again.
20
22
  4. **Confirm.** `ecdk check` has no errors, `ecdk dev` works, and `ecdk build --json` returns `ok: true`. Tell the person what caused it and what you changed.
21
23
 
22
24
  {{version}}
@@ -11,11 +11,12 @@ The full guide ships with the CLI. Read only the topics you need: `ecdk guide` l
11
11
 
12
12
  ## Steps
13
13
 
14
- 1. **Design before code.** Read `ecdk guide 0` (what the person decides) and `ecdk guide 2`. Decide ① what the student does, ② the completion policies and the grading (`on_access` · `on_submit` · `on_graded` with grading `type` `pattern` or `rubric`), written as the required `completionPolicies` in `elice.config.json` with the default first; one policy fixes it, more than one needs a completion policy screen where the instructor picks; the quiz template fixes `["on_graded"]`, so do not ask for a quiz, ③ the instructor screen, ④ the content edit screen, ⑤ the purpose. Decide what the request leaves out and tell the person briefly; ask only when the learning goal is unclear.
15
- 2. **Environment and project.** `ecdk --version && ecdk doctor --json` (`ecdk guide 1`), then `ecdk create --list` to pick a template and `ecdk create <folder> --template <name>` (`ecdk guide 3`).
16
- 3. **Write.** Screens and content (`ecdk guide 5`; the quiz template: `ecdk guide 6`). Write `commentary.txt` (key concepts and intent, no answers). Draft correct answers on the edit screen (the quiz: in each question card; saving in the content edit view of `ecdk dev` writes `grading.json`) and let the person confirm them.
14
+ 1. **Design before code.** Read `ecdk guide 0` (what the person decides) and `ecdk guide 2`. Decide ① what the student does, ② the completion policies and the grading (`on_access` · `on_submit` · `on_graded` with grading `type` `pattern` or `rubric`), written as the required `completionPolicies` in the project's `metadata.json` with the default first; one policy fixes it, more than one needs a completion policy screen where the instructor picks; the quiz template fixes `["on_graded"]`, so do not ask for a quiz, ③ the instructor screen, ④ the content edit screen, ⑤ the purpose. Decide what the request leaves out and tell the person briefly; ask only when the learning goal is unclear.
15
+ 2. **Environment and project.** `ecdk --version && ecdk doctor --json` (`ecdk guide 1`), then `ecdk create --list` to pick a template and `ecdk create <folder> --template <name>` (`ecdk guide 3`; it runs `npm install` for the SDK, so when that fails run `npm install` in the project).
16
+ 3. **Write the screens.** You build the template: screens and code (`ecdk guide 5`; the quiz template: `ecdk guide 6`), and `commentary.txt` (key concepts and intent, no answers). The real content and answers are entered in the LXP edit screen after upload; there is no default content file. In `ecdk dev`, try the edit and learn screens with a little sample input (saved only locally in `.ecdk/settings.json`, never uploaded); do not author the full question set locally.
17
+ - If the person describes the content (for example "5 questions about perceptrons"), give it as draft text with the answers for the person to enter in the LXP edit screen. A quiz material holds one question, so several questions mean several quiz materials (pages).
17
18
  4. **Check.** `ecdk check`, fix errors (`ecdk guide 8`), then `ecdk dev` and go through the screens (`ecdk guide 9`). The person looks at the screens too.
18
19
  5. **Build and report.** `ecdk build --json` must return `ok: true`. Report as `ecdk guide 10` says.
19
- 6. **Upload** only after the person approves: the elice-content-publish skill (`ecdk guide 12`), or the person uploads `dist/content.zip` in LXP.
20
+ 6. **Upload** only after the person approves: the elice-content-publish skill (`ecdk guide 12`), or the person uploads `dist/content.zip` in LXP. Then the person enters the content and answers in the LXP edit screen.
20
21
 
21
22
  {{version}}
@@ -13,8 +13,8 @@ The full guide ships with the CLI: `ecdk guide` lists the topics, `ecdk guide <t
13
13
 
14
14
  1. **Read** `ecdk guide 7` (move existing HTML) and `ecdk guide 4` (rules).
15
15
  2. **Look at the original first.** List its entry HTML, the files it loads, and anything the sandbox blocks (storage, cookies, dialogs, `window.open`, the parent window, external requests, absolute `/` paths). Tell the person what will change.
16
- 3. **Wrap it.** Make or reuse an ecdk project as `ecdk guide 7` says, keep the original files as they are where possible, and write `commentary.txt`.
17
- 4. **Completion and grading.** Decide how it completes (`ecdk guide 2`) and write the required `completionPolicies` in `elice.config.json`, default first (`["on_access"]` without a submission). When it grades, set the grader and the answers on the edit screen (`app.useGradingBlock()`); list more than one policy and add a completion policy screen only when the instructor should pick the policy. Ask the person for correct answers when it is graded.
16
+ 3. **Wrap it.** Make or reuse an ecdk project as `ecdk guide 7` says, keep the original files as they are where possible, and write `commentary.txt`. An old ecdk project (`elice.config.json`, or `lib/cdk.js` without `@eliceio/cdk` in `package.json`): `ecdk doctor --fix`, then `npm install`.
17
+ 4. **Completion and grading.** Decide how it completes (`ecdk guide 2`) and write the required `completionPolicies` in `metadata.json`, default first (`["on_access"]` without a submission). When it grades, set the grader and the answers on the edit screen (`app.useGradingBlock()`); list more than one policy and add a completion policy screen only when the instructor should pick the policy. Ask the person for correct answers when it is graded. Data the instructor should edit goes in the content the edit screen saves, not in a default JSON file; until it is saved the screens show `app.emptyState()`.
18
18
  5. **Check.** `ecdk check`, fix errors (`ecdk guide 8`), `ecdk dev`, compare with the original.
19
19
  6. **Build and report.** `ecdk build --json` returns `ok: true`; report what changed from the original (`ecdk guide 10`).
20
20
 
@@ -15,8 +15,9 @@ Read `ecdk guide 12` (upload with the material MCP) first. It has the tool order
15
15
  2. **Build.** `ecdk build --json` must return `ok: true`. Keep `zip` and `zipBytes`.
16
16
  3. **Pick the page.** Use `.ecdk/link.json` if it exists, or the LXP edit URL the person gives (`https://{org}.…/lecturepages/{id}/edit`). Otherwise list with `list_my_organizations` → `list_courses` → `list_lectures` → `list_custom_pages` and let the person choose. Make a new page with `create_custom_page` only after the person approves.
17
17
  4. **Upload.** `get_material` (keep `current_version.id`) → `create_package_upload` with `size_bytes = zipBytes` → run its `curl_command` with `package.zip` replaced by the zip path → `submit_package` → poll `get_draft` until ready or failed. On failure, report the server's reason with `ecdk check dist/content.zip` and stop.
18
- 5. **Approve.** Show what changes (page, title, completion policy, whether answers are saved) and the draft `preview_urls`. Saving is visible to learners at once if the page is open. Wait for an explicit yes.
19
- 6. **Save.** `save_draft` with `expected_current_version_id`, `completion_policy` and, for `on_graded`, the `grading` the person confirmed. On `MATERIAL_CHANGED`, stop: someone saved in between.
20
- 7. **Finish.** Set the title and icon with `update_material` if the page has none (`ecdk guide 12`). Write `.ecdk/link.json` as `{ "org": …, "lecture_page_id": …, "version_id": … }` so the next upload goes to the same page. Report the LXP URL. New pages stay closed until the person opens them in LXP.
18
+ 5. **Approve.** Show what changes (page, title, completion policy, and that the content and answers are entered on the LXP edit screen after saving) and the draft `preview_urls`. Saving is visible to learners at once if the page is open. Wait for an explicit yes.
19
+ 6. **Save.** `save_draft` with `expected_current_version_id` and `completion_policy`. Do not send content or `grading` from `.ecdk/settings.json`: it is sample input for local checks only and is never uploaded. On `MATERIAL_CHANGED`, stop: someone saved in between. A quiz (`on_graded`) has no answers at its first upload; the server's behavior there is undecided (G132): if it returns `MATERIAL_GRADING_REQUIRED`, stop and tell the person.
20
+ 7. **Content and answers.** Tell the person to open the LXP edit screen now and enter the content and answers (a quiz needs its answers right away to be graded). Until then learners see "아직 내용이 없습니다".
21
+ 8. **Finish.** Set the title and icon with `update_material` if the page has none (`ecdk guide 12`). Write `.ecdk/link.json` as `{ "org": …, "lecture_page_id": …, "version_id": … }` so the next upload goes to the same page. Report the LXP URL. New pages stay closed until the person opens them in LXP.
21
22
 
22
23
  {{version}}
@@ -2,10 +2,10 @@
2
2
  * @eliceio/cdk 1.x(EliceCDK)와 같은 공개 인터페이스를 가진 mock · 템플릿이 제공 (고치지 마세요)
3
3
  *
4
4
  * 서버 없이 화면을 시험할 때 키트가 대신 씁니다. 실제 SDK와 다른 점:
5
- * - 채점: 편집 화면이 저장한 채점 설정(settings.grading), 없으면 프로젝트의 grading.json({ type: pattern | rubric })과
6
- * 완료 정책으로 로컬 채점. pattern 답은 정규식 하나, 답 문자열 전체 일치
5
+ * - 채점: 편집 화면이 저장한 채점 설정(settings.grading { type: pattern | rubric })과 완료 정책으로 로컬 채점.
6
+ * pattern 답은 정규식 하나, 답 문자열 전체 일치. 프로젝트 폴더를 그대로 열면 ecdk dev가 저장한 .ecdk/settings.json으로 시작
7
7
  * - 완료 정책: material.completionPolicy · completionPolicies와 saveCompletionPolicy를 흉내 낸다. 지원하는 정책은
8
- * metadata completionPolicies(elice.config.json, 없으면 metadata.json · ecdk dev가 주는 값)이고, 처음 값은
8
+ * metadata completionPolicies(프로젝트의 metadata.json · ecdk dev가 주는 값)이고, 처음 값은
9
9
  * .ecdk/completion.json(그 안에 있을 때) · 없으면 첫 값(서버가 업로드 때 정하는 값). 바꾼 값은 이 브라우저에만
10
10
  * - 저장: 설정 화면이 저장한 내용과 제출 기록을 브라우저에 남겨 다른 화면에서도 보임
11
11
  * (sandbox라 저장소가 막히면 이 페이지 안에서만)
@@ -54,7 +54,7 @@ const MAX_ANSWER_BYTES = 64 * 1024;
54
54
  const STORE_PREFIX = 'elice-content-mock:';
55
55
  const MESSAGE_SOURCE = 'eliceio-content-sdk';
56
56
  const SETTINGS_SAVED_MESSAGE_TYPE = 'settings-saved';
57
- /** 템플릿의 metadata.json 진입 파일 (elice.config.json `screens`가 있으면 그것) */
57
+ /** 템플릿의 metadata.json 진입 파일 */
58
58
  const DEFAULT_ENTRIES = Object.freeze({
59
59
  learn: 'index.html',
60
60
  instructor: 'instructor.html',
@@ -164,7 +164,7 @@ const sleep = ms => new Promise(r => setTimeout(r, ms));
164
164
  * @typedef {object} MockOptions
165
165
  * @property {() => void} [onSessionExpired]
166
166
  * @property {string} [scenario] ?mock= 대신 직접 지정
167
- * @property {object} [grading] grading.json 대신 직접 지정 (settings.grading 모양)
167
+ * @property {object} [grading] 채점 설정 직접 지정 (settings.grading 모양, 테스트용)
168
168
  * @property {'on_access' | 'on_submit' | 'on_graded'} [completionPolicy] 로컬 완료 정책 대신 직접 지정
169
169
  * @property {Array<'on_access' | 'on_submit' | 'on_graded'>} [completionPolicies] metadata completionPolicies 대신 직접 지정
170
170
  * @property {Record<string, unknown>} [settings] 처음 저장된 내용
@@ -302,6 +302,8 @@ export class MockEliceCDK {
302
302
  if (this.#options.settings && Object.keys(this.#store.get('settings', {})).length === 0)
303
303
  this.#store.set('settings', this.#options.settings);
304
304
  const local = await this.#loadLocal();
305
+ if (local.settings && Object.keys(this.#store.get('settings', {})).length === 0)
306
+ this.#store.set('settings', local.settings);
305
307
  this.#grading = normalizeGradingSettings(this.#options.grading) ?? local.grading;
306
308
  const policies = this.#options.completionPolicies ?? local.policies;
307
309
  this.#policies = policies;
@@ -493,7 +495,7 @@ export class MockEliceCDK {
493
495
  this.#draftSubmissions = [];
494
496
  }
495
497
 
496
- /** 저장된 채점 설정(편집 화면), 없으면 로컬(grading.json · options.grading) */
498
+ /** 저장된 채점 설정(편집 화면), 없으면 ecdk dev가 주는 값 · options.grading */
497
499
  #effectiveGrading() {
498
500
  return normalizeGradingSettings(this.#store.get('settings', {}).grading) ?? this.#grading;
499
501
  }
@@ -547,9 +549,9 @@ export class MockEliceCDK {
547
549
 
548
550
  /**
549
551
  * 로컬 채점 설정 · 완료 정책. ecdk dev의 콘텐츠 주소를 직접 열면 dev가 주는 값을, 프로젝트 폴더를 그대로 열면
550
- * grading.json · .ecdk/completion.json과 completionPolicies(elice.config.json, 없으면 metadata.json)를 읽는다
551
- * (grading.json · .ecdk는 zip에서 빠짐, 로컬 채점용으로 일부러 읽음). 완료 정책은 .ecdk(목록 안일 때) > 첫 값
552
- * @returns {Promise<{ grading: object | null, policy: string | null, policies: string[] | null }>}
552
+ * .ecdk/settings.json(ecdk dev 편집 화면이 저장한 내용 + 답) · .ecdk/completion.json과 completionPolicies(metadata.json)를
553
+ * 읽는다 (.ecdk는 zip에서 빠짐, 로컬 채점용으로 일부러 읽음). 완료 정책은 .ecdk(목록 안일 때) > 첫 값
554
+ * @returns {Promise<{ grading: object | null, policy: string | null, policies: string[] | null, settings?: object | null }>}
553
555
  */
554
556
  async #loadLocal() {
555
557
  const loadJson =
@@ -566,18 +568,16 @@ export class MockEliceCDK {
566
568
  }
567
569
  if (this.#options.grading) return { grading: null, policy: null, policies: null };
568
570
  // ecdk-ignore-next-line project.answer-import
569
- const data = await loadJson('grading.json').catch(() => null);
571
+ const saved = await loadJson('.ecdk/settings.json').catch(() => null);
570
572
  const local = await loadJson('.ecdk/completion.json').catch(() => null);
571
- const manifest =
572
- // ecdk-ignore-next-line project.answer-import
573
- (await loadJson('elice.config.json').catch(() => null)) ??
574
- (await loadJson('metadata.json').catch(() => null));
573
+ const manifest = await loadJson('metadata.json').catch(() => null);
575
574
  const policies = listOf(manifest?.completionPolicies);
576
- const saved = local?.completion_policy;
575
+ const savedPolicy = local?.completion_policy;
577
576
  return {
578
- grading: normalizeGradingSettings(data),
579
- policy: policies?.includes(saved) ? saved : (policies?.[0] ?? null),
577
+ grading: null,
578
+ policy: policies?.includes(savedPolicy) ? savedPolicy : (policies?.[0] ?? null),
580
579
  policies,
580
+ settings: saved && typeof saved === 'object' && !Array.isArray(saved) ? saved : null,
581
581
  };
582
582
  }
583
583
 
@@ -63,6 +63,14 @@ p {
63
63
  color: var(--ec-muted);
64
64
  font-size: var(--eds-fs-body2);
65
65
  }
66
+ /* 편집 화면이 아직 내용을 저장하지 않았을 때 (app.emptyState) */
67
+ .ec-empty {
68
+ color: var(--ec-muted);
69
+ border: 1px dashed var(--ec-border);
70
+ border-radius: var(--ec-radius);
71
+ padding: 32px 16px;
72
+ text-align: center;
73
+ }
66
74
  .ec-card {
67
75
  border: 1px solid var(--ec-border);
68
76
  border-radius: var(--ec-radius);
@@ -145,7 +145,12 @@ export interface ContentApp<C = Record<string, unknown>> {
145
145
  account: { anonymousId: string; fullname: string | null } | null;
146
146
  result: { score: number | null; submitCount: number; completedAt: string | null } | null;
147
147
  readonly records: boolean;
148
+ /** 편집 화면이 저장한 내용 (settings에서 grading을 뺀 것). 아직 저장하지 않았으면 {} */
148
149
  readonly content: C;
150
+ /** 편집 화면이 내용을 저장했는지. false면 학생 · 교육자 화면은 emptyState()를 보여 준다 */
151
+ readonly hasContent: boolean;
152
+ /** "아직 내용이 없습니다 …" 안내 요소 (학생 · 교육자 화면에서 hasContent가 false일 때) */
153
+ emptyState(): Element;
149
154
  /** 저장된 채점 설정. edit 범위(편집 · 완료 정책 화면)에서만, 없으면 null */
150
155
  readonly grading: Grading | null;
151
156
  submit(answer: unknown): Promise<SubmitResult>;
@@ -197,7 +202,6 @@ export interface ContentApp<C = Record<string, unknown>> {
197
202
 
198
203
  export interface StartOptions {
199
204
  screen: Screen;
200
- defaults?: string;
201
205
  onError?: (error: ContentError) => void;
202
206
  sdk?: 'real' | 'mock' | object;
203
207
  mock?: {
@@ -21,7 +21,8 @@
21
21
  *
22
22
  * import { start } from '../lib/elice-content.js';
23
23
  * const app = await start({ screen: 'learn' });
24
- * app.content // 편집 화면(CMS)이 저장한 내용, 없으면 content.json
24
+ * if (!app.hasContent) root.replaceChildren(app.emptyState()) // 편집 화면에서 아직 저장하지 않음
25
+ * app.content // 편집 화면(CMS)이 저장한 내용 (settings, 없으면 {})
25
26
  * await app.submit(answer)
26
27
  *
27
28
  * 정답은 콘텐츠(zip)에 넣지 않습니다. 채점은 서버가 채점 설정(settings.grading)으로 합니다 (ADR 0009).
@@ -51,6 +52,8 @@ const MESSAGES = {
51
52
  rate_limited: '제출이 너무 잦습니다. 잠시 뒤 다시 시도해 주세요.',
52
53
  invalid_input: '답이 너무 크거나 형식이 올바르지 않습니다.',
53
54
  content_not_ready: '아직 저장된 자료가 없습니다.',
55
+ // 키트만의 문구: 편집 화면이 아직 내용을 저장하지 않음 (기본 내용 파일은 없음)
56
+ content_empty: '아직 내용이 없습니다. 편집 화면에서 내용을 만들어 저장하면 여기에 보입니다.',
54
57
  external_service_error: '채점하지 못했어요. 제출이 저장되지 않았으니 다시 제출해 주세요.',
55
58
  screen_not_supported: '이 화면에서는 할 수 없는 일입니다.',
56
59
  navigation_timeout: '수업 페이지 정보를 받지 못했습니다. 잠시 뒤 다시 시도해 주세요.',
@@ -249,11 +252,10 @@ export function resolveLaunch(hash, pathname, screen) {
249
252
  /**
250
253
  * @typedef {object} StartOptions
251
254
  * @property {'learn' | 'instructor' | 'edit' | 'completionPolicy'} screen 이 HTML이 어떤 화면인지
252
- * @property {string} [defaults] 저장된 내용이 없을 때 쓸 내용 파일 (기본 'content.json')
253
255
  * @property {(error: ContentError) => void} [onError] 화면 밖 오류(세션 만료 등)를 받을 함수. 기본은 상단 알림
254
256
  * @property {'real' | 'mock' | object} [sdk] SDK 고르기 (기본: pickSdk). 객체면 그대로 씀 (테스트)
255
257
  * @property {object} [mock] mock 옵션 (scenario, grading, settings, delayMs)
256
- * @property {(url: string) => Promise<unknown>} [loadJson] 테스트용
258
+ * @property {(url: string) => Promise<unknown>} [loadJson] 테스트용 (mock이 읽는 로컬 파일)
257
259
  * @property {string} [hash] 테스트용: location.hash 대신
258
260
  * @property {string} [pathname] 테스트용: location.pathname 대신
259
261
  * @property {string} [search] 테스트용: location.search 대신
@@ -266,7 +268,7 @@ export function resolveLaunch(hash, pathname, screen) {
266
268
  * @param {StartOptions} options
267
269
  */
268
270
  export async function start(options) {
269
- const { screen, defaults = 'content.json' } = options;
271
+ const { screen } = options;
270
272
  if (!SCREEN_ALLOWED[screen]) throw new Error(`알 수 없는 화면: ${screen}`);
271
273
  const notify = options.onError ?? showBanner;
272
274
 
@@ -326,14 +328,12 @@ export async function start(options) {
326
328
  throw e;
327
329
  }
328
330
 
329
- // 저장된 settings에서 채점 설정(grading, edit 범위에만 옴)을 떼어 둔다: 화면 내용(content)은 grading 없이,
330
- // grading만 저장된 자료는 내용이 없는 것으로 보고 content.json을 쓴다
331
+ // 저장된 settings에서 채점 설정(grading, edit 범위에만 옴)을 떼어 둔다: 화면 내용(content)은 grading 없이.
332
+ // 내용은 편집 화면이 저장한 settings뿐이다 (기본 내용 파일은 없음, ADR 0011). 아직 없으면 {}이고 hasContent가 false
331
333
  const { grading: rawGrading = null, ...saved } = sdk.material?.settings ?? {};
332
- const savedGrading = normalizeGrading(rawGrading);
333
- const loadJson = options.loadJson ?? (url => fetch(url).then(r => (r.ok ? r.json() : {})));
334
- let content = Object.keys(saved).length > 0 ? saved : await loadJson(defaults).catch(() => ({}));
335
- let grading = savedGrading;
336
- /** 다음 저장의 바탕: 서버에 저장된 settings 그대로 (content.json 기본값은 넣지 않음) */
334
+ let content = saved;
335
+ let grading = normalizeGrading(rawGrading);
336
+ /** 다음 저장의 바탕: 서버에 저장된 settings 그대로 */
337
337
  let savedSettings = sdk.material?.settings ?? {};
338
338
 
339
339
  const readOnly = viewer === 'tutor';
@@ -362,10 +362,18 @@ export async function start(options) {
362
362
  get records() {
363
363
  return viewer === 'student' && !app.isDraft && kind !== 'mock';
364
364
  },
365
- /** 편집 화면(CMS)이 저장한 내용. 학생에게도 공개되므로 정답을 넣지 않는다 */
365
+ /** 편집 화면(CMS)이 저장한 내용. 학생에게도 공개되므로 정답을 넣지 않는다. 아직 저장하지 않았으면 {} */
366
366
  get content() {
367
367
  return content;
368
368
  },
369
+ /** 편집 화면이 내용을 저장했는지. false면 학생 · 교육자 화면은 emptyState()를 보여 준다 */
370
+ get hasContent() {
371
+ return Object.keys(content).length > 0;
372
+ },
373
+ /** 내용이 없을 때 보여 줄 안내 ("아직 내용이 없습니다 …"). 학생 · 교육자 화면에서 app.hasContent가 false일 때 */
374
+ emptyState() {
375
+ return h('p', { className: 'ec-empty', role: 'status', textContent: MESSAGES.content_empty });
376
+ },
369
377
  /**
370
378
  * 저장된 채점 설정 `{ type: 'pattern', answer_key }` · `{ type: 'rubric', rubric }` 또는 null.
371
379
  * edit 범위(편집 · 완료 정책 화면)에서만 오고, 학생 · 튜터 · 교육자 화면에는 서버가 내려주지 않는다
@@ -10,16 +10,19 @@ Elice Custom HTML 학습자료 프로젝트입니다.
10
10
  | `screens/instructor.js` · `instructor.html` | 교육자 화면 |
11
11
  | `screens/edit.js` · `edit.html` | 내용 편집 화면 (CMS) |
12
12
  | `screens/completion.js` · `completion.html` | 완료 정책 화면 (교육자가 고름, 고칠 일 거의 없음) |
13
- | `content.json` | 처음 내용. 편집 화면에서 저장하면 저장한 내용을 씁니다 |
14
13
  | `styles.css` | 이 콘텐츠의 스타일 |
15
- | `elice.config.json` | 화면 구성(`screens`) · 지원하는 완료 정책(`completionPolicies`) |
14
+ | `metadata.json` | 화면 구성(`screens`) · 지원하는 완료 정책(`completionPolicies`) · 학습 참고 내용(`commentary`). `ecdk build`가 `build`만 채움 |
15
+ | `package.json` | SDK 버전(`@eliceio/cdk`) · 빌드 옵션 `"ecdk"` (`minify` 등). zip에 들어가지 않음 |
16
16
 
17
- `lib/`는 플랫폼 연결 로직이라 고치지 않습니다. 화면은 **누가 보는지(학생 · 교육자 · 튜터)나 미리보기인지 몰라도 됩니다.**
17
+ 이 프로젝트는 **템플릿(화면 · 코드)만** 만듭니다. 실제 내용과 정답은 LXP에 올린 뒤 편집 화면에서 입력합니다. `ecdk dev`의 내용 편집에서 넣은 것은 화면을 시험하는 견본이고 `.ecdk/settings.json`에만 남으며 올라가지 않습니다. 내용은 편집 화면이 저장한 것(`settings`)뿐입니다. 기본 내용 파일은 없어서, 편집 화면에서 저장하기 전에는 학생 · 교육자 화면이 "아직 내용이 없습니다" 안내를 보입니다 (`app.hasContent` · `app.emptyState()`).
18
+
19
+ `lib/`(화면 키트)는 플랫폼 연결 로직이라 고치지 않습니다. SDK(`lib/cdk.js`)는 프로젝트에 없고 `ecdk build` · `ecdk dev`가 `node_modules/@eliceio/cdk`에서 넣습니다 (처음 한 번 `npm install`, 올리기 `npm update @eliceio/cdk`). 화면은 **누가 보는지(학생 · 교육자 · 튜터)나 미리보기인지 몰라도 됩니다.**
18
20
 
19
21
  ```js
20
22
  // 학생 화면: 문항을 그리고 답을 모으고 채우는 방법만 알려 준다
21
23
  const app = await start({ screen: 'learn' });
22
- render(app.content);
24
+ if (app.hasContent) render(app.content);
25
+ else root.replaceChildren(app.emptyState()); // 편집 화면에서 아직 저장하지 않음
23
26
  app.useSubmit({ getAnswer, setAnswer, validate });
24
27
 
25
28
  // 여러 단계(슬라이드 · STEP)인 자료: 양옆 화살표와 n / N을 키트가 그린다.
@@ -48,8 +51,8 @@ app.useSave({ getContent, validate });
48
51
 
49
52
  | 언제 | SDK | 채점 · 저장 |
50
53
  | --------------------------------------------- | -------------------------------- | ----------------------------------------------------------------------------- |
51
- | 플랫폼에서 열 때 (`#token=`, 편집기 draft) | real (`lib/cdk.js`) | 서버 |
52
- | 그 밖 (로컬) | mock (`lib/cdk-mock.js`) | `grading.json`(완료 정책 · 정답)으로 로컬 채점, 저장 내용·제출은 이 브라우저에 |
54
+ | 플랫폼에서 열 때 (`#token=`, 편집기 draft) | real (`lib/cdk.js`, build가 넣음) | 서버 |
55
+ | 그 밖 (로컬) | mock (`lib/cdk-mock.js`) | 편집 화면이 저장한 정답 · 완료 정책으로 로컬 채점, 저장 내용·제출은 이 브라우저에 (프로젝트 폴더를 열면 `.ecdk/settings.json`으로 시작) |
53
56
 
54
57
  - 강제로 바꾸기: 주소에 `?sdk=mock` 또는 `?sdk=real`
55
58
  - 보는 사람 바꾸기 (mock): `#viewer=tutor` (`student` · `instructor` · `tutor`), 편집기 draft 흉내: `#preview=1` · `#edit=1`
@@ -61,8 +64,8 @@ app.useSave({ getContent, validate });
61
64
  정답은 zip에 넣지 않습니다 (ADR 0009, `ecdk guide 2` · `5`).
62
65
 
63
66
  - **채점 방식 · 답**: 답을 채점하는 자료면 편집 화면에 키트의 채점 블록을 붙입니다: `const grading = app.useGradingBlock();` 후 `app.useSave({ …, getGrading: () => grading.getGrading() })`. LXP와 같은 문구로 기준 답안(정규표현식) · 평가 기준을 받아 `settings.grading`에 저장합니다 (학생에게는 내려가지 않음).
64
- - **완료 정책**: `elice.config.json`의 `completionPolicies` (필수). 이 자료가 지원하는 정책이고, LXP에 올리면 서버가 **첫 값**으로 완료 정책을 정합니다. 기본은 `["on_submit", "on_access"]`(제출하면 완료, 교육자가 열면 완료로 바꿀 수 있음)이고, 교육자는 완료 정책 화면(`completion.html`, `screens.completionPolicy`)에서 이 안에서만 고릅니다. 하나로 고정하려면 `["on_submit"]`처럼 하나만 적고 완료 정책 화면(`completion.html` · `screens/completion.js` · `screens.completionPolicy`)을 지웁니다.
65
- - 채점해 통과하면 완료(`on_graded`)를 넣으려면 편집 화면에 채점 블록이 있어야 합니다 (위). 로컬 채점 흉내는 `grading.json` (`{ "type": "pattern", "answer_key": "^…$" }` · `{ "type": "rubric", "rubric": "…" }`), 로컬 완료 정책은 `.ecdk/completion.json`. `ecdk dev`의 내용 편집 · 완료 정책 보기에서 저장하면 이 파일들에 씁니다. 둘 다 `ecdk build`가 zip에서 뺍니다.
67
+ - **완료 정책**: `metadata.json`의 `completionPolicies` (필수). 이 자료가 지원하는 정책이고, LXP에 올리면 서버가 **첫 값**으로 완료 정책을 정합니다. 기본은 `["on_submit", "on_access"]`(제출하면 완료, 교육자가 열면 완료로 바꿀 수 있음)이고, 교육자는 완료 정책 화면(`completion.html`, `screens.completionPolicy`)에서 이 안에서만 고릅니다. 하나로 고정하려면 `["on_submit"]`처럼 하나만 적고 완료 정책 화면 파일(`completion.html` · `screens/completion.js`)을 지운 뒤 `screens.completionPolicy`를 `{ "enabled": false }`로 바꿉니다.
68
+ - 채점해 통과하면 완료(`on_graded`)를 넣으려면 편집 화면에 채점 블록이 있어야 합니다 (위). `ecdk dev`의 내용 편집에서 저장한 내용 · 채점 설정(`{ "type": "pattern", "answer_key": "^…$" }` · `{ "type": "rubric", "rubric": "…" }`)은 `.ecdk/settings.json`, 완료 정책 보기에서 고른 정책은 `.ecdk/completion.json`에 남고 로컬 채점에 쓰입니다. 둘 다 `ecdk build`가 zip에서 뺍니다. 정답 파일은 없습니다 (ADR 0011).
66
69
 
67
70
  ## 명령
68
71
 
@@ -0,0 +1,11 @@
1
+ {
2
+ "kind": "material",
3
+ "screens": {
4
+ "learn": { "enabled": true, "entry": "index.html" },
5
+ "instructor": { "enabled": true, "entry": "instructor.html" },
6
+ "edit": { "enabled": true, "entry": "edit.html" },
7
+ "completionPolicy": { "enabled": true, "entry": "completion.html" }
8
+ },
9
+ "completionPolicies": ["on_submit", "on_access"],
10
+ "commentary": "commentary.txt"
11
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "private": true,
3
+ "type": "module",
4
+ "scripts": {
5
+ "dev": "ecdk dev",
6
+ "build": "ecdk build",
7
+ "check": "ecdk check"
8
+ },
9
+ "dependencies": {
10
+ "@eliceio/cdk": "workspace:^1.0.0-alpha.3"
11
+ },
12
+ "ecdk": {}
13
+ }
@@ -1,6 +1,6 @@
1
1
  // 완료 정책 화면 (LXP 편집 페이지 설정 탭, screens.completionPolicy). 라디오 · 저장 · 변경 표시는 키트(useCompletion)가 합니다.
2
- // elice.config.json completionPolicies에 적은 정책만 보이고, 저장하면 SDK saveCompletionPolicy로 자료의 완료 정책이 바뀝니다.
3
- // 정책을 하나만 두면(고정) 이 화면은 지우고 elice.config.json screens에서도 뺍니다.
2
+ // metadata.json completionPolicies에 적은 정책만 보이고, 저장하면 SDK saveCompletionPolicy로 자료의 완료 정책이 바뀝니다.
3
+ // 정책을 하나만 두면(고정) 이 화면은 지우고 metadata.json screens.completionPolicy를 { "enabled": false }로 바꿉니다.
4
4
  import { start } from '../lib/elice-content.js';
5
5
 
6
6
  const app = await start({ screen: 'completionPolicy' });
@@ -2,8 +2,15 @@
2
2
  import { start } from '../lib/elice-content.js';
3
3
 
4
4
  const app = await start({ screen: 'instructor' });
5
- const title = document.createElement('h1');
6
- title.textContent = `${app.content.title ?? ''} · 교육자 화면`;
7
- const message = document.createElement('p');
8
- message.textContent = app.content.message ?? '';
9
- document.getElementById('app').replaceChildren(title, message);
5
+ const root = document.getElementById('app');
6
+ // 편집 화면에서 아직 내용을 저장하지 않았으면 안내만 보인다
7
+ if (app.hasContent) show();
8
+ else root.replaceChildren(app.emptyState());
9
+
10
+ function show() {
11
+ const title = document.createElement('h1');
12
+ title.textContent = `${app.content.title ?? ''} · 교육자 화면`;
13
+ const message = document.createElement('p');
14
+ message.textContent = app.content.message ?? '';
15
+ root.replaceChildren(title, message);
16
+ }
@@ -4,16 +4,21 @@ import { start } from '../lib/elice-content.js';
4
4
 
5
5
  const app = await start({ screen: 'learn' });
6
6
  const root = document.getElementById('app');
7
+ // 편집 화면에서 아직 내용을 저장하지 않았으면 안내만 보인다 (기본 내용은 없음)
8
+ if (app.hasContent) show();
9
+ else root.replaceChildren(app.emptyState());
7
10
 
8
- const title = Object.assign(document.createElement('h1'), { textContent: app.content.title ?? '' });
9
- const message = Object.assign(document.createElement('p'), {
10
- textContent: app.content.message ?? '',
11
- });
12
- const answer = Object.assign(document.createElement('textarea'), { ariaLabel: '답' });
13
- root.replaceChildren(title, message, answer);
11
+ function show() {
12
+ const title = Object.assign(document.createElement('h1'), { textContent: app.content.title ?? '' });
13
+ const message = Object.assign(document.createElement('p'), {
14
+ textContent: app.content.message ?? '',
15
+ });
16
+ const answer = Object.assign(document.createElement('textarea'), { ariaLabel: '답' });
17
+ root.replaceChildren(title, message, answer);
14
18
 
15
- app.useSubmit({
16
- getAnswer: () => ({ text: answer.value }),
17
- setAnswer: (a) => (answer.value = a?.text ?? ''),
18
- validate: (a) => a.text.trim() !== '' || '답을 입력해 주세요.',
19
- });
19
+ app.useSubmit({
20
+ getAnswer: () => ({ text: answer.value }),
21
+ setAnswer: (a) => (answer.value = a?.text ?? ''),
22
+ validate: (a) => a.text.trim() !== '' || '답을 입력해 주세요.',
23
+ });
24
+ }
@@ -10,10 +10,9 @@ Elice Custom HTML 학습자료 프로젝트입니다.
10
10
  | `screens/instructor.js` · `instructor.html` | 교육자 화면 |
11
11
  | `screens/edit.js` · `edit.html` | 내용 편집 화면 (CMS) |
12
12
  | `ui/` | 퀴즈의 모양: 색 · 간격 · 문구 · 마크업 (아래 표) |
13
- | `content.json` | 처음 내용 (단일 선택 한 문제). 편집 화면에서 저장하면 저장한 내용을 씁니다. 다섯 유형 모두 편집 화면 "문항 추가"로 더함 |
14
13
  | `styles.css` | 이 콘텐츠의 스타일 (값은 `ui/theme.css`의 변수) |
15
- | `elice.config.json` | 화면 구성(`screens`) · 완료 정책(`completionPolicies`) |
16
- | `grading.json` | 로컬 채점용 정답 정규식 (zip에 들어가지 않음) |
14
+ | `metadata.json` | 화면 구성(`screens`) · 완료 정책(`completionPolicies`) · 학습 참고 내용(`commentary`). `ecdk build`가 `build`만 채움 |
15
+ | `package.json` | SDK 버전(`@eliceio/cdk`) · 빌드 옵션 `"ecdk"` (`minify` 등). zip에 들어가지 않음 |
17
16
 
18
17
  ## 퀴즈 모양 바꾸기
19
18
 
@@ -50,12 +49,15 @@ core/ 동작 — 고치지 않습니다 (답 문자열 · 채점 약속,
50
49
 
51
50
  보기 · 칸 · 그룹 · 문항 요소의 `data-role` · `data-option` · `data-slot` · `data-group` · `data-id`, 상태 표시 `data-result`(`correct` · `wrong`) · `data-dragging` · `data-ghost`는 동작이 붙입니다. CSS에서 이 속성으로 상태를 꾸밀 수 있습니다.
52
51
 
53
- `lib/`는 플랫폼 연결 로직이라 고치지 않습니다. 화면은 **누가 보는지(학생 · 교육자 · 튜터)나 미리보기인지 몰라도 됩니다.**
52
+ 이 프로젝트는 **템플릿(화면 · 코드)만** 만듭니다. 실제 내용과 정답은 LXP에 올린 뒤 편집 화면에서 입력합니다. `ecdk dev`의 내용 편집에서 넣은 것은 화면을 시험하는 견본이고 `.ecdk/settings.json`에만 남으며 올라가지 않습니다. 내용은 편집 화면이 저장한 것(`settings`)뿐입니다. 기본 문항은 없어서, 편집 화면에서 저장하기 전에는 학생 · 교육자 화면이 "아직 내용이 없습니다" 안내를 보입니다 (`app.hasContent` · `app.emptyState()`).
53
+
54
+ `lib/`(화면 키트)는 플랫폼 연결 로직이라 고치지 않습니다. SDK(`lib/cdk.js`)는 프로젝트에 없고 `ecdk build` · `ecdk dev`가 `node_modules/@eliceio/cdk`에서 넣습니다 (처음 한 번 `npm install`, 올리기 `npm update @eliceio/cdk`). 화면은 **누가 보는지(학생 · 교육자 · 튜터)나 미리보기인지 몰라도 됩니다.**
54
55
 
55
56
  ```js
56
57
  // 학생 화면: 문항을 그리고 답을 모으고 채우는 방법만 알려 준다
57
58
  const app = await start({ screen: 'learn' });
58
- render(app.content);
59
+ if (app.hasContent) render(app.content);
60
+ else root.replaceChildren(app.emptyState()); // 편집 화면에서 아직 저장하지 않음
59
61
  app.useSubmit({ getAnswer, setAnswer, validate });
60
62
 
61
63
  // 편집 화면(CMS): 고칠 칸을 그리고 저장할 내용만 알려 준다
@@ -80,8 +82,8 @@ app.useSave({ getContent, validate });
80
82
 
81
83
  | 언제 | SDK | 채점 · 저장 |
82
84
  | ------------------------------------------ | ------------------------ | ------------------------------------------------------------------------------ |
83
- | 플랫폼에서 열 때 (`#token=`, 편집기 draft) | real (`lib/cdk.js`) | 서버 |
84
- | 그 밖 (로컬) | mock (`lib/cdk-mock.js`) | `grading.json`(완료 정책 · 정답)으로 로컬 채점, 저장 내용·제출은 이 브라우저에 |
85
+ | 플랫폼에서 열 때 (`#token=`, 편집기 draft) | real (`lib/cdk.js`, build가 넣음) | 서버 |
86
+ | 그 밖 (로컬) | mock (`lib/cdk-mock.js`) | 편집 화면이 저장한 정답 · 완료 정책으로 로컬 채점, 저장 내용·제출은 이 브라우저에 (프로젝트 폴더를 열면 `.ecdk/settings.json`으로 시작) |
85
87
 
86
88
  - 강제로 바꾸기: 주소에 `?sdk=mock` 또는 `?sdk=real`
87
89
  - 보는 사람 바꾸기 (mock): `#viewer=tutor` (`student` · `instructor` · `tutor`), 편집기 draft 흉내: `#preview=1` · `#edit=1`
@@ -90,21 +92,22 @@ app.useSave({ getContent, validate });
90
92
 
91
93
  ## 퀴즈 데이터와 정답
92
94
 
93
- - `content.json`: 처음 문항. 편집 화면에서 저장하면 저장값을 씁니다. 형식은 ecdk 문서 ADR 0006.
95
+ - 문항은 편집 화면에서 만들어 저장한 내용(`settings`)뿐입니다. 처음에는 문항이 없어 편집 화면은 **문항 추가**로 시작하고, 저장하기 전 학생 · 교육자 화면은 "아직 내용이 없습니다" 안내를 보입니다. 형식은 ecdk 문서 ADR 0006.
96
+ - 퀴즈 하나에 문항은 **하나**입니다 (기존 LXP 퀴즈처럼). 문항이 있으면 "문항 추가" 대신 안내가 보이고, 여러 문항은 퀴즈 페이지를 여러 개 만듭니다. 이미 여러 문항으로 저장된 퀴즈도 그대로 보이고 저장됩니다.
94
97
  - 문항 유형: 단일 선택 · 복수 선택 · 순서 맞추기 · 주관식 · 그룹 분류
95
98
  - 학생 답은 문자열 하나로 제출합니다: 문항 순서대로 `문항id=답`을 `;`로 잇고 주관식은 URL 인코딩 (`q1=b;q2=a,d;q4=%EA%B0%80…`).
96
- - 퀴즈는 완료 정책 **채점해 통과하면 완료(on_graded)** · 채점 방식 **기준 답안(pattern)** 고정입니다 (`elice.config.json` `"completionPolicies": ["on_graded"]`, ADR 0009). 하나뿐이라 완료 정책 화면이 없고, 모든 문항을 맞혀야 100점입니다 (문항별 점수 없음). 편집 화면은 답(`settings.grading`)만 저장하고 완료 정책은 보내지 않습니다.
99
+ - 퀴즈는 완료 정책 **채점해 통과하면 완료(on_graded)** · 채점 방식 **기준 답안(pattern)** 고정입니다 (`metadata.json` `"completionPolicies": ["on_graded"]`, ADR 0009). 하나뿐이라 완료 정책 화면이 없고, 모든 문항을 맞혀야 100점입니다 (문항별 점수 없음). 편집 화면은 답(`settings.grading`)만 저장하고 완료 정책은 보내지 않습니다.
97
100
 
98
101
  ## 정답
99
102
 
100
- 정답은 zip에 넣지 않습니다. **내용 편집 화면**(`edit.html`)에서 문항을 만들면서 같은 카드의 **정답**에서 답을 고릅니다 (주관식은 허용 답을 줄마다 하나). 저장할 때 고른 답으로 정답 정규식 하나를 만들어 `settings.grading`에 넣고 (학생에게는 내려가지 않음), 저장 전에 검증합니다 (ADR 0009):
103
+ 정답은 zip에 넣지 않습니다. **내용 편집 화면**(`edit.html`)에서 문항을 만들면서 같은 카드에서 답을 고릅니다. 단일 · 복수 선택은 보기 줄의 **정답**(radio · checkbox), 그룹 분류는 보기 줄의 그룹 고르기, 순서 맞추기 · 주관식은 아래 **정답** 칸에서 고릅니다 (주관식은 허용 답을 줄마다 하나). 정답은 보기 id로 저장해 보기 순서를 바꿔도 그대로이고, 보기를 지우면 정답에서 빠집니다. 저장할 때 고른 답으로 정답 정규식 하나를 만들어 `settings.grading`에 넣고 (학생에게는 내려가지 않음), 저장 전에 검증합니다 (ADR 0009):
101
104
 
102
105
  1. 모든 문항에 정답이 있고, 지운 보기를 가리키지 않는다
103
106
  2. 정규식이 컴파일되고 `^…$`로 감싸져 있으며 너무 길거나 느리지 않다
104
107
  3. 정답을 학생 화면과 같은 방식으로 이은 답이 맞는다 (주관식 허용 답은 하나씩 모두)
105
108
  4. 문항 하나를 다른 답으로 바꾸면 맞지 않는다 (너무 넓은 정답 방지)
106
109
 
107
- 로컬에서는 `ecdk dev`의 **내용 편집**에서 저장하면 `grading.json`에 쓰고, 학생 보기가 그 정답으로 채점합니다. `elice.config.json` · `grading.json`은 `ecdk build`가 zip에서 뺍니다.
110
+ 로컬에서는 `ecdk dev`의 **내용 편집**에서 저장하면 문항과 정답이 `.ecdk/settings.json`에 남고, 학생 보기가 그 정답으로 채점합니다. 정답 파일은 없습니다 (ADR 0011). `.ecdk/` · `package.json` · `node_modules/`는 `ecdk build`가 zip에서 뺍니다.
108
111
 
109
112
  ## 명령
110
113
 
@@ -37,7 +37,18 @@ export declare function createEditor(opts: {
37
37
  kind: 'option' | 'group',
38
38
  items: any[],
39
39
  key: string,
40
- opts?: { onDelete?: () => void },
40
+ opts?: {
41
+ onDelete?: () => void;
42
+ onInput?: (item: any) => void;
43
+ /** 줄마다 정답 칸 (data-role="answer"): radio · checkbox · select(choices: [값, 이름]) */
44
+ answer?: {
45
+ type: 'radio' | 'checkbox' | 'select';
46
+ name: string;
47
+ choices?: [string, string][] | undefined;
48
+ get(item: any): boolean | string;
49
+ set(item: any, value: boolean | string): void;
50
+ };
51
+ },
41
52
  ): HTMLElement;
42
53
  card(
43
54
  props: { q: any; index: number; count: number; types: [string, string][]; body: Node[] },