@eliceio/cdk-cli 1.3.0 → 1.4.0

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 (55) hide show
  1. package/README.md +5 -3
  2. package/es/commands/create/index.js +1 -0
  3. package/es/commands/create/scaffold.d.ts +1 -1
  4. package/es/commands/create/scaffold.js +1 -1
  5. package/es/commands/doctor/index.js +19 -2
  6. package/es/core/sandbox.d.ts +5 -0
  7. package/es/core/sandbox.js +19 -1
  8. package/es/engines/vite/plugin.js +7 -1
  9. package/es/rules/check.js +19 -2
  10. package/es/rules/grading.d.ts +25 -0
  11. package/es/rules/grading.js +131 -0
  12. package/es/rules/privacy.d.ts +2 -0
  13. package/es/rules/privacy.js +1 -1
  14. package/es/rules.json.js +1 -1
  15. package/package.json +2 -2
  16. package/rules.json +13 -1
  17. package/skills/_shared/references/02-design-the-material.md +1 -0
  18. package/skills/_shared/references/03-create-the-project.md +9 -9
  19. package/skills/_shared/references/05-screen-code.md +26 -0
  20. package/skills/_shared/references/06-using-the-quiz-template.md +8 -5
  21. package/skills/_shared/references/08-fix-check-errors.md +4 -2
  22. package/skills/_shared/references/12-upload-with-the-material-mcp.md +17 -1
  23. package/skills/_shared/references/13-edit-screen-design.md +1 -1
  24. package/skills/elice-content-create/SKILL.md +1 -1
  25. package/skills/elice-content-edit/SKILL.md +1 -1
  26. package/skills/elice-content-publish/SKILL.md +2 -2
  27. package/templates/_shared/lib/elice-content.d.ts +45 -0
  28. package/templates/_shared/lib/elice-content.js +133 -5
  29. package/templates/document/core/load.d.ts +1 -0
  30. package/templates/document/core/load.js +29 -2
  31. package/templates/document/core/pdf.d.ts +1 -0
  32. package/templates/document/core/pdf.js +5 -0
  33. package/templates/document/screens/edit.js +6 -3
  34. package/templates/document/screens/learn.js +3 -1
  35. package/templates/document/template.json +1 -1
  36. package/templates/video/README.md +68 -0
  37. package/templates/video/commentary.txt +2 -0
  38. package/templates/video/core/dom.d.ts +13 -0
  39. package/templates/video/core/dom.js +83 -0
  40. package/templates/video/core/settings.d.ts +19 -0
  41. package/templates/video/core/settings.js +52 -0
  42. package/templates/video/edit.html +17 -0
  43. package/templates/video/gitignore +4 -0
  44. package/templates/video/index.html +17 -0
  45. package/templates/video/metadata.json +9 -0
  46. package/templates/video/package.json +13 -0
  47. package/templates/video/screens/edit.js +69 -0
  48. package/templates/video/screens/learn.js +46 -0
  49. package/templates/video/styles.css +112 -0
  50. package/templates/video/template.json +6 -0
  51. package/templates/video/ui/templates/edit.js +26 -0
  52. package/templates/video/ui/templates/player.js +51 -0
  53. package/templates/video/ui/texts.d.ts +3 -0
  54. package/templates/video/ui/texts.js +50 -0
  55. package/templates/video/ui/theme.css +14 -0
@@ -2,15 +2,15 @@
2
2
 
3
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 (up to 20 questions per quiz material) | `ecdk create <folder>` (quiz template: starts with no question; the edit screen adds questions of any of the five types with "+ 문제 추가"; answers set on the edit screen; `pattern` or `partial_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) |
5
+ | Case | Start with |
6
+ | ------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
7
+ | A quiz (up to 20 questions per quiz material) | `ecdk create <folder>` (quiz template: starts with no question; the edit screen adds questions of any of the five types with "+ 문제 추가"; answers set on the edit screen; `pattern` or `partial_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; in `ecdk dev` the file stays in `.ecdk/assets/`; for a page on LXP upload it with the MCP `create_asset_upload`, [12](12-upload-with-the-material-mcp.md) "Images and documents") |
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) |
14
14
 
15
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).
16
16
 
