@eliceio/cdk-cli 1.4.1 → 1.5.1-qa.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 (79) hide show
  1. package/README.md +17 -16
  2. package/es/cli.js +1 -1
  3. package/es/commands/create/index.js +1 -0
  4. package/es/commands/create/scaffold.d.ts +1 -1
  5. package/es/commands/create/scaffold.js +1 -1
  6. package/es/core/config.d.ts +36 -0
  7. package/es/core/config.js +234 -6
  8. package/es/core/quiz-check.js +123 -4
  9. package/es/dev/grading.d.ts +26 -4
  10. package/es/dev/grading.js +66 -11
  11. package/es/dev/mock-api.d.ts +6 -1
  12. package/es/dev/mock-api.js +45 -6
  13. package/es/rules/answers.d.ts +1 -0
  14. package/es/rules/answers.js +8 -0
  15. package/es/rules.json.js +1 -1
  16. package/package.json +2 -2
  17. package/rules.json +1 -1
  18. package/skills/_shared/always.md +1 -1
  19. package/skills/_shared/references/02-design-the-material.md +8 -7
  20. package/skills/_shared/references/03-create-the-project.md +10 -9
  21. package/skills/_shared/references/12-upload-with-the-material-mcp.md +5 -5
  22. package/skills/_shared/references/16-using-the-survey-template.md +158 -0
  23. package/skills/elice-content-create/SKILL.md +2 -2
  24. package/skills/elice-content-edit/SKILL.md +2 -2
  25. package/skills/elice-content-publish/SKILL.md +1 -1
  26. package/templates/_shared/lib/cdk-mock.d.ts +22 -3
  27. package/templates/_shared/lib/cdk-mock.js +78 -11
  28. package/templates/_shared/lib/elice-content.d.ts +17 -1
  29. package/templates/_shared/lib/elice-content.js +47 -5
  30. package/templates/blank/template.json +1 -1
  31. package/templates/document/template.json +2 -2
  32. package/templates/quiz/README.md +26 -1
  33. package/templates/quiz/core/behaviors.d.ts +5 -0
  34. package/templates/quiz/core/behaviors.js +16 -1
  35. package/templates/quiz/core/model.d.ts +78 -1
  36. package/templates/quiz/core/model.js +219 -4
  37. package/templates/quiz/screens/edit.js +244 -55
  38. package/templates/quiz/screens/learn.js +137 -27
  39. package/templates/quiz/styles.css +258 -5
  40. package/templates/quiz/template.json +1 -1
  41. package/templates/quiz/ui/templates/edit.d.ts +1 -0
  42. package/templates/quiz/ui/templates/edit.js +67 -8
  43. package/templates/quiz/ui/templates/page.js +34 -0
  44. package/templates/quiz/ui/templates/text.js +15 -2
  45. package/templates/quiz/ui/texts.js +61 -0
  46. package/templates/steps/template.json +1 -1
  47. package/templates/survey/README.md +112 -0
  48. package/templates/survey/commentary.txt +2 -0
  49. package/templates/survey/core/behaviors.d.ts +14 -0
  50. package/templates/survey/core/behaviors.js +115 -0
  51. package/templates/survey/core/dom.d.ts +13 -0
  52. package/templates/survey/core/dom.js +83 -0
  53. package/templates/survey/core/editor.d.ts +80 -0
  54. package/templates/survey/core/editor.js +720 -0
  55. package/templates/survey/core/markdown.d.ts +21 -0
  56. package/templates/survey/core/markdown.js +298 -0
  57. package/templates/survey/core/model.d.ts +83 -0
  58. package/templates/survey/core/model.js +209 -0
  59. package/templates/survey/core/rich-text.d.ts +18 -0
  60. package/templates/survey/core/rich-text.js +469 -0
  61. package/templates/survey/edit.html +26 -0
  62. package/templates/survey/gitignore +4 -0
  63. package/templates/survey/index.html +26 -0
  64. package/templates/survey/metadata.json +9 -0
  65. package/templates/survey/package.json +13 -0
  66. package/templates/survey/screens/edit.js +345 -0
  67. package/templates/survey/screens/learn.js +100 -0
  68. package/templates/survey/styles.css +1264 -0
  69. package/templates/survey/template.json +12 -0
  70. package/templates/survey/ui/templates/edit.d.ts +27 -0
  71. package/templates/survey/ui/templates/edit.js +656 -0
  72. package/templates/survey/ui/templates/index.d.ts +3 -0
  73. package/templates/survey/ui/templates/index.js +3 -0
  74. package/templates/survey/ui/templates/learn.js +147 -0
  75. package/templates/survey/ui/templates/page.js +19 -0
  76. package/templates/survey/ui/texts.d.ts +3 -0
  77. package/templates/survey/ui/texts.js +116 -0
  78. package/templates/survey/ui/theme.css +42 -0
  79. package/templates/video/template.json +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eliceio/cdk-cli",
3
- "version": "1.4.1",
3
+ "version": "1.5.1-qa.0",
4
4
  "description": "교육자용 Custom HTML 콘텐츠 CLI",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
@@ -46,7 +46,7 @@
46
46
  "rollup": "^4.0.0",
47
47
  "tslib": "^2.6.1",
48
48
  "typescript": "~5.9.3",
49
- "@eliceio/cdk": "^1.4.1"
49
+ "@eliceio/cdk": "^1.5.1-qa.0"
50
50
  },
