@eliceio/cdk-cli 1.5.4 → 1.6.0-entryqa.1

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 (74) hide show
  1. package/README.md +31 -29
  2. package/es/commands/create/index.js +1 -0
  3. package/es/commands/create/scaffold.d.ts +1 -1
  4. package/es/commands/create/scaffold.js +1 -1
  5. package/es/core/config.d.ts +61 -2
  6. package/es/core/config.js +309 -3
  7. package/es/dev/grading.d.ts +31 -2
  8. package/es/dev/grading.js +68 -1
  9. package/es/dev/mock-api.d.ts +3 -1
  10. package/es/dev/mock-api.js +34 -4
  11. package/es/dev/server.js +5 -4
  12. package/es/rules/answers.d.ts +1 -0
  13. package/es/rules/answers.js +3 -0
  14. package/es/rules/check.js +8 -1
  15. package/es/rules/csp.d.ts +7 -0
  16. package/es/rules/csp.js +24 -3
  17. package/es/rules/index.d.ts +1 -1
  18. package/es/rules/index.js +1 -1
  19. package/es/rules/types.d.ts +4 -3
  20. package/es/rules.json.js +1 -1
  21. package/package.json +2 -2
  22. package/rules.json +5 -4
  23. package/skills/_shared/references/02-design-the-material.md +2 -1
  24. package/skills/_shared/references/05-screen-code.md +1 -0
  25. package/skills/_shared/references/12-upload-with-the-material-mcp.md +1 -1
  26. package/templates/_shared/lib/cdk-mock.d.ts +33 -2
  27. package/templates/_shared/lib/cdk-mock.js +171 -5
  28. package/templates/_shared/lib/elice-content.d.ts +38 -0
  29. package/templates/_shared/lib/elice-content.js +85 -2
  30. package/templates/blank/template.json +1 -1
  31. package/templates/document/template.json +3 -2
  32. package/templates/entry/README.md +117 -0
  33. package/templates/entry/commentary.txt +2 -0
  34. package/templates/entry/core/autosave.d.ts +13 -0
  35. package/templates/entry/core/autosave.js +69 -0
  36. package/templates/entry/core/default-project.d.ts +2 -0
  37. package/templates/entry/core/default-project.js +139 -0
  38. package/templates/entry/core/dom.d.ts +13 -0
  39. package/templates/entry/core/dom.js +83 -0
  40. package/templates/entry/core/grading.d.ts +52 -0
  41. package/templates/entry/core/grading.js +139 -0
  42. package/templates/entry/core/pack.d.ts +12 -0
  43. package/templates/entry/core/pack.js +71 -0
  44. package/templates/entry/core/settings.d.ts +33 -0
  45. package/templates/entry/core/settings.js +79 -0
  46. package/templates/entry/core/workspace.d.ts +40 -0
  47. package/templates/entry/core/workspace.js +320 -0
  48. package/templates/entry/docs/storage.md +44 -0
  49. package/templates/entry/edit.html +17 -0
  50. package/templates/entry/gitignore +4 -0
  51. package/templates/entry/index.html +17 -0
  52. package/templates/entry/metadata.json +9 -0
  53. package/templates/entry/package.json +13 -0
  54. package/templates/entry/screens/edit/panels/answer-project.js +15 -0
  55. package/templates/entry/screens/edit/panels/grading.d.ts +18 -0
  56. package/templates/entry/screens/edit/panels/grading.js +627 -0
  57. package/templates/entry/screens/edit/panels/index.js +25 -0
  58. package/templates/entry/screens/edit/panels/preference.js +56 -0
  59. package/templates/entry/screens/edit/panels/project-panel.js +93 -0
  60. package/templates/entry/screens/edit/panels/start-project.js +6 -0
  61. package/templates/entry/screens/edit.js +293 -0
  62. package/templates/entry/screens/learn.js +268 -0
  63. package/templates/entry/styles.css +1037 -0
  64. package/templates/entry/template.json +6 -0
  65. package/templates/entry/ui/templates/page.js +106 -0
  66. package/templates/entry/ui/texts.d.ts +3 -0
  67. package/templates/entry/ui/texts.js +160 -0
  68. package/templates/entry/ui/theme.css +17 -0
  69. package/templates/quiz/README.md +1 -1
  70. package/templates/quiz/template.json +3 -2
  71. package/templates/steps/template.json +1 -1
  72. package/templates/survey/README.md +1 -0
  73. package/templates/survey/template.json +3 -2
  74. package/templates/video/template.json +3 -2
@@ -2,8 +2,8 @@
2
2
  * @eliceio/cdk 1.x(EliceCDK)와 같은 공개 인터페이스를 가진 mock · 템플릿이 제공 (고치지 마세요)
3
3
  *
4
4
  * 서버 없이 화면을 시험할 때 키트가 대신 씁니다. 실제 SDK와 다른 점:
5
- * - 채점: 편집 화면이 저장한 채점 설정(settings.grading { type: pattern | partial_pattern | rubric | per_question })이 있으면 로컬 채점, 없으면 제출만 받음.
6
- * per_question의 AI 채점 문항은 AI 대신 글 길이로 만든 흉내 점수 (mockRubricScore)
5
+ * - 채점: 편집 화면이 저장한 채점 설정(settings.grading { type: pattern | partial_pattern | rubric | per_question | entry })이 있으면 로컬 채점, 없으면 제출만 받음.
6
+ * per_question의 AI 채점 문항은 AI 대신 글 길이로 만든 흉내 점수 (mockRubricScore). entry는 블록을 비교하지 않는 흉내 채점 (gradeLocally)
7
7
  * pattern 답은 정규식 하나, 답 문자열 전체 일치. partial_pattern은 문항별 정규식 · 점수, 답은 문자열 배열. 프로젝트 폴더를 그대로 열면 ecdk dev가 저장한 .ecdk/settings.json으로 시작
8
8
  * - 완료 정책: 흉내 내지 않는다 (LXP에 올린 뒤 자료 편집 화면의 '설정'에서 교육자가 고름, ADR 0012). material.completionPolicy는 null
9
9
  * - 저장: 설정 화면이 저장한 내용과 제출 기록을 브라우저에 남겨 다른 화면에서도 보임
@@ -199,8 +199,9 @@ const answerText = answer =>
199
199
 
200
200
  /**
201
201
  * 채점 설정을 서버 모양(2026-11-11 결정)으로: `{ type: 'pattern', answer_key }` ·
202
- * `{ type: 'partial_pattern', answer_key: string[], scores: number[] }` · `{ type: 'rubric', rubric }`.
203
- * camelCase(answerKey)도 받는다. 채점 방식이 아니면 null
202
+ * `{ type: 'partial_pattern', answer_key: string[], scores: number[] }` · `{ type: 'rubric', rubric }` ·
203
+ * 엔트리 템플릿 전용 `{ type: 'entry', mode: 'general' | 'ai', answer_project: { enc, data }, rubrics? }`(rubrics는 ai일 때만,
204
+ * 모르는 mode는 그대로). camelCase(answerKey)도 받는다. 채점 방식이 아니면 null
204
205
  */
