@eliceio/cdk-cli 1.7.1 → 1.8.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 (127) hide show
  1. package/README.md +18 -15
  2. package/es/commands/create/index.js +6 -3
  3. package/es/commands/create/scaffold.d.ts +1 -1
  4. package/es/commands/create/scaffold.js +1 -1
  5. package/es/commands/doctor/index.js +34 -1
  6. package/es/core/lesson-check.d.ts +7 -0
  7. package/es/core/lesson-check.js +87 -0
  8. package/es/core/templates.d.ts +2 -0
  9. package/es/core/templates.js +4 -1
  10. package/es/dev/host-page.js +5 -2
  11. package/es/dev/learner-files.d.ts +1 -1
  12. package/es/dev/learner-files.js +7 -4
  13. package/es/dev/learner-shares.d.ts +90 -0
  14. package/es/dev/learner-shares.js +282 -0
  15. package/es/dev/mock-api.d.ts +28 -0
  16. package/es/dev/mock-api.js +32 -1
  17. package/es/dev/server.d.ts +3 -0
  18. package/es/dev/server.js +22 -1
  19. package/package.json +2 -2
  20. package/skills/_shared/always.md +1 -1
  21. package/skills/_shared/references/02-design-the-material.md +10 -9
  22. package/skills/_shared/references/03-create-the-project.md +12 -11
  23. package/skills/_shared/references/05-screen-code.md +1 -0
  24. package/skills/_shared/references/08-fix-check-errors.md +1 -0
  25. package/skills/_shared/references/12-upload-with-the-material-mcp.md +2 -2
  26. package/skills/_shared/references/17-using-the-entry-template.md +44 -5
  27. package/skills/_shared/references/18-using-the-lesson-template.md +207 -0
  28. package/skills/_shared/references/19-lesson-layouts.md +2132 -0
  29. package/skills/elice-content-create/SKILL.md +4 -3
  30. package/skills/elice-content-publish/SKILL.md +3 -3
  31. package/templates/_shared/lib/cdk-mock.d.ts +16 -0
  32. package/templates/_shared/lib/cdk-mock.js +49 -0
  33. package/templates/blank/template.json +1 -1
  34. package/templates/board/README.md +15 -7
  35. package/templates/board/core/board.d.ts +13 -0
  36. package/templates/board/core/board.js +11 -1
  37. package/templates/board/core/files.d.ts +40 -0
  38. package/templates/board/core/files.js +176 -0
  39. package/templates/board/core/model.d.ts +5 -0
  40. package/templates/board/core/model.js +24 -7
  41. package/templates/board/core/settings.d.ts +2 -0
  42. package/templates/board/core/settings.js +12 -1
  43. package/templates/board/package.json +1 -1
  44. package/templates/board/screens/board.js +58 -0
  45. package/templates/board/screens/edit.js +36 -1
  46. package/templates/board/template.json +1 -1
  47. package/templates/board/ui/board.css +176 -0
  48. package/templates/board/ui/card.js +74 -1
  49. package/templates/board/ui/composer.js +169 -20
  50. package/templates/board/ui/icons.js +2 -0
  51. package/templates/board/ui/texts.js +30 -2
  52. package/templates/lesson/README.md +71 -0
  53. package/templates/lesson/commentary.txt +7 -0
  54. package/templates/lesson/core/dom.d.ts +4 -0
  55. package/templates/lesson/core/dom.js +22 -0
  56. package/templates/lesson/core/engine.d.ts +23 -0
  57. package/templates/lesson/core/engine.js +169 -0
  58. package/templates/lesson/core/interact.d.ts +2 -0
  59. package/templates/lesson/core/interact.js +429 -0
  60. package/templates/lesson/core/layout-files.d.ts +4 -0
  61. package/templates/lesson/core/layout-files.js +9 -0
  62. package/templates/lesson/core/lesson.d.ts +95 -0
  63. package/templates/lesson/core/lesson.js +609 -0
  64. package/templates/lesson/core/sample.d.ts +4 -0
  65. package/templates/lesson/core/sample.js +128 -0
  66. package/templates/lesson/edit.html +21 -0
  67. package/templates/lesson/gitignore +4 -0
  68. package/templates/lesson/index.html +22 -0
  69. package/templates/lesson/layouts/_actions.html +1 -0
  70. package/templates/lesson/layouts/_cmp.html +1 -0
  71. package/templates/lesson/layouts/_deco-corner.html +1 -0
  72. package/templates/lesson/layouts/_deco-cover.html +1 -0
  73. package/templates/lesson/layouts/_deco-section.html +1 -0
  74. package/templates/lesson/layouts/_foot.html +1 -0
  75. package/templates/lesson/layouts/_head.html +1 -0
  76. package/templates/lesson/layouts/_media.html +1 -0
  77. package/templates/lesson/layouts/agenda.html +13 -0
  78. package/templates/lesson/layouts/bar-chart.html +14 -0
  79. package/templates/lesson/layouts/cards.html +12 -0
  80. package/templates/lesson/layouts/checklist.html +12 -0
  81. package/templates/lesson/layouts/choice-list.html +13 -0
  82. package/templates/lesson/layouts/closing.html +13 -0
  83. package/templates/lesson/layouts/compare.html +12 -0
  84. package/templates/lesson/layouts/cover-dark.html +13 -0
  85. package/templates/lesson/layouts/cover.html +15 -0
  86. package/templates/lesson/layouts/figures.html +12 -0
  87. package/templates/lesson/layouts/flow.html +13 -0
  88. package/templates/lesson/layouts/how-to.html +15 -0
  89. package/templates/lesson/layouts/image-bg.html +12 -0
  90. package/templates/lesson/layouts/image-pair.html +15 -0
  91. package/templates/lesson/layouts/image-split.html +12 -0
  92. package/templates/lesson/layouts/layers.html +12 -0
  93. package/templates/lesson/layouts/objectives.html +12 -0
  94. package/templates/lesson/layouts/ox-card.html +24 -0
  95. package/templates/lesson/layouts/ox-list.html +21 -0
  96. package/templates/lesson/layouts/process.html +14 -0
  97. package/templates/lesson/layouts/profile.html +13 -0
  98. package/templates/lesson/layouts/prompt-builder.html +18 -0
  99. package/templates/lesson/layouts/quiz.html +14 -0
  100. package/templates/lesson/layouts/quote.html +12 -0
  101. package/templates/lesson/layouts/scenario-rows.html +12 -0
  102. package/templates/lesson/layouts/section.html +14 -0
  103. package/templates/lesson/layouts/simulation.html +18 -0
  104. package/templates/lesson/layouts/stat.html +14 -0
  105. package/templates/lesson/layouts/statement.html +13 -0
  106. package/templates/lesson/layouts/stats.html +12 -0
  107. package/templates/lesson/layouts/stepper.html +13 -0
  108. package/templates/lesson/layouts/table.html +12 -0
  109. package/templates/lesson/layouts/tabs.html +13 -0
  110. package/templates/lesson/layouts/text-visual.html +16 -0
  111. package/templates/lesson/layouts/timeline.html +12 -0
  112. package/templates/lesson/layouts/toggle.html +16 -0
  113. package/templates/lesson/layouts/variables.html +14 -0
  114. package/templates/lesson/layouts/venn.html +15 -0
  115. package/templates/lesson/layouts/versus.html +12 -0
  116. package/templates/lesson/metadata.json +9 -0
  117. package/templates/lesson/package.json +15 -0
  118. package/templates/lesson/public/img/sample-chat.svg +21 -0
  119. package/templates/lesson/screens/edit.js +79 -0
  120. package/templates/lesson/screens/learn.js +56 -0
  121. package/templates/lesson/styles.css +27 -0
  122. package/templates/lesson/template.json +7 -0
  123. package/templates/lesson/ui/design.css +1103 -0
  124. package/templates/lesson/ui/fonts/PretendardVariable.woff2 +0 -0
  125. package/templates/lesson/ui/learn.css +64 -0
  126. package/templates/lesson/ui/mobile.css +492 -0
  127. package/templates/lesson/ui/reset.css +6 -0