51
51
  "scripts": {
52
52
  "prebuild": "del-cli \"buildcache/*\" \"es/*\"",
package/rules.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.20.0",
2
+ "version": "0.21.0",
3
3
  "manifest": {
4
4
  "file": "metadata.json",
5
5
  "kinds": ["material", "description"],
@@ -1,7 +1,7 @@
1
1
  ## Always
2
2
 
3
3
  - **Never ask for, store or send a learner's personal data (name, phone number, email, address, date of birth, student number, resident registration number, bank account, face photo, location, or anything else that identifies a person): not in a submission (`submit` · `useSubmit`), `kvstore`, `saveSettings` (`useSave`), a file upload (`assets`) or an AI call (`mlapi`). If the request needs it, ask the person before you build.** Why and what to use instead: `references/02-design-the-material.md` "Personal data".
4
- - Answer the person in their language. The reference files are in English: `references/` next to this SKILL.md, read only the ones you need with the Read tool: 00 what the person decides · 01 environment · 02 design · 03 create the project · 04 sandbox rules · 05 screen code and kit API · 06 quiz template · 07 move existing HTML · 08 error ids · 09 check · 10 build and report · 11 more · 12 upload · 13 edit screen design · 14 layouts and stepper · 15 edit settings by hand.
4
+ - Answer the person in their language. The reference files are in English: `references/` next to this SKILL.md, read only the ones you need with the Read tool: 00 what the person decides · 01 environment · 02 design · 03 create the project · 04 sandbox rules · 05 screen code and kit API · 06 quiz template · 07 move existing HTML · 08 error ids · 09 check · 10 build and report · 11 more · 12 upload · 13 edit screen design · 14 layouts and stepper · 15 edit settings by hand · 16 survey template.
5
5
  - Never put correct answers in the content zip. The edit screen saves them to `settings.grading` (locally `.ecdk/settings.json` from `ecdk dev`, which stays local unless the person agrees to send it with the upload, `references/12-upload-with-the-material-mcp.md`).
6
6
  - The completion policy is not in the project or the zip: it is a setting of the LXP page. Say which one fits (`references/02-design-the-material.md` ②); the elice-content-publish skill sets it with the upload after the person agrees (`on_graded` only with grading saved), otherwise the instructor picks it in the '설정' panel at the top of the LXP edit page. Only `on_graded` grades: `on_submit` completes on any submission without grading (`is_correct: null`, the kit shows "제출했어요."), `on_access` completes on open.
7
7
  - The content runs in a sandboxed iframe on its own origin: use the SDK (`app.useSubmit`, `app.useSave`) for anything that must be kept (storage and cookies stay only in that browser), and in-page UI instead of `alert`/`confirm`, new windows, the parent window or external requests.
@@ -15,13 +15,13 @@ Read or watch / change values and observe (simulation, visualization) / follow s
15
15
 
16
16
  **② Submission and grading** (the completion policy is a setting of the LXP page, not in the package, ADR 0012; since 2026-11-12 the publish skill sets it with the upload after the person agrees, otherwise the instructor picks it in the '설정' panel at the top of the LXP edit page. The grading settings `settings.grading` hold the grader `type` and its answers)
17
17
 
18
- | Material | Policy to propose (LXP setting) | Grading (`type`) | Student screen |
19
- | ----------------------------------------------------------- | --------------------------------- | ----------------------- | ----------------------------------------- |
20
- | Something to read or watch, such as a simulation | `on_access` (done on open) | - | No submission |
21
- | Done when the activity ends (results, self-check, survey) | `on_submit` (done on submit) | - | Submit the result with `useSubmit` |
22
- | One correct answer or one set of answers | `on_graded` (done when it passes) | `pattern` (one regex) | `useSubmit` |
23
- | Several questions with a score per question (partial score) | `on_graded` | `partial_pattern` | `useSubmit` with a string array |
24
- | Writing or assignments graded against a rubric (AI grading) | `on_graded` | `rubric` (the criteria) | `useSubmit`, the score comes back at once |
18
+ | Material | Policy to propose (LXP setting) | Grading (`type`) | Student screen |
19
+ | ----------------------------------------------------------- | --------------------------------- | ----------------------- | --------------------------------------------------------------------------------------------------------- |
20
+ | Something to read or watch, such as a simulation | `on_access` (done on open) | - | No submission |
21
+ | Done when the activity ends (results, self-check, survey) | `on_submit` (done on submit) | - | Submit the result with `useSubmit` (a survey: the survey template, [16](16-using-the-survey-template.md)) |
22
+ | One correct answer or one set of answers | `on_graded` (done when it passes) | `pattern` (one regex) | `useSubmit` |
23
+ | Several questions with a score per question (partial score) | `on_graded` | `partial_pattern` | `useSubmit` with a string array |
24
+ | Writing or assignments graded against a rubric (AI grading) | `on_graded` | `rubric` (the criteria) | `useSubmit`, the score comes back at once |
25
25
 
26
26
  > **Personal data: never collect it.** A material never asks for, stores or sends a learner's personal data: name, phone number, email, address, date of birth, student number, resident registration number, bank account, face photo, location, or anything else that identifies a person. Not in a submission (`useSubmit` · `submit`), `kvstore`, the content the edit screen saves (`useSave` · `saveSettings`), a file upload (`assets`) or an AI call (`mlapi`).
27
27
  >
@@ -32,6 +32,7 @@ Read or watch / change values and observe (simulation, visualization) / follow s
32
32
  - **The grader and the answers are set on the edit screen** and saved to `settings.grading` with the edit token (`useSave` with `getGrading`): `{ "type": "pattern", "answer_key": "^…$" }` or `{ "type": "rubric", "rubric": "…" }`. The kit's default block `app.useGradingBlock()` uses LXP's wording (기준 답안 (정규표현식), 작성 예시 보기, 평가 기준). When the answers depend on the content's structure (questions, choices, steps), set them where the content is edited, for example in each question card. The answer to `pattern` is **one regular expression** that must match the whole submitted answer string (trimmed), so submit one string and build the regex from the instructor's choices.
33
33
  - **AI grading is `rubric`, saved on the edit screen.** AI가 답을 평가해 점수를 매기는 학습자료는 `settings.grading`을 `rubric`으로 저장한다 (편집 화면 `useSave`의 `getGrading`으로 평가 기준을 rubric 글로 만들어 저장), 학습 화면은 학습자 답만 제출한다, 화면에서 계산한 점수는 서버 채점에 쓰이지 않는다. Without `settings.grading`, `on_graded` scores 0 and never completes and `on_submit` gives 100 whatever the AI said. With `on_graded` + `rubric` the server grades 0–100 and completes at 1 point or more. Never compute the score with `mlapi` in the browser and submit it. Sketch and details: [5](05-screen-code.md) "AI grading".
34
34
  - **`partial_pattern` (partial score per question)**: `{ "type": "partial_pattern", "answer_key": ["^…$", "^…$"], "scores": [50, 50] }`. The student submits a **string array** in question order and `answer[i]` is matched against `answer_key[i]` the same way as `pattern` (trimmed, full match). The score is the sum of `scores[i]` of the matched questions, capped at 100. Rules the server enforces on save (422 otherwise): both arrays 1–50 long and the same length, each score an integer 0–100, the sum at least 100 (a lower sum could never complete). Only 100 is `is_correct: true` and completes `on_graded`; a missing item scores 0, extra items are ignored, and an answer that is not an array of strings is rejected (422). The response also carries `answer_correctness` (per question, `answer_key` order; `[]` for `pattern` · `rubric`), in the submit response and the submission lists, so a screen can mark each question right or wrong (SDK `answerCorrectness`). Kit helpers: `validatePartialGrading` (the same rules, for `getGrading`) and `splitScores(n)` (equal integer split summing to 100, e.g. 3 → [33, 33, 34]). The quiz template supports both (6).
35
+ - **`per_question` (regex and AI-graded questions mixed, quiz template 1.11.0+)**: `{ "type": "per_question", "questions": [{ "score": 50, "grader": { "type": "pattern", "answer_key": "^q1=b$" } }, { "score": 50, "grader": { "type": "rubric", "rubric": "…", "question": "the problem text" } }], "pass_score": 60 }`. The answer is a string array in question order; an AI-graded item is the plain answer text (no `qN=`). A question earns `floor(grader score 0–100 × score / 100)`, the total is capped at 100, only 100 is `is_correct: true`, and `on_graded` completes at `pass_score` (1–100, default 100). Save rules (422 otherwise): 1–50 questions, integer scores summing to at least 100, at most 10 `rubric` graders, `rubric` ≤ 10,000 and `question` ≤ 2,000 characters. The response carries `question_results: [{ score, is_correct }]` per question (in the submission lists too). Use the quiz template's AI-graded question rather than writing this by hand.
35
36
  - **Choosing between `pattern` and `partial_pattern` is the person's call.** For a material with several questions, ask: "모두 맞혀야 100점" (`pattern`) or "문항별 부분 점수" (`partial_pattern`). For partial scores, take the per-question scores from the person or from the planning material; if neither gives them, use an equal score and say so in the summary (the quiz template's automatic score is `ceil(100 / questions)` each, 3 → 34 · 34 · 34; the kit's `splitScores` sums to exactly 100, 3 → 33 · 33 · 34). In the quiz template the author can also change the grader and the scores on the edit screen. Scores are integers 0–100 summing to at least 100 (usually exactly 100). Students must answer every question before they submit (the quiz blocks an unanswered question), so a skipped question cannot score 0 by design.
36
37
  - **Regexes run on the server in Python `re`**, not JavaScript: for a case-insensitive match put `(?i)` at the very start (`(?i)^(paris|파리)$`); the kit, `ecdk dev` and the local mock turn a leading `(?i)` · `(?s)` · `(?m)` into the JS flag. Avoid what the two engines read differently: `\w` · `\d` · `\b` match Unicode (Korean letters, full-width digits) in Python but only ASCII in JS, so write the characters out (`[0-9]`, `[가-힣A-Za-z]`); named groups are `(?P<name>…)` in Python and `(?<name>…)` in JS (do not use them); lookbehind must be fixed-width in Python; inline flags anywhere but the start fail in both. The generated keys (escaped literals, `(?:…|…)`, `^…$`) mean the same in both.
37
38
  - **The completion policy is picked in LXP**, not in the project: the publish skill proposes it from this table and sets it with the upload after the person agrees (graded: the quiz template or settings with `grading` → `on_graded`; submits without grading → `on_submit`; no submission → `on_access`), or the instructor chooses it in the '설정' panel at the top of the LXP edit page, which applies at once (ADR 0012). `on_graded` needs `settings.grading` saved first, so it goes in the same save as settings with `grading`, or later. Do not write it in `metadata.json` (the old `completionPolicies` and `screens.completionPolicy` are ignored with the warning `manifest.completion-policies-ignored`, and `ecdk build` leaves them out of the zip). The content can read the current policy (SDK `material.completionPolicy`) but never sets it. Build what the suggested policy needs: a submission (`useSubmit`) for `on_submit` · `on_graded`, and the grading saved on the edit screen for `on_graded`. The server rejects `on_graded` without `settings.grading` (`MATERIAL_GRADING_REQUIRED`). The edit screen never sends a policy.
@@ -2,15 +2,16 @@
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; 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) |
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
+ | A survey (course feedback: scale, single or multiple choice with "other", free text; no answers or grading) | `ecdk create <folder> --template survey` (edit screen builds the questions; the student submits and sees a thank-you screen, reopening shows it and lets them change the answers; no instructor screen; no `grading`, so suggest `on_submit`; then [16](16-using-the-survey-template.md)) |
9
+ | 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) |
10
+ | 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)) |
11
+ | 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") |
12
+ | A dark screen | Add `--theme dark` to the above |
13
+ | 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 |
14
+ | An existing HTML page | [7. Move existing HTML](07-move-existing-html.md) |
14
15
 