205
206
  export function normalizeGradingSettings(grading) {
206
207
  if (!grading || typeof grading !== 'object') return null;
@@ -228,9 +229,158 @@ export function normalizeGradingSettings(grading) {
228
229
  : [],
229
230
  ...(grading.pass_score === undefined ? {} : { pass_score: grading.pass_score }),
230
231
  };
232
+ // 엔트리 채점 (일반 · AI). 정답 작품 · 기준은 복사해 둔다 (값은 그대로)
233
+ if (grading.type === 'entry') {
234
+ const project = grading.answer_project;
235
+ const validProject = project && typeof project === 'object' && typeof project.enc === 'string' && typeof project.data === 'string';
236
+ return {
237
+ type: 'entry',
238
+ ...(grading.mode === undefined ? {} : { mode: grading.mode }),
239
+ ...(validProject ? { answer_project: { enc: project.enc, data: project.data } } : {}),
240
+ ...(grading.mode === 'ai'
241
+ ? { rubrics: Array.isArray(grading.rubrics) ? grading.rubrics.map(r => (r && typeof r === 'object' ? { ...r } : r)) : [] }
242
+ : {}),
243
+ };
244
+ }
245
+ return null;
246
+ }
247
+
248
+ /**
249
+ * 엔트리 제출 답에서 작품 { enc, data }를 꺼낸다. 답은 엔트리 템플릿 모양 `{ v: 1, project: { enc, data } }`
250
+ * (작품만 `{ enc, data }`이거나 그 JSON 글자여도 받는다). 없으면 null
251
+ * @param {unknown} answer
252
+ */
253
+ export function entryProjectOf(answer) {
254
+ let value = answer;
255
+ if (typeof value === 'string') {
256
+ try {
257
+ value = JSON.parse(value);
258
+ } catch {
259
+ return null;
260
+ }
261
+ }
262
+ const project = value && typeof value === 'object' && value.project && typeof value.project === 'object' ? value.project : value;
263
+ return project && typeof project === 'object' && typeof project.enc === 'string' && typeof project.data === 'string'
264
+ ? { enc: project.enc, data: project.data }
265
+ : null;
266
+ }
267
+
268
+ /**
269
+ * 묶은 엔트리 작품 { enc: 'gzip+base64' | 'json', data }을 푼다 (objects 배열이 있는 객체). 풀지 못하면 null
270
+ * @param {unknown} project
271
+ */
272
+ export async function decodeEntryProject(project) {
273
+ if (!project || typeof project !== 'object' || typeof project.data !== 'string' || !project.data) return null;
274
+ try {
275
+ let text = null;
276
+ if (project.enc === 'json') text = project.data;
277
+ else if (project.enc === 'gzip+base64' && typeof DecompressionStream === 'function') {
278
+ const bytes = Uint8Array.from(atob(project.data), c => c.charCodeAt(0));
279
+ const stream = new Response(bytes).body.pipeThrough(new DecompressionStream('gzip'));
280
+ text = await new Response(stream).text();
281
+ }
282
+ if (text === null) return null;
283
+ const parsed = JSON.parse(text);
284
+ return parsed && typeof parsed === 'object' && Array.isArray(parsed.objects) ? parsed : null;
285
+ } catch {
286
+ return null;
287
+ }
288
+ }
289
+
290
+ /** 작품에 채점거리(블록 묶음이 있는 오브젝트나 전역 리스트)가 있나. 서버 entry_answer_project_empty와 같은 규칙 */
291
+ export function entryHasGradable(project) {
292
+ const hasScript = project.objects.some(o => {
293
+ let script = o?.script;
294
+ if (typeof script === 'string') {
295
+ try {
296
+ script = JSON.parse(script);
297
+ } catch {
298
+ return false;
299
+ }
300
+ }
301
+ return Array.isArray(script) && script.some(thread => Array.isArray(thread) && thread.length > 0);
302
+ });
303
+ if (hasScript) return true;
304
+ const variables = Array.isArray(project.variables) ? project.variables : [];
305
+ return variables.some(v => v?.variableType === 'list' && !v.object);
306
+ }
307
+
308
+ /**
309
+ * 엔트리 채점 설정 저장 검사 중 작품 안을 보는 것 (서버 422 VALIDATION_ERROR detail type 이름 그대로):
310
+ * ai인데 settings.entry.startProject 없음 entry_project_invalid, ai 기준 object가 ''이거나 정답 작품에 없음
311
+ * entry_rubric_object_not_found, general 정답 작품에 채점거리 없음 entry_answer_project_empty.
312
+ * 모양 검사(배점 합 등)는 흉내 내지 않음 (ecdk dev 흉내 서버가 함). 문제없으면 null
313
+ * @param {Record<string, unknown>} settings
314
+ */
315
+ export async function entrySaveIssue(settings) {
316
+ const g = settings?.grading;
317
+ if (!g || typeof g !== 'object' || g.type !== 'entry') return null;
318
+ const at = ['body', 'settings', 'grading', 'entry'];
319
+ const decoded = await decodeEntryProject(g.answer_project);
320
+ if (g.mode === 'general')
321
+ return decoded && !entryHasGradable(decoded) ? { type: 'entry_answer_project_empty', loc: [...at, 'answer_project'] } : null;
322
+ if (g.mode !== 'ai') return null;
323
+ const start = settings.entry && typeof settings.entry === 'object' ? settings.entry.startProject : undefined;
324
+ if (!start || typeof start !== 'object' || typeof start.data !== 'string' || !start.data)
325
+ return { type: 'entry_project_invalid', loc: ['body', 'settings', 'entry', 'startProject'], ctx: { field: 'entry.startProject' } };
326
+ const ids = decoded ? new Set(decoded.objects.map(o => o?.id).filter(id => typeof id === 'string')) : null;
327
+ for (const [i, r] of (Array.isArray(g.rubrics) ? g.rubrics : []).entries()) {
328
+ const object = r?.object;
329
+ if (object === '' || (typeof object === 'string' && ids && !ids.has(object)))
330
+ return {
331
+ type: 'entry_rubric_object_not_found',
332
+ loc: [...at, 'rubrics', i, 'object'],
333
+ ctx: { field: `grading.rubrics.${i}.object`, object },
334
+ };
335
+ }
231
336
  return null;
232
337
  }
233
338
 
