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

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 (120) hide show
  1. package/README.md +288 -200
  2. package/es/cli.js +70 -66
  3. package/es/commands/build/index.d.ts +1 -1
  4. package/es/commands/build/index.js +27 -15
  5. package/es/commands/create/index.d.ts +5 -1
  6. package/es/commands/create/index.js +34 -15
  7. package/es/commands/create/install.d.ts +17 -0
  8. package/es/commands/create/install.js +53 -0
  9. package/es/commands/create/scaffold.d.ts +4 -1
  10. package/es/commands/create/scaffold.js +19 -13
  11. package/es/commands/dev/index.d.ts +1 -1
  12. package/es/commands/dev/index.js +5 -5
  13. package/es/commands/doctor/index.d.ts +29 -2
  14. package/es/commands/doctor/index.js +253 -55
  15. package/es/commands/mcp/index.d.ts +0 -12
  16. package/es/commands/mcp/index.js +6 -57
  17. package/es/commands/setup/index.d.ts +11 -3
  18. package/es/commands/setup/index.js +112 -37
  19. package/es/commands/skill/index.d.ts +46 -8
  20. package/es/commands/skill/index.js +151 -35
  21. package/es/commands/uninstall/index.d.ts +54 -0
  22. package/es/commands/uninstall/index.js +304 -0
  23. package/es/commands/update/index.d.ts +59 -0
  24. package/es/commands/update/index.js +251 -0
  25. package/es/commands/validate/index.d.ts +18 -0
  26. package/es/commands/{check → validate}/index.js +16 -10
  27. package/es/core/collect.d.ts +5 -2
  28. package/es/core/config.d.ts +99 -50
  29. package/es/core/config.js +244 -91
  30. package/es/core/latest.d.ts +21 -0
  31. package/es/core/latest.js +43 -0
  32. package/es/core/manifest.d.ts +2 -1
  33. package/es/core/manifest.js +2 -1
  34. package/es/core/minify.js +2 -2
  35. package/es/core/prepare.d.ts +18 -2
  36. package/es/core/prepare.js +48 -16
  37. package/es/core/project-check.d.ts +19 -8
  38. package/es/core/project-check.js +36 -9
  39. package/es/core/sandbox.js +2 -2
  40. package/es/core/sdk.d.ts +39 -0
  41. package/es/core/sdk.js +95 -0
  42. package/es/core/templates.d.ts +2 -4
  43. package/es/core/templates.js +2 -5
  44. package/es/dev/grading.d.ts +7 -8
  45. package/es/dev/grading.js +6 -16
  46. package/es/dev/host-page.d.ts +1 -1
  47. package/es/dev/host-page.js +12 -10
  48. package/es/dev/mock-api.d.ts +13 -18
  49. package/es/dev/mock-api.js +56 -66
  50. package/es/dev/server.js +52 -52
  51. package/es/rules/check.js +43 -31
  52. package/es/rules/index.d.ts +1 -1
  53. package/es/rules/index.js +1 -1
  54. package/es/rules/manifest.d.ts +28 -20
  55. package/es/rules/manifest.js +58 -55
  56. package/es/rules/types.d.ts +18 -20
  57. package/es/rules.json.js +2 -2
  58. package/es/test-packages.d.ts +7 -0
  59. package/package.json +3 -4
  60. package/rules.json +27 -43
  61. package/skills/_shared/always.md +4 -4
  62. package/skills/elice-content-check/SKILL.md +11 -8
  63. package/skills/elice-content-create/SKILL.md +8 -7
  64. package/skills/elice-content-guide/SKILL.md +42 -0
  65. package/skills/elice-content-guide/topics/00-what-the-person-decides.md +11 -0
  66. package/skills/elice-content-guide/topics/01-check-the-environment.md +10 -0
  67. package/skills/elice-content-guide/topics/02-design-the-material.md +35 -0
  68. package/skills/elice-content-guide/topics/03-create-the-project.md +22 -0
  69. package/skills/elice-content-guide/topics/04-rules.md +12 -0
  70. package/skills/elice-content-guide/topics/05-screen-code.md +101 -0
  71. package/skills/elice-content-guide/topics/06-using-the-quiz-template.md +22 -0
  72. package/skills/elice-content-guide/topics/07-move-existing-html.md +10 -0
  73. package/skills/elice-content-guide/topics/08-fix-check-errors.md +24 -0
  74. package/skills/elice-content-guide/topics/09-check.md +10 -0
  75. package/skills/elice-content-guide/topics/10-build.md +8 -0
  76. package/skills/elice-content-guide/topics/11-more.md +4 -0
  77. package/skills/elice-content-guide/topics/12-upload-with-the-material-mcp.md +41 -0
  78. package/skills/elice-content-migrate/SKILL.md +8 -7
  79. package/skills/elice-content-publish/SKILL.md +8 -7
  80. package/templates/_shared/lib/cdk-mock.d.ts +5 -13
  81. package/templates/_shared/lib/cdk-mock.js +49 -144
  82. package/templates/_shared/lib/elice-content.css +68 -1
  83. package/templates/_shared/lib/elice-content.d.ts +11 -38
  84. package/templates/_shared/lib/elice-content.js +43 -248
  85. package/templates/blank/README.md +12 -10
  86. package/templates/blank/metadata.json +9 -0
  87. package/templates/blank/package.json +13 -0
  88. package/templates/blank/screens/edit.js +1 -1
  89. package/templates/blank/screens/instructor.js +12 -5
  90. package/templates/blank/screens/learn.js +16 -11
  91. package/templates/blank/template.json +2 -2
  92. package/templates/quiz/README.md +15 -12
  93. package/templates/quiz/core/behaviors.js +4 -1
  94. package/templates/quiz/core/editor.d.ts +21 -10
  95. package/templates/quiz/core/editor.js +44 -31
  96. package/templates/quiz/core/model.d.ts +14 -0
  97. package/templates/quiz/core/model.js +76 -4
  98. package/templates/quiz/metadata.json +9 -0
  99. package/templates/quiz/package.json +13 -0
  100. package/templates/quiz/screens/edit.js +101 -34
  101. package/templates/quiz/screens/instructor.js +18 -12
  102. package/templates/quiz/screens/learn.js +45 -36
  103. package/templates/quiz/styles.css +65 -22
  104. package/templates/quiz/template.json +2 -2
  105. package/templates/quiz/ui/templates/edit.d.ts +1 -0
  106. package/templates/quiz/ui/templates/edit.js +65 -19
  107. package/templates/quiz/ui/templates/group.js +10 -2
  108. package/templates/quiz/ui/texts.js +11 -11
  109. package/es/commands/check/index.d.ts +0 -15
  110. package/es/commands/guide/index.d.ts +0 -29
  111. package/es/commands/guide/index.js +0 -120
  112. package/guides/content-development.md +0 -294
  113. package/templates/_shared/lib/cdk.js +0 -3
  114. package/templates/blank/completion.html +0 -15
  115. package/templates/blank/content.json +0 -4
  116. package/templates/blank/elice.config.json +0 -10
  117. package/templates/blank/screens/completion.js +0 -7
  118. package/templates/quiz/content.json +0 -35
  119. package/templates/quiz/elice.config.json +0 -9
  120. package/templates/quiz/grading.json +0 -4