15
16
  `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
17
 
@@ -66,11 +66,11 @@ Next time, read it, confirm the page with the person as above (기관 · 과목
66
66
 
67
67
  The completion policy is not in the project or the zip (ADR 0012): it is a setting of the LXP page, independent of versions, and it applies as soon as it is set. The publish skill proposes one and sets it with the save after the person agrees, when the save tool takes it. Detect support like `settings`: use `completion_policy` only when the input schema of `save_draft` (or `update_material`) lists it in `payload`. If no tool has it, tell the person after saving which one to pick in the '설정' panel opened from the top of the LXP edit page (choosing applies at once).
68
68
 
69
- | The material | Propose |
70
- | ------------------------------------------------------------------------ | ---------------------------------------- |
71
- | Graded: the quiz template, or any material whose settings have `grading` | `on_graded` ("답안 확인 후 완료") |
72
- | Submits (`useSubmit`) without grading | `on_submit` (complete on any submission) |
73
- | No submission | `on_access` (complete on open) |
69
+ | The material | Propose |
70
+ | --------------------------------------------------------------------------------------------------------------------- | ---------------------------------------- |
71
+ | Graded: the quiz template, or any material whose settings have `grading` | `on_graded` ("답안 확인 후 완료") |
72
+ | Submits (`useSubmit`) without grading (the survey template, [16](16-using-the-survey-template.md); never `on_graded`) | `on_submit` (complete on any submission) |
73
+ | No submission | `on_access` (complete on open) |
74
74
 
75
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.
76
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).
@@ -0,0 +1,158 @@
1
+ # 16. Using the survey template
2
+
3
+ `ecdk create <folder> --template survey` makes a survey: scale, single choice, multiple choice (with an optional '기타' box) and free-text questions. **There are no correct answers and no grading.** The student answers and presses "제출"; the screen turns into "응답해 주셔서 감사합니다.", and reopening it shows that screen with "응답 확인하고 수정하기" to change the answers and submit again. There is no instructor (results) screen: an instructor who opens it on LXP sees the student screen. The project `README.md` lists which file draws what.
4
+
5
+ ## Survey or quiz?
6
+
7
+ | The person wants | Template |
8
+ | --------------------------------------------------------------------------------------------------- | ---------------------------------------------- |
9
+ | Opinions, course feedback, self-assessment ("이해도"), expectations, a poll: **no answer is right** | `survey` (this page) |
10
+ | Checking what the student knows: there is a correct answer and a score | `quiz` ([6](06-using-the-quiz-template.md)) |
11
+ | A self-check that shows the right answer afterwards | `quiz` (a survey never shows or keeps answers) |
12
+
13
+ If a request mixes both ("수업 피드백 + 확인 문제"), suggest two materials (pages): a quiz and a survey. Never put grading into a survey.
14
+
15
+ ## The content (settings)
16
+
17
+ The questions are what the edit screen saves (`settings`; locally `.ecdk/settings.json` from `ecdk dev`). The template starts with **no questions**: the student screen shows "학습 자료를 준비하고 있어요" until the edit screen saves, and the edit screen starts with one empty single-choice question. Everything in `settings` is public (the student screen gets it), and a survey has no `grading`.
18
+
19
+ **Everything the survey owns is under `settings.survey`**. The server recognizes a survey by this key and checks the question and answer shapes; nothing else goes at the top of `settings`.
20
+
21
+ ```ts
22
+ {
23
+ survey: {
24
+ description?: string, // survey intro above the questions (Markdown)
25
+ questions: [{
26
+ id: string, // q1, q2, … (options o1, o2, …)
27
+ type: 'single' | 'multiple' | 'scale' | 'text',
28
+ title: string, // the question, plain text, up to 300 characters
29
+ description?: string, // a note under the question (Markdown, "설명 추가 +")
30
+ required: boolean, // "필수 응답": must be answered before submitting
31
+ options?: [{ id, text }], // single · multiple: 2–10 options
32
+ other?: true, // single · multiple: adds '기타(자유 입력)'
33
+ scale?: { min: 0 | 1, max: 2..10, minLabel: string, maxLabel: string } // scale only
34
+ }]
35
+ }
36
+ }
37
+ ```
38
+
39
+ - **Write it under `survey`.** When you write `.ecdk/settings.json` by hand, always use `{ "survey": { … } }`; never put the questions at the top of `settings`.
40
+ - **Limits** (`core/model.js` `LIMITS`, the edit screen enforces them): up to **30 questions**, **2–10 options** per choice question, title up to 300 characters, a '기타' answer up to 300 characters, a free-text answer up to 1000 characters. Up to 50 uploaded images in the whole survey. Keep the whole `settings` well under **about 64KB** (the server limit): that is why images are never inline.
41
+ - **Ids are permanent.** Answers are stored by question id and option id, and everything that reads them (the tutoring view, the course survey report) matches by id. Once the survey may have responses (it is on LXP), never renumber, reuse or swap ids: changing an option's text keeps its id, a new question or option gets an unused id (`q6`, `o5`), and a deleted id is not given to something else. Changing the meaning of an option under the same id mixes old and new answers; add a new option instead.
42
+ - **Images**: in a `description` (Markdown) only, through the edit screen's image button (the toolbar shows when the intro or a description box has focus). It uploads the picture to the server and keeps only `![설명](asset:assets/…/….webp)` in the text, the same as the quiz ([6](06-using-the-quiz-template.md) "Adding images": the button works on the LXP edit screen of a saved material; the `elice-material` MCP `create_asset_upload` when it is listed). Keep every `asset:` reference as it is. Never put a `data:` address into the settings.
43
+ - **Filling it in for the person**: write `.ecdk/settings.json` in this shape (`{ "survey": { … } }`, the full example below), then have the person open the content edit view in `ecdk dev` and press "초안으로 저장" once, so the edit screen's own checks run ("문항을 하나 이상 추가해 주세요.", "질문을 입력해 주세요.", "보기 내용을 입력해 주세요.", at least 2 options). `ecdk doctor` has no survey check. The questions and their wording are the person's: draft them, and ask before you change wording the request does not name in an existing survey.
44
+
45
+ ## Submission and completion
46
+
47
+ - **Completion policy: `on_submit`** ("제출 시 완료"). The server records any submission as complete with 100 and no grading (`is_correct: null`). **Never `on_graded`**: a survey has no `grading`, so the server refuses it. `on_access` also works (complete on open, even without submitting) if the person wants that. The publish skill proposes it ([12](12-upload-with-the-material-mcp.md) "Completion policy"); otherwise the person picks it in the '설정' panel of the LXP edit page.
48
+ - **The answer shape is the template's.** The student screen submits one JSON object keyed by question id:
49
+
50
+ ```json
51
+ {
52
+ "q1": 4,
53
+ "q2": "o2",
54
+ "q3": ["o1", "other"],
55
+ "q3:other": "발표 자료",
56
+ "q4": "예제가 좋았습니다."
57
+ }
58
+ ```
59
+
60
+ Single choice: an option id, `"other"` or `null` · multiple: an array of option ids · scale: an integer or `null` · text: a string · the '기타' text under `<question id>:other` (only when '기타' is picked and the text is not empty). There is no `meta`: the server knows who submitted from the token. When `settings.survey` exists the server refuses a value of the wrong kind for a known question (422 `not_a_survey_answer`); it ignores unknown keys, and the template never sends them. **Never write your own submit code, add keys or change this shape**: it is in `core/` (do not edit), and the tutoring view and the course survey report read exactly this. Never add personal data to the answers.
61
+
62
+ ## Writing good survey questions
63
+
64
+ Apply these when you draft or review the questions, and tell the person what you changed and why.
65
+
66
+ - **One idea per question.** Split "강의 내용과 진행 속도는 적절했나요?" into two questions; a double-barreled question cannot be answered honestly.
67
+ - **Neutral wording.** No leading or loaded questions ("이번 강의가 얼마나 유익했나요?" assumes it was): ask "이번 강의는 나에게 유익했다." on an agree scale. No double negatives ("~하지 않은 것은 아니다").
68
+ - **Balanced, labeled scales.** Use a symmetric agree scale with both ends labeled, for example 1 "전혀 그렇지 않다" – 5 "매우 그렇다" (`minLabel` · `maxLabel`; 5 points by default, 7 at most unless the person asks, since 7+ wraps to two rows on phones). Keep **the same direction in every scale question** (low = negative, high = positive) and the same range, so the averages compare. Use `min: 0` only for a 0–10 recommendation scale ("0 전혀 추천하지 않는다" – "10 적극 추천한다").
69
+ - **Options mutually exclusive and exhaustive.** No overlapping ranges ("1–3시간" / "3–5시간" → "1시간 이상 3시간 미만" / "3시간 이상 5시간 미만"). When the list may miss someone, turn on '기타(자유 입력)' (`other: true`) instead of guessing more options. Use `multiple` only when several answers can be true together, and say so in the title ("모두 골라 주세요").
70
+ - **`required` only for the essential questions** (usually the scale questions the course needs). Make free-text questions optional; forcing them gets "없음" answers.
71
+ - **Keep it short**: aim for **10 questions or fewer, about 3 minutes**. Say in the intro (`description`) why the survey is asked, how long it takes and how the answers are used.
72
+ - **Order**: easy, general questions first; sensitive and open-ended (text) questions last.
73
+ - **Korean polite form**: titles as statements to rate or questions ending in "~나요?", instructions as "~해 주세요" ("해당하는 것을 모두 골라 주세요."). Keep each title one sentence.
74
+
75
+ ## Personal data
76
+
77
+ - **Never ask for a name, phone number, email, student number, address, birth date or anything else that identifies the learner** (Always; [2](02-design-the-material.md) "Personal data"; `ecdk validate` warns with `privacy.personal-field`, [8](08-fix-check-errors.md)). Ask about the topic, the level and the experience instead. If the request asks for it, do not build that question and offer the anonymous version (the example sentence is in [2](02-design-the-material.md)).
78
+ - For a free-text question, add "개인정보(이름 · 연락처 등)는 적지 마세요." to its `description` or to the survey intro.
79
+ - **A survey is not anonymous.** The server keeps each submission with the learner's account: instructors see each student's answers in the tutoring view, and operators can look them up. If the person calls the survey anonymous ("익명 설문"), tell them this and suggest the intro say how the answers are used (for example "응답은 다음 수업을 준비하는 데만 씁니다.") rather than "익명" or "완전 익명".
80
+
81
+ ## Where the answers are
82
+
83
+ - **No results screen in this template.** On LXP an instructor who opens the page sees the student screen, and what they submit there is recorded like a student's answer.
84
+ - **One student's answer**: the LXP tutoring view opens that student's screen read-only with their latest answer filled in.
85
+ - **All answers together**: a course survey report from the server is planned ("Custom 설문 LXP 연동" design); until it exists, do not promise one. Tell the person this when they ask where the results are.
86
+ - Locally, `ecdk dev` keeps what you submit in the student view, and reopening shows it again.
87
+
88
+ ## Example: course feedback (5 questions)
89
+
90
+ ```json
91
+ {
92
+ "survey": {
93
+ "description": "오늘 수업에 대한 의견을 들려주세요. 약 2분 걸리며, 응답은 이름 없이 모아서 다음 수업을 준비하는 데만 씁니다.",
94
+ "questions": [
95
+ {
96
+ "id": "q1",
97
+ "type": "scale",
98
+ "title": "오늘 수업 내용을 이해했다.",
99
+ "required": true,
100
+ "scale": { "min": 1, "max": 5, "minLabel": "전혀 그렇지 않다", "maxLabel": "매우 그렇다" }
101
+ },
102
+ {
103
+ "id": "q2",
104
+ "type": "scale",
105
+ "title": "오늘 배운 내용을 실제로 활용할 수 있을 것 같다.",
106
+ "required": true,
107
+ "scale": { "min": 1, "max": 5, "minLabel": "전혀 그렇지 않다", "maxLabel": "매우 그렇다" }
108
+ },
109
+ {
110
+ "id": "q3",
111
+ "type": "single",
112
+ "title": "수업 진행 속도는 어땠나요?",
113
+ "required": true,
114
+ "other": true,
115
+ "options": [
116
+ { "id": "o1", "text": "너무 느렸다" },
117
+ { "id": "o2", "text": "적당했다" },
118
+ { "id": "o3", "text": "너무 빨랐다" }
119
+ ]
120
+ },
121
+ {
122
+ "id": "q4",
123
+ "type": "multiple",
124
+ "title": "도움이 된 활동을 모두 골라 주세요.",
125
+ "required": false,
126
+ "options": [
127
+ { "id": "o1", "text": "개념 설명" },
128
+ { "id": "o2", "text": "예제 풀이" },
129
+ { "id": "o3", "text": "실습" },
130
+ { "id": "o4", "text": "질의응답" }
131
+ ]
132
+ },
133
+ {
134
+ "id": "q5",
135
+ "type": "text",
136
+ "title": "다음 수업에서 더 다뤄 주었으면 하는 내용이 있다면 적어 주세요.",
137
+ "description": "개인정보(이름 · 연락처 등)는 적지 마세요.",
138
+ "required": false
139
+ }
140
+ ]
141
+ }
142
+ }
143
+ ```
144
+
145
+ ## Before upload
146
+
147
+ - [ ] It is really a survey (no right answers); otherwise the quiz template.
148
+ - [ ] No question asks who the learner is; free-text questions carry the personal-data note; `ecdk validate` has no `privacy.personal-field`.
149
+ - [ ] One idea per question, neutral wording, no double negatives, polite form.
150
+ - [ ] Every scale has both end labels, the same direction and range.
151
+ - [ ] Options do not overlap and cover every case, or '기타' is on.
152
+ - [ ] `required` only on the essential questions; 10 questions or fewer if possible.
153
+ - [ ] Ids unchanged for a survey that is already on LXP; new items have unused ids.
154
+ - [ ] Images only as `asset:` (edit screen image button or MCP), no `data:`.
155
+ - [ ] The person opened the edit view and pressed "초안으로 저장" once; the student and edit screens pass `ecdk dev --check --screens learn,edit`.
156
+ - [ ] Completion policy `on_submit` proposed (never `on_graded`); the person knows where the answers are (tutoring view, below).
157
+
158
+ - File split, as in the quiz: **`ui/` is the look** (`ui/texts.js` wording, `ui/theme.css` `--qz-*` variables, `ui/templates/*.js` markup; keep the `data-role` attributes), **`screens/` the layout**, **`core/` the behavior and the answer shape** (do not edit).
@@ -15,8 +15,8 @@ Write the progress line `[n/N] …` before and after every step below (Always
15
15
 
16
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
- 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
- - 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 `이 자료에 맞게 바꿀 곳`.
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`; a survey (opinions, feedback, self-assessment, no right answers): the survey template and `references/16-using-the-survey-template.md` for the settings shape, question-writing rules, personal data and where the answers are); 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
+ - For a material that is not a quiz or a survey, 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 `이 자료에 맞게 바꿀 곳`.
20
20
  - If the person describes the content (for example "5 questions about perceptrons"), fill it in so the upload can carry it: write `.ecdk/settings.json` in the shape `references/09-check.md` describes (the edit screen's content object at the top level, `grading` when graded), then have the person open the edit view in `ecdk dev`, check it and save with the edit screen's button, so the edit screen's own validation runs. Draft the answers, but the person confirms them before any upload (Always). One quiz material holds up to 20 questions (`references/06-using-the-quiz-template.md`): put them all in one material; only more than 20 means several quiz materials (pages). If the person prefers, give the content as draft text (the content editor: one JSON block for 코드 보기) to enter in the LXP edit screen instead.
21
21
  4. **Check each screen** with `ecdk dev <folder> --check --screens <screen>` after you write it (`references/09-check.md`), fix what it reports (error ids: `references/08-fix-check-errors.md`). The person looks at the screens too.
22
22
  5. **Build and report.** `ecdk validate` once, then `ecdk build --json` must return `ok: true`. Report as `references/10-build.md` says.
@@ -5,7 +5,7 @@ description: Change an existing Elice Custom HTML learning material made with ec
5
5
 
6
6
  # Change an existing Elice learning material
7
7
 
8
- Reference files are in `references/` in this skill's folder (see Always). For this skill: `references/15-edit-settings-by-hand.md` (what each settings key means, building answer regexes with `core/model.js`, example diffs), `references/00-what-the-person-decides.md`, and for a quiz `references/06-using-the-quiz-template.md`.
8
+ Reference files are in `references/` in this skill's folder (see Always). For this skill: `references/15-edit-settings-by-hand.md` (what each settings key means, building answer regexes with `core/model.js`, example diffs), `references/00-what-the-person-decides.md`, for a quiz `references/06-using-the-quiz-template.md`, and for a survey `references/16-using-the-survey-template.md` (keep question and option ids, no `grading`, its writing rules and checklist).
9
9
 
10
10
  {{always}}
11
11
 
@@ -14,7 +14,7 @@ Reference files are in `references/` in this skill's folder (see Always). For th
14
14
  0. **Only a zip, no project folder?** Never unzip it to edit the files and zip it again (Always), and do not offer that. Questions, answers and points are not in the zip but in the material's settings on the server: tell the person to change them in the LXP edit page (내용 편집), press "초안으로 저장" and then "수업 자료에 반영". Screen wording, look or behavior needs the original ecdk project folder: ask the person for it first. No folder: read `build.template` in the zip's `metadata.json` (for example `quiz@1.10.0`) and make a new project with `ecdk create <folder> --template <name>` (the name before `@`; say so if this ecdk has another version), and explain that the content stays in the LXP edit page, not in the zip. A zip without `build` in `metadata.json` was not made with ecdk: that is the elice-content-migrate skill.
15
15
  1. **Look first.** In the project, `ecdk doctor --json` (note what already fails before you change anything), read `.ecdk/settings.json` (the content and answers the edit screen saved; the quiz: `questions`, `grading`, with partial scores `gradingType` · `pointsMode` · each question's `points`, and from quiz 1.10.0 `answerFormat` · `requires` · a text question's `answerMode`) and `package.json` `"ecdk"."template"` (the quiz template version) and the project `README.md` ("고치는 곳"). Start `ecdk dev <folder>` in the background and give the person the URL.
16
16
  2. **Sort the request.**
17
- - Content, answers, points or grading → `.ecdk/settings.json`, keeping every id.
17
+ - Content, answers, points or grading → `.ecdk/settings.json`, keeping every id (a survey: questions and options under `survey` only, never `grading`; answers are matched by id).
18
18
  - Wording or look of the screens → `ui/` (quiz: `ui/texts.js`, `ui/theme.css`, `ui/templates/`) and `screens/`.
19
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.
@@ -14,7 +14,7 @@ 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); 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.
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 (the survey template) → `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
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.
@@ -40,6 +40,8 @@ export interface SubmitResult {
40
40
  score: number | null;
41
41
  /** partial_pattern 문항별 맞음 (answer_key 순서, 없는 답은 false). pattern · rubric · 채점 없음은 [] (옛 서버는 없음) */