@@ -0,0 +1,282 @@
1
+ import { randomBytes, timingSafeEqual, randomUUID, createHmac } from 'node:crypto';
2
+ import { createReadStream } from 'node:fs';
3
+ import { stat, unlink, rm, readdir } from 'node:fs/promises';
4
+ import { join } from 'node:path';
5
+ import { pipeline } from 'node:stream/promises';
6
+ import { DEV_BLOB_PREFIX } from './assets.js';
7
+
8
+ /**
9
+ * 학생 공유 파일(보드 카드에 붙이는 그림 · PDF) 흉내 (dev 전용). elice-material 명세(learner-shares) 기준:
10
+ * 1. SDK `sharedFiles.post` → 흉내 API `POST /storage/upload-url` `{ key: "shared.{ext}", content_length, content_type }`
11
+ * (learn · edit 토큰, 튜터 403 `MATERIAL_READ_ONLY_MODE`) → `{ upload_url, key: "learner-shares/{material}/{account}/{uuid}.{ext}" }`.
12
+ * 검사 순서도 서버와 같게: 종류 → 크기 · content_type → 1분 10번 → 한 사람 50개
13
+ * 2. SDK가 `upload_url`로 Azure 블록 업로드 → 콘텐츠 서버 `/__ecdk/blob/learner-shares/…`가 받아 `.ecdk/learner-shares/…`에 둔다
14
+ * (dev/learner-files.ts `handleLearnerBlobPut`이 같이 받음)
15
+ * 3. 흉내 API `GET /materials/{id}/learner-shares/url` → `{ base_url, key_prefix, expires_at }`. 서명은 자료 폴더
16
+ * `learner-shares/{material}` 하나라 주소가 모두에게 같다. 파일 주소는 base_url + (key에서 key_prefix를 뺀 것).
17
+ * 운영처럼 출처는 콘텐츠 출처라(img-src에 있음) 콘텐츠 서버가 `/s/{exp}.{sig}/learner-shares/…`를 내준다
18
+ * 4. 흉내 API `DELETE /materials/{id}/learner-shares?key=` → 204. 본인 · 교육자(learn) · edit 토큰만, 튜터 403, 없는 파일도 204
19
+ */
20
+ /** 받은 공유 파일을 두는 곳 (프로젝트 기준). `.ecdk/`라 감시 · zip에서 빠진다 */
21
+ const LEARNER_SHARES_DIR = '.ecdk/learner-shares';
22
+ /** 서명 주소 유효 시간 (초): 서버 LEARNER_FILES_URL_TTL_SECONDS와 같은 6시간 */
23
+ const LEARNER_SHARES_URL_TTL_SECONDS = 6 * 3600;
24
+ /** 한 사람 × 자료마다 1분에 발급하는 업로드 주소 수 */
25
+ const LEARNER_SHARE_UPLOADS_PER_MINUTE = 10;
26
+ /** 한 사람 × 자료마다 남길 수 있는 공유 파일 수 */
27
+ const LEARNER_SHARE_MAX_FILES = 50;
28
+ const MB = 1024 * 1024;
29
+ /** 확장자(소문자만) → 받는 Content-Type · 최대 크기. gif · svg · html은 없음 (서버 LEARNER_SHARE_KINDS) */
30
+ const LEARNER_SHARE_KINDS = Object.freeze({
31
+ png: {
32
+ type: 'image/png',
33
+ maxBytes: 10 * MB
34
+ },
35
+ jpg: {
36
+ type: 'image/jpeg',
37
+ maxBytes: 10 * MB
38
+ },
39
+ jpeg: {
40
+ type: 'image/jpeg',
41
+ maxBytes: 10 * MB
42
+ },
43
+ webp: {
44
+ type: 'image/webp',
45
+ maxBytes: 10 * MB
46
+ },
47
+ pdf: {
48
+ type: 'application/pdf',
49
+ maxBytes: 20 * MB
50
+ }
51
+ });
52
+ /** 저장 키 `learner-shares/{material}/{account}/{uuid}.{ext}` (서버 LEARNER_SHARE_KEY_REGEX) */
53
+ const SHARED_STORAGE_KEY = /^learner-shares\/([0-9a-f-]{36})\/([0-9]+)\/[0-9a-f-]{36}\.(png|jpg|jpeg|webp|pdf)$/;
54
+ const UPLOAD_URL_EXPIRES_IN = 900;
55
+ const detail = (ctx, msg) => [{
56
+ msg,
57
+ type: 'app_exception_detail',
58
+ ctx
59
+ }];
60
+ /** 그 사람 폴더에 남은 공유 파일 수 (서버는 한도를 넘는 큰 파일을 지우고 셈; dev는 크기 검사 뒤에만 저장하므로 그대로 셈) */
61
+ async function countFiles(dir, materialId, accountId) {
62
+ const names = await readdir(join(dir, LEARNER_SHARES_DIR, materialId, String(accountId))).catch(() => []);
63
+ return names.filter(name => !name.endsWith('.part')).length;
64
+ }
65
+ /**
66
+ * `POST /storage/upload-url`의 `shared.{ext}` 흉내. 권한(learn · edit 토큰, 튜터 403)은 부르는 쪽(mock-api)이 본다.
67
+ * 오류: 모르는 확장자 · 대문자 · gif · svg · html은 400 INVALID_INPUT `unsupported_upload_kind`, 한도 초과
68
+ * MATERIAL_PACKAGE_TOO_LARGE(`max_bytes`), 다른 content_type은 INVALID_INPUT `unsupported_content_type`,
69
+ * 1분 10번 초과 429 MATERIAL_TOO_MANY_LEARNER_UPLOADS(`learner_share_upload_rate_limited`),
70
+ * 50개 409 MATERIAL_TOO_MANY_LEARNER_SHARES(`limit`)
71
+ */
72
+ async function createSharedUploadUrl(body, opts) {
73
+ const b = body && typeof body === 'object' ? body : {};
74
+ const key = typeof b.key === 'string' ? b.key : '';
75
+ const ext = key.slice('shared.'.length);
76
+ const kind = key.startsWith('shared.') ? LEARNER_SHARE_KINDS[ext] : undefined;
77
+ if (!kind) {
78
+ const message = 'key: shared.{png|jpg|jpeg|webp|pdf}';
79
+ return {
80
+ ok: false,
81
+ status: 400,
82
+ code: 'INVALID_INPUT',
83
+ message,
84
+ details: detail({
85
+ field: 'key',
86
+ reason: 'unsupported_upload_kind'
87
+ }, message)
88
+ };
89
+ }
90
+ const length = Number(b.content_length ?? b.contentLength);
91
+ if (!Number.isInteger(length) || length <= 0) return {
92
+ ok: false,
93
+ status: 400,
94
+ code: 'INVALID_INPUT',
95
+ message: 'content_length: 1 byte or more'
96
+ };
97
+ if (length > kind.maxBytes) return {
98
+ ok: false,
99
+ status: 400,
100
+ code: 'MATERIAL_PACKAGE_TOO_LARGE',
101
+ message: `content_length: up to ${kind.maxBytes} bytes (${kind.maxBytes / MB}MB)`,
102
+ details: detail({
103
+ max_bytes: kind.maxBytes
104
+ }, 'too large')
105
+ };
106
+ const type = b.content_type ?? b.contentType;
107
+ if (type != null && type !== kind.type) {
108
+ const message = `content_type: ${kind.type} for .${ext}`;
109
+ return {
110
+ ok: false,
111
+ status: 400,
112
+ code: 'INVALID_INPUT',
113
+ message,
114
+ details: detail({
115
+ field: 'content_type',
116
+ reason: 'unsupported_content_type'
117
+ }, message)
118
+ };
119
+ }
120
+ if (opts.rate) {
121
+ const now = opts.now ?? Date.now();
122
+ const rateKey = `shared:${opts.materialId}/${opts.accountId}`;
123
+ const recent = (opts.rate.get(rateKey) ?? []).filter(t => t > now - 60_000);
124
+ if (recent.length >= LEARNER_SHARE_UPLOADS_PER_MINUTE) {
125
+ opts.rate.set(rateKey, recent);
126
+ const message = `up to ${LEARNER_SHARE_UPLOADS_PER_MINUTE} shared file uploads a minute per material`;
127
+ return {
128
+ ok: false,
129
+ status: 429,
130
+ code: 'MATERIAL_TOO_MANY_LEARNER_UPLOADS',
131
+ message,
132
+ details: detail({
133
+ reason: 'learner_share_upload_rate_limited'
134
+ }, message)
135
+ };
136
+ }
137
+ opts.rate.set(rateKey, [...recent, now]);
138
+ }
139
+ if ((await countFiles(opts.dir, opts.materialId, opts.accountId)) >= LEARNER_SHARE_MAX_FILES) {
140
+ const message = `up to ${LEARNER_SHARE_MAX_FILES} shared files per learner and material`;
141
+ return {
142
+ ok: false,
143
+ status: 409,
144
+ code: 'MATERIAL_TOO_MANY_LEARNER_SHARES',
145
+ message,
146
+ details: detail({
147
+ limit: LEARNER_SHARE_MAX_FILES
148
+ }, message)
149
+ };
150
+ }
151
+ const storageKey = `learner-shares/${opts.materialId}/${opts.accountId}/${randomUUID()}.${ext}`;
152
+ opts.pending.set(storageKey, {
153
+ allowed: length,
154
+ blocks: new Map()
155
+ });
156
+ return {
157
+ ok: true,
158
+ data: {
159
+ upload_url: `${opts.uploadOrigin}${DEV_BLOB_PREFIX}${storageKey}?sig=dev`,
160
+ key: storageKey,
161
+ expires_in: UPLOAD_URL_EXPIRES_IN
162
+ }
163
+ };
164
+ }
165
+ /** dev 서명 열쇠 (실행마다 새로). 서명 · 만료를 확인해 다른 자료 · 지난 주소는 403 */
166
+ const SIGNING_KEY = randomBytes(32);
167
+ const signFolder = (prefix, exp) => createHmac('sha256', SIGNING_KEY).update(`${exp}:${prefix}`).digest('base64url').slice(0, 22);
168
+ /**
169
+ * `GET /materials/{id}/learner-shares/url`의 응답: 자료 폴더 서명 주소, 파일 key에서 뺄 `key_prefix`, 만료 시각(ISO).
170
+ * @param contentOrigin 서명 경로를 붙일 콘텐츠 출처 (운영처럼 자료의 콘텐츠 출처)
171
+ */
172
+ function learnerSharesUrl(contentOrigin, materialId, now = Date.now()) {
173
+ const exp = Math.floor(now / 1000) + LEARNER_SHARES_URL_TTL_SECONDS;
174
+ const prefix = `learner-shares/${materialId}`;
175
+ return {
176
+ base_url: `${contentOrigin}/s/${exp}.${signFolder(prefix, exp)}/${prefix}/`,
177
+ key_prefix: `${prefix}/`,
178
+ expires_at: new Date(exp * 1000).toISOString()
179
+ };
180
+ }
181
+ /**
182
+ * 콘텐츠 서버 `GET · HEAD /s/{exp}.{sig}/learner-shares/{material}/{account}/{uuid}.{ext}`: 서명이 그 자료 폴더의 것이고
183
+ * 만료 전이면 받은 파일을 내준다 (inline, nosniff, `private, no-cache`). 모양이 틀리면 404, 서명이 틀리면 403.
184
+ * 이 경로가 아니면 false
185
+ */
186
+ async function serveLearnerShare(req, res, pathname, dir) {
187
+ const m = /^\/s\/(\d+)\.([A-Za-z0-9_-]+)\/(learner-shares\/.*)$/.exec(pathname);
188
+ if (!m) return false;
189
+ const [, expText = '', sig = '', storageKeyRaw = ''] = m;
190
+ const storageKey = decodeURIComponent(storageKeyRaw);
191
+ if (req.method !== 'GET' && req.method !== 'HEAD') {
192
+ res.writeHead(405).end();
193
+ return true;
194
+ }
195
+ const key = SHARED_STORAGE_KEY.exec(storageKey);
196
+ if (!key) {
197
+ res.writeHead(404).end('not found');
198
+ return true;
199
+ }
200
+ const exp = Number(expText);
201
+ const expected = signFolder(`learner-shares/${key[1]}`, exp);
202
+ const valid = exp * 1000 > Date.now() && expected.length === sig.length && timingSafeEqual(Buffer.from(expected), Buffer.from(sig));
203
+ if (!valid) {
204
+ res.writeHead(403).end('invalid signature');
205
+ return true;
206
+ }
207
+ const file = join(dir, '.ecdk', storageKey);
208
+ const info = await stat(file).catch(() => null);
209
+ if (!info?.isFile()) {
210
+ res.writeHead(404).end('not found');
211
+ return true;
212
+ }
213
+ res.writeHead(200, {
214
+ 'Content-Type': LEARNER_SHARE_KINDS[key[3] ?? '']?.type ?? 'application/octet-stream',
215
+ 'Content-Length': String(info.size),
216
+ 'Content-Disposition': 'inline',
217
+ 'Cache-Control': 'private, no-cache'
218
+ });
219
+ if (req.method === 'HEAD') {
220
+ res.end();
221
+ return true;
222
+ }
223
+ await pipeline(createReadStream(file), res).catch(() => undefined);
224
+ return true;
225
+ }
226
+ /**
227
+ * `DELETE /materials/{id}/learner-shares?key=`의 판정 (서버 순서): 모양이 틀린 key 422 VALIDATION_ERROR → 다른 자료 404
228
+ * RESOURCE_NOT_FOUND → 튜터 403 MATERIAL_READ_ONLY_MODE → 본인도 교육자 · edit도 아니면 403 AUTH_PERMISSION_DENIED →
229
+ * 지움(없어도 204). scope 검사(learn · edit)는 dev 토큰이 둘뿐이라 생략
230
+ */
231
+ async function deleteLearnerShare(key, claims, materialId, dir) {
232
+ const match = SHARED_STORAGE_KEY.exec(key);
233
+ if (!match) return {
234
+ ok: false,
235
+ status: 422,
236
+ code: 'VALIDATION_ERROR',
237
+ message: `invalid key "${key}"`
238
+ };
239
+ if (match[1] !== materialId) return {
240
+ ok: false,
241
+ status: 404,
242
+ code: 'RESOURCE_NOT_FOUND',
243
+ message: 'shared file of another material',
244
+ details: detail({
245
+ resource_type: 'learner_share',
246
+ requested_id: key
247
+ }, 'not found')
248
+ };
249
+ if (claims.viewer === 'tutor') return {
250
+ ok: false,
251
+ status: 403,
252
+ code: 'MATERIAL_READ_ONLY_MODE',
253
+ message: 'tutor is read-only',
254
+ details: detail({
255
+ reason: 'tutor_read_only'
256
+ }, 'tutor is read-only')
257
+ };
258
+ const isOwner = Number(match[2]) === claims.account_id;
259
+ const isModerator = claims.scope === 'edit' || claims.viewer === 'instructor';
260
+ if (!isOwner && !isModerator) return {
261
+ ok: false,
262
+ status: 403,
263
+ code: 'AUTH_PERMISSION_DENIED',
264
+ message: "another learner's shared file",
265
+ details: detail({
266
+ resource: 'learner_share',
267
+ resource_id: key,
268
+ required_role: 'owner'
269
+ }, 'denied')
270
+ };
271
+ await unlink(join(dir, '.ecdk', key)).catch(() => undefined);
272
+ return {
273
+ ok: true
274
+ };
275
+ }
276
+ /** "처음 상태로": 받은 공유 파일도 지운다 */
277
+ const removeLearnerShares = dir => rm(join(dir, LEARNER_SHARES_DIR), {
278
+ recursive: true,
279
+ force: true
280
+ });
281
+
282
+ export { LEARNER_SHARES_DIR, LEARNER_SHARES_URL_TTL_SECONDS, LEARNER_SHARE_KINDS, LEARNER_SHARE_MAX_FILES, LEARNER_SHARE_UPLOADS_PER_MINUTE, SHARED_STORAGE_KEY, createSharedUploadUrl, deleteLearnerShare, learnerSharesUrl, removeLearnerShares, serveLearnerShare };
@@ -137,6 +137,34 @@ export interface MockApiOptions {
137
137
  }>;