@@ -1,294 +0,0 @@
1
- # Developing Elice Custom HTML learning materials
2
-
3
- A Custom HTML learning material is **a small web app in one zip**. Anything that runs in a browser can be a learning material: an explanation, an interactive simulation or visualization, a guided exercise, a game-like activity, flashcards, a self-check or survey, a quiz, or the description of a practice problem.
4
-
5
- Build it with the `ecdk` CLI (`@eliceio/cdk-cli`). Read one topic of this guide with `ecdk guide <topic>` (`ecdk guide` lists the topics). For a command's options, run `ecdk <command> --help`.
6
-
7
- One zip has up to four screens.
8
-
9
- | Screen | Files | What it does |
10
- | ---------------------------- | ------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
11
- | Student (required) | `index.html` + `screens/learn.js` | The learning activity (read, interact, solve, make). Submits a result when needed |
12
- | Instructor (optional) | `instructor.html` + `screens/instructor.js` | What only instructors see: activity summary, explanations, teaching tips |
13
- | Content edit (optional) | `edit.html` + `screens/edit.js` | Instructors edit text and data without code and save it → `app.content` of the other screens. Also sets the grader and the answers or rubric, saved to `settings.grading` (never sent to students) |
14
- | Completion policy (optional) | `completion.html` + `screens/completion.js` | The instructor picks when the material counts as done, among `completionPolicies` (`screens.completionPolicy`). Off when the material lists one policy |
15
-
16
- Elice opens the content in a **sandboxed (`allow-scripts`) iframe on another origin**. There is no server: everything runs as browser JS, and only submission, saving and grading go to the Elice server.
17
-
18
- ## 0. What the person decides
19
-
20
- The person (the instructor or author) is responsible for the content and its answers. Do not settle the following on your own; ask, or get a confirmation.
21
-
22
- 1. **The learning goal, when it is unclear.** Decide the rest of the design to fit the goal and tell the person briefly what you decided.
23
- 2. **Correct answers.** You may draft answers and rubrics, but the person confirms that they are right.
24
- 3. **How it completes and how it is graded**: which completion policies the material supports (`completionPolicies`, the first one is the default) and the grader. One policy fixes it; more than one lets the instructor pick on a completion policy screen. Propose what fits the material and get a confirmation.
25
- 4. **What the learning notes say** (`commentary.txt`). A material needs them (LXP rejects the upload without them); once they are filled in, AI Helpy answers only questions about this material, so let the person check the wording.
26
- 5. **Checking the screens.** The person looks at the student, tutoring, instructor, edit and mobile views in the preview. When they cannot, tell them what to check and in which order.
27
- 6. **Uploading to LXP.** A saved version is **visible to learners at once** (when the page is open). Before uploading, show what changes and get approval. The same goes for changing a material that is already open, changing answers, and restoring an older version.
28
- 7. **Global installs, accounts and permissions.** Leave them to the person.
29
-
30
- ## 1. Check the environment
31
-
32
- ```bash
33
- ecdk --version && ecdk doctor --json
34
- ```
35
-
36
- - Without `ecdk`: it needs Node.js 20.19 or later (22 LTS recommended) and `@eliceio/cdk-cli`. Tell the user how to install it, and run **a global install (`npm install -g @eliceio/cdk-cli`) only after the user agrees**. Without agreement, run `npx @eliceio/cdk-cli <command>`.
37
- - `doctor` item `mcp.material` warns when the Elice material server MCP is not registered. It is used later to upload to LXP (the publish skill is not available yet), so it is not needed to make a material. To register it, ask the user first, then run `ecdk setup` (installs the skills and registers the MCP in one go; production by default, `--env qa5` for the QA server; `ecdk mcp setup` registers the MCP only) and tell the user the login step it prints.
38
- - Fix each `fail` item in `doctor` as its `fix.description` says. `--fix` fixes only the items that can be fixed automatically.
39
-
40
- ## 2. Design the material
41
-
42
- Decide the following before writing code. Decide what the request leaves out to fit the material's purpose, and tell the user briefly what you decided. Ask only when the learning goal is unclear.
43
-
44
- **① What the student does**
45
- Read or watch / change values and observe (simulation, visualization) / follow steps / solve problems / make something. Tie the activity directly to the learning goal.
46
-
47
- **② Completion policy and grading** (2026-11-11: the material lists the completion policies it supports in `completionPolicies` and the server sets the first one; the grading settings `settings.grading` hold the grader `type` and its answers)
48
-
49
- | Material | Completion policy | Grading (`type`) | Student screen |
50
- | ----------------------------------------------------------- | --------------------------------- | ----------------------- | ----------------------------------------- |
51
- | Something to read or watch, such as a simulation | `on_access` (done on open) | - | No submission |
52
- | Done when the activity ends (results, self-check, survey) | `on_submit` (100 on submit) | - | Submit the result with `useSubmit` |
53
- | One correct answer or one set of answers | `on_graded` (done when it passes) | `pattern` (one regex) | `useSubmit` |
54
- | Writing or assignments graded against a rubric (AI grading) | `on_graded` | `rubric` (the criteria) | `useSubmit`, the score comes back at once |
55
-
56
- - **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.
57
- - **`completionPolicies` is required** in `elice.config.json` (copied into `metadata.json`; a material without it, or with an empty list, fails `manifest.completion-policies-missing`): for example `"completionPolicies": ["on_submit"]`. The server sets the **first** value as the material's policy on upload. Put `on_graded` in it only when the edit screen saves the grading. The grader is not listed here: it is `settings.grading.type` (`pattern` · `rubric`), set on the edit screen.
58
- - **One policy fixes it** (`["on_graded"]` in the quiz template; no completion policy screen). **More than one** lets the instructor pick among them on the **completion policy screen** (`screens.completionPolicy`, `app.useCompletion()`, which shows only the listed policies). That screen saves through `app.completion.set()` → SDK `saveCompletionPolicy` (`PATCH` `completion_policy`); it never touches `settings`, and the edit screen never sends a policy. The server rejects `on_graded` without `settings.grading` (`MATERIAL_GRADING_REQUIRED`). More than one policy without the screen warns `completion.no-screen`; one policy with the screen warns `completion.screen-unused`. The blank template lists `["on_submit", "on_access"]` with the screen.
59
- - Custom HTML does not use manual grading (`manual`) or no grading (`none`). There is no per-question grading: every question must be right for 100. Changing the answers does not regrade past submissions.
60
- - Answers never go in the zip (`metadata.json` · `content.json` · code). The old `gradingTypes` field is gone (2026-11-10): `ecdk build` warns when it is still in `elice.config.json`. A `grading.json` with the 11-10 policy and grader fields is rejected with how to rewrite it.
61
-
62
- **②-1 Learning notes**: write the key concepts, the activity, and the intent of the questions in `commentary.txt` (plain text) at the top of the project. `build` puts it in the zip and writes `"commentary": "commentary.txt"` in `metadata.json`; LXP's AI Helpy and AI quiz generation read it. It is inside the zip, so students can read it: **never put answers in it.** A material needs it: LXP rejects an upload without learning notes, and `ecdk check` reports `manifest.commentary-missing` (a problem description, `kind: description`, does not need it). Once it is filled in, AI Helpy answers only questions about this material.
63
-
64
- **③ Does it need an instructor screen?** Make one when there are explanations, a summary of the answer conditions, or teaching tips. Turn it off when it would equal the student screen.
65
-
66
- **④ Does it need a content edit screen?** When instructors may want to rewrite text, numbers or lists (for example a simulation's initial values, a card list, step descriptions), collect them in `content.json` and let the edit screen change them. Turn it off when there is nothing to edit.
67
-
68
- **⑤ Purpose**: the material itself (`kind: material`, the default), or the **problem description** of another material such as a practice (`kind: description`: student screen only, no grading).
69
-
70
- **Steps inside one material (paging)**: LXP already draws a bar **under every material** with `< 이전 · 3/6 · 다음 >` that moves between **lecture pages** of the course. Inside the material, never draw a bottom bar with 이전 · 다음 (or "◀ 이전 · 2 / 6 · 다음 ▶") that looks like it: the student cannot tell which one moves the step and which one leaves the material. For a material with several steps (slides, STEP 1~5), use the kit's `app.usePaging` (see 5):
71
-
72
- - Between steps: **round chevron buttons on the left and right edges** of the content, vertically centered, and a small **`n / N` indicator inside the content**.
73
- - On the **first step the left button, on the last step the right button go to the previous / next lecture page** in LXP (SDK `app.navigation.previous()` · `next()`). They look different on purpose (a labeled pill "‹ 이전 자료" · "다음 자료 ›" instead of a bare chevron), so the student knows they are leaving this material. When there is no lecture page on that side, or the material is not in LXP (editor preview, local), they are hidden.
74
- - If the last step has its own action (submit, "결과 보기"), keep it in the content; the right pill still leads on to the next material.
75
- - On a phone (narrower than 512px) the kit puts the buttons under the content instead of over its edges.
76
-
77
- ## 3. Create the project
78
-
79
- Run `ecdk create --list` first: it prints each template with its own version (`quiz@1.0.0`), what it is for, its screens and its completion policy. Pick the template from that list. `ecdk create` records the template and version in `elice.config.json` (`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).
80
-
81
- | Case | Start with |
82
- | --------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
83
- | A multi-question quiz | `ecdk create <folder>` (quiz template: starts with one single-choice question; the edit screen adds any of the five question types; answers set on the edit screen; `"completionPolicies": ["on_graded"]` + `pattern`) |
84
- | Any other material | `ecdk create <folder> --template blank` (skeleton of the three screens) |
85
- | A dark screen | Add `--theme dark` to the above |
86
- | A problem description | Create with blank, set `elice.config.json` to `{ "kind": "description", "screens": { "learn": "index.html" } }`, delete the instructor and edit files |
87
- | An existing HTML page | [7. Move existing HTML](#7-move-existing-html) |
88
-
89
- `create` refuses a folder that is not empty. Use a new subfolder.
90
-
91
- Then:
92
-
93
- 1. Set `screens` in `elice.config.json` to the design (only the screens you keep: `{ "learn": "index.html", "edit": "edit.html", "completionPolicy": "completion.html" }`). Set `completionPolicies` too. Local grading reads `grading.json` (`{ "type": "pattern", "answer_key": "^…$" }`) and the local completion policy `.ecdk/completion.json`; saving in the content edit and completion policy views of `ecdk dev` writes them for you.
94
- 2. Shape `content.json` as the data in ④.
95
- 3. Write the screen code ([5](#5-screen-code)). Delete the HTML and JS of screens you do not use.
96
- 4. Check ([9](#9-check)) → build ([10](#10-build)).
97
-
98
- ## 4. Rules
99
-
100
- 1. **Never put correct answers in the content**: not in `content.json`, the screen code, or comments. They reach the student's browser. Answers go in `settings.grading` through the edit screen (the server never sends it to students), and in `grading.json` only for local checks (it is left out of the zip).
101
- 2. **Screen code calls only `lib/elice-content.js` (the kit).** Do not edit `lib/`. Do not call the SDK (`lib/cdk.js`) directly.
102
- 3. **Do not use blocked features**: `localStorage` · `sessionStorage` · `indexedDB` · `document.cookie` · `alert`/`confirm`/`prompt` · `window.open` · `<form>` submission · access to `window.parent`/`top` · `fetch`/`WebSocket` to external addresses · external `<script src>`. To keep progress, submit it (`useSubmit`); to keep content, save it from the edit screen.
103
- 4. **Libraries and media go inside the zip.** Download libraries for charts, visualization or physics (for example Chart.js, D3, p5.js) into `vendor/` and load them by relative path instead of a CDN. Fonts, images and sounds also go in the zip. Limits: zip 20 MB, 300 files. Upload long videos separately as Elice video materials.
104
- 5. **Use relative paths** (`img/a.png`). Paths starting with `/` break. Match file name case. Prefer letters, digits, `-` and `_`.
105
- 6. **Switch views inside one HTML.** Show and hide steps or pages within the same HTML. Moving to another HTML or reloading loses the access token and shows "please reopen the material".
106
- 7. **Never insert user input as HTML**: use `textContent`. When `innerHTML` is really needed, escape it and leave `// ecdk-ignore-next-line sec.html-injection` with the reason.
107
- 8. **Colors and fonts use EDS tokens** (`var(--eds-primary-main)`, `var(--eds-text-primary)`, `var(--eds-background-paper)` …). When drawing on canvas or SVG, read them with `getComputedStyle(document.documentElement).getPropertyValue('--eds-primary-main')`. Do not write colors directly (the dark theme will not match).
108
- 9. **Mobile and accessibility**: touch targets 44 px or more, input text 16 px, no breakage at 360 px width. Work with touch (Pointer Events) and keyboard, not only a mouse. Give images `alt`.
109
- 10. Never include keys, tokens or passwords (comments are checked too).
110
-
111
- ## 5. Screen code
112
-
113
- ```js
114
- import { start } from '../lib/elice-content.js';
115
-
116
- // Student screen
117
- const app = await start({ screen: 'learn' });
118
- render(app.content); // what the edit screen saved, or content.json
119
-
120
- // Only for materials with a submission: say how to collect and restore the answer (result).
121
- // Locking, restoring and result messages are handled by the kit.
122
- app.useSubmit({
123
- getAnswer: () => ({ result: currentResult() }), // small JSON (a few KB at most)
124
- setAnswer: a => restore(a?.result), // filled on reopen and in tutoring
125
- validate: a => a.result != null || 'Finish the activity before submitting.',
126
- onResult: res => showFeedback(res), // grading result (score · isCorrect)
127
- });
128
- ```
129
-
130
- ```js
131
- // Content edit screen: render the fields and say what to save
132
- const app = await start({ screen: 'edit' });
133
- renderForm(app.content);
134
- app.useSave({
135
- getContent: () => ({ ...app.content, title: titleInput.value, steps: readSteps() }),
136
- validate: c => c.title.trim() !== '' || 'Enter a title.',
137
- });
138
- ```
139
-
140
- ```js
141
- // Edit screen with the grader block: the kit draws LXP's grader radios, the "기준 답안 (정규표현식)" field
142
- // with "작성 예시 보기", and the "평가 기준" field. useSave saves the content and the grader in one save.
143
- const grading = app.useGradingBlock();
144
- app.useSave({ getContent: () => app.content, getGrading: () => grading.getGrading() });
145
- ```
146
-
147
- ```js
148
- // Completion policy screen (screens.completionPolicy): radios for the policies in completionPolicies and the save button.
149
- // It saves through app.completion.set() → SDK saveCompletionPolicy (PATCH completion_policy), not settings.
150
- const app = await start({ screen: 'completionPolicy' });
151
- app.useCompletion();
152
- ```
153
-
154
- - `getGrading` returns the grading settings (`{ type: 'pattern', answer_key }` or `{ type: 'rubric', rubric }`) or an error message that blocks saving. `app.grading` is the saved grading (only on the edit and completion policy screens). `app.completion.get()` · `set(policy)` read and change the completion policy (`set` only on the completion policy screen and only within `completionPolicies`).
155
- - With `on_graded` in `completionPolicies`, the edit screen must save the grading (`completion.no-grading` warns when its code never uses `useGradingBlock` · `getGrading` · `grading:`).
156
- - Saving on the edit screen (`useSave`) **saves to the material at once** (SDK `saveSettings`, with the edit token LXP opens the edit screen with): a new version, shown on the student and instructor screens right away. The kit shows the result and the failure messages (the upload is not saved yet, someone saved in between, session expired), so the screen code does not announce "saved" itself.
157
- - Materials without a submission (`on_access`) do not call `useSubmit`.
158
- - Use `app.mode` (`learn` · `preview` · `tutor` · `instructor` · `edit`), `app.readOnly` (tutoring) and `app.account.anonymousId` (for example a per-person fixed random seed) only when needed. The kit handles per-mode behavior such as the tutoring lock, so the screen code does not branch on the mode.
159
- - Steps inside one material (see "Steps inside one material" in 2): let the kit draw the side buttons and the `n / N` indicator. Never draw an LXP-like bottom 이전 · 다음 bar.
160
-
161
- ```js
162
- app.usePaging({
163
- count: steps.length,
164
- // also called once at start. Draw only into `content` (#app by default); the kit keeps its buttons outside it
165
- onChange: (i, { content }) => content.replaceChildren(renderStep(steps[i])),
166
- });
167
- ```
168
-
169
- The kit wraps the content area (`root`, default `#app`) in its own frame and puts the side buttons and `n / N` in the frame, so redrawing `#app` (`replaceChildren`, `innerHTML`) does not remove them. Toggling `hidden` on prepared step elements works too. `usePaging({ count, onChange, start, root })` returns `{ element, content, go(i), step, ready }`. Use `go(i)` to jump (for example "다시 배분하기" back to step 3). Gating a step (for example "submit before moving on") is the screen's job: show a message in the step, the kit does not lock the arrows.
170
-
171
- - Run simulations and animations with `requestAnimationFrame` and stop them while the view is hidden. Split heavy computation into small pieces.
172
-
173
- ## 6. Using the quiz template
174
-
175
- - The template starts with **one single-choice question** (`content.json`) and its answer in `grading.json` (`^q1=b$`). Replace it with the requested questions; any of the five types can be added from the edit screen ("문항 추가"). Write the questions into `content.json` and set the answers on the edit screen or in `grading.json` with the same regex rules.
176
- - Question types: `select_one` · `select_multiple` · `order` · `text` · `group`. Question, choice and group ids (`q1`, `a`, `g1`) are lower-case letters and digits; once set, do not change them.
177
- - Student answer: **one string**, `id=answer` per question joined by `;` in question order: `q1=b;q2=a,d;q3=c,a,b;q4=weight;q5=g1:a|g2:b,c`. Multiple choice lists choice ids **sorted**, order lists them in slot order, group lists `group:choices(sorted)` in group order joined by `|`, and a text answer is trimmed and `encodeURIComponent`-encoded.
178
- - Answers: the instructor picks the answer in each question card of the edit screen (text questions take one allowed answer per line). Saving builds one regex and checks it, and blocks the save with the question number when an answer is missing, points at a deleted choice, or the regex does not match the answers back or still matches a changed answer (`grading.json` holds the same for local checks). The quiz lists only `on_graded` (`"completionPolicies": ["on_graded"]`) and grades with `pattern`, so it has no completion policy screen and no hand-written regex. `pattern` compares the whole answer at once, so **everything must match for 100** (no partial score per question).
179
-
180
- ```json
181
- {
182
- "type": "pattern",
183
- "answer_key": "^q1=b;q2=a,d;q3=c,a,b;q4=(?:weight|%EA%B0%80%EC%A4%91%EC%B9%98);q5=g1:a\\|g2:b,c$"
184
- }
185
- ```
186
-
187
- - 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).
188
- - Colors, spacing, corners, choice cards: the `--qz-*` variables in `ui/theme.css` (they point at EDS tokens, so `--theme dark` also fits)
189
- - Text: `ui/texts.js` (tab title, loading, student, instructor, edit, and validation messages)
190
- - Markup: the `` html`…` `` snippets in `ui/templates/*.js` (`choice` card, `question` frame, `order`, `group`, `text`, `page` header, `edit` fields). Inserted values are escaped. Classes and tags are free; **keep the `data-role` attributes** (`result` · `explanation` · `choice` · `input` · `pool` · `slots` · `items` and so on, listed at the top of each file) and selecting, dragging and the answer strings keep working.
191
- - Behavior adds state as attributes: `data-result="correct|wrong"` · `data-dragging` · `data-ghost`. Style them in CSS.
192
- - After a change, solve all five types in `ecdk dev` by clicking and dragging, submit, and check that the answer string (local grading) is unchanged.
193
-
194
- To mix a visualization or simulation into a quiz, edit the quiz template, or write the question data in the same shape on top of blank.
195
-
196
- ## 7. Move existing HTML
197
-
198
- 1. Create a skeleton with `ecdk create <new folder> --template blank`.
199
- 2. Move the original body, styles and scripts to the student screen (`index.html` · `screens/learn.js` · `styles.css`). Copy image, font and library folders as they are and use relative paths.
200
- 3. Download external CDN scripts and fonts into the zip.
201
- 4. Replace blocked code (storage, `alert`, external sends) as in [4](#4-rules).
202
- 5. Merge multiple HTML pages into one HTML that switches views.
203
- 6. Decide completion and grading as in [2 ②](#2-design-the-material). Without grading, pick `on_access` or `on_submit` and write it in `elice.config.json` (`"completionPolicies": ["on_access"]` when there is no submission).
204
- 7. Remove the instructor, edit and completion policy screens from `screens` and delete their files when they are not needed.
205
-
206
- ## 8. Fix check errors
207
-
208
- Read `check.issues[]` (`id` · `level` · `path` · `line` · `message`) from `ecdk build --json`. With an `error` no zip is made. Each `message` says how to fix it.
209
-
210
- | id | Fix |
211
- | ---------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
212
- | `ref.missing` · `ref.case-mismatch` | Match the path and case to the real file |
213
- | `ref.root-absolute` | Change `/…` to a relative path |
214
- | `ref.external-script` · `ref.external-request` | Put the library or font in the zip and use a relative path |
215
- | `api.storage` · `api.cookie` | Do not use storage. Submit results; save content from the edit screen |
216
- | `api.dialog` · `api.window-open` · `html.form` | An in-page message · the same view · a button click + `useSubmit` |
217
- | `api.external-send` | Remove the external send |
218
- | `sec.html-injection` | Use `textContent`. If justified: escape + `ecdk-ignore` + the reason |
219
- | `sec.secret` · `file.secret` | Remove the secret or the answer file (if it was already uploaded, tell the user to **revoke the key**) |
220
- | `manifest.completion-policies-missing` (error) | Add `"completionPolicies": ["on_submit"]` (or the policies you chose, default first) to `elice.config.json` |
221
- | `completion.no-screen` (warn) | Turn on the completion policy screen (`screens.completionPolicy`), or keep only one policy |
222
- | `completion.screen-unused` (warn) | One policy is fixed: remove the completion policy screen, or list more policies |
223
- | `completion.no-edit` (error) | `on_graded` needs an edit screen to set the answers: turn on `screens.edit`, or pick `on_submit` · `on_access` |
224
- | `completion.no-grading` (warn) | Add `app.useGradingBlock()` to the edit screen and pass `getGrading` to `useSave` |
225
- | `grading.missing` (warn, project only) | Save the answers in the `ecdk dev` content edit view (writes `grading.json`) |
226
- | `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 `elice.config.json` |
227
- | `manifest.*` · `entry.*` | Check `screens` and `kind` in `elice.config.json` |
228
- | `limit.*` · `file.large-image` | Shrink images and video, drop unused files (build output: "files not referenced anywhere") |
229
-
230
- 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.
231
-
232
- ## 9. Check
233
-
234
- ```bash
235
- ecdk dev # http://localhost:4170: student, tutoring, instructor, content edit, completion policy (when on); desktop and mobile widths
236
- ```
237
-
238
- - With a browser tool, open it and finish the student activity (with the score and result when it submits), then check the tutoring lock, saving on the edit screen → the change on the student screen, saving answers on the edit view → grading of the student view, changing the policy in the completion policy view (when on), the mobile width, and the dark theme. Without one, ask the user to check in this order.
239
- - Even after your own check, the person looks at the screens before uploading (see [0. What the person decides](#0-what-the-person-decides)).
240
- - Fix the content console errors and 404s printed in the terminal.
241
- - Opening files directly with `file://` is not a check.
242
-
243
- ## 10. Build
244
-
245
- ```bash
246
- ecdk build --json
247
- ```
248
-
249
- - With `ok: true` the zip is `dist/content.zip`. To make it smaller, set `"minify": true` in `elice.config.json` (quiz template about 122 KB → 87 KB).
250
- - Report to the user: what the material is (what the student does, which screens are on, how it completes), the zip path and size, **how it completes and what to pick in the settings tab** (the completion policy and the grading type, and where the answers are set), the upload steps (Custom HTML material in LXP → upload the zip → settings tab → save → check the student and instructor screens), and anything left to check. Saving makes the new version visible to learners at once, so the person approves it first (see [0. What the person decides](#0-what-the-person-decides)).
251
-
252
- ## 11. More
253
-
254
- - CLI usage: the `@eliceio/cdk-cli` README
255
- - Command help: `ecdk <command> --help`
256
-
257
- ## 12. Upload with the material MCP
258
-
259
- The `elice-material` MCP server (elice-material backend) uploads a built zip to a LXP Custom page and saves it as a new version. Register it with `ecdk setup` (QA: `ecdk mcp setup --env qa5`) and log in once per tool (Claude Code `/mcp` → elice-material → Authenticate, Helpy Code `⌘ ;`). Every page tool takes `org` (the organization's `name_short`, the subdomain of `https://{org}.elice.io`) and `lecture_page_id`.
260
-
261
- **Order**
262
-
263
- | Step | Tool or command | Notes |
264
- | ------------------- | ------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
265
- | Build | `ecdk build --json` | `ok: true` required. Use `zip` and `zipBytes` |
266
- | Find the page | `list_my_organizations` → `list_courses` → `list_lectures` → `list_custom_pages` | Or read `.ecdk/link.json` (written after a save, see below), or parse the LXP edit URL `https://{org}.…/courses/{c}/lectures/{l}/lecturepages/{id}/edit`. Only lectures with `can_hold_pages: true` hold pages |
267
- | New page (optional) | `create_custom_page` (`org`, `lecture_id`) | Ask first. The page is closed to learners and has no title until its first save. Fails where the elice-api change is not deployed: then use an existing Custom page |
268
- | Current version | `get_material` | Keep `current_version.id` (null for a page never saved) |
269
- | Upload URL | `create_package_upload` (`size_bytes`) | At most 20 MB. Returns `key` and `curl_command` |
270
- | Upload | the `curl_command`, `package.zip` replaced by the zip path | From a desktop app, run it through a login shell (see Always) |
271
- | Draft | `submit_package` (`key`) → `get_draft` every 2–3 s | `ready`: shows `preview_urls`, `warnings`, the package metadata. `failed`: report `failure` with `ecdk check dist/content.zip` and stop |
272
- | Approve | — | Show page, title, completion policy, answers saved or not, `preview_urls`. Saving is visible to learners at once when the page is open |
273
- | Save | `save_draft` (`material_draft_id`, `expected_current_version_id`, `completion_policy`, `grading`) | See below. `MATERIAL_CHANGED`: someone saved after your `get_material`; do not retry blindly, tell the person |
274
- | Title, icon | `update_material` (`expected_current_version_id`, `payload`) | Only keys to change, e.g. `{ "title": "…", "icon": "quiz" }`. Read the new version id with `get_material` first |
275
-
276
- After a successful save, write `.ecdk/link.json` in the project (it is not put in the zip; add `.ecdk/` to `.gitignore`):
277
-
278
- ```json
279
- { "org": "trial-cdk-qa5", "lecture_page_id": 129, "version_id": "…" }
280
- ```
281
-
282
- Next time, read it, confirm the page with the person, and compare `version_id` with `get_material`'s `current_version.id`: if they differ, someone saved in LXP since — tell the person before uploading.
283
-
284
- **Completion policy and answers**
285
-
286
- - `completion_policy`: `on_access` (complete on open), `on_submit` (complete on any submission) or `on_graded` (complete when the grading passes). Pass the first value of `completionPolicies` on the first `save_draft` (the server will also read it from `metadata.json`, G132; until then a first version without it gets `on_access`), and later versions keep the current policy unless you pass one. Pass it on `save_draft`, not afterwards, so learners never complete the page under the wrong policy. `on_graded` needs `grading`.
287
- - `on_graded` needs `grading`: `{ "type": "pattern", "answer_key": "^…$" }` or `{ "type": "rubric", "rubric": "…" }`. Take it from `grading.json` only after the person confirms the answers. The server merges it into `settings.grading` and does not send it to learners. Answers never go into the zip.
288
- - The quiz template is `on_graded` with a pattern; other materials follow the design (②).
289
-
290
- **Icon**: one of `note`, `video`, `pdf`, `exercise`, `quiz`, `notebook`, `live`, `assignment`, `external`, `survey`, or `null` (free-form, the default). Use `quiz` for the quiz template, otherwise `null` unless the person picks one. Title and icon also update the lecture page list.
291
-
292
- **Errors**: a login prompt → ask the person to log in again (`/mcp`). A permission error → the account needs HeadTA or higher in that course. `MATERIAL_GRADING_REQUIRED` → `on_graded` without `grading`. `PACKAGE_TOO_LARGE` → over 20 MB.
293
-
294
- **After saving**: report the LXP URL of the page and that a new page stays closed until the person opens it in LXP. If the LXP edit tab of the page is open, it must be refreshed before editing there, or it overwrites this save.
@@ -1,3 +0,0 @@
1
- /* @eliceio/cdk 1.0.0-alpha.3 — UMD. Copied at build time by scripts/copy-cdk.mjs; do not edit. */
2
- // ecdk-ignore-next-line api.parent-access sec.postmessage-wildcard
3
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).elice=e.elice||{})}(this,function(e){"use strict";function t(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)}function n(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n}"function"==typeof SuppressedError&&SuppressedError;var i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},r={exports:{}};!function(e){!function(t){var n=function(e,t,i){if(!c(t)||l(t)||d(t)||h(t)||a(t))return t;var r,s=0,o=0;if(u(t))for(r=[],o=t.length;s<o;s++)r.push(n(e,t[s],i));else for(var f in r={},t)Object.prototype.hasOwnProperty.call(t,f)&&(r[e(f,i)]=n(e,t[f],i));return r},i=function(e){return f(e)?e:(e=e.replace(/[\-_\s]+(.)?/g,function(e,t){return t?t.toUpperCase():""})).substr(0,1).toLowerCase()+e.substr(1)},r=function(e){var t=i(e);return t.substr(0,1).toUpperCase()+t.substr(1)},s=function(e,t){return function(e,t){var n=(t=t||{}).separator||"_",i=t.split||/(?=[A-Z])/;return e.split(i).join(n)}(e,t).toLowerCase()},o=Object.prototype.toString,a=function(e){return"function"==typeof e},c=function(e){return e===Object(e)},u=function(e){return"[object Array]"==o.call(e)},l=function(e){return"[object Date]"==o.call(e)},d=function(e){return"[object RegExp]"==o.call(e)},h=function(e){return"[object Boolean]"==o.call(e)},f=function(e){return(e-=0)==e},p=function(e,t){var n=t&&"process"in t?t.process:t;return"function"!=typeof n?e:function(t,i){return n(t,e,i)}},m={camelize:i,decamelize:s,pascalize:r,depascalize:s,camelizeKeys:function(e,t){return n(p(i,t),e)},decamelizeKeys:function(e,t){return n(p(s,t),e,t)},pascalizeKeys:function(e,t){return n(p(r,t),e)},depascalizeKeys:function(){return this.decamelizeKeys.apply(this,arguments)}};e.exports?e.exports=m:t.humps=m}(i)}(r);var s=r.exports;const o=e=>s.camelizeKeys(e,(e,t)=>/^\w{2}-\w{2,3}$/.test(e)?e:t(e)),a="http://localhost".replace(/\/+$/,"");class c{constructor(e={}){this.configuration=e}set config(e){this.configuration=e}get basePath(){return null!=this.configuration.basePath?this.configuration.basePath:a}get fetchApi(){return this.configuration.fetchApi}get middleware(){return this.configuration.middleware||[]}get queryParamsStringify(){return this.configuration.queryParamsStringify||p}get username(){return this.configuration.username}get password(){return this.configuration.password}get apiKey(){const e=this.configuration.apiKey;if(e)return"function"==typeof e?e:()=>e}get accessToken(){const e=this.configuration.accessToken;if(e)return"function"==typeof e?e:async()=>e}get headers(){return this.configuration.headers}get credentials(){return this.configuration.credentials}}const u=new c;class l{constructor(e=u){this.configuration=e,this.fetchApi=async(e,t)=>{let n,i={url:e,init:t};for(const e of this.middleware)e.pre&&(i=await e.pre(Object.assign({fetch:this.fetchApi},i))||i);try{n=await(this.configuration.fetchApi||fetch)(i.url,i.init)}catch(e){for(const t of this.middleware)t.onError&&(n=await t.onError({fetch:this.fetchApi,url:i.url,init:i.init,error:e,response:n?n.clone():void 0})||n);if(void 0===n)throw e}for(const e of this.middleware)e.post&&(n=await e.post({fetch:this.fetchApi,url:i.url,init:i.init,response:n.clone()})||n);return n},this.middleware=e.middleware}withMiddleware(...e){const t=this.clone();return t.middleware=t.middleware.concat(...e),t}withPreMiddleware(...e){const t=e.map(e=>({pre:e}));return this.withMiddleware(...t)}withPostMiddleware(...e){const t=e.map(e=>({post:e}));return this.withMiddleware(...t)}async request(e,t){const{url:n,init:i}=await this.createFetchParams(e,t),r=await this.fetchApi(n,i);if(r&&r.status>=200&&r.status<300)return r;const s=await r.json().then(e=>o(e)).catch(()=>({}));throw new h(Object.assign(Object.assign({},function(e){var t,n,i;const r=null===(t=null==e?void 0:e.meta)||void 0===t?void 0:t.error;if(r)return{code:r.code,message:r.message,detail:null!==(n=r.details)&&void 0!==n?n:[]};return{code:null==e?void 0:e.code,message:null==e?void 0:e.message,detail:null!==(i=null==e?void 0:e.detail)&&void 0!==i?i:e}}(s)),{status:r.status}))}async createFetchParams(e,t){let n=this.configuration.basePath+e.path;void 0!==e.query&&0!==Object.keys(e.query).length&&(n+="?"+this.configuration.queryParamsStringify(e.query));const i=Object.assign({},this.configuration.headers,e.headers);Object.keys(i).forEach(e=>void 0===i[e]?delete i[e]:{});const r="function"==typeof t?t:async()=>t,o={method:e.method,headers:i,body:e.body,credentials:this.configuration.credentials},a=Object.assign(Object.assign({},o),await r({init:o,context:e}));var c,u;return{url:n,init:Object.assign(Object.assign({},a),{body:(u=a.body,"undefined"!=typeof FormData&&u instanceof FormData||a.body instanceof URLSearchParams||d(a.body)?a.body:JSON.stringify((c=a.body,s.decamelizeKeys(c,(e,t)=>/^\w{2}-\w{2,3}$/.test(e)?e:t(e)))))})}}clone(){const e=new(0,this.constructor)(this.configuration);return e.middleware=this.middleware.slice(),e}}function d(e){return"undefined"!=typeof Blob&&e instanceof Blob}class h extends Error{constructor(e){super(`[${e.code||"unknown"}] ${e.message||"N/A"}`),this.cause=e,this.name="EliceResponseError"}}class f extends Error{constructor(e,t){super(t),this.field=e,this.name="RequiredError"}}function p(e,t=""){return Object.keys(e).map(n=>m(n,e[n],t)).filter(e=>e.length>0).join("&")}function m(e,t,n=""){const i=n+(n.length?`[${e}]`:e);if(t instanceof Array){const e=t.map(e=>encodeURIComponent(String(e))).join(`&${encodeURIComponent(i)}=`);return`${encodeURIComponent(i)}=${e}`}if(t instanceof Set){return m(e,Array.from(t),n)}return t instanceof Date?`${encodeURIComponent(i)}=${encodeURIComponent(t.toISOString())}`:t instanceof Object?p(t,i):`${encodeURIComponent(i)}=${encodeURIComponent(String(t))}`}class v{constructor(e,t=e=>e){this.raw=e,this.transformer=t}async value(){return o(this.transformer(await this.raw.json()))}}async function y(e){const{data:t}=await e.value();return t}function w(e,t=""){return`/materials/{material_id}${t}`.replace("{material_id}",encodeURIComponent(String(e)))}class g extends l{async withBearer(e={}){if(this.configuration&&this.configuration.accessToken){const t=this.configuration.accessToken,n=await t("HTTPBearer",[]);n&&(e.Authorization=`Bearer ${n}`)}return e}async authTokenRefreshRaw(e){const t=await this.request({path:"/auth/token/refresh",method:"POST",headers:await this.withBearer(),query:{}},e);return new v(t)}async authTokenRefresh(e){return y(await this.authTokenRefreshRaw(e))}async materialGetRaw(e,t){const n=await this.request({path:w(e.materialId),method:"GET",headers:await this.withBearer(),query:{}},t);return new v(n)}async materialGet(e,t){return y(await this.materialGetRaw(e,t))}async materialMeGetRaw(e,t){const n=await this.request({path:w(e.materialId,"/me"),method:"GET",headers:await this.withBearer(),query:{}},t);return new v(n)}async materialMeGet(e,t){return y(await this.materialMeGetRaw(e,t))}async materialUpdateRaw(e,t){if(null===e.materialUpdateRequest||void 0===e.materialUpdateRequest)throw new f("materialUpdateRequest","Required parameter requestParameters.materialUpdateRequest was null or undefined when calling materialUpdate.");const n={"Content-Type":"application/json"},i=await this.request({path:w(e.materialId),method:"PATCH",headers:await this.withBearer(n),query:{},body:e.materialUpdateRequest},t);return new v(i)}async materialUpdate(e,t){return y(await this.materialUpdateRaw(e,t))}async submissionCreateRaw(e,t){if(null===e.submissionCreateRequest||void 0===e.submissionCreateRequest)throw new f("submissionCreateRequest","Required parameter requestParameters.submissionCreateRequest was null or undefined when calling submissionCreate.");const n={"Content-Type":"application/json"},i=await this.request({path:w(e.materialId,"/submissions"),method:"POST",headers:await this.withBearer(n),query:{},body:e.submissionCreateRequest},t);return new v(i)}async submissionCreate(e,t){return y(await this.submissionCreateRaw(e,t))}async submissionMeListRaw(e,t){const n={};void 0!==e.offset&&(n.offset=e.offset),void 0!==e.limit&&(n.limit=e.limit);const i=await this.request({path:w(e.materialId,"/submissions/me"),method:"GET",headers:await this.withBearer(),query:n},t);return new v(i)}async submissionMeList(e,t){return y(await this.submissionMeListRaw(e,t))}}var b;e.ErrorCode=void 0,(b=e.ErrorCode||(e.ErrorCode={})).Init="init",b.InvalidParam="invalid_param",b.InvalidToken="invalid_token",b.NotInitialized="not_initialized",b.Unauthorized="unauthorized",b.SessionExpired="session_expired",b.PermissionDenied="permission_denied",b.ReadOnlyMode="read_only_mode",b.ScreenNotSupported="screen_not_supported",b.DraftNotSaved="draft_not_saved",b.ContentNotReady="content_not_ready",b.InvalidInput="invalid_input",b.RateLimited="rate_limited",b.ExternalServiceError="external_service_error",b.NavigationTimeout="navigation_timeout",b.RequestFailed="request_failed";const _=Object.assign(class e extends Error{constructor(t,n,i){var r;const s=i?i instanceof Error?i:new Error(i):void 0;super(`[@eliceio/cdk] ${t} - ${n}${s?`\n${null!==(r=s.stack)&&void 0!==r?r:""}`:""}`),this.code=t,this.cause=s,"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,e)}},{code:e.ErrorCode});var P;const z="preview";class k{constructor(e="learn",t="instructor",n={}){this.scope=e,this.viewer=t,this.settings=n,P.set(this,[])}async authTokenRefresh(){return{accessToken:"",expiresAt:new Date(Date.now()+72e5).toISOString()}}async materialGet(e){return{id:e.materialId,lecturePageId:0,courseId:0,description:{type:"text",text:""},currentVersion:{id:z,contentUrls:{},metadata:{screens:{}},fileTree:[],settings:this.settings}}}async materialMeGet(e){return{scope:this.scope,viewer:this.viewer,user:{anonymousId:"preview",fullname:null},result:null}}async materialUpdate(e){throw new _(_.code.DraftNotSaved,"Settings of an unsaved upload cannot be saved. Save the material in the editor first.")}async submissionCreate(e){const n={isCorrect:!0,score:100};return t(this,P,"f").unshift(Object.assign({id:`preview-${t(this,P,"f").length+1}`,materialVersionId:z,accountId:0,createdAt:(new Date).toISOString(),answer:e.submissionCreateRequest.answer},n)),n}async submissionMeList(e){const{offset:n=0,limit:i=20}=e;return t(this,P,"f").slice(n,n+i)}}P=new WeakMap;function O(e){const t=Object.values(e).filter(e=>"number"==typeof e);return Object.entries(e).filter(([e,n])=>-1===t.indexOf(+e)).map(([e,t])=>t)}function S(e,t){return"bigint"==typeof t?t.toString():t}class T{constructor(e){this._getter=e,this._value=void 0}get value(){const e=this._getter;return void 0!==e&&(this._value=e(),this._getter=void 0),this._value}}function E(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}const j="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function I(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}const R=new Set(["string","number","symbol"]);function C(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function x(e){const t=e;if(!t)return{};if("string"==typeof t)return{error:()=>t};if(void 0!==t?.message){if(void 0!==t?.error)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,"string"==typeof t.error?{...t,error:()=>t.error}:t}function $(e,t=0){if(!0===e.aborted)return!0;for(let n=t;n<e.issues.length;n++)if(!0!==e.issues[n]?.continue)return!0;return!1}function M(e,t=0){if(!0===e.aborted)return!0;for(let n=t;n<e.issues.length;n++)if(!1===e.issues[n]?.continue)return!0;return!1}function U(e){return"string"==typeof e?e:e?.message}function A(e,t,n){var i;for(let r=t;r<e.length;r++)(i=e[r]).schema??(i.schema=n)}function L(e,t,n){var i;const r=e.inst?._zod?.traits;r?.has("$ZodType")&&(r.has("$ZodCheck")?(i=e).schema??(i.schema=e.inst):e.schema=e.inst);const s=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,o=e.message?e.message:U(e.inst?._zod.def?.error?.(e))??U(s?.(e))??U(t?.error?.(e))??U(n.customError?.(e))??U(n.localeError?.(e))??"Invalid input",a={};for(const t of Object.keys(e))"inst"!==t&&"schema"!==t&&"continue"!==t&&"input"!==t&&"__proto__"!==t&&(a[t]=e[t]);return a.path??(a.path=[]),a.message=o,t?.reportInput&&(a.input=e.input),a}function q(e,t,n,i=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:i,value:n}),n}function N(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return null==this?n:q(this,t,n.bind(this))},set(e){q(this,t,e)}})}let D,Z=!1;const W={configurable:!0,get(){Z=!0}};function V(e,t,n){const i=Object.getPrototypeOf(e._zod);t in i&&D!==e._zod?D=void 0:(D=e._zod,Object.defineProperty(i,t,{configurable:!0,get(){Object.defineProperty(this,t,W);const e=Z;Z=!1;try{const i=n(this);return Z?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i}),Z=Z||e,i}catch(n){throw delete this[t],Z=Z||e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}}))}function K(e,t,n,i){const r=function(e,t){const n=Object.getPrototypeOf(e);return t in n?void 0:n}(e,t);r&&Object.defineProperty(r,t,{configurable:!0,get(){const e={configurable:!0,writable:!0,enumerable:i,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:i,value:e})}})}function F(e){const t=()=>e;return t["~constantCatch"]=!0,t}var G;const B={value:void 0,enumerable:!1};let J="captureStackTrace"in Error?Error:null;function H(e,t,n,i){function r(e){this.def=e,this.constr=l,this.traits=new Set}r.prototype={};const s=n,o=s&&new WeakSet;function a(n,i){if(n._zod){if(n._zod.traits.has(e))return}else{B.value=new r(i);try{Object.defineProperty(n,"_zod",B)}finally{B.value=void 0}}if(n._zod.traits.add(e),t(n,i),o){const e=Object.getPrototypeOf(n),t=n._zod.constr.prototype;let i=e;for(;i&&i!==t;)i=Object.getPrototypeOf(i);const r=i??e;o.has(r)||(o.add(r),function(e,t){for(const n in t){const i=Object.getOwnPropertyDescriptor(t,n);i.get?Object.defineProperty(e,n,{...i,enumerable:!1}):N(e,n,i.value)}}(r,s))}const a=l.prototype;for(const e in a)Object.prototype.hasOwnProperty.call(a,e)&&(e in n||(n[e]=a[e].bind(n)))}const c=i?.Parent??Object;class u extends c{}function l(e){const t=i?.Parent?function(e){const t=J;if(t){const n=t.stackTraceLimit;if("number"==typeof n){try{t.stackTraceLimit=0}catch{return J=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}(u):this;a(t,e);const n=t._zod.deferred;if(n){for(const e of n)e();t._zod.deferred=void 0}const r=globalThis.__zod_globalConfig?.postProcessor;return r&&r(t),t}return Object.defineProperty(u,"name",{value:e}),Object.defineProperty(l,"init",{value:a}),Object.defineProperty(l,Symbol.hasInstance,{value:t=>!!(i?.Parent&&t instanceof i.Parent)||t?._zod?.traits?.has(e)}),Object.defineProperty(l,"name",{value:e}),l}class Y extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}(G=globalThis).__zod_globalConfig??(G.__zod_globalConfig={});const X=globalThis.__zod_globalConfig;function Q(e){return X}const ee={get:function(){const e=this._zod;return e.message??(e.message=JSON.stringify(e.def,S,2)),e.message},set:function(e){this._zod.message=e},enumerable:!0,configurable:!0},te={value:void 0,enumerable:!1},ne=new WeakSet([Object.prototype,Error.prototype]),ie=H("$ZodError",(e,t)=>{e.name="$ZodError",te.value=t,Object.defineProperty(e,"issues",te),te.value=void 0,Object.defineProperty(e,"message",ee);const n=Object.getPrototypeOf(e);ne.has(n)||(ne.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){const e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))},void 0,{Parent:Error}),re=(e=>{const t=(n,i,r,s)=>{const o=r?{...r,async:!1}:{async:!1},a=n._zod.run({value:i,issues:[]},o);if(a instanceof Promise)throw new Y;if(a.issues.length){const n=new(s?.Err??e)(a.issues.map(e=>L(e,o,Q())));throw j(n,s?.callee??t),n}return a.value};return t})(ie),se=e=>{const t=async(n,i,r,s)=>{const o=r?{...r,async:!0}:{async:!0};let a=n._zod.run({value:i,issues:[]},o);if(a instanceof Promise&&(a=await a),a.issues.length){const n=new(s?.Err??e)(a.issues.map(e=>L(e,o,Q())));throw j(n,s?.callee??t),n}return a.value};return t},oe=se(ie),ae=(e=>(t,n,i)=>{const r=i?{...i,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},r);if(s instanceof Promise)throw new Y;return s.issues.length?ce(e,s.issues,r):{success:!0,data:s.value}})(ie);function ce(e,t,n){let i;return{success:!1,get error(){return i||(i=new e(t.map(e=>L(e,n,Q()))),t=void 0,n=void 0),i},set error(e){i=e,t=void 0,n=void 0}}}const ue=(e=>async(t,n,i)=>{const r=i?{...i,async:!0}:{async:!0};let s=t._zod.run({value:n,issues:[]},r);return s instanceof Promise&&(s=await s),s.issues.length?ce(e,s.issues,r):{success:!0,data:s.value}})(ie),le=/^https?$/,de=/^[\s\S]{0,}$/,he=H("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),fe=H("$ZodCheckStringFormat",(e,t)=>{var n,i;he.init(e,t),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(i=e._zod).check??(i.check=()=>{})}),pe={major:4,minor:6,patch:7},me=H("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=pe;const i=e._zod.def.checks,r=e._zod.traits.has("$ZodCheck")?[e,...i??[]]:i?.length?[...i]:[];for(const t of r)for(const n of t._zod.onattach)n(e);if(0===r.length)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const t=(t,n,i)=>{if(t.memo)return t;let r,s=$(t);for(const o of n){if(o._zod.def.when){if(M(t))continue;if(!o._zod.def.when(t))continue}else if(s)continue;const n=t.issues.length,a=o._zod.check(t);if(a instanceof Promise&&!1===i?.async)throw new Y;if(r||a instanceof Promise)r=(r??Promise.resolve()).then(async()=>{await a;t.issues.length!==n&&(A(t.issues,n,e),s||(s=$(t,n)))});else{if(t.issues.length===n)continue;A(t.issues,n,e),s||(s=$(t,n))}}return r?r.then(()=>t):t},n=(n,i,s)=>{if($(n))return n.aborted=!0,n;const o=t(i,r,s);if(o instanceof Promise){if(!1===s.async)throw new Y;return o.then(t=>e._zod.parse(t,s))}return e._zod.parse(o,s)};e._zod.run=(i,s)=>{if(s.skipChecks)return e._zod.parse(i,s);if("backward"===s.direction){const t=e._zod.parse({value:i.value,issues:[]},{...s,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,s)):n(t,i,s)}const o=e._zod.parse(i,s);if(o instanceof Promise){if(!1===s.async)throw new Y;return o.then(e=>t(e,r,s))}return t(o,r,s)}}},{get"~standard"(){return function(e,t,n){return q(e,t,n,!1)}(this,"~standard",(e=this,{validate:t=>{const n={async:!1};try{const i=e._zod.run({value:t,issues:[]},n);if(!(i instanceof Promise))return ve(i,n)}catch(e){}return async function(e,t){const n={async:!0};return ve(await e._zod.run({value:t,issues:[]},n),n)}(e,t)},vendor:"zod",version:1}));var e},set"~standard"(e){q(this,"~standard",e)}}),ve=(e,t)=>e.issues.length?{issues:e.issues.map(e=>L(e,t,Q()))}:{value:e.value};const ye=H("$ZodString",(e,t)=>{me.init(e,t),e._zod.pattern=t.pattern??de,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=String(n.value)}catch(i){}return"string"==typeof n.value||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),we=H("$ZodStringFormat",(e,t)=>{fe.init(e,t),ye.init(e,t)});function ge(e,t){return"normalize"in t||"hostname"in t||"protocol"in t?function(e,t){if(!t.normalize&&t.protocol?.source===le.source&&!/^https?:\/\//i.test(e))return 1;try{if("undefined"!=typeof URL){const t=URL;if("function"==typeof t.parse)return t.parse(e)??2}return new URL(e)}catch{return 2}}(e,t):function(e){try{return"undefined"!=typeof URL&&"function"==typeof URL.canParse?URL.canParse(e):(new URL(e),!0)}catch{return!1}}(e)||2}const be=/[\t\n\r]/g;function _e(e){return e.replace(be,"")}const Pe=H("$ZodURL",(e,t)=>{we.init(e,t),e._zod.check=n=>{try{const i=n.value.trim(),r=ge(i,t);return 1===r?void n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort}):2===r?void n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort}):!0===r?void(n.value=_e(i)):(t.hostname&&!function(e,t){return t.lastIndex=0,t.test(e.hostname)}(r,t.hostname)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!function(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}(r,t.protocol)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),void(n.value=t.normalize?r.href:_e(i)))}catch(i){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}});const ze=H("$ZodJWT",(e,t)=>{we.init(e,t),e._zod.check=n=>{(function(e,t=null){try{const n=e.split(".");if(3!==n.length)return!1;const[i]=n;if(!i)return!1;const r=JSON.parse(atob(i));return!("typ"in r&&"JWT"!==r?.typ||!r.alg||t&&(!("alg"in r)||r.alg!==t))}catch{return!1}})(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}});function ke(e,t,n,i,r,s){const o=n in i,a="optional"===s;if(o||!a||"optional"!==r){if(e.issues.length){if(void 0!==r&&a&&!o)return;t.issues.push(...(c=n,u=e.issues,u.map(e=>{var t;return(t=e).path??(t.path=[]),e.path.unshift(c),e})))}var c,u;o||void 0!==r?void 0===e.value?(o||"defaulted"===r&&!a)&&(t.value[n]=void 0):t.value[n]=e.value:e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]})}}const Oe=[];function Se(e){const t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),i=n.length?n:Oe,r=i.length?[...t,...i]:t;for(const t of r)if(!e.shape?.[t]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${String(t)}": expected a Zod schema`);const s=(o=e.shape,Object.keys(o).filter(e=>void 0!==o[e]._zod.optin&&"optional"===o[e]._zod.optout));var o;return{...e,allKeys:r,symbolKeys:i,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}const Te=H("$ZodObject",(e,t)=>{me.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape"),i=n?.get?n.get.raw:t.shape??{};if(i){const e=()=>{const n={...i};return Object.defineProperty(t,"shape",{value:n}),e.raw=n,n};e.raw=i,Object.defineProperty(t,"shape",{get:e})}const r=new T(()=>Se(t));V(e,"propValues",e=>{const t=e.def.shape,n={};for(const e in t){const i=t[e]._zod;if(i.values){Object.prototype.hasOwnProperty.call(n,e)||E(n,e,new Set);for(const t of i.values)n[e].add(t);void 0!==i.optin&&n[e].add(void 0)}}return n});const s=I,o=t.catchall;let a;const c=X.memoizer;c?.attach(e),e._zod.parse=(t,n)=>{a??(a=r.value);const i=t.value;if(!s(i))return t.issues.push({expected:"object",code:"invalid_type",input:i,inst:e}),t;t.value=c?c.alloc(e,t,{},n):{};const u=[],l=a.shape,d=n?.abortEarly;let h=t.issues.length;for(const e of a.allKeys){if(d&&t.issues.length!==h){if($(t,h))break;h=t.issues.length}if("__proto__"===e)continue;const r=l[e],s=r._zod.optin,o=r._zod.optout,a=r._zod.run({value:i[e],issues:[]},n);a instanceof Promise?u.push(a.then(n=>ke(n,t,e,i,s,o))):ke(a,t,e,i,s,o)}return o?function(e,t,n,i,r,s,o){const a=[],c=r.keySet,u=r.catchall._zod,l=u.def.type,d=u.optin,h=u.optout;let f=0;for(const r in t){if(o&&n.issues.length!==f){if($(n,f))break;f=n.issues.length}if(c.has(r))continue;if("__proto__"===r){"never"===l&&a.push(r);continue}if("never"===l){a.push(r);continue}const s=u.run({value:t[r],issues:[]},i);s instanceof Promise?e.push(s.then(e=>ke(e,n,r,t,d,h))):ke(s,n,r,t,d,h)}return a.length&&n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s,continue:!0}),e.length?Promise.all(e).then(()=>n):n}(u,i,t,n,r.value,e,!0===d):u.length?Promise.all(u).then(()=>t):t}}),Ee=H("$ZodEnum",(e,t)=>{me.init(e,t);const n=O(t.entries),i=new Set(n);e._zod.values=i,V(e,"pattern",e=>{const t=O(e.def.entries).filter(e=>R.has(typeof e));return new RegExp(t.length?`^(${t.map(e=>C(e.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(t,r)=>{const s=t.value;return i.has(s)||t.issues.push({code:"invalid_value",values:n,input:s,inst:e}),t}}),je=H("$ZodLiteral",(e,t)=>{me.init(e,t);const n=new Set(t.values);e._zod.values=n,V(e,"pattern",e=>{const t=e.def.values;return new RegExp(t.length?`^(${t.map(e=>"string"==typeof e?C(e):e?C(e.toString()):String(e)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(i,r)=>{const s=i.value;return n.has(s)||i.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),i}});function Ie(e,t){return e.value=t.issues.length?void 0:t.value,e}const Re=H("$ZodOptional",(e,t)=>{me.init(e,t),V(e,"optin",e=>"defaulted"===e.def.innerType._zod.optin?"defaulted":"optional"),e._zod.optout="optional",V(e,"values",e=>{const t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),V(e,"pattern",e=>{const t=e.def.innerType._zod.pattern;return t?new RegExp(`^(${function(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(void 0===e.value){if("defaulted"!==t.innerType._zod.optin)return e;const i=t.innerType._zod.run({value:e.value,issues:[]},n);return i instanceof Promise?i.then(t=>Ie(e,t)):Ie(e,i)}return t.innerType._zod.run(e,n)}});function Ce(e,t,n,i){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>L(e,i,Q()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}const xe=H("$ZodCatch",(e,t)=>{me.init(e,t),V(e,"optin",e=>"defaulted"===e.def.innerType._zod.optin?"defaulted":"optional"),V(e,"optout",e=>e.def.innerType._zod.optout),V(e,"values",e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);const i=t.innerType._zod.run({value:e.value,issues:[]},n);return i instanceof Promise?i.then(i=>Ce(e,i,t,n)):Ce(e,i,t,n)}}),$e=H("$ZodCustom",(e,t)=>{he.init(e,t),me.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{const i=n.value,r=t.fn(i);if(r instanceof Promise)return r.then(t=>Me(t,n,i,e));Me(r,n,i,e)}});function Me(e,t,n,i){if(!e){const e={code:"custom",input:n,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};i._zod.def.params&&(e.params=i._zod.def.params),t.issues.push(function(...e){const[t,n,i]=e;return"string"==typeof t?{message:t,code:"custom",input:n,inst:i}:{...t}}(e))}}const Ue=H("ZodMiniType",(e,t)=>{if(!e._zod)throw new Error("Uninitialized schema in ZodMiniType.");me.init(e,t),e.def=t,e.type=t.type},{get with(){return this.check},set with(e){q(this,"with",e)},parse(e,t){return re(this,e,t,{callee:this.parse})},parseAsync(e,t){return oe(this,e,t,{callee:this.parseAsync})},safeParse(e,t){return ae(this,e,t)},safeParseAsync(e,t){return ue(this,e,t)},check(...e){const t=this.def;return this.clone({...t,checks:[...t.checks??[],...e.map(e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e)]},{parent:!0})},clone(e,t){return function(e,t,n){const i=new e._zod.constr(t??e._zod.def);return t&&!n?.parent||(i._zod.parent=e),i}(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},apply(e,...t){return 0===t.length?e(this):e(this,...t)}}),Ae=H("ZodMiniString",(e,t)=>{ye.init(e,t),Ue.init(e,t)}),Le=H("ZodMiniStringFormat",(e,t)=>{we.init(e,t),Ae.init(e,t)}),qe=H("ZodMiniURL",(e,t)=>{Pe.init(e,t),Le.init(e,t)});const Ne=H("ZodMiniJWT",(e,t)=>{ze.init(e,t),Le.init(e,t)});const De=H("ZodMiniObject",(e,t)=>{Te.init(e,t),Ue.init(e,t),K(e,"shape",e=>e._zod.def.shape,!1)});const Ze=H("ZodMiniEnum",(e,t)=>{Ee.init(e,t),Ue.init(e,t),e.options=[...e._zod.values]});const We=H("ZodMiniLiteral",(e,t)=>{je.init(e,t),Ue.init(e,t)});function Ve(e,t){return new We({type:"literal",values:Array.isArray(e)?e:[e],...x(t)})}const Ke=H("ZodMiniOptional",(e,t)=>{Re.init(e,t),Ue.init(e,t)});function Fe(e){return new Ke({type:"optional",innerType:e})}const Ge=H("ZodMiniCatch",(e,t)=>{xe.init(e,t),Ue.init(e,t)});const Be=H("ZodMiniCustom",(e,t)=>{$e.init(e,t),Ue.init(e,t)});const Je=function(e,t){const n={type:"object",shape:e??{},...x(t)};return new De(n)}({token:Fe((Xe="access token(`token`) is not a JWT",function(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...x(t)})}(Ne,Xe))),preview:Fe(Ve("1")),edit:Fe(Ve("1")),completionPolicy:Fe(Ve("1")),baseUrl:(He=Fe(function(e){return function(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...x(t)})}(qe,e)}({protocol:/^https?$/})),Ye=void 0,new Ge({type:"catch",innerType:He,catchValue:F(Ye)})),screen:Fe(function(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new Ze({type:"enum",entries:n,...x(t)})}(["learn","instructor","completionPolicy"]))}).check(function(e,t={}){return function(e,t,n){return new e({type:"custom",check:"custom",fn:t,...x(n)})}(Be,e,t)}(e=>null!=e.token||"1"===e.preview||"1"===e.edit||"1"===e.completionPolicy,{message:"access token(`token`) is not provided"}));var He,Ye,Xe;const Qe=/\/materials\/([0-9a-f-]{36})\//i;const et="undefined"==typeof window,tt="eliceio-content-sdk";function nt(){if(et||window.parent===window)return null;const e=window.parent;return{post(t){e.postMessage(t,"*")},subscribe(t){function n(n){n.source===e&&function(e){if("object"!=typeof e||null===e)return!1;const{source:t,type:n}=e;return t===tt&&"string"==typeof n}(n.data)&&t(n.data)}return window.addEventListener("message",n),()=>{window.removeEventListener("message",n)}}}}function it(e){let t="";return t=(e=>{try{let t=e.replace(/-/g,"+").replace(/_/g,"/");for(;t.length%4;)t+="=";return decodeURIComponent((e=>e.split("").map(e=>{let t=e.charCodeAt(0).toString(16).toUpperCase();return t.length<2&&(t=`0${t}`),`%${t}`}).join(""))(atob(t)))}catch(e){throw new _(_.code.InvalidToken,"Fail to decode base64 format.",e)}})(e.split(".")[1]),t=(e=>{try{return JSON.parse(e)}catch(e){throw new _(_.code.InvalidToken,"Fail to parse JSON format.",e)}})(t),o(t)}var rt,st,ot;const at=Object.freeze({previous:"navigate-prev",next:"navigate-next",navigate:"navigate",stateSync:"navigate-state-sync"}),ct="navigate-state";class ut{constructor(e){rt.add(this),this.ctx=e}async getHasPrevious(){return(await t(this,rt,"m",ot).call(this)).hasPreviousLecturePage}async getHasNext(){return(await t(this,rt,"m",ot).call(this)).hasNextLecturePage}previous(){t(this,rt,"m",st).call(this,at.previous)}next(){t(this,rt,"m",st).call(this,at.next)}navigate(e){t(this,rt,"m",st).call(this,at.navigate,{lecturePageId:e})}}var lt,dt,ht,ft,pt,mt,vt,yt,wt,gt,bt,_t,Pt,zt,kt,Ot,St,Tt,Et,jt,It,Rt,Ct,xt,$t,Mt,Ut,At,Lt,qt,Nt,Dt,Zt;rt=new WeakSet,st=function(e,t,n){const i=this.ctx.assertNavigable();if(this.ctx.isDraft()||null==this.ctx.channel)return!1;const r={source:tt,type:e,materialId:i};return void 0!==t&&(r.payload=t),void 0!==n&&(r.requestId=n),this.ctx.channel.post(r),!0},ot=function(){var e;const n="undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,i=this.ctx.channel,r=null!==(e=this.ctx.stateTimeoutMs)&&void 0!==e?e:1e3;return new Promise((e,s)=>{let o=()=>{},a=null;const c=()=>{o(),null!==a&&clearTimeout(a)};let u;null!=i&&(o=i.subscribe(t=>{var i;if(t.type!==ct||t.requestId!==n)return;c();const r=null!==(i=t.payload)&&void 0!==i?i:{};e({hasPreviousLecturePage:!0===r.hasPreviousLecturePage,hasNextLecturePage:!0===r.hasNextLecturePage})}));try{u=t(this,rt,"m",st).call(this,at.stateSync,void 0,n)}catch(e){return c(),void s(e)}if(!u)return c(),void e({hasPreviousLecturePage:!1,hasNextLecturePage:!1});a=setTimeout(()=>{c(),s(new _(_.code.NavigationTimeout,"The learning page did not answer the navigation state request."))},r)})};const Wt=Object.freeze({AUTH_PERMISSION_DENIED:e.ErrorCode.PermissionDenied,AUTHENTICATION_INVALID:e.ErrorCode.Unauthorized,EXTERNAL_SERVICE_ERROR:e.ErrorCode.ExternalServiceError,INVALID_INPUT:e.ErrorCode.InvalidInput,MATERIAL_CONTENT_NOT_READY:e.ErrorCode.ContentNotReady,MATERIAL_READ_ONLY_MODE:e.ErrorCode.ReadOnlyMode,MATERIAL_TOO_MANY_SUBMISSIONS:e.ErrorCode.RateLimited});function Vt(e,t){var n,i,r;if(e instanceof h){const s=null!==(i=Wt[null!==(n=e.cause.code)&&void 0!==n?n:""])&&void 0!==i?i:_.code.RequestFailed;return new _(s,null!==(r=e.cause.message)&&void 0!==r?r:t,e)}return new _(_.code.RequestFailed,t,e)}function Kt(e){return e instanceof h&&401===e.cause.status}function Ft(e){if(!Kt(e))return!1;const t=e.cause.detail;return Array.isArray(t)&&t.some(e=>{var t;return"session_expired"===(null===(t=null==e?void 0:e.ctx)||void 0===t?void 0:t.reason)})}dt=new WeakMap,ht=new WeakMap,ft=new WeakMap,pt=new WeakMap,mt=new WeakMap,vt=new WeakMap,yt=new WeakMap,wt=new WeakMap,gt=new WeakMap,bt=new WeakMap,_t=new WeakMap,Pt=new WeakMap,zt=new WeakMap,kt=new WeakMap,Ot=new WeakMap,St=new WeakMap,Tt=new WeakMap,lt=new WeakSet,Et=function(){if(!this.initialized||!t(this,bt,"f"))throw new _(_.code.NotInitialized,"The SDK is not initialized. Please call the init function first.");if(t(this,mt,"f"))throw new _(_.code.SessionExpired,"The session has expired. Please reload the material.");return t(this,bt,"f").materialId},jt=function(e){var n;if(!t(this,bt,"f"))return;const i={source:tt,type:"settings-saved",materialId:t(this,bt,"f").materialId,payload:e};null===(n=t(this,St,"f"))||void 0===n||n.post(i)},It=function(e){const n=t(this,lt,"m",Rt).call(this,e),i=e instanceof h&&n.code!==_.code.SessionExpired?e.cause.code:void 0;return t(this,lt,"m",jt).call(this,{status:"failed",code:null!=i?i:n.code}),n},Rt=function(e){return e instanceof _?e:Ft(e)?(t(this,lt,"m",Zt).call(this),new _(_.code.SessionExpired,"The session has expired. Please reload the material.",e)):Vt(e,"Failed to save the settings.")},Ct=function(...e){if(null==t(this,wt,"f")||!e.includes(t(this,wt,"f")))throw new _(_.code.ScreenNotSupported,`This call is only available on the ${e.join(" or ")} screen.`)},xt=function(){var e,n,i,r,s;if(t(this,zt,"f"))return{materials:new k(null!==(e=t(this,vt,"f"))&&void 0!==e?e:"learn","instructor")};const o=new c({basePath:(null!==(s=null!==(i=null===(n=this.options)||void 0===n?void 0:n.baseUrl)&&void 0!==i?i:null===(r=t(this,Ot,"f"))||void 0===r?void 0:r.baseUrl)&&void 0!==s?s:"https://api-material.elice.io").replace(/\/+$/,""),accessToken:()=>{var e;return null!==(e=t(this,ht,"f"))&&void 0!==e?e:""}});return{materials:new g(o)}},$t=async function(e){const i=null!=e?e:et?"":window.location.hash,r=/(^|[#&])(token|preview|edit|completionPolicy)=/.test(i);if(void 0===e&&!r&&t(this,Ot,"f"))return t(this,Ot,"f");const s=new URLSearchParams(i.replace(/^#/,"")),{data:o,error:a}=await Je.safeParseAsync(Object.fromEntries(s.entries()));if(a)throw new AggregateError(a.issues.map(e=>new _(_.code.InvalidParam,e.message)),"Failed to resolve fragment params during initialization.");return n(this,Ot,o,"f"),o},Mt=function(){if(et||!window.location.hash.includes("token="))return;const e=new URLSearchParams(window.location.hash.replace(/^#/,""));e.delete("token");const t=e.toString(),{pathname:n,search:i}=window.location;window.history.replaceState(window.history.state,"",`${n}${i}${t?`#${t}`:""}`)},Ut=function(e,i){var r,s,o,a,c,u;n(this,zt,null==e.token,"f"),n(this,mt,!1,"f"),t(this,lt,"m",Lt).call(this,null!==(r=e.token)&&void 0!==r?r:null);const l=t(this,ht,"f")?it(t(this,ht,"f")):null,d=null!==(o=null!==(s=function(e){const t=Qe.exec(e);return t?t[1].toLowerCase():null}(null!=i?i:et?"":window.location.pathname))&&void 0!==s?s:null==l?void 0:l.materialId)&&void 0!==o?o:null;if(null==d)throw new _(_.code.InvalidParam,"The material id is not found in the content URL or the access token.");if(n(this,bt,{materialId:d,lecturePageId:null!==(a=null==l?void 0:l.lecturePageId)&&void 0!==a?a:null,courseId:null!==(c=null==l?void 0:l.courseId)&&void 0!==c?c:null},"f"),n(this,Pt,null!==(u=null==l?void 0:l.locale)&&void 0!==u?u:"ko","f"),t(this,zt,"f")){const t="1"===e.edit||"1"===e.completionPolicy;n(this,vt,t?"edit":"learn","f"),n(this,wt,"1"===e.completionPolicy?"completionPolicy":"1"===e.edit?"edit":"learn","f")}return d},At=async function(e){var i,r,s,o,a,c,u;const[l,d]=await Promise.all([this.internal_apis.materials.materialGet({materialId:e}),this.internal_apis.materials.materialMeGet({materialId:e})]),h=null!==(r=null===(i=l.currentVersion.metadata)||void 0===i?void 0:i.screens)&&void 0!==r?r:{},f={};for(const e of["learn","instructor","edit","completionPolicy"]){const{entry:t,enabled:n}=null!==(s=h[e])&&void 0!==s?s:{};!1!==n&&"string"==typeof t&&(f[e]=t)}n(this,_t,{description:l.description,entries:f,settings:l.currentVersion.settings,completionPolicy:null!==(o=l.currentVersion.completionPolicy)&&void 0!==o?o:null,completionPolicies:null!==(c=null===(a=l.currentVersion.metadata)||void 0===a?void 0:a.completionPolicies)&&void 0!==c?c:null},"f"),n(this,kt,l.currentVersion.id,"f"),n(this,dt,d.user,"f"),n(this,gt,d.result,"f"),n(this,yt,d.viewer,"f"),t(this,zt,"f")||(n(this,vt,d.scope,"f"),n(this,wt,function(e,t,n,i){return"edit"===e?null==i?"edit":"completionPolicy"===i?"completionPolicy":"instructor"===i&&n.instructor?"instructor":"learn":"instructor"===t&&n.instructor?"instructor":"learn"}(d.scope,d.viewer,t(this,_t,"f").entries,null===(u=t(this,Ot,"f"))||void 0===u?void 0:u.screen),"f"))},Lt=function(e){var t;n(this,ht,e,"f");const i=e?null===(t=it(e))||void 0===t?void 0:t.exp:void 0;n(this,ft,i?1e3*i:null,"f")},qt=function(e){if(t(this,lt,"m",Nt).call(this),t(this,zt,"f")||null==t(this,ft,"f")||et)return;const i=null!=e?e:Math.max(0,t(this,ft,"f")-3e5-Date.now());n(this,pt,setTimeout(()=>{t(this,lt,"m",Dt).call(this)},i),"f")},Nt=function(){null!=t(this,pt,"f")&&(clearTimeout(t(this,pt,"f")),n(this,pt,null,"f"))},Dt=async function(){try{const{accessToken:e}=await this.internal_apis.materials.authTokenRefresh();t(this,lt,"m",Lt).call(this,e),t(this,lt,"m",qt).call(this)}catch(e){if(Ft(e)||Kt(e))return void t(this,lt,"m",Zt).call(this);t(this,lt,"m",qt).call(this,3e4)}},Zt=function(){var e,i;t(this,lt,"m",Nt).call(this),n(this,mt,!0,"f"),null===(i=(e=this.options).onSessionExpired)||void 0===i||i.call(e)},e.EliceCDK=class{constructor(e={}){lt.add(this),this.options=e,this.initialized=!1,dt.set(this,null),ht.set(this,null),ft.set(this,null),pt.set(this,null),mt.set(this,!1),vt.set(this,null),yt.set(this,null),wt.set(this,null),gt.set(this,null),bt.set(this,null),_t.set(this,null),Pt.set(this,"ko"),zt.set(this,!1),kt.set(this,null),Ot.set(this,null),St.set(this,void 0),Tt.set(this,void 0),this.internal_apis=t(this,lt,"m",xt).call(this),n(this,St,nt(),"f"),n(this,Tt,new ut({channel:t(this,St,"f"),isDraft:()=>t(this,zt,"f"),assertNavigable:()=>{const e=t(this,lt,"m",Et).call(this);return t(this,lt,"m",Ct).call(this,"learn","instructor"),e}}),"f")}get account(){return t(this,dt,"f")}get scope(){return t(this,vt,"f")}get viewer(){return t(this,yt,"f")}get screen(){return t(this,wt,"f")}get result(){return t(this,gt,"f")}get metadata(){return t(this,bt,"f")}get material(){return t(this,_t,"f")}get locale(){return t(this,Pt,"f")}get isDraft(){return t(this,zt,"f")}get isSessionExpired(){return t(this,mt,"f")}get navigation(){return t(this,Tt,"f")}async init(e={}){this.initialized=!1,t(this,lt,"m",Nt).call(this);const n=await t(this,lt,"m",$t).call(this,e.hash);void 0===e.hash&&t(this,lt,"m",Mt).call(this);try{const i=t(this,lt,"m",Ut).call(this,n,e.pathname);this.internal_apis=t(this,lt,"m",xt).call(this),await t(this,lt,"m",At).call(this,i),this.initialized=!0,t(this,lt,"m",qt).call(this)}catch(e){if(e instanceof _)throw e;throw Vt(e,"Failed to initialize elice content sdk.")}return this}async submit(e){const n=t(this,lt,"m",Et).call(this);t(this,lt,"m",Ct).call(this,"learn","instructor");try{return await this.internal_apis.materials.submissionCreate({materialId:n,submissionCreateRequest:{answer:e}})}catch(e){throw Vt(e,"Failed to submit the answer.")}}async history(e={}){const n=t(this,lt,"m",Et).call(this);try{return await this.internal_apis.materials.submissionMeList(Object.assign({materialId:n},e))}catch(e){throw Vt(e,"Failed to load submissions.")}}async saveSettings(e){var i;this.initialized&&"edit"===t(this,wt,"f")||(t(this,lt,"m",Et).call(this),t(this,lt,"m",Ct).call(this,"edit"));try{if(t(this,zt,"f"))throw new _(_.code.DraftNotSaved,"Settings of an unsaved upload cannot be saved. Save the material in the editor first.");const r=t(this,lt,"m",Et).call(this),s=await this.internal_apis.materials.materialUpdate({materialId:r,materialUpdateRequest:{settings:e,expectedCurrentVersionId:null!==(i=t(this,kt,"f"))&&void 0!==i?i:void 0}});n(this,kt,s.currentVersion.id,"f"),t(this,_t,"f")&&n(this,_t,Object.assign(Object.assign({},t(this,_t,"f")),{settings:s.currentVersion.settings}),"f"),t(this,lt,"m",jt).call(this,{status:"saved"})}catch(e){throw t(this,lt,"m",It).call(this,e)}}async saveCompletionPolicy(e){var i,r;this.initialized&&"completionPolicy"===t(this,wt,"f")||(t(this,lt,"m",Et).call(this),t(this,lt,"m",Ct).call(this,"completionPolicy"));try{if(t(this,zt,"f"))throw new _(_.code.DraftNotSaved,"The completion policy of an unsaved upload cannot be saved. Save the material in the editor first.");const s=t(this,lt,"m",Et).call(this),o=await this.internal_apis.materials.materialUpdate({materialId:s,materialUpdateRequest:{completionPolicy:e,expectedCurrentVersionId:null!==(i=t(this,kt,"f"))&&void 0!==i?i:void 0}});n(this,kt,o.currentVersion.id,"f"),t(this,_t,"f")&&n(this,_t,Object.assign(Object.assign({},t(this,_t,"f")),{completionPolicy:null!==(r=o.currentVersion.completionPolicy)&&void 0!==r?r:e}),"f"),t(this,lt,"m",jt).call(this,{status:"saved"})}catch(e){throw t(this,lt,"m",It).call(this,e)}}dispose(){t(this,lt,"m",Nt).call(this)}},e.EliceCDKError=_,e.EliceCDKNavigation=ut,e.NAVIGATION_MESSAGE_TYPE=at,e.NAVIGATION_STATE_MESSAGE_TYPE=ct});
@@ -1,15 +0,0 @@
1
- <!doctype html>
2
- <html lang="ko">
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1" />
6
- <title>완료 정책</title>
7
- <link rel="stylesheet" href="lib/elice-tokens.css" />
8
- <link rel="stylesheet" href="lib/elice-content.css" />
9
- <link rel="stylesheet" href="styles.css" />
10
- <script type="module" src="screens/completion.js"></script>
11
- </head>
12
- <body>
13
- <main id="app"><p class="ec-muted">불러오는 중…</p></main>
14
- </body>
15
- </html>
@@ -1,4 +0,0 @@
1
- {
2
- "title": "새 학습 자료",
3
- "message": "학생에게 보여 줄 내용을 편집 화면에서 고치세요."
4
- }
@@ -1,10 +0,0 @@
1
- {
2
- "kind": "material",
3
- "screens": {
4
- "learn": "index.html",
5
- "instructor": "instructor.html",
6
- "edit": "edit.html",
7
- "completionPolicy": "completion.html"
8
- },
9
- "completionPolicies": ["on_submit", "on_access"]
10
- }
@@ -1,7 +0,0 @@
1
- // 완료 정책 화면 (LXP 편집 페이지 설정 탭, screens.completionPolicy). 라디오 · 저장 · 변경 표시는 키트(useCompletion)가 합니다.
2
- // elice.config.json completionPolicies에 적은 정책만 보이고, 저장하면 SDK saveCompletionPolicy로 자료의 완료 정책이 바뀝니다.
3
- // 정책을 하나만 두면(고정) 이 화면은 지우고 elice.config.json screens에서도 뺍니다.
4
- import { start } from '../lib/elice-content.js';
5
-
6
- const app = await start({ screen: 'completionPolicy' });
7
- app.useCompletion();
@@ -1,35 +0,0 @@
1
- {
2
- "title": "퍼셉트론 확인 문제",
3
- "description": "문제를 풀고 제출해요.",
4
- "questions": [
5
- {
6
- "id": "q1",
7
- "type": "select_one",
8
- "title": "퍼셉트론이 1을 내보내는 조건은 무엇인가요?",
9
- "description": "가중치와 편향이 어떻게 쓰이는지 떠올려 보세요.",
10
- "options": [
11
- {
12
- "id": "a",
13
- "text": "입력의 합이 0보다 클 때"
14
- },
15
- {
16
- "id": "b",
17
- "text": "가중합에 편향을 더한 값이 0보다 클 때"
18
- },
19
- {
20
- "id": "c",
21
- "text": "두 입력이 모두 1일 때"
22
- },
23
- {
24
- "id": "d",
25
- "text": "편향이 0보다 클 때"
26
- }
27
- ],
28
- "shuffle": false,
29
- "explanation": {
30
- "enabled": true,
31
- "text": "퍼셉트론은 **w1·x1 + w2·x2 + b > 0** 이면 1을 내보냅니다."
32
- }
33
- }
34
- ]
35
- }
@@ -1,9 +0,0 @@
1
- {
2
- "kind": "material",
3
- "screens": {
4
- "learn": "index.html",
5
- "instructor": "instructor.html",
6
- "edit": "edit.html"
7
- },
8
- "completionPolicies": ["on_graded"]
9
- }
@@ -1,4 +0,0 @@
1
- {
2
- "type": "pattern",
3
- "answer_key": "^q1=b$"
4
- }