339
+ /**
340
+ * 엔트리 채점 흉내 (블록을 비교하지 않음, 같은 답이면 늘 같은 결과). ecdk dev 흉내 서버(src/dev/grading.ts gradeEntry)와 같은 규칙:
341
+ * - general: 제출 작품의 enc · data가 정답 작품과 글자까지 같으면 100, 아니면 0. 문항별 결과 [], gradingFeedback { message: '', criteria: [] }
342
+ * - ai: 기준마다 floor(mockRubricScore(작품 data) × 배점 / 100) (빈 작품 0), 합은 100에서 자름.
343
+ * 문항별 결과는 기준 순서 { score, isCorrect: 배점을 다 받았을 때 }, gradingFeedback { message, criteria: [{ feedback }] }(기준 순서,
344
+ * question_results와 같은 길이)도 흉내. 서버 응답 키는 grading_feedback (제출 · 미리보기 · /submissions/me)
345
+ * @param {{ mode?: unknown, answer_project?: { enc: string, data: string }, rubrics?: unknown[] }} g normalizeGradingSettings 결과
346
+ * @param {unknown} answer
347
+ */
348
+ function gradeEntry(g, answer) {
349
+ const project = entryProjectOf(answer);
350
+ if (g.mode === 'ai') {
351
+ const rubrics = Array.isArray(g.rubrics) ? g.rubrics : [];
352
+ const graderScore = mockRubricScore(project?.data);
353
+ const questionResults = rubrics.map(r => {
354
+ const points = Number.isInteger(r?.score) ? r.score : 0;
355
+ const score = Math.floor((graderScore * points) / 100);
356
+ return { score, isCorrect: score === points && points > 0 };
357
+ });
358
+ const score = Math.min(100, questionResults.reduce((sum, r) => sum + r.score, 0));
359
+ return {
360
+ isCorrect: score === 100,
361
+ score,
362
+ answerCorrectness: [],
363
+ questionResults,
364
+ gradingFeedback: {
365
+ message: '흉내 채점입니다 (AI를 부르지 않고 작품 크기로 점수를 냈습니다).',
366
+ criteria: rubrics.map((r, i) => ({
367
+ feedback: `흉내 채점: ${questionResults[i].score} / ${Number.isInteger(r?.score) ? r.score : 0}점`,
368
+ })),
369
+ },
370
+ mockRubric: true,
371
+ };
372
+ }
373
+ const answerProject = g.answer_project;
374
+ const ok = Boolean(project && answerProject && project.enc === answerProject.enc && project.data === answerProject.data);
375
+ return {
376
+ isCorrect: ok,
377
+ score: ok ? 100 : 0,
378
+ answerCorrectness: [],
379
+ questionResults: [],
380
+ gradingFeedback: { message: '', criteria: [] },
381
+ };
382
+ }
383
+
234
384
  /**
235
385
  * per_question AI 채점(rubric) 문항 흉내 점수 0~100 (AI를 부르지 않음, 같은 답이면 늘 같은 점수):
236
386
  * 빈 답 0, 아니면 min(100, 20 + 글자 수 / 5)을 내림. ecdk dev 흉내 서버(src/dev/grading.ts mockRubricScore)와 같은 식
@@ -282,6 +432,8 @@ export function answerShapeError(grading, answer) {
282
432
  * - per_question (서버 #65): 문항마다 채점기 점수(pattern은 맞으면 100, rubric은 AI 대신 mockRubricScore 0~100, 빈 답 0)를
283
433
  * floor(채점기 점수 × score / 100)으로 (서버처럼 내림). 합은 100에서 자르고 100점만 정답, pass_score(없으면 100) 이상이면 통과.
284
434
  * 문항별 결과 questionResults [{ score, isCorrect }](isCorrect는 채점기 점수 100일 때만)와 그것으로 만든 answerCorrectness도
435
+ * - entry (엔트리 템플릿): 블록을 비교하지 않는 흉내 (gradeEntry). general은 작품 글자가 정답 작품과 같으면 100,
436
+ * ai는 기준별 흉내 점수의 합과 기준 순서 questionResults, 흉내 gradingFeedback도
285
437
  * - 채점 설정 없음: 점수 없음 `{ isCorrect: null, score: null }`
286
438
  * 맨 앞 (?i)는 서버(Python re)처럼 대소문자 무시
287
439
  * @param {object | null} grading settings.grading
@@ -327,6 +479,7 @@ export function gradeLocally(grading, answer) {
327
479
  ...(mockRubric ? { mockRubric: true } : {}),
328
480
  };
329
481
  }
482
+ if (g?.type === 'entry') return gradeEntry(g, answer);
330
483
  return { isCorrect: null, score: null };
331
484
  }
332
485
 
@@ -578,6 +731,11 @@ export class MockEliceCDK {
578
731
  settings: this.#scope === 'edit' && effective ? { ...rest, grading: effective } : rest,
579
732
  // 완료 정책은 LXP 설정 (로컬에는 없음)
580
733
  completionPolicy: null,
734
+ // entry 채점 방식 (실제 SDK는 /me grading_mode): 학습 화면에서만, edit 토큰 · draft는 /me가 없어 null
735
+ gradingMode:
736
+ this.#scope !== 'edit' && !this.#isDraft && effective?.type === 'entry' && (effective.mode === 'general' || effective.mode === 'ai')
737
+ ? effective.mode
738
+ : null,
581
739
  };
582
740
  }
583
741
  get result() {
@@ -699,7 +857,7 @@ export class MockEliceCDK {
699
857
  const graded = gradeLocally(this.#effectiveGrading(), answer);
700
858
  const { mockRubric, passed, ...rest } = graded;
701
859
  if (mockRubric && typeof console !== 'undefined')
702
- console.info('[cdk-mock] per_question의 AI 채점(rubric) 점수는 흉내 값입니다 (AI를 부르지 않음, 글 길이로 계산)');
860
+ console.info('[cdk-mock] AI 채점(per_question rubric 문항 · entry ai) 점수는 흉내 값입니다 (AI를 부르지 않음, 글 길이로 계산)');
703
861
  // 문항별 결과(question_results)도 실제 SDK처럼 submit 결과와 제출 기록에 늘 준다: partial_pattern · per_question이 아니면 []
704
862
  const res = {
705
863
  ...rest,
@@ -742,6 +900,12 @@ export class MockEliceCDK {
742
900
  });
743
901
  if (this.#scenario === 'request_failed')
744
902
  throw new EliceCDKError(ErrorCode.RequestFailed, 'Network error (mock).');
903
+ // 서버처럼 엔트리 채점 설정의 작품 안 규칙을 어기면 422 VALIDATION_ERROR (실제 SDK는 RequestFailed, 서버 코드 · detail은 cause)
904
+ const issue = await entrySaveIssue(settings);
905
+ if (issue)
906
+ throw new EliceCDKError(ErrorCode.RequestFailed, `Settings rejected: ${issue.type} (mock 422).`, {
907
+ cause: { status: 422, code: 'VALIDATION_ERROR', detail: [issue] },
908
+ });
745
909
  this.#store.set('settings', settings);
746
910
  this.#postSettingsSaved({ status: 'saved' });
747
911
  } catch (err) {
@@ -809,6 +973,8 @@ export class MockEliceCDK {
809
973
  score: res.score,
810
974
  answerCorrectness: res.answerCorrectness ?? [],
811
975
  questionResults: res.questionResults ?? [],
976
+ // entry만: 서버 /submissions/me의 grading_feedback (실제 SDK history는 키를 camelCase로 바꿔 그대로 넘김)
977
+ ...(res.gradingFeedback ? { gradingFeedback: res.gradingFeedback } : {}),
812
978
  };
813
979
  }
814
980
 
@@ -33,6 +33,11 @@ export interface SubmitResult {
33
33
  answerCorrectness?: boolean[];
34
34
  /** 문항별 결과 (서버 question_results, 문항 순서): score는 받은 점수, 만점일 때만 isCorrect. per_question · partial_pattern만, 그 밖은 [] (옛 서버는 없음) */