138
138
  /** `GET /materials/{id}/learner-files/url` (dev/learner-files.ts `learnerFolderUrl`) */
139
139
  learnerFolderUrl?: (materialId: string, accountId: number) => unknown;
140
+ /** `POST /storage/upload-url`의 `shared.{ext}` (dev/learner-shares.ts `createSharedUploadUrl`) */
141
+ createSharedUploadUrl?: (body: unknown, materialId: string, accountId: number) => Promise<{
142
+ ok: true;
143
+ data: unknown;
144
+ } | {
145
+ ok: false;
146
+ status: number;
147
+ code: string;
148
+ message: string;
149
+ details?: unknown[];
150
+ }>;
151
+ /** `GET /materials/{id}/learner-shares/url` (dev/learner-shares.ts `learnerSharesUrl`) */
152
+ learnerSharesUrl?: (materialId: string) => unknown;
153
+ /** `DELETE /materials/{id}/learner-shares?key=` (dev/learner-shares.ts `deleteLearnerShare`) */
154
+ deleteLearnerShare?: (key: string, claims: {
155
+ material_id: string;
156
+ account_id: number;
157
+ viewer: string;
158
+ scope: string;
159
+ }, materialId: string) => Promise<{
160
+ ok: true;
161
+ } | {
162
+ ok: false;
163
+ status: number;
164
+ code: string;
165
+ message: string;
166
+ details?: unknown[];
167
+ }>;
140
168
  onEvent?: (message: string) => void;