42
42
  answerCorrectness?: boolean[];
43
+ /** 문항별 결과 (서버 question_results, 문항 순서): score는 받은 점수, 만점일 때만 isCorrect. per_question · partial_pattern만, 그 밖은 [] (옛 서버는 없음) */
44
+ questionResults?: { score: number; isCorrect: boolean }[];
43
45
  }
44
46
 
45
47
  export interface Submission extends SubmitResult {
@@ -50,16 +52,33 @@ export interface Submission extends SubmitResult {
50
52
  answer: unknown;
51
53
  }
52
54
 
53
- /** 채점 설정을 서버 모양으로 ({ type: pattern | partial_pattern | rubric }). camelCase answerKey도 받는다. 채점 방식이 아니면 null */
55
+ /** 채점 설정을 서버 모양으로 ({ type: pattern | partial_pattern | rubric | per_question }). camelCase answerKey도 받는다. 채점 방식이 아니면 null */
54
56
  export declare function normalizeGradingSettings(
55
57
  grading: unknown
56
58
  ):
57
59
  | { type: 'pattern'; answer_key?: string }
58
60
  | { type: 'partial_pattern'; answer_key: string[]; scores: number[] }
59
61
  | { type: 'rubric'; rubric?: string }
62
+ | {
63
+ type: 'per_question';
64
+ questions: {
65
+ score: number;
66
+ grader:
67
+ | { type: 'pattern'; answer_key: string }
68
+ | { type: 'rubric'; rubric: string; question?: string };
69
+ }[];
70
+ pass_score?: number;
71
+ }
60
72
  | null;
61
- /** 채점 설정이 있으면 로컬 채점, 없으면 제출만 받음 (점수 null). partial_pattern은 맞은 문항 점수의 합(최대 100) */
62
- export declare function gradeLocally(grading: unknown, answer: unknown): SubmitResult;
73
+ /** 채점 설정이 있으면 로컬 채점, 없으면 제출만 받음 (점수 null). partial_pattern은 맞은 문항 점수의 합(최대 100).
74
+ * per_question은 pattern 문항 + AI 채점 흉내 점수(floor(mockRubricScore × score / 100))의 합, mockRubric: true.
75
+ * per_question · partial_pattern은 문항별 결과 questionResults도 (제출 기록에만 남김) */
76
+ export declare function gradeLocally(
77
+ grading: unknown,
78
+ answer: unknown
79
+ ): SubmitResult & { mockRubric?: boolean; passed?: boolean };
80
+ /** per_question AI 채점 문항 흉내 점수 0~100: 빈 답 0, 아니면 min(100, floor(20 + 글자 수 / 5)) */
81
+ export declare function mockRubricScore(answer: unknown): number;
63
82
  /** 서버가 채점 전에 거절하는 답(422)이면 이유: partial_pattern에 문자열 배열이 아닌 답. 문제가 없으면 null */
64
83
  export declare function answerShapeError(grading: unknown, answer: unknown): string | null;
65
84
 
@@ -2,7 +2,8 @@
2
2
  * @eliceio/cdk 1.x(EliceCDK)와 같은 공개 인터페이스를 가진 mock · 템플릿이 제공 (고치지 마세요)
3
3
  *
4
4
  * 서버 없이 화면을 시험할 때 키트가 대신 씁니다. 실제 SDK와 다른 점:
5
- * - 채점: 편집 화면이 저장한 채점 설정(settings.grading { type: pattern | partial_pattern | rubric })이 있으면 로컬 채점, 없으면 제출만 받음.
5
+ * - 채점: 편집 화면이 저장한 채점 설정(settings.grading { type: pattern | partial_pattern | rubric | per_question })이 있으면 로컬 채점, 없으면 제출만 받음.
6
+ * per_question의 AI 채점 문항은 AI 대신 글 길이로 만든 흉내 점수 (mockRubricScore)
6
7
  * pattern 답은 정규식 하나, 답 문자열 전체 일치. partial_pattern은 문항별 정규식 · 점수, 답은 문자열 배열. 프로젝트 폴더를 그대로 열면 ecdk dev가 저장한 .ecdk/settings.json으로 시작
7
8
  * - 완료 정책: 흉내 내지 않는다 (LXP에 올린 뒤 자료 편집 화면의 '설정'에서 교육자가 고름, ADR 0012). material.completionPolicy는 null
8
9
  * - 저장: 설정 화면이 저장한 내용과 제출 기록을 브라우저에 남겨 다른 화면에서도 보임
@@ -214,9 +215,33 @@ export function normalizeGradingSettings(grading) {
214
215
  };
215
216
  if (grading.type === 'rubric')
216
217
  return { type: 'rubric', ...(typeof grading.rubric === 'string' ? { rubric: grading.rubric } : {}) };
218
+ // 문항별 채점 (정규식 · AI 채점 섞음, 서버 #65). 1.11.0 개발 중 제안 items는 서버가 받지 않아 채점 설정이 아닌 것으로 본다
219
+ if (grading.type === 'per_question')
220
+ return {
221
+ type: 'per_question',
222
+ questions: Array.isArray(grading.questions)
223
+ ? grading.questions.map(q =>
224
+ q && typeof q === 'object'
225
+ ? { ...q, ...(q.grader && typeof q.grader === 'object' ? { grader: { ...q.grader } } : {}) }
226
+ : q
227
+ )
228
+ : [],
229
+ ...(grading.pass_score === undefined ? {} : { pass_score: grading.pass_score }),
230
+ };
217
231
  return null;
218
232
  }