@@ -112,6 +112,32 @@ app.useSave({ getContent: () => app.content, getGrading: () => grading.getGradin
112
112
 
113
113
  - Run simulations and animations with `requestAnimationFrame` and stop them while the view is hidden. Split heavy computation into small pieces.
114
114
 
115
+ ### AI grading
116
+
117
+ **AI가 답을 평가해 점수를 매기는 학습자료는 `settings.grading`을 `rubric`으로 저장한다 (편집 화면 `useSave`의 `getGrading`으로 평가 기준을 rubric 글로 만들어 저장), 학습 화면은 학습자 답만 제출한다, 화면에서 계산한 점수는 서버 채점에 쓰이지 않는다.**
118
+
119
+ - The server grades a submission only from `settings.grading`, never from a score inside the answer. With the LXP policy `on_graded` and no `settings.grading` every submission scores 0 and never completes; with `on_submit` every submission scores 100 whatever the AI said (2026-11-20, an essay material that scored with `sdk.mlapi.fetch` in the browser and submitted `{ text, score, scores }`: "채점이 안 됨").
120
+ - `rubric` grading: the server asks AI to grade the submitted answer against the rubric text (up to 10,000 characters), 0–100; `on_graded` completes at 1 point or more, and 100 is `is_correct: true`. Keep the evaluation criteria (names, points, descriptions) in the content if the edit screen edits them, and build the rubric text from them on save. The rubric is never sent to students.
121
+ - The learn screen submits only the learner's answer: plain text, or the smallest JSON the grading needs. The server puts the whole answer JSON into the grading prompt, so never add a client score, per-criterion scores or other numbers to it.
122
+ - Per-criterion feedback from your own `mlapi.fetch` call is optional and display-only: it costs AI credits a second time and its numbers never become the grade. Mixing AI grading for some questions with regex grading for others is not available yet.
123
+
124
+ ```js
125
+ // screens/edit.js: criteria = [{ name, points, description }] edited in the content
126
+ const criteriaToRubric = c =>
127
+ c.criteria.map((x, i) => `${i + 1}. ${x.name} (${x.points}점): ${x.description}`).join('\n') +
128
+ '\n\n항목 점수를 더해 0~100점으로 채점한다.';
129
+ app.useSave({
130
+ getContent: () => content,
131
+ getGrading: () => ({ type: 'rubric', rubric: criteriaToRubric(content) }),
132
+ });
133
+
134
+ // screens/learn.js: the answer only, no score
135
+ app.useSubmit({ getAnswer: () => textarea.value, setAnswer: v => (textarea.value = v ?? '') });
136
+ // or: await app.submit({ text });
137
+ ```
138
+
139
+ The check warns about both mistakes: `grading.client-score` (a `score` · `scores` · `points` key in a submitted object) and `grading.ai-without-grading` (`mlapi.fetch` and a submission, but no `getGrading` · `useGradingBlock` · `grading:`). Propose `on_graded` (2 ②); `on_submit` only for AI feedback that is shown and not graded, and then tell the person the score will not reflect the AI result.
140
+
115
141
  ### Content editor (JSON)
116
142
 
117
143
  Design the **content JSON shape first** (for example `{ title, intro, unit, items: [{ name, value, note }] }`); the student and instructor screens only read that shape from `app.content`. Then the edit screen does not need hand-written fields: the kit's content editor draws them from the shape.
@@ -16,13 +16,16 @@
16
16
 
17
17
  - **Writing `.ecdk/settings.json` by hand (answer format tags, ADR 0013)**: put `"answerFormat": 2` and `"requires": { "quiz": "1.10.0" }` at the top level and `"answerMode": "list"` (or `"regex"`) on every text question, and write text answers in the regex **as typed** (escape regex characters, `%` → `%25`, `;` → `%3B`), e.g. `q4=(?:weight|가중치|50%25)`. A regex-mode question stores the author's regex wrapped in `(?:…)`, e.g. `q4=(?:[Aa]pples?|사과)`. Without `answerFormat` the student screen sends `encodeURIComponent` answers, so the regex must use that form instead (`q4=(?:%EA%B0%80%EC%A4%91%EC%B9%98)`); never mix the two. Then save once in the edit view so the edit screen checks and rewrites everything. If a material goes back to a 1.9.x zip, the answers must be saved again on that edit screen (the old screen ignores the tag).
18
18
 
19
- **Adding images** (a picture in a question's `description` or in `explanation.text`, both Markdown). There are two ways:
19
+ **Adding images** (a picture in a question's `description` or in `explanation.text`, both Markdown; the question `title` is plain text, so an image there shows as the raw `![…](…)`). There are two ways:
20
20
 
21
- - **An image in the zip (you can do this).** Save the file as `public/img/<name>` (letters, digits, `-`, `_` and `.` only: the quiz reads only such `img/` paths) and write `![alt](img/<name>)` in the text, with alt text that says what the picture shows. `ecdk build` copies it into the zip **as is** (it does not shrink or convert it); `file.large-image` warns above 1MB (a warning only). Never put an image into the settings as a `data:` address (the old `![…](image:id)` + `images` form is only kept for old quizzes).
22
- - **Prepare the file first, the way the editor's image button does**, so both kinds look the same: longest side 2048px or less, WebP quality about 85 (keep PNG when transparency matters, GIF as is), no EXIF · GPS, well under 1MB. Use the first tool that exists: `cwebp -q 85 -resize <w> 0 -metadata none in.png -o out.webp` (`-resize` only when a side is over 2048) → macOS `sips` (`sips -Z 2048`, then `-s format jpeg` or keep PNG) → ImageMagick `magick in.png -resize '2048x2048>' -strip -quality 85 out.webp` → none of them: ask the person to shrink it, do not add a large original.
23
- - **An image added with the editor's image button (`asset:`).** On the LXP edit screen of a **saved** material only, the image button shrinks the picture in the browser (`app.assets.uploadImage` → `optimizeImage`: longest side 2048px, WebP 0.85, JPEG fallback, PNG kept when it may be transparent, EXIF · GPS dropped, GIF as is, up to 10MB) and stores `![alt](asset:assets/{material id}/{id}.webp)` in the settings. It is refused on the learn and instructor screens (`ScreenNotSupported`), on the edit screen of an upload that is not saved yet (`#edit=1`) and in previews or a `versionId` (`DraftNotSaved`). **You cannot do this**: there is no edit token and the `elice-material` MCP has no image upload tool. Keep every `asset:` reference you find exactly as it is. When the person wants an image added or replaced this way, tell them: open the page's editor → click the question or explanation box → the image button → '초안으로 저장' → '수업 자료에 반영'.
21
+ - **An image uploaded to the page (`asset:`, preferred for a quiz that is on LXP).** It is stored on the server for the page and the text holds `![alt](asset:assets/{material id}/{id}.webp)`: the same as the editor's image button, so the person can replace it in the LXP editor, and it does not grow the zip.
22
+ - **You do it with the `elice-material` MCP** when it lists `create_asset_upload` ([12](12-upload-with-the-material-mcp.md) "Images and documents (`asset:` files)"): prepare the file (below; this path does not shrink it for you), upload it to the confirmed page, and write `![alt](asset:<key>)` with the returned `key` (never the URL), with alt text that says what the picture shows. Merge the page's current settings first and save only after the person's yes.
23
+ - **The person does it with the editor's image button.** On the LXP edit screen of a **saved** material only, the button shrinks the picture in the browser (`app.assets.uploadImage` → `optimizeImage`: longest side 2048px, WebP 0.85, JPEG fallback, PNG kept when it may be transparent, EXIF · GPS dropped, GIF as is, up to 10MB) and stores the `asset:` reference. It is refused on the learn and instructor screens (`ScreenNotSupported`), on the edit screen of an upload that is not saved yet (`#edit=1`) and in previews or a `versionId` (`DraftNotSaved`). Tell them: open the page's editor → click the question or explanation box → the image button → '초안으로 저장' → '수업 자료에 반영'.
24
+ - Keep every `asset:` reference you find exactly as it is. `ecdk dev` cannot show a server image.
25
+ - **An image in the zip (`img/`).** For a project not uploaded yet (no LXP page), or when the MCP has no `create_asset_upload` (tell the person). Save the file as `public/img/<name>` (letters, digits, `-`, `_` and `.` only: the quiz reads only such `img/` paths) and write `![alt](img/<name>)` in the text, with alt text that says what the picture shows. `ecdk build` copies it into the zip **as is** (it does not shrink or convert it); `file.large-image` warns above 1MB (a warning only). Never put an image into the settings as a `data:` address (the old `![…](image:id)` + `images` form is only kept for old quizzes).
26
+ - **Prepare the file first, the way the editor's image button does** (both ways above), so every image looks the same: longest side 2048px or less, WebP quality about 85 (keep PNG when transparency matters, GIF as is), no EXIF · GPS, well under 1MB. Use the first tool that exists: `cwebp -q 85 -resize <w> 0 -metadata none in.png -o out.webp` (`-resize` only when a side is over 2048) → macOS `sips` (`sips -Z 2048`, then `-s format jpeg` or keep PNG) → ImageMagick `magick in.png -resize '2048x2048>' -strip -quality 85 out.webp` → none of them: ask the person to shrink it, do not add a large original.
24
27
  - **Display size**: there is no setting for it today. An image fills the card width (`.qz-image`, `max-width: 100%`). Say so; never add CSS for one file path in `styles.css` (it breaks when the image changes). The only way now is to crop or resize the source file.
25
- - **A quiz that is already on LXP**: before adding a zip image, merge the page's current settings into `.ecdk/settings.json` ([12](12-upload-with-the-material-mcp.md) "Content and answers (settings)", item 8), so the upload does not wipe what was edited in LXP.
28
+ - **A quiz that is already on LXP**: before adding an image either way, merge the page's current settings into `.ecdk/settings.json` ([12](12-upload-with-the-material-mcp.md) "Content and answers (settings)", item 8), so the upload does not wipe what was edited in LXP.
26
29
 
27
30
  - 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).
28
31
  - Colors, spacing, corners, choice cards: the `--qz-*` variables in `ui/theme.css` (they point at EDS tokens, so `--theme dark` also fits)
@@ -19,14 +19,16 @@ Read `check.issues[]` (`id` · `level` · `path` · `line` · `message`) from `e
19
19
  | `sec.secret` · `file.secret` | Remove the secret or the answer file (if it was already uploaded, tell the user to **revoke the key**) |
20
20
  | `manifest.completion-policies-ignored` (warn) | Remove the old `completionPolicies` and `screens.completionPolicy` from `metadata.json` (and the completion policy screen files). The instructor picks the policy in the '설정' panel at the top of the LXP edit page |
21
21
  | `grading.no-submit` (warn) | The edit screen saves the grading but nothing submits: add `useSubmit` to the student screen, or drop the grading block when the material is not graded |
22
+ | `grading.client-score` (warn) | The submitted answer (a `submit(` argument, `useSubmit`'s `getAnswer`) has a `score` · `scores` · `points` key. The server never uses a score inside the answer and puts the whole answer into the AI grading prompt: submit only the learner's answer and grade with `settings.grading` ([5](05-screen-code.md) "AI grading"). `ecdk-ignore` only for code that shows a score and does not submit it, with the reason |
23
+ | `grading.ai-without-grading` (warn) | The screens call `mlapi.fetch` and submit, but nothing saves `settings.grading`. Build the rubric on the edit screen: `useSave({ …, getGrading: () => ({ type: 'rubric', rubric: criteriaToRubric(content) }) })` and submit only the answer ([5](05-screen-code.md) "AI grading"). AI feedback that is only shown, with no grading: `ecdk-ignore-next-line grading.ai-without-grading` on the `mlapi.fetch` line with the reason, and `on_submit` on purpose (scores do not reflect the AI) |
22
24
  | `project.legacy-file` (warn, project only) | An old `elice.config.json` · `content.json` · `grading.json` is left: `ecdk doctor --fix` moves `elice.config.json`; re-enter the content and answers in the edit screen, then delete the other files |
23
25
  | `sdk.outdated` (error) | The installed SDK bundled into the zip is older than the minimum (1.0.0-alpha.3 or older cannot save in the LXP edit screen - draft save fails): `npm update @eliceio/cdk`, then build again |
24
26
  | `project.deps` (doctor) · "@eliceio/cdk 패키지를 찾지 못했습니다" | The SDK package is not installed in the project: run `npm install` in the project, then build again |
25
- | `project.grading` (doctor) | The saved `.ecdk/settings.json` `grading` breaks the server's save rules or does not match the public `gradingType`. Have the person open the edit view in `ecdk dev`, fix the marked field (points, answers) and save again; if you edited the file by hand, correct those values ([15](15-edit-settings-by-hand.md)). Never delete the file: the content goes with it |
27
+ | `project.grading` (doctor) | The saved `.ecdk/settings.json` `grading` breaks the server's save rules or does not match the public `gradingType`. Have the person open the edit view in `ecdk dev`, fix the marked field (points, answers) and save again; if you edited the file by hand, correct those values ([15](15-edit-settings-by-hand.md)). Never delete the file: the content goes with it. It warns when the settings hold AI evaluation config (`criteria` · `apiId`) but no `grading`: save a `rubric` with the edit screen's `getGrading` ([5](05-screen-code.md) "AI grading") |
26
28
  | `project.quiz` (doctor, quiz template) | The saved questions, answers or points do not pass the quiz edit screen's own checks (run with the project's `core/model.js`): answers or scores left in the old question order, `points` ≠ `scores`, an answer pointing at a deleted option, a missing `gradingType`, a regex the edit screen cannot read (a text answer in the wrong shape for the project's template version), quiz 1.10.0+: a regex answer not in the stored shape or with a blocked syntax, an answer regex over 500 characters, `answerFormat` · `requires` · `answerMode` the project's template does not know, text answers that look as typed (or a regex question) but `answerFormat` is missing, `answerFormat` 2 with URL-encoded text answers (saved again by a 1.9.x edit screen) - for these two, students typing 한글, spaces or `%` are marked wrong: have the person press "초안으로 저장" once in the edit view and the answers are saved again in the right shape. A warning (`warn`): tags written in snake_case (`answer_format` · `answer_mode`). Fix as [15](15-edit-settings-by-hand.md) says, run `ecdk doctor` again, then have the person save once in the edit view ("초안으로 저장") |
27
29
  | `build.template-unknown` (warn) | The material was made with a template or template version this ecdk does not know. Update ecdk (`npm i -g @eliceio/cdk-cli`) or check `template` in `package.json` `"ecdk"` |
28
30
  | `manifest.*` · `entry.*` | Check `screens` and `kind` in `metadata.json` |
29
- | `limit.*` · `file.large-image` | Shrink images and video, drop unused files (build output: "files not referenced anywhere") |
31
+ | `limit.*` · `file.large-image` | Shrink images (longest side 2048px, WebP 85, [6](06-using-the-quiz-template.md) "Adding images") and video, drop unused files (build output: "files not referenced anywhere") |
30
32
  | `sdk.lib-copy` (error, project only) | An SDK copy `lib/cdk.js` in the project (never put in the zip): `ecdk doctor --fix`, `npm install`, replace the kit `lib/elice-content.js` with a new `ecdk create` one, delete `lib/cdk.js` |
31
33
 
32
34
  Use `ecdk-ignore`, which turns a rule off, only for legitimate code a regular expression cannot tell apart, and **always with the reason**. Do not scatter it to silence errors.
@@ -18,6 +18,7 @@ The `elice-material` MCP server (elice-material backend) uploads a built zip to
18
18
  | Upload URL | `create_package_upload` (`size_bytes`) | At most 20 MB. Returns `key` and `curl_command` |
19
19
  | Upload | the `curl_command`, `package.zip` replaced by the zip path | From a desktop app, run it through a login shell (see Always) |
20
20
  | Draft | `submit_package` (`key`) → `get_draft` every 2–3 s | `ready`: shows `preview_urls`, `warnings`, the package metadata. `failed`: report `failure` with `ecdk validate dist/content.zip` and stop |
21
+ | Files (optional) | `create_asset_upload` (`extension`, `size_bytes`) → its `curl_command`, per file | Images for quiz text, the PDF/PPTX of the document template. Only after the draft is `ready`. Put the returned `key` (never the URL) into the settings. See "Images and documents (`asset:` files)" below |
21
22
  | Approve | — | Show page, title, whether content and answers go with it (the summary, no answer values), the completion policy to set (below), `preview_urls`. Saving is visible to learners at once when the page is open |
22
23
  | Save | `save_draft` (`material_draft_id`, `expected_current_version_id`, `payload`) | One save carries everything, so no extra version is made. `payload` holds only the keys to set, each only when the tool's schema lists it: `settings` and `completion_policy` when the person said yes (below; `on_graded` only together with `settings` that include `grading`), and `title` · `icon` when the page has none (a new page). `MATERIAL_CHANGED`: someone saved after your `get_material`; do not retry blindly, tell the person |
23
24
  | Check | `get_material` (or `get_draft` before saving) | When settings were sent: the saved settings have the same top-level keys and item count and `grading.type` as the summary. When a policy was sent: it shows that policy. Show any `warnings` in the result to the person. If not as sent, tell the person and use the fallback |
@@ -42,7 +43,20 @@ Next time, read it, confirm the page with the person as above (기관 · 과목
42
43
  5. **Summary and an explicit yes.** Before the upload, show what goes with it: the title, the number of questions or items, and whether answers are included (`grading.type`, `pattern`, `partial_pattern` or `rubric`; for `partial_pattern` also the number of questions and the scores), but never the answer values (`answer_key`, `rubric`). **Settings reach every viewer, students included: never send settings that hold a learner's personal data** (names, contact details, student numbers …; 2 "Personal data"). The answers must be ones the person confirmed (Always: ask before you settle correct answers). Send it only after an explicit yes; a no means the fallback.
43
44
  6. **Send** it as `payload.settings` with the save (`save_draft` above), with the completion policy the person agreed to (below). Then check it with `get_material` (or `get_draft` when the draft shows it before saving) as in the table.
44
45
  7. **No settings file?** Suggest filling the edit view in `ecdk dev` first and saving, so the upload carries it, or skip it (the person enters the content in the LXP edit screen later).
45
- 8. **Adding images to a page that already has a version.** Read the page's current settings first (`get_material`, or `get_draft` for a draft not saved yet) and merge them into the local `.ecdk/settings.json` before you change anything: `settings` replaces the whole object, so skipping this overwrites what was edited in the LXP editor, including `asset:` images people added there (keep those references exactly as they are). Then add the zip image (6 "Adding images"), `ecdk build`, and upload as usual: `create_package_upload` → the `curl_command` → `submit_package` → `get_draft` until ready → show the person → `save_draft` with the merged settings only after their yes (items 3–6 still apply).
46
+ 8. **Adding images to a page that already has a version.** Read the page's current settings first (`get_material`, or `get_draft` for a draft not saved yet) and merge them into the local `.ecdk/settings.json` before you change anything: `settings` replaces the whole object, so skipping this overwrites what was edited in the LXP editor, including `asset:` images people added there (keep those references exactly as they are). Then, when the MCP lists `create_asset_upload`, upload the image as an `asset:` file ("Images and documents" below; no new zip needed: `update_material` with the merged settings after the person's yes). Only when it does not: add a zip image (6 "Adding images"), `ecdk build`, and upload as usual: `create_package_upload` → the `curl_command` → `submit_package` → `get_draft` until ready → show the person → `save_draft` with the merged settings only after their yes (items 3–6 still apply).
47
+
48
+ **Images and documents (`asset:` files)**
49
+
50
+ `create_asset_upload` gives a signed upload URL for one file stored on the server for this page, the same place the LXP editor's image and file buttons use. The settings then point at the file by its `key`, so it stays editable in the LXP editor and does not grow the zip.
51
+
52
+ - **When.** Images in quiz text (a question's `description`, `explanation.text`: `![alt](asset:<key>)`, never `title`, which is plain text; 6 "Adding images"), and the PDF or PPTX of the document template (`settings.document`). Files the screen code loads itself still go in the zip.
53
+ - **Is the tool there?** Use it only when the MCP lists `create_asset_upload`. If not (an older server), tell the person and fall back: a quiz image goes in the zip as `img/` (6 "Adding images"); a document is uploaded by the person on the LXP edit screen (the file button, then '수업 자료에 반영').
54
+ - **Types and limits.** `extension`: `png` · `jpg` · `jpeg` · `webp` · `gif` (at most 10 MB) or `pdf` · `pptx` (at most 95 MB); no SVG, no `.ppt` (save as `.pptx` or `.pdf` first). `size_bytes` is the exact file size (`wc -c < file`). Above the limit the tool answers `MATERIAL_PACKAGE_TOO_LARGE` with the limit. **Shrink an image first** (6 "Adding images": longest side 2048px or less, WebP about 85, EXIF · GPS stripped): this path does not run the editor's in-browser `optimizeImage`.
55
+ - **Order.** Confirm the target page first (above). With a new zip: build → `create_package_upload` → the `curl_command` → `submit_package` → `get_draft` until `ready` → then, per file, `create_asset_upload` → its `curl_command` (replace `asset.<extension>` with the file's path; from a desktop app through a login shell) → put the key into the settings → show the person → `save_draft` with the merged settings after their yes. Never call it before the new draft is ready: the file's folder follows the ready draft's package (a copied page uses its source's folder until then), so an earlier key can point where the new version does not read. Without a new zip (the page already has a version): `get_material` → `create_asset_upload` → the `curl_command` → `update_material` with the merged settings after the person's yes.
56
+ - **The key, not the URL.** Put the returned `key` (`assets/{material id}/{id}.{ext}`) into the settings exactly as returned; never the upload URL or any signed address (it expires and carries a signature). Quiz: `![alt](asset:<key>)` in the Markdown, with alt text that says what the picture shows. Document template: `settings.document = { "asset_key": <key>, "name": <file name>, "size": <bytes>, "type": "pdf" | "pptx", "pages": <page count, or 0 if unknown> }` (`templates/document/core/settings.js`).
57
+ - **Files uploaded in `ecdk dev` are local.** A key under `assets/00000000-0000-4000-8000-0000000000e1/` in `.ecdk/settings.json` (quiz `asset:` images, `settings.document.asset_key`) points to `.ecdk/assets/<same file name>` on this PC and does not exist on LXP. Before sending such settings, upload each of those files with `create_asset_upload` (after the draft is `ready`) and replace the local key with the returned one everywhere it appears. Never send a local key; if the tool is missing, tell the person the files must be added again in the LXP edit screen.
58
+ - **Merge, then show.** `settings` replaces the whole object: start from the page's current settings (`get_material`, or `get_draft` before the first save), keep every `asset:` reference already there exactly as it is, add the new keys, and write the result to `.ecdk/settings.json` as well. Before saving, show the person which file goes where (question number or the document, file name, size after shrinking, alt text) and wait for a yes. The draft preview does not show these settings before the save, and `ecdk dev` cannot show a server file: check on the LXP page after saving.
59
+ - **Nothing changes until a save.** An uploaded file that no saved settings point at is unused; there is no MCP tool to delete it. If the person says no, do not save.
46
60
 
47
61
  **Fallback (the server has no `settings`, the person said no, or there is no file)**: upload the zip only, without content or `grading`, and without `on_graded` (see "Completion policy"). After saving, tell the person to open the LXP edit page, enter the content and answers on the edit screen (`settings`, with `settings.grading` for `on_graded`) and save with the edit screen's own button (the quiz template: "초안으로 저장"). That saves to the draft; learners see it only after '수업 자료에 반영' at the top of the LXP edit page.
48
62
 
@@ -60,6 +74,7 @@ The completion policy is not in the project or the zip (ADR 0012): it is a setti
60
74
 
61
75
  - Show the proposal in the target summary and the approval (on a page that already has a policy, show the current one too; changing it needs the yes). Send it only after an explicit yes.
62
76
  - **`on_graded` needs grading saved first** (the server answers `MATERIAL_GRADING_REQUIRED` otherwise). Send `on_graded` in the same save only together with `settings` that include `grading` (the server takes `settings` and the person agreed), or when the page already has grading (`get_material` shows it).
77
+ - **AI grading: check `grading` before `on_graded`.** Before a `save_draft` (or `update_material`) with `completion_policy: on_graded`, check that the settings you send (or the page's settings in `get_material`) contain `grading`. A material that grades with AI (its screens call `mlapi.fetch` to evaluate the answer, its content has evaluation criteria such as `criteria: [{ name, points, description }]`, or `ecdk validate` warns `grading.ai-without-grading` · `grading.client-score`) and has no `grading`: stop and fix it first. The edit screen saves `settings.grading = { type: 'rubric', rubric: <text built from the criteria> }` through `useSave`'s `getGrading`, the learn screen submits only the learner's answer, then save again in the `ecdk dev` edit view ([5](05-screen-code.md) "AI grading"). Never publish `on_graded` without grading: every submission would score 0 and never complete. When the AI only gives feedback on screen and nothing is graded, use `on_submit` deliberately and tell the person the scores will not reflect the AI result (every submission is 100).
63
78
  - **Without settings** (the server has no `settings`, no file, or the person said no): do not send `on_graded` at the first save. Send no policy, or `on_submit` only if the person wants learners to complete by submitting until the answers exist (ask). Then the person enters the answers on the LXP edit screen and applies them with '수업 자료에 반영'; afterwards either the person picks 답안 확인 후 완료 in the '설정' panel, or, if `update_material` takes `completion_policy`, offer to set `on_graded` through the MCP once `get_material` shows the grading.
64
79
  - **Only `on_graded` grades.** `on_submit` completes on any submission and does not grade: the submission comes back `is_correct: null`, `score: 100`, and the kit shows "제출했어요.". `on_access` completes on open. Saved answers are used only with `on_graded`; say so in the report so the person does not think grading is broken.
65
80
  - Answers never go into the zip: only in `settings.grading`, sent with the save above or entered on the edit screen.
@@ -77,6 +92,7 @@ The completion policy is not in the project or the zip (ADR 0012): it is a setti
77
92
  | `MATERIAL_CHANGED` | Someone saved after your `get_material`. Do not retry blindly; tell the person |
78
93
  | `MATERIAL_GRADING_REQUIRED` | `on_graded` without `grading`. Stop and tell the person |
79
94
  | `MATERIAL_DRAFT_PENDING` (`update_material`) | Someone uploaded a package to this page and did not save it: a ready draft holds a package different from the current version. Nothing changed. Stop, explain it, and ask whether to save that draft (`save_draft`, which publishes their upload) or discard it (`discard_draft`). Never pick for the person |
95
+ | `MATERIAL_PACKAGE_TOO_LARGE` (`create_asset_upload`) | The file is above its limit (images 10 MB, PDF · PPTX 95 MB). Shrink the image (6 "Adding images") or ask the person for a smaller document |
80
96
  | `PACKAGE_TOO_LARGE` | Over 20 MB |
81
97
  | An error about `settings` (for example `INVALID_INPUT`, a bad `settings.grading` pattern or rubric, `partial_pattern` scores summing to less than 100) | Nothing was saved: report it, and save without settings (the fallback) only after the person agrees |
82
98
  | `warnings` in a tool result | Show them to the person close to word for word (for example `settings.grading` sent while the policy is not `on_graded`). No `warnings` key means none |
@@ -4,7 +4,7 @@ Every content edit screen (CMS) looks the same: the designer's edit-screen desig
4
4
 
5
5
  ## Layout rules
6
6
 
7
- 1. `<body class="ec-edit-page">` on `edit.html` (the content editor adds it itself): gray page, white cards, the save bar from `app.useSave` fixed white at the bottom with a top line. Content sits in the kit's centered `main` column (720px) by default. A material whose main editing surface is a wide visual (slides with a thumbnail strip) may widen `main` with its own token (like the document template's `--dc-max-width: 1120px`); never full-bleed. Keep the template's own save button label (`useSave({ label })`, for example the quiz's '초안에 반영'); do not rename it.
7
+ 1. `<body class="ec-edit-page">` on `edit.html` (the content editor adds it itself): gray page, white cards, the save bar from `app.useSave` fixed white at the bottom with a top line. Content sits in the kit's centered `main` column (720px) by default. A material whose main editing surface is a wide visual (slides with a thumbnail strip) may widen `main` with its own token (like the document template's `--dc-max-width: 1120px`). Only a material whose whole edit screen is one media field (the video template: upload, then the player preview) fills the width (`main { max-width: none }`, save bar `padding-inline: 16px`); a form of questions or options never does. Keep the template's own save button label (`useSave({ label })`, for example the quiz's '초안에 반영'); do not rename it.
8
8
  2. **Top: title and description of the material**, in one card `.ec-edit-card.ec-edit-info` with underline fields and no visible labels (title `.ec-field-title`, description `.ec-field-body`). An always-true hint about how the screen works goes above it as one `.ec-info-line` (ⓘ, for example "정답으로 고른 보기로 자동 채점합니다."); a hint the person must read first goes in `.ec-edit-notice` (light purple box).
9
9
  3. **One card per item** (question, step, slide, uploaded file): `.ec-edit-card`. Head `.ec-edit-card-head`: name in bold ("문항 1"), then a type `<select>` if the item has types, then on the right the bordered icon buttons ↑ · ↓ · trash (`button.ec-icon-button`, `aria-label` always). Hide ↑ · ↓ when there is one card. Below the last card a dashed full-width `button.ec-add` ("+ 문항 추가").
10
10
  4. **Underline fields, placeholder as the label**: `.ec-field` + `input.ec-field-input` / `textarea.ec-field-input` with `placeholder` and `aria-label` (sizes `.ec-field-title` · `.ec-field-question` · `.ec-field-body`). A field whose meaning is not clear from its place (unit, value, file language) gets a small label above: `.ec-field-label` (+ `.ec-required` "\*" or `.ec-optional` "선택"), and a hint `.ec-field-hint`. Character count `.ec-field-count` shows only while the field has focus. An empty required field on save: `aria-invalid="true"` (red underline) and focus it.
@@ -13,7 +13,7 @@ Reference files are in `references/` in this skill's folder (see Always). For a
13
13
 
14
14
  Write the progress line `[n/N] …` before and after every step below (Always › Progress); the person sees nothing else while you work.
15
15
 
16
- 1. **Design before code.** Read `references/00-what-the-person-decides.md` and `references/02-design-the-material.md`. Decide ① what the student does, ② whether the student submits and the grading (`type` `pattern` or `rubric`, set on the edit screen; the quiz template uses `pattern`, so do not ask for a quiz) and which completion policy fits (the publish skill sets it after the person agrees; only `on_graded` grades, `on_submit` completes on any submission without grading), ③ the instructor screen (seen only in the LXP editor preview; instructors on the learning page see the student 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. Then show the numbered plan.
16
+ 1. **Design before code.** Read `references/00-what-the-person-decides.md` and `references/02-design-the-material.md`. Decide ① what the student does, ② whether the student submits and the grading (`type` `pattern` or `rubric`, set on the edit screen; the quiz template uses `pattern`, so do not ask for a quiz; AI grading is `rubric` saved by the edit screen's `getGrading` and the student submits only the answer, never a score computed with `mlapi`, `references/05-screen-code.md` "AI grading") and which completion policy fits (the publish skill sets it after the person agrees; only `on_graded` grades, `on_submit` completes on any submission without grading), ③ the instructor screen (seen only in the LXP editor preview; instructors on the learning page see the student 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. Then show the numbered plan.
17
17
  2. **Environment and project.** `ecdk --version && ecdk doctor --json` (`references/01-check-the-environment.md`, also for `cli.latest`), then `ecdk create --list` to pick a template and `ecdk create <folder> --template <name>` (`references/03-create-the-project.md`; it runs `npm install` for the SDK, so when that fails run `npm install` in the project). Start `ecdk dev <folder>` in the background now and give the person the URL.
18
18
  3. **Write the screens.** Start from the template's example code and the kit API table at the top of `references/05-screen-code.md`; do not open `lib/` to learn the API (the table is the API). Follow its UI patterns (kit icon buttons, list rows, drop zones; the quiz template: `references/06-using-the-quiz-template.md`); an edit screen you write by hand follows `references/13-edit-screen-design.md` (kit classes, layout, microcopy); when a student or instructor screen has nothing to show, always use `app.emptyState()`, never your own empty-state markup, illustration or text (`references/05-screen-code.md`, "Nothing to show"), and write `commentary.txt` (key concepts and intent, no answers). There is no default content file: the content and answers are what the edit screen saves (`ecdk dev` writes `.ecdk/settings.json`, local by default; the elice-content-publish skill can send it with the upload after the person agrees, otherwise the person enters it in the LXP edit screen).
19
19
  - For a material that is not a quiz, start from the blank template and its content editor: design the content JSON shape and its schema first (`references/02-design-the-material.md` ④-1), put them in `screens/edit.js` (`useContentEditor(app, { initial, schema })`), then write the student screen against that shape. Replace the template's example everywhere it says `이 자료에 맞게 바꿀 곳`.
@@ -16,7 +16,7 @@ Reference files are in `references/` in this skill's folder (see Always). For th
16
16
  2. **Sort the request.**
17
17
  - Content, answers, points or grading → `.ecdk/settings.json`, keeping every id.
18
18
  - Wording or look of the screens → `ui/` (quiz: `ui/texts.js`, `ui/theme.css`, `ui/templates/`) and `screens/`.
19
- - An image in a question or explanation → `references/06-using-the-quiz-template.md` "Adding images": a zip image in `public/img/` you prepare, `asset:` images only the person adds in the LXP editor, no size setting.
19
+ - An image in a question or explanation → `references/06-using-the-quiz-template.md` "Adding images": for a quiz on LXP an `asset:` image you upload with the MCP `create_asset_upload` (or the person adds with the editor's image button), otherwise a zip image in `public/img/`; prepare it first, no size setting.
20
20
  - Something the template does not do (for example a text answer that ignores upper case or spaces, a new question type, a new grading rule) → never edit `core/` or `lib/` to add it (Always). Offer what works now (for a text answer: list each spelling the person wants to accept as its own accepted answer; with quiz 1.10.0 or later also a regex answer, `answerMode: "regex"`, if the person picks it) and, if that is not enough, tell the person it is a feature request for the template.
21
21
  3. **Ask first** about any value the person decides that the request does not spell out (Always): points or their split, correct or accepted answers (also when translating: the translated answers), a question's title or wording beyond what was asked. Say what you would set and wait for a yes; change only what the request names.
22
22
  4. **Change it** as `references/15-edit-settings-by-hand.md` says: keep question, option and group ids; when you delete or reorder questions, `grading.answer_key` and `grading.scores` move with them; build answer regexes with the project's `core/model.js` (its script), never by hand. The text answer shape follows the project's quiz template version: from 1.10.0 the edit screen writes `answerFormat: 2` · `requires`, keeps text answers as typed and may have regex questions (`answerMode`) with their own rules (reference 15, "Regex answers"); older projects keep URL-encoded text answers and must not get `answerFormat`, `requires` or `answerMode`.
@@ -14,9 +14,9 @@ Reference files are in `references/` in this skill's folder (see Always). Read `
14
14
  1. **MCP ready?** The `elice-material` tools must be available. If not, ask the person to run `ecdk setup --only mcp` and log in (Claude Code `/mcp` → elice-material → Authenticate, Helpy Code `⌘ ;`), then stop.
15
15
  2. **Build.** `ecdk build --json` must return `ok: true`. Keep `zip` and `zipBytes`.
16
16
  3. **Content and answers.** Check whether the input schema of `save_draft` (or `update_material`) lists `settings` as a key of `payload` (on an older server, a top-level parameter). If it does and this project has `.ecdk/settings.json`: make sure the edit screen saved it (the person saves the edit view in `ecdk dev`; a file you wrote by hand must go through that save), run `ecdk doctor` and send no `settings` while its `project.grading` or `project.quiz` check fails (tell the person why, never the answer values; they fix it in the edit view), show a short summary (title, number of questions or items, answers included or not and `grading.type`, never the answer values) and ask for an explicit yes to send it with the upload. `settings` replaces the page's settings as a whole: on a page that already has a version, compare `get_material`'s settings with the file first, and if keys would disappear or the LXP content differs (an instructor edited it in LXP), show the difference briefly and ask before overwriting (a new page needs no comparison). Adding images to a page that already has a version: merge its current settings (`get_material` or `get_draft`) into `.ecdk/settings.json` first, keeping `asset:` images as they are (`references/12-upload-with-the-material-mcp.md` item 8). No file: suggest filling the edit view in `ecdk dev` first, or skip it. No `settings` key, or the person says no: zip only (the fallback). Details: `references/12-upload-with-the-material-mcp.md` "Content and answers (settings)".
17
- 4. **Completion policy.** If `save_draft` (or `update_material`) lists `completion_policy` in its input schema (in `payload`), propose one (`references/12-upload-with-the-material-mcp.md` "Completion policy"): graded (the quiz template, or settings with `grading`) → `on_graded`, submits without grading → `on_submit`, no submission → `on_access`. `on_graded` only when the same save carries `settings` with `grading` (or the page already has grading); otherwise no policy at the first save, or `on_submit` if the person wants it (ask). Tell the person that only `on_graded` grades: `on_submit` completes on any submission without grading ("제출했어요."), `on_access` completes on open. The policy is a page setting and applies at once.
17
+ 4. **Completion policy.** If `save_draft` (or `update_material`) lists `completion_policy` in its input schema (in `payload`), propose one (`references/12-upload-with-the-material-mcp.md` "Completion policy"): graded (the quiz template, or settings with `grading`) → `on_graded`, submits without grading → `on_submit`, no submission → `on_access`. `on_graded` only when the same save carries `settings` with `grading` (or the page already has grading); a material that grades with AI (`mlapi.fetch`, evaluation criteria) and has no `grading`: stop and fix it first (rubric from the criteria, `references/12-upload-with-the-material-mcp.md` "AI grading"), never `on_graded` without grading, and `on_submit` only on purpose for display-only AI feedback (tell the person scores won't reflect the AI); otherwise no policy at the first save, or `on_submit` if the person wants it (ask). Tell the person that only `on_graded` grades: `on_submit` completes on any submission without grading ("제출했어요."), `on_access` completes on open. The policy is a page setting and applies at once.
18
18
  5. **Pick the page and confirm it.** Candidates: `.ecdk/link.json`, the LXP edit URL the person gives (`https://{org}.…/lecturepages/{id}/edit`), or the person's choice from `list_my_organizations` → `list_courses` → `list_lectures` → `list_custom_pages`. Never pick a page yourself (not the first in a list, not a guess by title, not a page from another project); if the answer is ambiguous, ask again. Before any upload call (`create_package_upload`, `submit_package`), show the full target, 기관 · 과목 · 수업 · 페이지 with names and ids, its LXP edit URL, whether content and answers go with it and the completion policy to set (the page's current one too), then wait for an explicit yes. Do this every time: also for `.ecdk/link.json` (and compare its `version_id` with `get_material`) and for a URL the person gave (confirm the names it resolves to). `.ecdk/link.json` and an edit URL give only the org's `name_short`: get the 기관 name from `list_my_organizations` and the 과목 · 수업 · 페이지 names from `get_material`. A new page (`create_custom_page`) needs its own yes that names the 수업 it goes into. If the page already has content or answers saved in LXP, say that sending settings replaces them and ask again.
19
- 6. **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 validate dist/content.zip` and stop.
19
+ 6. **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 validate dist/content.zip` and stop. Images or a PDF/PPTX for the settings: only now (draft ready), `create_asset_upload` per file → its `curl_command`, and put the returned `key`, never the URL, into the merged settings (`references/12-upload-with-the-material-mcp.md` "Images and documents"); no such tool: zip images, and tell the person.
20
20
  7. **Approve.** Show what changes (page, title, whether the content and answers go with it or are entered on the LXP edit screen after saving, the completion policy) and the draft `preview_urls`. Saving is visible to learners at once if the page is open. Wait for an explicit yes.
21
21
  8. **Save.** One `save_draft` with `material_draft_id`, `expected_current_version_id` and `payload` holding only keys its schema lists: `settings` (the content of `.ecdk/settings.json`) only when step 3 got a yes, `completion_policy` only when step 4 got a yes, and `title` · `icon` when the page has none (a new page; icon: `references/12-upload-with-the-material-mcp.md` "Icon"), all in this one save so no extra version is made. On `MATERIAL_CHANGED` or `MATERIAL_GRADING_REQUIRED`, stop and tell the person (`references/12-upload-with-the-material-mcp.md` "Errors and warnings").
22
22
  9. **Check.** Show any `warnings` in the result to the person close to word for word. `get_material` must show what was sent: the settings (same keys, item count and `grading.type` as the summary), the completion policy, the title. If not, tell the person and use the fallback. Without settings: tell the person to enter the content and answers in the LXP edit screen, save with its own button, then press '수업 자료에 반영' at the top of the LXP edit page (`references/12-upload-with-the-material-mcp.md` "Fallback"); for a graded material, then pick 답안 확인 후 완료 in the '설정' panel at the top of the LXP edit page, or offer to set `on_graded` with `update_material` (when it takes `completion_policy`) once `get_material` shows the grading. No `completion_policy` key: tell the person which policy to pick in that '설정' panel. `update_material` stopping with `MATERIAL_DRAFT_PENDING`: someone's upload is not saved; explain and ask whether to save it (`save_draft`) or discard it (`discard_draft`), never pick for them.
@@ -60,6 +60,19 @@ export interface SubmitOptions<A = unknown> {
60
60
  label?: string;
61
61
  }
62
62
 
63
+ export interface AutoSubmitOptions<A = unknown> {
64
+ /** 낼 답 (submit()을 부를 때 읽음) */
65
+ getAnswer: () => A;
66
+ /** 낸 직후, 또는 다시 열었을 때 지난 제출 */
67
+ onResult?: (result: SubmitResult & { answer?: A }, info: { restored: boolean }) => void;
68
+ /** 내지 못했을 때 (알림 줄에도 보임) */
69
+ onError?: (error: ContentError) => void;
70
+ /** 알림 줄을 붙일 화면 영역 (기본 #app, 그 뒤에 붙임) */
71
+ root?: Element;
72
+ }
73
+
74
+ export type AutoSubmitState = 'idle' | 'sending' | 'done' | 'readonly';
75
+
63
76
  export interface UploadFileOptions {
64
77
  /** 올린 바이트 / 전체 바이트 */
65
78
  onProgress?: (progress: { loaded: number; total: number }) => void;
@@ -245,6 +258,8 @@ export interface ContentApp<C = Record<string, unknown>> {
245
258
  navigation: Navigation | null;
246
259
  isLocal: boolean;
247
260
  sdkKind: 'real' | 'mock' | 'custom';
261
+ /** 자료 id (토큰 · 주소가 아님) */
262
+ materialId: string | null;
248
263
  account: { anonymousId: string; fullname: string | null } | null;
249
264
  result: { score: number | null; submitCount: number; completedAt: string | null } | null;
250
265
  readonly records: boolean;
@@ -288,6 +303,36 @@ export interface ContentApp<C = Record<string, unknown>> {
288
303
  uploadImage(file: File, options?: UploadFileOptions): Promise<UploadedImage>;
289
304
  url(assetKey: string): Promise<string | null>;
290
305
  };
306
+ /**
307
+ * 버튼 없는 제출: 조건이 되면 submit()을 부른다. 한 번만 내고, 이미 낸 제출이 있으면 · 튜터면 내지 않는다
308
+ */
309
+ useAutoSubmit<A = unknown>(
310
+ options: AutoSubmitOptions<A>
311
+ ): {
312
+ /** 오류 알림 줄 */
313
+ element: Element;
314
+ /** 지난 제출을 확인했을 때 */
315
+ ready: Promise<void>;
316
+ readonly state: AutoSubmitState;
317
+ /** 이번에 또는 예전에 냈는지 */
318
+ readonly done: boolean;
319
+ /** 이미 냈거나 내는 중이거나 튜터면 아무것도 하지 않는다. 결과 또는 null */
320
+ submit(): Promise<SubmitResult | null>;
321
+ };
322
+ /**
323
+ * Elice 비디오 플레이어 (embed.js의 <elice-video> · <elice-video-upload>). 올리기 · 진행률 · 인코딩 대기 · 재생 화면은 플레이어가 그린다
324
+ */
325
+ readonly videoPlayer: {
326
+ /** 플랫폼이 넘긴 embed.js 주소 (SDK videoPlayerUrl). 없으면 null */
327
+ readonly url: string | null;
328
+ /** embed.js를 불러온다 (전역 EliceVideoPlayer). url이 없으면 ContentError video_player_unavailable */
329
+ load(): Promise<unknown>;
330
+ /** 태그에 자료 id · 영상 id · 토큰을 넣고 토큰 갱신을 따라간다. 돌려주는 함수로 멈춘다 */
331
+ connect(
332
+ element: HTMLElement & { materialId: string; resourceId: string; token: string },
333
+ options?: { resourceId?: string }
334
+ ): () => void;
335
+ };
291
336
  /** 편집 화면 저장 영역 */
292
337
  useSave(options: SaveOptions<C>): {
293
338
  element: Element;
@@ -9,6 +9,9 @@
9
9
  * 자료 파일 (편집 화면에서 PDF · PPTX 올리기, 학생 화면에서 열기): app.assets.uploadFile(file, { onProgress, signal }) · await app.assets.url(asset_key)
10
10
  * 이미지 (편집 화면에서 줄여 올리기): app.assets.uploadImage(file, { onProgress, signal }) · 보기는 같은 app.assets.url(asset_key)
11
11
  * 화면 틀: data-ec-layout="single | split | stage | media" + data-ec-region (CSS만, lib/elice-content.css "레이아웃" 절)
12
+ * 버튼 없이 제출 (예: 영상을 N% 보면): app.useAutoSubmit({ getAnswer }) → 조건이 되면 auto.submit()
13
+ * Elice 비디오 플레이어 (동영상 올리기 · 재생): await app.videoPlayer.load() → <elice-video-upload> · <elice-video>에
14
+ * app.videoPlayer.connect(element, { resourceId })로 자료 id · 토큰(갱신 포함)을 넣는다
12
15
  * 읽기 전용 잠금, 답 복원, 결과·오류 안내, 저장 문구, 로컬 mock 표시는 키트가 합니다.
13
16
  *
14
17
  * 화면(screens/*.js)은 이 키트만 부릅니다. 키트가 SDK로 인증 · 화면 확인 · 내용 불러오기 ·
@@ -79,6 +82,10 @@ const MESSAGES = {
79
82
  save_regex_invalid: '정답 형식이 올바르지 않아요.',
80
83
  save_invalid: '저장할 내용의 형식이 올바르지 않아요.',
81
84
  not_initialized: '아직 준비되지 않았습니다.',
85
+ // 키트만의 코드: Elice 비디오 플레이어 (app.videoPlayer)
86
+ video_player_unavailable: '동영상을 불러올 수 없습니다.',
87
+ script_load_failed: '동영상 플레이어를 불러오지 못했어요. 잠시 뒤 다시 시도해 주세요.',
88
+ script_namespace_not_found: '동영상 플레이어를 불러오지 못했어요. 잠시 뒤 다시 시도해 주세요.',
82
89
  // 키트만의 코드: 자료 파일 올리기 (app.assets.uploadFile)
83
90
  upload_not_supported:
84
91
  '아직 파일을 올릴 수 없어요. 이 SDK에는 파일 올리기가 없습니다 (@eliceio/cdk를 올려 주세요).',
@@ -422,6 +429,8 @@ export async function start(options) {
422
429
  isLocal: launch.local,
423
430
  /** 쓰고 있는 SDK: 'real' | 'mock' | 'custom' */
424
431
  sdkKind: kind,
432
+ /** 자료 id (토큰 · 주소가 아님. 이 브라우저에 남기는 값의 키 등에) */
433
+ materialId: sdk.metadata?.materialId ?? null,
425
434
  /** 보는 사람 { anonymousId, fullname } */
426
435
  account: sdk.account,
427
436
  /** 내 결과 { score(가장 최근 채점, 숫자 · null), submitCount, completedAt } 또는 null */
@@ -516,6 +525,46 @@ export async function start(options) {
516
525
  return mountSubmit(app, opts);
517
526
  },
518
527
 
528
+ /**
529
+ * 버튼 없는 제출 (예: 영상을 기준만큼 보면 학습 완료). 화면이 조건이 될 때 submit()을 부르면 한 번만 낸다.
530
+ * 이미 낸 제출이 있으면(다시 열기) 내지 않고, 튜터(보기 전용)는 내지 않는다. 미리보기 · 교육자는 useSubmit처럼
531
+ * 내지만 기록되지 않는다 (SDK · 서버가 정함). 오류는 useSubmit처럼 화면 영역 뒤 알림 줄에 보이고 다음 submit()에서 다시 시도
532
+ * @param {AutoSubmitOptions} opts
533
+ */
534
+ useAutoSubmit(opts) {
535
+ return mountAutoSubmit(app, opts);
536
+ },
537
+
538
+ /**
539
+ * Elice 비디오 플레이어 (`embed.js`의 <elice-video> 재생 · <elice-video-upload> 올리기). 올리기 · 진행률 · 인코딩 대기 ·
540
+ * 재생 · 오류 문구는 플레이어가 그리고, 화면은 태그를 놓고 이벤트(complete · ended …)로 저장 · 제출만 한다.
541
+ * - url: 플랫폼이 넘긴 이 환경의 embed.js 주소 (SDK videoPlayerUrl). 없으면 null (아직 넘기지 않는 플랫폼 · ecdk dev · mock)
542
+ * - load(): embed.js를 불러온다 (SDK loadScript, 전역 EliceVideoPlayer). url이 없으면 ContentError video_player_unavailable
543
+ * - connect(element, { resourceId }): 태그에 자료 id · 영상 id · 토큰을 넣고, 플랫폼이 토큰을 바꿀 때마다 다시 넣는다.
544
+ * 돌려주는 함수를 부르면 토큰 따라가기를 멈춘다. 토큰은 속성이 아니라 프로퍼티로만 넣는다 (DOM에 남지 않게)
545
+ */
546
+ videoPlayer: Object.freeze({
547
+ get url() {
548
+ return sdk.videoPlayerUrl ?? null;
549
+ },
550
+ async load() {
551
+ const url = sdk.videoPlayerUrl ?? null;
552
+ if (!url) throw new ContentError('video_player_unavailable', MESSAGES.video_player_unavailable);
553
+ try {
554
+ const { loadScript } = await import('@eliceio/cdk');
555
+ return await loadScript(url, 'EliceVideoPlayer');
556
+ } catch (err) {
557
+ throw toContentError(err);
558
+ }
559
+ },
560
+ connect(element, { resourceId } = {}) {
561
+ element.materialId = sdk.metadata?.materialId ?? '';
562
+ if (resourceId) element.resourceId = resourceId;
563
+ element.token = sdk.accessToken ?? '';
564
+ return sdk.onAccessTokenChange?.(token => (element.token = token)) ?? (() => {});
565
+ },
566
+ }),
567
+
519
568
  /**
520
569
  * 자료 파일 (서버 스펙: POST /storage/upload-url → PUT, settings에는 asset_key, 보기는 asset_base_url + asset_key).
521
570
  * SDK `assets.post` · `assets.get`(!99)을 부른다.
@@ -619,6 +668,14 @@ export async function start(options) {
619
668
  * @property {string} [label] 버튼 글자 (기본 '제출')
620
669
  */
621
670
 
671
+ /**
672
+ * @typedef {object} AutoSubmitOptions
673
+ * @property {() => unknown} getAnswer 낼 답 (submit()을 부를 때 읽음)
674
+ * @property {(result: object, info: { restored: boolean }) => void} [onResult] 낸 직후, 또는 다시 열었을 때 지난 제출
675
+ * @property {(error: ContentError) => void} [onError] 내지 못했을 때 (알림 줄에도 보임)
676
+ * @property {Element} [root] 알림 줄을 붙일 화면 영역 (기본 #app, 그 뒤에 붙임)
677
+ */
678
+
622
679
  /**
623
680
  * @typedef {object} StepperOptions
624
681
  * @property {number} [count] 단계 수 (1 이상). 없으면 내용 영역 안 `[data-ec-step]` 요소 수
@@ -680,6 +737,81 @@ function resultText(r) {
680
737
  : `${r.score}점이에요. 다시 풀어 볼 수 있어요.`;
681
738
  }
682
739
 
740
+ /**
741
+ * 지난 점수: app.result에는 점수만 있어 채점했는지(isCorrect)는 마지막 제출에서 읽는다 (못 읽으면 점수로 짐작).
742
+ * 점수가 없으면 null (useSubmit · useAutoSubmit 공통)
743
+ */
744
+ function pastScore(app) {
745
+ return app.result && app.result.score !== null && app.result.score !== undefined
746
+ ? { score: app.result.score, isCorrect: app.result.score === 100 }
747
+ : null;
748
+ }
749
+
750
+ /** 답 하나를 내고 결과를 화면에 알린다 (useSubmit · useAutoSubmit 공통). 오류는 ContentError로 던진다 */
751
+ async function submitOnce(app, answer, onResult) {
752
+ const res = await app.submit(answer);
753
+ onResult?.(res, { restored: false });
754
+ return res;
755
+ }
756
+
757
+ function mountAutoSubmit(app, { getAnswer, onResult, onError, root }) {
758
+ const area = appRoot(root);
759
+ const error = h('p', { className: 'ec-error', role: 'alert' });
760
+ area.after(error);
761
+ // 'idle' 낼 수 있음 · 'sending' 내는 중 · 'done' 냈음(이번에 또는 예전에) · 'readonly' 튜터라 내지 않음
762
+ let state = app.readOnly ? 'readonly' : 'idle';
763
+ // 다시 열면: 지난 결과(완료 · 점수)나 마지막 제출이 있으면 이미 낸 것으로 본다
764
+ const done = app.result && (app.result.submitCount > 0 || app.result.completedAt);
765
+ if (done && state === 'idle') state = 'done';
766
+ const ready = app
767
+ .lastSubmission()
768
+ .then(last => {
769
+ if (!last) return;
770
+ if (state === 'idle') state = 'done';
771
+ onResult?.(last, { restored: true });
772
+ })
773
+ .catch(() => {
774
+ // 지난 제출을 읽지 못하면 결과(app.result)만으로 판단한다
775
+ const past = pastScore(app);
776
+ if (past) onResult?.(past, { restored: true });
777
+ });
778
+ let sending = null;
779
+ return {
780
+ element: error,
781
+ ready,
782
+ /** 'idle' · 'sending' · 'done' · 'readonly' */
783
+ get state() {
784
+ return state;
785
+ },
786
+ /** 이번에 또는 예전에 냈는지 */
787
+ get done() {
788
+ return state === 'done';
789
+ },
790
+ /** 조건이 되면 부른다. 이미 냈거나 내는 중이거나 튜터면 아무것도 하지 않는다 (결과 또는 null) */
791
+ async submit() {
792
+ await ready;
793
+ if (state !== 'idle') return sending ?? null;
794
+ state = 'sending';
795
+ error.textContent = '';
796
+ sending = submitOnce(app, getAnswer(), onResult)
797
+ .then(res => {
798
+ state = 'done';
799
+ return res;
800
+ })
801
+ .catch(e => {
802
+ state = 'idle';
803
+ error.textContent = e.message;
804
+ onError?.(e);
805
+ return null;
806
+ })
807
+ .finally(() => {
808
+ sending = null;
809
+ });
810
+ return sending;
811
+ },
812
+ };
813
+ }
814
+
683
815
  const UNCHANGED_HINT = '답을 고치면 다시 제출할 수 있어요.';
684
816
 
685
817
  function mountSubmit(
@@ -780,11 +912,7 @@ function mountSubmit(
780
912
  button.hidden = true;
781
913
  error.textContent = '보기 전용이라 제출할 수 없습니다.';
782
914
  }
783
- // 지난 점수: app.result에는 점수만 있어 채점했는지(isCorrect)는 마지막 제출에서 읽는다 (못 읽으면 점수로 짐작)
784
- const past =
785
- app.result && app.result.score !== null && app.result.score !== undefined
786
- ? { score: app.result.score, isCorrect: app.result.score === 100 }
787
- : null;
915
+ const past = pastScore(app);
788
916
  if (past && !app.readOnly) button.textContent = `다시 ${label}`;
789
917
  // 다시 열면 마지막 제출의 답을 채우고, 채점 결과({ isCorrect, score })도 화면에 알려 준다.
790
918
  // 복원 응답보다 먼저 제출했으면 늦게 온 복원은 버린다 (방금 낸 답 · 결과를 덮지 않게)
@@ -6,6 +6,7 @@ export declare class FetchError extends Error {
6
6
  constructor(message: string, status: number);
7
7
  }
8
8
  export declare function fetchBytes(url: string, fetchImpl?: typeof fetch): Promise<Uint8Array>;
9
+ export declare function preloadViewer(kind: 'pdf' | 'pptx'): void;
9
10
  export declare function openDocument(
10
11
  kind: 'pdf' | 'pptx',
11
12
  source: Uint8Array | string,