141
169
  }
142
170
  /** `/api` 아래 요청을 처리한다 */
@@ -233,6 +233,20 @@ async function handleMockApi(req, res, path, opts) {
233
233
  log(`학생 파일 업로드 주소를 발급했습니다 (${key})`);
234
234
  return send(res, 200, r.data);
235
235
  }
236
+ // 공유 파일(key `shared.{ext}`, SDK sharedFiles.post): learn · edit 토큰, 튜터 403, 계정 · 자료는 토큰에서
237
+ if (typeof key === 'string' && key.startsWith('shared.')) {
238
+ if (claims.viewer === 'tutor') return fail(res, 403, 'MATERIAL_READ_ONLY_MODE', 'tutor is read-only', [{
239
+ type: 'app_exception_detail',
240
+ ctx: {
241
+ reason: 'tutor_read_only'
242
+ }
243
+ }]);
244
+ if (!opts.createSharedUploadUrl) return fail(res, 404, 'RESOURCE_NOT_FOUND', 'uploads are off (dev)');
245
+ const r = await opts.createSharedUploadUrl(json, claims.material_id, claims.account_id);
246
+ if (!r.ok) return fail(res, r.status, r.code, r.message, r.details);
247
+ log(`공유 파일 업로드 주소를 발급했습니다 (${key}, ${claims.viewer} ${claims.account_id})`);
248
+ return send(res, 200, r.data);
249
+ }
236
250
  if (claims.scope !== 'edit') return fail(res, 403, 'AUTH_PERMISSION_DENIED', 'upload only with an edit token');