35
35
  questionResults?: { score: number; isCorrect: boolean }[];
36
+ /**
37
+ * entry 채점 피드백 (서버 grading_feedback): { message, criteria: [{ feedback }] }, criteria는 기준 순서.
38
+ * 일반(general)은 { message: '', criteria: [] }. 다른 채점 · 옛 서버 · 옛 SDK는 없음 (undefined 또는 null)
39
+ */
40
+ gradingFeedback?: { message: string; criteria: { feedback: string }[] } | null;
36
41
  }
37
42
 
38
43
  export interface Navigation {
@@ -156,8 +161,26 @@ export type Grading =
156
161
  | { type: 'rubric'; rubric: string; question?: string };
157
162
  }[];
158
163
  pass_score?: number;
164
+ }
165
+ /** 엔트리 일반 채점 (엔트리 템플릿 전용): 정답 작품과 비교해 0 · 100점. rubrics 등 다른 키는 서버가 422 */
166
+ | { type: 'entry'; mode: 'general'; answer_project: EntryProject }
167
+ /**
168
+ * 엔트리 AI 채점 (엔트리 템플릿 전용): 기준 1~10개(criteria 1~1,000자, score 1~100 정수, 배점 합 100), object는 기준이 보는
169
+ * 정답 작품의 오브젝트 id(작품 전체 기준은 없음: ''이나 없는 id는 서버 422 entry_rubric_object_not_found). 점수는 기준별 AI 점수의 합, 결과 questionResults는 기준 순서
170
+ */
171
+ | {
172
+ type: 'entry';
173
+ mode: 'ai';
174
+ answer_project: EntryProject;
175
+ rubrics: { object: string; criteria: string; score: number }[];
159
176
  };
160
177
 
178
+ /** 엔트리 작품 묶음 (엔트리 템플릿 core/pack.js 모양): gzip 뒤 base64 글자, 또는 줄이지 않은 JSON 글자 */
179
+ export interface EntryProject {
180
+ enc: 'gzip+base64' | 'json';
181
+ data: string;
182
+ }
183
+
161
184
  /** @deprecated Grading을 쓴다 */
162
185
  export type GradingPart = Grading;
163
186
 
@@ -287,6 +310,11 @@ export interface ContentApp<C = Record<string, unknown>> {
287
310
  emptyState(options?: EmptyStateOptions): Element;
288
311
  /** 저장된 채점 설정. edit 범위(편집 화면)에서만, 없으면 null */
289
312
  readonly grading: Grading | null;
313
+ /**
314
+ * entry 채점 방식 (SDK material.gradingMode, 서버 /me grading_mode): 'general' · 'ai'. 다른 채점 · 편집 화면(edit 토큰) ·
315
+ * draft · 옛 서버 · 옛 SDK는 null
316
+ */
317
+ readonly gradingMode: 'general' | 'ai' | null;
290
318
  submit(answer: unknown): Promise<SubmitResult>;
291
319
  lastAnswer(): Promise<unknown>;
292
320
  lastSubmission(): Promise<
@@ -349,6 +377,16 @@ export interface ContentApp<C = Record<string, unknown>> {
349
377
  options?: { resourceId?: string }
350
378
  ): () => void;
351
379
  };
380
+ /**
381
+ * 보는 사람의 이 자료 저장 칸 (SDK kvstore, 학습자료 × 계정마다). key는 점 경로('progress.step'), value는 JSON 값.
382
+ * 튜터링(readOnly)은 학생 값을 읽기만 (post · delete는 ContentError read_only_mode), 편집기 미리보기는 SDK가 메모리에만 둔다
383
+ */
384
+ readonly kvstore: {
385
+ /** 저장한 값, 없으면 null. key ''면 맨 위 key 전부 { key: value } */
386
+ get<T = unknown>(params: { key: string }): Promise<T | null>;
387
+ post(params: { key: string; value: unknown }): Promise<void>;
388
+ delete(key: string): Promise<void>;
389
+ };
352
390
  /** 편집 화면 저장 영역 */