219
233
 
234
+ /**
235
+ * per_question AI 채점(rubric) 문항 흉내 점수 0~100 (AI를 부르지 않음, 같은 답이면 늘 같은 점수):
236
+ * 빈 답 0, 아니면 min(100, 20 + 글자 수 / 5)을 내림. ecdk dev 흉내 서버(src/dev/grading.ts mockRubricScore)와 같은 식
237
+ * @param {unknown} answer
238
+ */
239
+ export function mockRubricScore(answer) {
240
+ const text = typeof answer === 'string' ? answer.trim() : '';
241
+ if (!text) return 0;
242
+ return Math.min(100, Math.floor(20 + text.length / 5));
243
+ }
244
+
220
245
  /** 서버(Python re) 맨 앞 전체 플래그 (?i) · (?s) · (?m): JS는 받지 않아 떼고 같은 JS 플래그로 (키트 toJsRegex와 같음) */
221
246
  const LEADING_FLAGS = /^\(\?([ims]+)\)/;
222
247
 
@@ -239,10 +264,11 @@ function fullMatch(regex, text) {
239
264
  * @param {unknown} answer
240
265
  */
241
266
  export function answerShapeError(grading, answer) {
242
- if (normalizeGradingSettings(grading)?.type !== 'partial_pattern') return null;
243
- if (!Array.isArray(answer)) return 'partial_pattern: answer must be an array of strings';
267
+ const type = normalizeGradingSettings(grading)?.type;
268
+ if (type !== 'partial_pattern' && type !== 'per_question') return null;
269
+ if (!Array.isArray(answer)) return `${type}: answer must be an array of strings`;
244
270
  const bad = answer.findIndex(item => typeof item !== 'string');
245
- return bad < 0 ? null : `partial_pattern: answer[${bad}] must be a string`;
271
+ return bad < 0 ? null : `${type}: answer[${bad}] must be a string`;
246
272
  }
247
273
 
248
274
  /**
@@ -250,8 +276,12 @@ export function answerShapeError(grading, answer) {
250
276
  * 돌려준다. 완료 정책은 LXP 설정이라 보지 않는다 (ADR 0012): 채점 설정이 있으면 채점하고, 없으면 제출만 받는다.
251
277
  * - pattern: 정답 정규식(문자열 하나)이 답 문자열 전체와 맞으면 100, 아니면 0
252
278
  * - partial_pattern: answer[i]를 answer_key[i]에 맞춰 맞은 문항의 scores[i]를 더함 (최대 100, 100점만 정답).
253
- * 없는 문항은 0점, 남는 답은 무시. 문항별 맞음 answerCorrectness도 (submit · 제출 기록에는 그 밖의 방식이면 [])
279
+ * 없는 문항은 0점, 남는 답은 무시. 문항별 맞음 answerCorrectness와 문항별 결과 questionResults({ score, isCorrect })도
280
+ * (submit · 제출 기록에는 그 밖의 방식이면 [])
254
281
  * - rubric: 바로 80점으로 흉내, 통과로 봄 (통과 기준 pass_threshold는 정해지지 않음)
282
+ * - per_question (서버 #65): 문항마다 채점기 점수(pattern은 맞으면 100, rubric은 AI 대신 mockRubricScore 0~100, 빈 답 0)를
283
+ * floor(채점기 점수 × score / 100)으로 (서버처럼 내림). 합은 100에서 자르고 100점만 정답, pass_score(없으면 100) 이상이면 통과.
284
+ * 문항별 결과 questionResults [{ score, isCorrect }](isCorrect는 채점기 점수 100일 때만)와 그것으로 만든 answerCorrectness도
255
285
  * - 채점 설정 없음: 점수 없음 `{ isCorrect: null, score: null }`
256
286
  * 맨 앞 (?i)는 서버(Python re)처럼 대소문자 무시
257
287
  * @param {object | null} grading settings.grading
@@ -268,9 +298,35 @@ export function gradeLocally(grading, answer) {
268
298
  const answerCorrectness = g.answer_key.map((key, i) => typeof items[i] === 'string' && fullMatch(key, items[i]));
269
299
  const total = answerCorrectness.reduce((sum, ok, i) => sum + (ok ? (g.scores[i] ?? 0) : 0), 0);
270
300
  const score = Math.min(100, total);
271
- return { isCorrect: score === 100, score, answerCorrectness };
301
+ const questionResults = answerCorrectness.map((ok, i) => ({ score: ok ? (g.scores[i] ?? 0) : 0, isCorrect: ok }));
302
+ return { isCorrect: score === 100, score, answerCorrectness, questionResults };
272
303
  }
273
304
  if (g?.type === 'rubric') return { isCorrect: true, score: RUBRIC_MOCK_SCORE };
305
+ if (g?.type === 'per_question') {
306
+ const items = Array.isArray(answer) ? answer : [];
307
+ const graderScores = g.questions.map((q, i) => {
308
+ const piece = items[i];
309
+ if (q?.grader?.type === 'rubric') return mockRubricScore(piece);
310
+ return typeof piece === 'string' && fullMatch(q?.grader?.answer_key, piece) ? 100 : 0;
311
+ });
312
+ const questionResults = g.questions.map((q, i) => ({
313
+ // 서버처럼 정수로 내림 (99.5점이 반올림돼 '100점인데 미완료'로 보이지 않게)
314
+ score: Math.floor((graderScores[i] * (Number.isInteger(q?.score) ? q.score : 0)) / 100),
315
+ isCorrect: graderScores[i] === 100,
316
+ }));
317
+ const score = Math.min(100, questionResults.reduce((sum, r) => sum + r.score, 0));
318
+ const pass = Number.isInteger(g.pass_score) ? g.pass_score : 100;
319
+ const mockRubric = g.questions.some(q => q?.grader?.type === 'rubric');
320
+ // is_correct는 100점일 때만, 완료는 합계가 pass_score(없으면 100) 이상일 때
321
+ return {
322
+ isCorrect: score === 100,
323
+ passed: score >= pass,
324
+ score,
325
+ answerCorrectness: questionResults.map(r => r.isCorrect),
326
+ questionResults,
327
+ ...(mockRubric ? { mockRubric: true } : {}),
328
+ };
329
+ }
274
330
  return { isCorrect: null, score: null };
275
331
  }
276
332
 
@@ -639,11 +695,20 @@ export class MockEliceCDK {
639
695
  const shapeError = answerShapeError(this.#effectiveGrading(), answer);
640
696
  // 실제 SDK는 서버 422(VALIDATION_ERROR)를 RequestFailed로 던진다
641
697
  if (shapeError) throw new EliceCDKError(ErrorCode.RequestFailed, `${shapeError} (mock 422).`);
642
- // 서버처럼 문항별 맞음은 늘 준다: partial_pattern이 아니면 []
698
+ // 서버처럼 문항별 맞음은 늘 준다: partial_pattern · per_question이 아니면 []
643
699
  const graded = gradeLocally(this.#effectiveGrading(), answer);
644
- const res = { ...graded, answerCorrectness: graded.answerCorrectness ?? [] };
645
- if (this.#isDraft) this.#draftSubmissions.unshift(this.#submission(answer, res, 'preview'));
646
- else if (this.#viewer === 'student') this.#record(res, answer);
700
+ const { mockRubric, passed, ...rest } = graded;
701
+ if (mockRubric && typeof console !== 'undefined')
702
+ console.info('[cdk-mock] per_question의 AI 채점(rubric) 점수는 흉내 값입니다 (AI를 부르지 않음, 글 길이로 계산)');
703
+ // 문항별 결과(question_results)도 실제 SDK처럼 submit 결과와 제출 기록에 늘 준다: partial_pattern · per_question이 아니면 []
704
+ const res = {
705
+ ...rest,
706
+ answerCorrectness: rest.answerCorrectness ?? [],
707
+ questionResults: rest.questionResults ?? [],
708
+ };
709
+ const stored = { ...res, passed };
710
+ if (this.#isDraft) this.#draftSubmissions.unshift(this.#submission(answer, stored, 'preview'));
711
+ else if (this.#viewer === 'student') this.#record(stored, answer);
647
712
  return res;
648
713
  }
649
714
 
@@ -743,6 +808,7 @@ export class MockEliceCDK {
743
808
  isCorrect: res.isCorrect,
744
809
  score: res.score,
745
810
  answerCorrectness: res.answerCorrectness ?? [],
811
+ questionResults: res.questionResults ?? [],
746
812
  };
747
813
  }
748
814
 
@@ -755,7 +821,8 @@ export class MockEliceCDK {
755
821
  const score = res.score ?? prev?.score ?? null;
756
822
  // 기록의 완료 시각: 채점 설정이 있으면 통과(pattern 100점 · rubric 흉내 점수)해야, 없으면 제출만으로
757
823
  // (운영에서 완료 여부는 LXP '설정'의 완료 정책이 정한다)
758
- const completed = res.isCorrect === true || !this.#effectiveGrading();
824
+ // per_question은 통과 점수(pass_score) 이상이면 완료 (100점 미만이라 isCorrect가 false여도)
825
+ const completed = res.passed === true || res.isCorrect === true || !this.#effectiveGrading();
759
826
  this.#store.set('result', {
760
827
  score,
761
828
  submitCount: (prev?.submitCount ?? 0) + 1,