237
251
  if (!opts.createUploadUrl) return fail(res, 404, 'RESOURCE_NOT_FOUND', 'uploads are off (dev)');
238
252
  const r = opts.createUploadUrl(json, claims.material_id);
@@ -244,7 +258,7 @@ async function handleMockApi(req, res, path, opts) {
244
258
  if (await handlePublicKvApi(req, res, path, {
245
259
  store: state.publicKv,
246
260
  kv: state.kv})) return;
247
- const m = path.match(/^\/materials\/([0-9a-f-]{36})(\/me|\/draft|\/submissions|\/submissions\/me|\/kv\/account|\/learner-files\/url)?$/);
261
+ const m = path.match(/^\/materials\/([0-9a-f-]{36})(\/me|\/draft|\/submissions|\/submissions\/me|\/kv\/account|\/learner-files\/url|\/learner-shares\/url|\/learner-shares)?$/);
248
262
  if (!m) return fail(res, 404, 'RESOURCE_NOT_FOUND', `no route: ${method} ${path}`);
249
263
  const claims = readClaims(req);
250
264
  if (!claims) return fail(res, 401, 'AUTHENTICATION_INVALID', 'missing or expired token (dev)');
@@ -516,6 +530,23 @@ async function handleMockApi(req, res, path, opts) {
516
530
  if (!opts.learnerFolderUrl) return fail(res, 404, 'RESOURCE_NOT_FOUND', 'learner files are off (dev)');
517
531
  return send(res, 200, opts.learnerFolderUrl(claims.material_id, subject));
518
532
  }
533
+ // 공유 파일 서명 주소: 자료 하나에 하나 (모두에게 같은 주소, 튜터도 읽음)
534
+ if (sub === '/learner-shares/url') {
535
+ if (method !== 'GET') return fail(res, 405, 'RESOURCE_NOT_FOUND', `${method} ${path}`);
536
+ if (!opts.learnerSharesUrl) return fail(res, 404, 'RESOURCE_NOT_FOUND', 'shared files are off (dev)');
537
+ return send(res, 200, opts.learnerSharesUrl(claims.material_id));
538
+ }
539
+ // 공유 파일 지우기: 본인 · 교육자 · edit 토큰 (dev/learner-shares.ts deleteLearnerShare)
540
+ if (sub === '/learner-shares') {
541
+ if (method !== 'DELETE') return fail(res, 405, 'RESOURCE_NOT_FOUND', `${method} ${path}`);
542
+ if (!opts.deleteLearnerShare) return fail(res, 404, 'RESOURCE_NOT_FOUND', 'shared files are off (dev)');
543
+ const shareKey = new URL(req.url ?? '', 'http://x').searchParams.get('key') ?? '';
544
+ const r = await opts.deleteLearnerShare(shareKey, claims, claims.material_id);
545
+ if (!r.ok) return fail(res, r.status, r.code, r.message, r.details);
546
+ log(`공유 파일을 지웠습니다 (${shareKey}, ${claims.viewer} ${claims.account_id})`);
547
+ res.writeHead(204).end();
548
+ return;
549
+ }
519
550
  // kvstore: 보는 사람(튜터는 보고 있는 학생) · 이 자료. 맨 위 key마다 값 하나
520
551
  if (sub === '/kv/account') {
521
552
  const doc = state.kv.get(subject) ?? {};
@@ -48,5 +48,8 @@ export declare const devOnlyConnectSrc: (contentOrigin: string) => string[];
48
48
  * - 학생 파일 흉내 (dev/learner-files.ts): upload-url `learner/…`(learn 토큰, 학생 × 자료 1분 30번) → 같은 PUT 경로
49
49
  * (/__ecdk/blob/learners/…, Azure 블록 업로드도 받음) → .ecdk/learners/, learner-files/url의 폴더 서명
50
50
  * 주소(흉내 API /api/s/{exp}.{sig}/learners/{material}/{account}/) 아래 파일을 내준다
51
+ * - 공유 파일 흉내 (dev/learner-shares.ts): upload-url `shared.{ext}`(learn · edit 토큰, 1분 10번, 한 사람 50개) → 같은 PUT
52
+ * 경로(/__ecdk/blob/learner-shares/…) → .ecdk/learner-shares/, learner-shares/url의 자료 폴더 서명 주소(콘텐츠 출처
53
+ * /s/{exp}.{sig}/learner-shares/{material}/) 아래 파일을 내준다. DELETE는 본인 · 교육자 · edit
51
54
  */
52
55
  export declare function startDevServer(opts: DevServerOptions): Promise<DevServer>;
package/es/dev/server.js CHANGED
@@ -17,6 +17,7 @@ import { isCompletionPolicy, recommendedCompletionPolicy } from './grading.js';
17
17
  import { hostPage } from './host-page.js';
18
18
  import { closePublicKv } from './kv-public-mock.js';
19
19
  import { handleLearnerBlobPut, serveLearnerFile, learnerFolderUrl, createLearnerUploadUrl, removeLearnerFiles } from './learner-files.js';
20
+ import { serveLearnerShare, deleteLearnerShare, learnerSharesUrl, createSharedUploadUrl, removeLearnerShares } from './learner-shares.js';
20
21
  import { DEV_MATERIAL_ID, handleMockApi, isTokenScenario, issueToken, createState } from './mock-api.js';
21
22
 
22
23
  /** 운영 콘텐츠 경로(/s/{exp}.{sig}/materials/{id}/{draft}/…)와 같은 모양. SDK가 여기서 자료 id를 읽는다 */
@@ -71,6 +72,9 @@ const listen = (server, port) => new Promise((ok, fail) => {
71
72
  * - 학생 파일 흉내 (dev/learner-files.ts): upload-url `learner/…`(learn 토큰, 학생 × 자료 1분 30번) → 같은 PUT 경로
72
73
  * (/__ecdk/blob/learners/…, Azure 블록 업로드도 받음) → .ecdk/learners/, learner-files/url의 폴더 서명
73
74
  * 주소(흉내 API /api/s/{exp}.{sig}/learners/{material}/{account}/) 아래 파일을 내준다
75
+ * - 공유 파일 흉내 (dev/learner-shares.ts): upload-url `shared.{ext}`(learn · edit 토큰, 1분 10번, 한 사람 50개) → 같은 PUT
76
+ * 경로(/__ecdk/blob/learner-shares/…) → .ecdk/learner-shares/, learner-shares/url의 자료 폴더 서명 주소(콘텐츠 출처
77
+ * /s/{exp}.{sig}/learner-shares/{material}/) 아래 파일을 내준다. DELETE는 본인 · 교육자 · edit
74
78
  */
75
79
  async function startDevServer(opts) {
76
80
  const dir = resolve(opts.dir);
@@ -177,6 +181,12 @@ async function startDevServer(opts) {
177
181
  });
178
182
  return;
179
183
  }
184
+ // 공유 파일 (sharedFiles base_url + {account}/{uuid}.{ext}): 운영처럼 콘텐츠 출처의 자료 폴더 서명 경로
185
+ if (url.pathname.startsWith('/s/') && url.pathname.includes('/learner-shares/')) {
186
+ for (const [k, v] of Object.entries(headers)) res.setHeader(k, v);
187
+ res.setHeader('Cache-Control', 'private, no-cache');
188
+ if (await serveLearnerShare(req, res, url.pathname, dir)) return;
189
+ }
180
190
  if (!url.pathname.startsWith(CONTENT_PREFIX)) {
181
191
  res.writeHead(404, headers).end('not found');
182
192
  return;
@@ -244,6 +254,16 @@ async function startDevServer(opts) {
244
254
  rate: learnerUploadRate
245
255
  }),
246
256
  learnerFolderUrl: (materialId, accountId) => learnerFolderUrl(`${hostOrigin}/api`, materialId, accountId),
257
+ createSharedUploadUrl: (body, materialId, accountId) => createSharedUploadUrl(body, {
258
+ dir,
259
+ materialId,
260
+ accountId,
261
+ uploadOrigin: contentOrigin,
262
+ pending: pendingLearnerUploads,
263
+ rate: learnerUploadRate
264
+ }),
265
+ learnerSharesUrl: materialId => learnerSharesUrl(contentOrigin, materialId),
266
+ deleteLearnerShare: (key, claims, materialId) => deleteLearnerShare(key, claims, materialId, dir),
247
267
  onEvent: m => log(`[api] ${m}`)
248
268
  });
249
269
  return;
@@ -360,8 +380,9 @@ async function startDevServer(opts) {
360
380
  });