353
391
  useSave(options: SaveOptions<C>): {
354
392
  element: Element;
@@ -89,7 +89,18 @@ const MESSAGES = {
89
89
  save_length_mismatch: '문항별 정답과 점수의 개수가 맞지 않아요.',
90
90
  save_regex_invalid: '정답 형식이 올바르지 않아요.',
91
91
  save_invalid: '저장할 내용의 형식이 올바르지 않아요.',
92
+ // 엔트리 채점 설정 (서버 422 VALIDATION_ERROR detail type, elice-material !91)
93
+ save_entry_object: '정답 작품에 없는 오브젝트를 고른 AI 채점 기준이 있어요. 오브젝트를 다시 골라 주세요.',
94
+ save_entry_empty: '정답 작품에 블록이 없어요. 정답으로 인정할 블록을 만들어 주세요.',
95
+ save_entry_project:
96
+ "엔트리 작품을 저장하지 못했어요. AI 채점에는 시작 화면 작품이 있어야 해요. '시작 화면' 탭에서 작품을 만들어 저장해 주세요.",
97
+ // 엔트리 제출 (서버 422, detail reason · type): 작품이 너무 크거나 복잡함 · 엔트리 작품이 아님
98
+ submit_entry_too_large: '작품이 너무 커요. 오브젝트나 블록을 줄여서 다시 제출해 주세요.',
99
+ submit_entry_invalid: '엔트리 작품을 읽지 못해 제출하지 못했어요. 새로고침한 뒤 다시 제출해 주세요.',
92
100
  not_initialized: '아직 준비되지 않았습니다.',
101
+ // 저장 칸 (app.kvstore): 학습자료 × 계정 한도(서버)를 넘음 · 저장 이름(key) 형식이 틀림
102
+ storage_limit_exceeded: '저장할 내용이 너무 커서 저장하지 못했어요.',
103
+ invalid_param: '저장 이름이 올바르지 않습니다.',
93
104
  // 키트만의 코드: Elice 비디오 플레이어 (app.videoPlayer)
94
105
  video_player_unavailable: '동영상을 불러올 수 없습니다.',
95
106
  script_load_failed: '동영상 플레이어를 불러오지 못했어요. 잠시 뒤 다시 시도해 주세요.',
@@ -145,6 +156,16 @@ const SAVE_VALIDATION_MESSAGES = {
145
156
  per_question_too_many_rubrics: 'save_too_many_rubrics',
146
157
  partial_pattern_length_mismatch: 'save_length_mismatch',
147
158
  regex_answer_key_invalid: 'save_regex_invalid',
159
+ entry_rubric_object_not_found: 'save_entry_object',
160
+ entry_answer_project_empty: 'save_entry_empty',
161
+ entry_project_invalid: 'save_entry_project',
162
+ };
163
+
164
+ /** 제출 422: 서버 detail의 reason · type → 문구 (엔트리 작품). 없으면 submit_invalid */
165
+ const SUBMIT_VALIDATION_MESSAGES = {
166
+ project_too_large: 'submit_entry_too_large',
167
+ project_too_complex: 'submit_entry_too_large',
168
+ not_an_entry_project: 'submit_entry_invalid',
148
169
  };
149
170
 
150
171
  /**
@@ -171,6 +192,12 @@ function toContentError(err, action) {
171
192
  if (serverCode === 'MATERIAL_CREDIT_DISABLED' || serverCode === 'MATERIAL_CREDIT_INSUFFICIENT')
172
193
  return new ContentError('grading_credit', MESSAGES.grading_credit, err);
173
194
  // 422 VALIDATION_ERROR: 제출은 채점 설정과 답 모양이 맞지 않음(예: partial_pattern인데 문자열 답), 저장은 detail type별
195
+ // 엔트리 제출 422 (작품이 너무 큼 · 엔트리 작품이 아님): 서버 코드와 상관없이 detail reason · type으로
196
+ const entryKey =
197
+ action === 'submit'
198
+ ? [...reasonsOf(err), ...typesOf(err)].map(t => SUBMIT_VALIDATION_MESSAGES[t]).find(Boolean)
199
+ : undefined;
200
+ if (entryKey) return new ContentError('validation_error', MESSAGES[entryKey], err);
174
201
  if (serverCode === 'VALIDATION_ERROR' && action === 'submit')
175
202
  return new ContentError('validation_error', MESSAGES.submit_invalid, err);
176
203
  if (serverCode === 'VALIDATION_ERROR' && action === 'save') {
@@ -202,7 +229,9 @@ const MATERIAL_PATH = /\/materials\/[0-9a-f-]{36}\//i;
202
229
  * 저장된 채점 설정을 서버 모양(2026-11-11 결정)으로: `{ type: 'pattern', answer_key }` ·
203
230
  * `{ type: 'partial_pattern', answer_key: string[], scores: number[] }` · `{ type: 'rubric', rubric }` ·
204
231
  * `{ type: 'per_question', questions: [{ score, grader: { type: 'pattern', answer_key } | { type: 'rubric', rubric, question? } }], pass_score? }`
205
- * (서버 #65) · 1.11.0 개발 중 제안 `{ type: 'items', items, pass_score? }`(서버는 받지 않음, 퀴즈 편집 화면이 per_question으로 다시 씀).
232
+ * (서버 #65) · 엔트리 템플릿 전용 `{ type: 'entry', mode: 'general' | 'ai', answer_project: { enc, data }, rubrics? }`
233
+ * (일반은 정답 작품과 비교해 0 · 100점, AI는 `rubrics: [{ object, criteria, score }]` 1~10개 · 배점 합 100. rubrics는 ai일 때만 둔다.
234
+ * 모르는 mode는 그대로 둬 서버 422가 보이게) · 1.11.0 개발 중 제안 `{ type: 'items', items, pass_score? }`(서버는 받지 않음, 퀴즈 편집 화면이 per_question으로 다시 씀).
206
235
  * 옛 SDK(G129 해결 전)는 settings 안 키까지 camelCase로 바꿔 answer_key가 answerKey로 왔다. 그 SDK로 빌드한 자료를 위해 둘 다 받는다.
207
236
  * partial_pattern 배열은 복사해 둔다 (값은 그대로, 검사는 validatePartialGrading).
208
237
  * 채점 방식이 아닌 값(옛 on_access · on_submit 등)이면 null
@@ -233,6 +262,19 @@ export function normalizeGrading(grading) {
233
262
  : [],
234
263
  ...(grading.pass_score === undefined ? {} : { pass_score: grading.pass_score }),
235
264
  };
265
+ // 엔트리 채점 (일반 · AI). 정답 작품 · 기준은 복사해 둔다 (값은 그대로, 검사는 서버 · ecdk). rubrics는 ai일 때만
266
+ if (grading.type === 'entry') {
267
+ const project = grading.answer_project;
268
+ const validProject = project && typeof project === 'object' && typeof project.enc === 'string' && typeof project.data === 'string';
269
+ return {
270
+ type: 'entry',
271
+ ...(grading.mode === undefined ? {} : { mode: grading.mode }),
272
+ ...(validProject ? { answer_project: { enc: project.enc, data: project.data } } : {}),
273
+ ...(grading.mode === 'ai'
274
+ ? { rubrics: Array.isArray(grading.rubrics) ? grading.rubrics.map(r => (r && typeof r === 'object' ? { ...r } : r)) : [] }
275
+ : {}),
276
+ };
277
+ }
236
278
  // 1.11.0 개발 중 제안 items (서버는 받지 않음). 읽기만: 항목은 복사해 둔다 (값은 그대로)
237
279
  if (grading.type === 'items')
238
280
  return {
@@ -502,6 +544,14 @@ export async function start(options) {
502
544
  get grading() {
503
545
  return grading;
504
546
  },
547
+ /**
548
+ * entry 채점 방식 'general' · 'ai' (SDK material.gradingMode, 서버 /me grading_mode). 다른 채점 · 편집 화면 · draft ·
549
+ * 옛 서버 · 옛 SDK(1.5.x까지)는 null
550
+ */
551
+ get gradingMode() {
552
+ const mode = sdk.material?.gradingMode;
553
+ return mode === 'general' || mode === 'ai' ? mode : null;
554
+ },
505
555
 
506
556
  /** 답 제출 → 서버 채점 결과 { isCorrect, score } (점수 없는 채점이면 둘 다 null). 보통은 useSubmit을 쓴다 */
507
557
  async submit(answer) {
@@ -537,7 +587,7 @@ export async function start(options) {
537
587
  * settings.grading으로 그대로(배열도 바꾸지 않고) 같이 저장하고,
538
588
  * 주지 않으면 저장된 채점 설정을 그대로 둔다
539
589
  * @param {Record<string, unknown>} next
540
- * @param {{ type: 'pattern' | 'partial_pattern' | 'rubric' | 'per_question', answer_key?: string | string[], scores?: number[], rubric?: string, questions?: object[], pass_score?: number }} [nextGrading]
590
+ * @param {{ type: 'pattern' | 'partial_pattern' | 'rubric' | 'per_question' | 'entry', answer_key?: string | string[], scores?: number[], rubric?: string, questions?: object[], pass_score?: number, mode?: 'general' | 'ai', answer_project?: { enc: string, data: string }, rubrics?: object[] }} [nextGrading]
541
591
  */
542
592
  async saveContent(next, nextGrading) {
543
593
  if (screen !== 'edit')
@@ -554,6 +604,39 @@ export async function start(options) {
554
604
  }
555
605
  },
556
606
 
607
+ /**
608
+ * 보는 사람의 이 자료 저장 칸 (SDK kvstore, 서버가 학습자료 × 계정마다 둠). 진행 중인 작업을 자동 저장할 때 쓴다.
609
+ * key는 점 경로(영문 · 숫자 · `_` · 한글 이름, 예: 'progress.step'), value는 JSON 값.
610
+ * - 튜터링(readOnly)은 보고 있는 학생의 값을 읽기만 한다: post · delete는 ContentError read_only_mode
611
+ * - 편집기 미리보기(isDraft)는 SDK가 메모리에만 둔다 (서버에 남지 않음), mock은 이 브라우저에
612
+ * 오류는 ContentError (storage_limit_exceeded 한도 초과 · rate_limited 너무 잦음 · invalid_param key 형식 등)
613
+ */
614
+ kvstore: Object.freeze({
615
+ async get({ key }) {
616
+ try {
617
+ return (await sdk.kvstore.get({ key })) ?? null;
618
+ } catch (err) {
619
+ throw toContentError(err);
620
+ }
621
+ },
622
+ async post({ key, value }) {
623
+ if (readOnly) throw new ContentError('read_only_mode', MESSAGES.read_only_mode);
624
+ try {
625
+ await sdk.kvstore.post({ key, value });
626
+ } catch (err) {
627
+ throw toContentError(err);
628
+ }
629
+ },
630
+ async delete(key) {
631
+ if (readOnly) throw new ContentError('read_only_mode', MESSAGES.read_only_mode);
632
+ try {
633
+ await sdk.kvstore.delete(key);
634
+ } catch (err) {
635
+ throw toContentError(err);
636
+ }
637
+ },
638
+ }),
639
+
557
640
  /**
558
641
  * 학생 화면의 제출 영역. 화면은 답을 모으고 채우는 방법만 알려 주면, 보는 사람별 처리는 키트가 한다.
559
642
  * - 튜터링: 화면을 읽기 전용으로 잠그고 학생 답을 채움, 제출 버튼 없음
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blank",
3
- "version": "1.2.5",
3
+ "version": "1.2.6",
4
4
  "title": "빈 자료",
5
5
  "description": "퀴즈가 아닌 모든 자료(시뮬레이션 · 시각화 · 활동 · 설명 · 플래시카드 · 설문)를 직접 만들 때. 예제 \"예측하고 확인하기\"(막대 예측 · 정답 보기)와 내용 JSON 편집기(폼 보기 · 코드 보기)로 시작 (완료 정책은 LXP 자료 편집 화면의 '설정'에서 교육자가 고름)"
6
6
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "document",
3
- "version": "1.2.6",
3
+ "version": "1.2.8",
4
4
  "title": "PDF/PPT",
5
5
  "description": "PDF, PPT 문서를 올립니다",
6
6
  "catalog": {
@@ -8,6 +8,7 @@
8
8
  "icon": "pdf",
9
9
  "sortOrder": 10,
10
10
  "thumbnailUrl": "https://static.elice.io/elice-material/custom/templates/document/thumbnail.png",
11
- "previewUrl": "https://static.elice.io/elice-material/custom/templates/document/preview.png"
11
+ "previewUrl": "https://static.elice.io/elice-material/custom/templates/document/preview.png",
12
+ "defaultCompletionPolicy": "on_access"
12
13
  }
13
14
  }
@@ -0,0 +1,117 @@
1
+ # {{name}}
2
+
3
+ Elice Custom HTML 학습자료 프로젝트입니다 (엔트리 템플릿). 엔트리 워크스페이스를 학습자료 안에 iframe으로 띄워 블록 코딩을 합니다.
4
+
5
+ - 편집 화면: 위에서 언어(블록 코딩, 엔트리파이썬)를 고르고, '시작 화면' 탭에서 학생이 처음 볼 작품을, '채점 설정' 탭에서 정답 작품을 만든 뒤 그 아래에서 채점 방식(일반 채점, AI 채점)과 AI 채점 기준을 정해 저장합니다. 작품 아래 줄 오른쪽 칩에 설정 전체 용량(최대 64KB)이 보입니다.
6
+ - 학생 화면: 저장한 작품 또는 시작 화면 작품을 열고, 바뀌면 자동 저장합니다. '제출하기'로 작품을 내면 서버가 채점하고, 아래 줄에 '최종 제출 : 점수 (날짜 시각)'이 보입니다. 일반 채점이면 '올바르게 작성했어요' · '틀렸어요. 다시 해보세요.', AI 채점이면 'AI 채점' 표시와 'AI 피드백 보기'(기준별 피드백)가 보입니다.
7
+
8
+ > **운영 LXP에서는 아직 워크스페이스가 뜨지 않습니다.** 학습자료의 콘텐츠 보안 정책(CSP)이 다른 주소를 iframe으로 띄우지 못하게 막고 있어서, 서버 CSP의 `frame-src`에 워크스페이스 주소(`https://entry-workspace.elice.io`)가 들어가야 뜹니다. 그 전에는 워크스페이스 자리에 "엔트리를 열 수 없습니다" 안내가 보입니다. `ecdk dev`에서는 로컬 워크스페이스로 확인할 수 있습니다 (아래 "로컬에서 확인").
9
+
10
+ ## 고치는 곳
11
+
12
+ | 파일 | 화면 |
13
+ | --- | --- |
14
+ | `screens/learn.js`, `index.html` | 학생 화면 (워크스페이스, 아래 줄: 저장 표시, 채점 결과, 최종 제출 점수와 시각, AI 채점 표시, AI 피드백, 제출하기) |
15
+ | `screens/edit.js`, `edit.html` | 내용 편집 화면. 언어 선택과 탭 카드('시작 화면', '채점 설정')에 패널을 그리고 키트 저장 바로 저장 |
16
+ | `screens/edit/panels/` | 편집 화면 패널. 새 기능은 패널 파일 하나와 `index.js` 목록에 한 줄 |
17
+ | `ui/` | 모양: 크기와 색(`theme.css`), 문구(`texts.js`), 마크업(`templates/`) |
18
+ | `styles.css` | 배치 |
19
+ | `core/workspace.js` | 엔트리 어댑터: 워크스페이스와 나누는 메시지를 모두 여기서 (고치지 않음) |
20
+ | `core/settings.js`, `core/grading.js`, `core/pack.js`, `core/autosave.js` | 저장 모양, 채점 설정 모양, 작품 줄이기, 자동 저장 (고치지 않음) |
21
+ | `docs/storage.md` | 무엇을 어디에 저장하는지 표 |
22
+ | `metadata.json` | 화면 구성(`screens`), 학습 참고 내용(`commentary`). `ecdk build`가 `build`만 채움 |
23
+ | `package.json` | SDK 버전(`@eliceio/cdk`), 빌드 옵션 `"ecdk"`. zip에 들어가지 않음 |
24
+
25
+ 워크스페이스 안(블록, 메뉴, 실행 화면)은 다른 출처의 iframe이라 이 프로젝트에서 바꿀 수 없습니다. 바꿀 수 있는 것은 워크스페이스 바깥 화면과 워크스페이스에 넘기는 작품, 설정입니다.
26
+
27
+ ## 엔트리 어댑터 (`core/workspace.js`)
28
+
29
+ 화면은 어댑터 함수만 씁니다. 나중에 엔트리 엔진을 직접 띄우는 방식으로 바꿔도 같은 함수를 주면 화면 코드는 그대로입니다.
30
+
31
+ ```js
32
+ const ws = connectWorkspace({ mode: 'user', provider, preference });
33
+ stage.append(ws.element); // 붙이면 iframe이 열림
34
+ await ws.ready; // 워크스페이스 준비 끝
35
+ const project = await ws.getProject(); // 지금 작품 JSON
36
+ ws.onChange(() => autosave.schedule()); // 블록이 바뀔 때마다
37
+ ```
38
+
39
+ - `provider`는 워크스페이스가 물을 때 줄 것입니다: `getProject()`(열 작품), `getInitialProject()`(처음부터 다시), `saveProject(project)`(워크스페이스 안 "저장하기").
40
+ - 워크스페이스는 물음마다 답을 받을 때까지 시간 제한 없이 기다립니다. 어댑터는 모든 물음에 답하고, 모르는 물음에는 빈 답을 줍니다.
41
+ - 받은 메시지는 그 iframe에서 워크스페이스 주소로 온 것만 처리하고, 보낼 때도 받는 주소를 정해서 보냅니다.
42
+ - 워크스페이스 주소는 `WORKSPACE_ORIGINS` 한곳에서 정합니다. 운영은 `https://entry-workspace.elice.io`, 로컬(화면 주소가 localhost, 127.0.0.1)은 `http://localhost:9000`입니다. 로컬에서는 주소에 `?entryWorkspace=<주소>`를 붙여 다른 워크스페이스를 쓸 수 있습니다. 다른 환경의 워크스페이스로 시험하려면 `production` 값을 바꿔 빌드합니다 (SDK가 환경을 알려 주지 않아 자동으로 고르지 못함).
43
+ - AI 학습 블록의 데이터 저장은 엘리스 계정 토큰이 필요한데, 학습자료에는 그 토큰이 없어 지금은 쓸 수 없습니다 (토큰 없음으로 답함).
44
+
45
+ ## 자동 저장과 제출
46
+
47
+ 1. 워크스페이스가 블록이 바뀔 때마다 알려 줍니다(`UPDATED_PROJECT`).
48
+ 2. 2초 동안 더 바뀌지 않으면 워크스페이스에 지금 작품을 물어(`TO_GET_PROJECT`) 받고, 줄여서 kvstore `entry`에 저장합니다. 위 줄에 "저장 중", "저장됨 시각"이 보입니다.
49
+ 3. 워크스페이스 안 "저장하기"는 받은 작품을 바로 같은 칸에 저장합니다.
50
+ 4. 다시 열면 kvstore의 작품, 없으면 시작 작품, 그것도 없으면 엔트리 기본 작품(`core/default-project.js`)을 엽니다. 워크스페이스는 "작품 없음"을 받지 못해(빈 답이면 "불러오기에 실패하였습니다" 창) 어댑터가 기본 작품을 줍니다.
51
+ 5. 제출 버튼은 지금 작품을 받아 줄인 뒤 `{ v: 1, project }`로 제출합니다. 64KB를 넘으면 막고 안내합니다.
52
+
53
+ - 튜터링(보기 전용)은 학생이 저장한 작품을 보여 주고 저장, 제출하지 않습니다. 편집기 미리보기는 저장하지 않습니다.
54
+ - 블록 위치만 옮기는 것처럼 파이썬 코드가 그대로인 변경은 워크스페이스가 알리지 않아 다음 변경 때 함께 저장됩니다.
55
+ - 파이썬 모드에서 코드에 문법 오류가 있으면 워크스페이스가 작품을 주지 않습니다. 그때는 저장, 제출이 실패로 표시됩니다.
56
+ - 창을 닫을 때 기다리던 저장은 바로 시도하지만, 끝나기 전에 닫히면 마지막 몇 초가 빠질 수 있습니다.
57
+
58
+ 저장 위치와 한도는 [`docs/storage.md`](docs/storage.md) 표에 있습니다.
59
+
60
+ ## 채점과 학습 완료
61
+
62
+ 편집 화면 '채점 설정' 탭에서 저장한 채점 설정(`settings.grading`)으로 서버가 채점합니다. 정답 작품과 기준은 학생 화면에 내려가지 않습니다.
63
+
64
+ - 일반 채점: 정답 작품과 비교해 0점 또는 100점. 학생 화면에 '올바르게 작성했어요' · '틀렸어요. 다시 해보세요.'(LXP 문구). 정답 작품에 블록(또는 전역 리스트)이 하나도 없으면 저장을 막습니다 (아무도 100점을 받을 수 없음, 서버도 422 `entry_answer_project_empty`).
65
+ - AI 채점: 기준(오브젝트, 채점 기준, 부분 점수)마다 AI가 부분 점수를 줍니다. 기준은 1~10개, 부분 점수는 1~100 정수이고 합이 100점이어야 저장됩니다. '자동 배점'은 기준 수로 100점을 정수로 나눠 채웁니다 (나머지는 마지막 기준에, 예: 3개면 33 · 33 · 34). 저장을 눌렀을 때 빈 칸이나 총점 문제는 칸 아래에 빨간 글로 보입니다. 오브젝트 목록은 **정답 작품**의 오브젝트이고(정답 작품은 시작 화면을 복사해 시작하므로 학생 작품과 같은 id), 기준마다 오브젝트를 하나 골라야 합니다. 작품 전체("공통") 기준은 없습니다: 고르지 않았거나 정답 작품에 없는 오브젝트면 저장을 막습니다(서버도 422 `entry_rubric_object_not_found`). AI 채점은 시작 화면 작품도 있어야 저장됩니다(서버 422 `entry_project_invalid`). 학생 화면은 'AI 채점' 표시, 제출 뒤 "AI가 채점하고 있습니다. 최대 45초 걸릴 수 있습니다."를 보여 줍니다.
66
+ - AI 채점 자료에서 저장했던 시작 화면을 바꾸면 '시작 화면' 탭에 경고가 보입니다 (막지 않음). 이미 공개한 자료면 학생 작품이 바뀐 시작 화면과 같을 때 '아직 풀지 않음'(0점)이 되고, 이미 시작한 학생은 옛 화면에서 출발해 채점이 틀릴 수 있습니다. SDK가 공개 여부를 알려 주지 않아 시작 화면을 저장한 적이 있으면 보입니다.
67
+ - '채점 설정' 탭을 처음 열면 정답 작품 워크스페이스가 저장된 정답, 없으면 지금 시작 화면 작품으로 열립니다. 탭을 열지 않은 새 자료는 채점 설정 없이 저장되고(점수 '--'), AI 채점은 정답 작품이 있어야 저장됩니다.
68
+ - 서버가 저장을 거절하면(422) 키트가 서버 코드를 한국어 문구로 보여 줍니다. 제출이 너무 크거나 복잡하면(422 `project_too_large` · `project_too_complex`) "작품이 너무 커요…", AI 채점 실패(502) · 크레딧 없음(409)은 키트 문구입니다.
69
+ - 학생 화면이 채점 방식을 아는 방법: `app.gradingMode`(SDK `material.gradingMode`, 서버 `/me` `grading_mode`). 이 값을 주지 않는 SDK에서는 'AI 채점' 표시 · 기다림 문구를 보이지 않고, 일반 채점 문구는 제출 결과의 `gradingFeedback`이 일반 모양(`criteria: []`)일 때만 보입니다.
70
+ - `ecdk dev`의 채점은 흉내입니다: 일반은 작품 글자가 정답과 같을 때만 100점, AI는 작품 크기로 낸 점수와 흉내 피드백입니다.
71
+
72
+ 학습 완료는 교육자가 LXP 편집 페이지 위쪽 '설정' 패널에서 고릅니다: 채점해 통과하면 완료(on_graded, 화면 이름 '답안 확인 후 완료') 또는 제출 시 학습 완료(on_submit). 채점 점수로 완료하려면 '답안 확인 후 완료'여야 합니다 ('채점 설정' 탭에도 안내). publish 스킬이 동의를 받아 업로드 때 정할 수도 있습니다.
73
+
74
+ ## 샌드박스에서 안 되는 것
75
+
76
+ 학습자료는 LXP 안에서 제한된 iframe(sandbox)으로 열리고, 그 안에 띄운 워크스페이스도 같은 제한을 받습니다. 지금 LXP 엔트리는 이 제한 밖에서 돌아서 생기지 않던 일입니다.
77
+
78
+ LXP 학습자료 iframe에 `allow-downloads` · `allow-popups` · `allow-modals`가 들어간 LXP에서는 `.ent` 내려받기 · 오브젝트 내보내기 · 확인 창 · 도움말 새 창은 됩니다. `ecdk dev`는 아직 예전 sandbox라 여기서는 막힐 수 있습니다. 남은 제한:
79
+
80
+ | 기능 | 결과 | 필요한 것 |
81
+ | --- | --- | --- |
82
+ | AI 채점 기준의 오브젝트 그림 (편집 화면) | 빈 칸으로 보임 (워크스페이스 출처 그림을 콘텐츠 CSP `img-src`가 막아 띄우지 않음) | 서버 CSP `img-src`에 워크스페이스 출처 |
83
+ | 카메라, 마이크 같은 기기 권한 | LXP가 학습자료 iframe에 준 권한까지만 | LXP iframe `allow` |
84
+
85
+ ## 저장 모양 (`settings`)
86
+
87
+ ```js
88
+ {
89
+ entry: {
90
+ startProject: { enc: 'gzip+base64', data: '...' }, // 시작 화면 작품
91
+ preference: { workspaceMode: 'block' }, // 언어 선택: 'block' 또는 'python'
92
+ },
93
+ grading: { type: 'entry', mode: 'ai', answer_project: { enc, data }, rubrics: [{ object: 'ik8o', criteria: '...', score: 100 }] }, // 학생에게 안 감
94
+ }
95
+ ```
96
+
97
+ - 다른 키(예: AI나 MCP가 넣은 것)는 저장 때 그대로 둡니다. 학생에게도 내려가므로 비밀 값을 넣지 않습니다.
98
+ - `ecdk dev`의 내용 편집에서 저장한 것은 `.ecdk/settings.json`에 남습니다 (zip에는 들어가지 않음). 기본으로는 로컬에만 있고, publish 스킬로 올릴 때 동의하면 업로드와 함께 보냅니다.
99
+ - 편집 화면에서 아직 저장하지 않았으면 학생 화면은 "학습 자료를 준비하고 있어요" 안내를 보입니다.
100
+
101
+ 교육자 화면은 없습니다 (`metadata.json` `screens.instructor.enabled: false`). LXP에서 교육자가 열면 학생 화면이 열립니다.
102
+
103
+ `lib/`(화면 키트)는 플랫폼 연결 로직이라 고치지 않습니다. SDK는 `package.json` 의존성(`@eliceio/cdk`)이고 키트가 import하며, `ecdk build`(Vite)가 화면 코드와 함께 번들로 묶습니다 (처음 한 번 `npm install`, 올리기 `npm update @eliceio/cdk`).
104
+
105
+ ## 로컬에서 확인
106
+
107
+ 1. 엔트리 워크스페이스를 `http://localhost:9000`에 띄웁니다 (워크스페이스 저장소의 안내대로).
108
+ 2. 이 프로젝트에서 `ecdk dev`를 엽니다. `ecdk dev`는 콘텐츠 CSP `frame-src`에 `http://localhost:9000`을 더해 줍니다 (운영 CSP에는 없음).
109
+ 3. 내용 편집에서 작품을 만들고 저장한 뒤 학생 화면에서 엽니다.
110
+
111
+ ## 명령
112
+
113
+ ```sh
114
+ ecdk dev # 로컬에서 보기 (로컬 워크스페이스 필요)
115
+ ecdk doctor # 환경, 프로젝트 점검
116
+ ecdk build # 검사 후 dist/content.zip (편집 화면에 올릴 파일)
117
+ ```
@@ -0,0 +1,2 @@
1
+ 엔트리로 블록 코딩(또는 엔트리파이선)을 하는 실습 자료입니다. 무엇을 만들어야 하는지, 꼭 써야 하는 블록과 완성 기준을 적어 주세요.
2
+ 실습 내용을 바꾸면 이 파일도 이 자료에 맞게 고쳐 주세요. zip 안 파일이라 학생도 읽을 수 있습니다.
@@ -0,0 +1,13 @@
1
+ // core/autosave.js 타입 (편집기 자동완성 · 테스트용)
2
+ export type AutosaveState = 'idle' | 'pending' | 'saving' | 'saved' | 'error';
3
+
4
+ export declare function createAutosave(options: {
5
+ save: () => Promise<void>;
6
+ delayMs?: number;
7
+ onState?: (state: AutosaveState, info: { error?: unknown; at?: Date }) => void;
8
+ }): {
9
+ readonly state: AutosaveState;
10
+ schedule(): void;
11
+ flush(): Promise<void>;
12
+ saveNow(): Promise<void>;
13
+ };