361
381
  await removeAssets(dir);
362
382
  await removeLearnerFiles(dir);
383
+ await removeLearnerShares(dir);
363
384
  learnerUploadRate.clear();
364
- log(`[api] 저장 내용(${SETTINGS_DATA_FILE}) · 올린 파일 · 학생 파일 · 제출 기록 · 보드를 지웠습니다`);
385
+ log(`[api] 저장 내용(${SETTINGS_DATA_FILE}) · 올린 파일 · 학생 파일 · 공유 파일 · 제출 기록 · 보드를 지웠습니다`);
365
386
  res.writeHead(204).end();
366
387
  return;
367
388
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eliceio/cdk-cli",
3
- "version": "1.7.1",
3
+ "version": "1.8.0",
4
4
  "description": "교육자용 Custom HTML 콘텐츠 CLI",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
@@ -47,7 +47,7 @@
47
47
  "rollup": "4.62.4",
48
48
  "tslib": "2.8.1",
49
49
  "typescript": "6.0.3",
50
- "@eliceio/cdk": "^1.7.1"
50
+ "@eliceio/cdk": "^1.8.0"
51
51
  },
52
52
  "scripts": {
53
53
  "prebuild": "del-cli \"buildcache/*\" \"es/*\"",
@@ -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 · 16 survey template · 17 Entry template.
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 · 17 Entry template · 18 lesson template (the default learning material) · 19 lesson layouts.
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,15 +15,16 @@ 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
- | A survey (decided 2026-11-25; may change) | `on_access` (done on open) | - | Submit the answers with `useSubmit` (the survey template, [16](16-using-the-survey-template.md)); submissions are still recorded |
22
- | Done when the activity ends (results, self-check) | `on_submit` (done on submit) | - | Submit the result with `useSubmit` |
23
- | One correct answer or one set of answers | `on_graded` (done when it passes) | `pattern` (one regex) | `useSubmit` |
24
- | Several questions with a score per question (partial score) | `on_graded` | `partial_pattern` | `useSubmit` with a string array |
25
- | Writing or assignments graded against a rubric (AI grading) | `on_graded` | `rubric` (the criteria) | `useSubmit`, the score comes back at once |
26
- | Block coding in Entry (the Entry template) | `on_graded` (`on_submit` without grading) | `entry` (general or AI) | The template submits the project ([17](17-using-the-entry-template.md)) |
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
+ | A lesson-template learning material (the lesson template, [18](18-using-the-lesson-template.md)) | `on_access` (done on open) | - | No submission; its quizzes are self-check on the page |
22
+ | A survey (decided 2026-11-25; may change) | `on_access` (done on open) | - | Submit the answers with `useSubmit` (the survey template, [16](16-using-the-survey-template.md)); submissions are still recorded |
23
+ | Done when the activity ends (results, self-check) | `on_submit` (done on submit) | - | Submit the result with `useSubmit` |
24
+ | One correct answer or one set of answers | `on_graded` (done when it passes) | `pattern` (one regex) | `useSubmit` |
25
+ | Several questions with a score per question (partial score) | `on_graded` | `partial_pattern` | `useSubmit` with a string array |
26
+ | Writing or assignments graded against a rubric (AI grading) | `on_graded` | `rubric` (the criteria) | `useSubmit`, the score comes back at once |
27
+ | Block coding in Entry (the Entry template) | `on_graded` (`on_submit` without grading) | `entry` (general or AI) | The template submits the project ([17](17-using-the-entry-template.md)) |
27
28
 
28
29
  > **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`).
29
30
  >
@@ -2,17 +2,18 @@
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
- | 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`; suggest `on_access` (decided 2026-11-25; may change); 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
- | Block coding or Entry Python practice in Entry, AI blocks included | `ecdk create <folder> --template entry` (the Entry workspace in an iframe, so it works only where the server's content CSP allows the workspace; the person builds the start and answer projects on the edit screen; general or AI grading; then [17](17-using-the-entry-template.md)) |
13
- | A dark screen | Add `--theme dark` to the above |
14
- | 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 |
15
- | 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`; suggest `on_access` (decided 2026-11-25; may change); then [16](16-using-the-survey-template.md)) |
9
+ | A learning material to read and practice (explanation, guided practice, workshop, self-check) when the person gives no screen layout: **the default** for anything that is not a type template above or below | `ecdk create <folder> --template lesson` (39 fixed page layouts in the designer's style; you write only the content `{ meta, slides }` and the edit screen checks it; quizzes are self-check, no grading; suggest `on_access`; then [18](18-using-the-lesson-template.md) and [19](19-lesson-layouts.md)) |
10
+ | The person designs the screens, or an interaction the lesson layouts cannot do (live simulation, game, custom visualization) | `ecdk create <folder> --template blank` (three screens with a small example to replace, "예측하고 확인하기", and the kit content editor on the edit screen: see 5) |
11
+ | 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)) |
12
+ | 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") |
13
+ | Block coding or Entry Python practice in Entry, AI blocks included | `ecdk create <folder> --template entry` (the Entry workspace in an iframe, so it works only where the server's content CSP allows the workspace; the person builds the start and answer projects on the edit screen; general or AI grading; then [17](17-using-the-entry-template.md)) |
14
+ | A dark screen | Add `--theme dark` to the above |
15
+ | 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 |
16
+ | An existing HTML page | [7. Move existing HTML](07-move-existing-html.md) |
16
17
 
17
18
  `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).
18
19
 
@@ -89,6 +89,7 @@ app.useSave({ getContent: () => app.content, getGrading: () => grading.getGradin
89
89
  - Saving on the edit screen (`useSave`) **saves to the material's draft** (SDK `saveSettings`, with the edit token LXP opens the edit screen with). LXP's previews show the draft right away; learners see it only after the person presses '수업 자료에 반영' at the top of the LXP edit page, which publishes the draft as a new version. In `ecdk dev` there is no publish step, so the student view changes at once. The kit shows the result and the failure messages (the upload is not saved yet, the upload is still processing, session expired, and for a server 422 `VALIDATION_ERROR` a message by the server's error type: "배점 합계는 100점 이상이어야 합니다." · "문항별 정답과 점수의 개수가 맞지 않아요." · "정답 형식이 올바르지 않아요.", otherwise "저장할 내용의 형식이 올바르지 않아요."), so the screen code does not announce "saved" itself. A submission the server rejects with 422 (the saved grading and the answer shape do not match, for example `partial_pattern` with a string answer) shows "이 자료의 채점 설정과 답 모양이 맞지 않아 제출하지 못했어요. 교육자에게 알려 주세요." in every template.
90
90
  - Materials without a submission do not call `useSubmit` (only `on_access` fits them in LXP).
91
91
  - **No personal data in what you submit, save, upload or send to AI.** `getAnswer`, `useSave` content, `assets` uploads and `mlapi` bodies never hold a learner's name, phone number, email, address, date of birth, student number, resident registration number, bank account, face photo or location, and the screens have no input for them. Submissions stay on the server for instructors and operators, the content reaches every viewer, and AI calls go to an outside model. To tell learners apart use `app.account.anonymousId`; `app.account.fullname` may only be shown, never stored or sent ([2](02-design-the-material.md) "Personal data").
92
+ - **Files the whole class sees** (pictures and PDFs on board cards): SDK `app.sdk.sharedFiles` (provisional API) — `post(file)` gives `{ key, size, contentType }` (PNG · JPEG · WebP up to 10MB, PDF up to 20MB, no GIF or SVG; pictures are redrawn at most 2048px without EXIF), `url(key)` the signed URL for `<img>` or a link, `delete(key)`. Keep only the `key` in `kvstore`, delete the file with its card, and open a PDF in a new tab (`target="_blank"`), never in an `<iframe>` (the browser PDF viewer is blocked inside the LXP sandbox). A tutor only reads; an editor preview keeps files in memory. The board template already does all of this
92
93
  - Use `app.viewer` (`student` · `instructor` · `tutor`), `app.readOnly` (tutoring) and `app.account.anonymousId` (for example a per-person fixed random seed) only when needed. The kit handles per-viewer behavior such as the tutoring lock, so the screen code does not branch on the viewer.
93
94
  - **The instructor screen shows only in the LXP editor preview** (student/instructor switch → instructor; `app.screen` `instructor`). On the learning page an instructor gets the student screen (`app.screen` `learn`, `app.viewer` `instructor`, submissions graded but not recorded). Never add instructor-only parts to the student screen with `if (app.viewer === 'instructor')`: the editor preview's student switch also has viewer `instructor`, so the author would not see what students see, and everything in the student screen (code and `settings`) reaches students anyway. Put explanations and teaching tips on the instructor screen instead. In `ecdk dev` open it with the '교육자 화면 (미리보기)' view (`?view=instructor`): like the editor preview it runs with an edit token, so submissions there are rejected.
94
95
  - Steps inside one material: turn on the kit's stepper and give each step a layout ([14](14-layouts.md)). Never draw an LXP-like bottom 이전 · 다음 bar or your own `n / N`.
@@ -26,6 +26,7 @@ Read `check.issues[]` (`id` · `level` · `path` · `line` · `message`) from `e
26
26
  | `project.deps` (doctor) · "@eliceio/cdk 패키지를 찾지 못했습니다" | The SDK package is not installed in the project: run `npm install` in the project, then build again |
27
27
  | `project.grading` (doctor) | The saved `.ecdk/settings.json` `grading` breaks the server's save rules or does not match the public `gradingType`. Have the person open the edit view in `ecdk dev`, fix the marked field (points, answers) and save again; if you edited the file by hand, correct those values ([15](15-edit-settings-by-hand.md)). Never delete the file: the content goes with it. It warns when the settings hold AI evaluation config (`criteria` · `apiId`) but no `grading`: save a `rubric` with the edit screen's `getGrading` ([5](05-screen-code.md) "AI grading") |
28
28
  | `project.quiz` (doctor, quiz template) | The saved questions, answers or points do not pass the quiz edit screen's own checks (run with the project's `core/model.js`): answers or scores left in the old question order, `points` ≠ `scores`, an answer pointing at a deleted option, a missing `gradingType`, a regex the edit screen cannot read (a text answer in the wrong shape for the project's template version), quiz 1.10.0+: a regex answer not in the stored shape or with a blocked syntax, an answer regex over 500 characters, `answerFormat` · `requires` · `answerMode` the project's template does not know, text answers that look as typed (or a regex question) but `answerFormat` is missing, `answerFormat` 2 with URL-encoded text answers (saved again by a 1.9.x edit screen) - for these two, students typing 한글, spaces or `%` are marked wrong: have the person press "초안으로 저장" once in the edit view and the answers are saved again in the right shape. A warning (`warn`): tags written in snake_case (`answer_format` · `answer_mode`). Fix as [15](15-edit-settings-by-hand.md) says, run `ecdk doctor` again, then have the person save once in the edit view ("초안으로 저장") |
29
+ | `project.lesson` (doctor, lesson template) | The saved slides do not pass the lesson edit screen's checks (run with the project's `core/lesson.js`). Errors: a missing required slot, a list with too few or too many items, a value outside the allowed list, an unknown layout, a quiz `answer` that is not an option number (`ox-*`: not `O`/`X`), an external image URL (the content CSP blocks it) or an image file missing from `public/`, a wrong `meta` value. Warnings: over the character limit, writing style, the same layout three times in a row, an empty image place. Fix as [18](18-using-the-lesson-template.md) and [19](19-lesson-layouts.md) say (shorten or split a page, never shrink the font), run `ecdk doctor` again, then have the person save once in the edit view |
29
30
  | `build.template-unknown` (warn) | The material was made with a template or template version this ecdk does not know. Update ecdk (`npm i -g @eliceio/cdk-cli`) or check `template` in `package.json` `"ecdk"` |
30
31
  | `manifest.*` · `entry.*` | Check `screens` and `kind` in `metadata.json` |
31
32
  | `limit.*` · `file.large-image` | Shrink images (longest side 2048px, WebP 85, [6](06-using-the-quiz-template.md) "Adding images") and video, drop unused files (build output: "files not referenced anywhere") |