@eliceio/cdk-cli 0.1.0-alpha.4 → 0.1.0-alpha.6

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 (107) hide show
  1. package/README.md +215 -152
  2. package/es/cli.js +65 -66
  3. package/es/commands/build/index.d.ts +1 -1
  4. package/es/commands/build/index.js +20 -7
  5. package/es/commands/create/index.d.ts +1 -1
  6. package/es/commands/create/index.js +5 -9
  7. package/es/commands/dev/index.d.ts +1 -1
  8. package/es/commands/dev/index.js +5 -5
  9. package/es/commands/doctor/index.d.ts +18 -1
  10. package/es/commands/doctor/index.js +137 -27
  11. package/es/commands/mcp/index.d.ts +0 -12
  12. package/es/commands/mcp/index.js +6 -57
  13. package/es/commands/setup/index.d.ts +11 -3
  14. package/es/commands/setup/index.js +112 -37
  15. package/es/commands/skill/index.d.ts +46 -8
  16. package/es/commands/skill/index.js +151 -35
  17. package/es/commands/uninstall/index.d.ts +54 -0
  18. package/es/commands/uninstall/index.js +304 -0
  19. package/es/commands/update/index.d.ts +59 -0
  20. package/es/commands/update/index.js +251 -0
  21. package/es/commands/{check → validate}/index.d.ts +1 -1
  22. package/es/commands/{check → validate}/index.js +1 -1
  23. package/es/core/collect.js +1 -1
  24. package/es/core/config.d.ts +20 -37
  25. package/es/core/config.js +36 -89
  26. package/es/core/latest.d.ts +21 -0
  27. package/es/core/latest.js +43 -0
  28. package/es/core/prepare.js +4 -3
  29. package/es/core/project-check.d.ts +2 -2
  30. package/es/core/project-check.js +2 -2
  31. package/es/core/sandbox.js +6 -3
  32. package/es/core/templates.d.ts +1 -3
  33. package/es/core/templates.js +1 -4
  34. package/es/dev/grading.d.ts +7 -8
  35. package/es/dev/grading.js +6 -16
  36. package/es/dev/host-page.d.ts +1 -1
  37. package/es/dev/host-page.js +29 -12
  38. package/es/dev/inject.d.ts +6 -0
  39. package/es/dev/inject.js +16 -1
  40. package/es/dev/mock-api.d.ts +8 -12
  41. package/es/dev/mock-api.js +50 -81
  42. package/es/dev/server.d.ts +4 -2
  43. package/es/dev/server.js +18 -29
  44. package/es/rules/check.js +80 -41
  45. package/es/rules/csp.d.ts +26 -0
  46. package/es/rules/csp.js +42 -0
  47. package/es/rules/index.d.ts +2 -1
  48. package/es/rules/index.js +2 -1
  49. package/es/rules/manifest.d.ts +28 -20
  50. package/es/rules/manifest.js +58 -55
  51. package/es/rules/refs.d.ts +12 -2
  52. package/es/rules/refs.js +50 -18
  53. package/es/rules/types.d.ts +6 -13
  54. package/es/rules.json.js +2 -2
  55. package/package.json +2 -3
  56. package/rules.json +48 -57
  57. package/skills/_shared/always.md +5 -4
  58. package/skills/elice-content-check/SKILL.md +10 -9
  59. package/skills/elice-content-create/SKILL.md +7 -7
  60. package/skills/elice-content-guide/SKILL.md +42 -0
  61. package/skills/elice-content-guide/topics/00-what-the-person-decides.md +11 -0
  62. package/skills/elice-content-guide/topics/01-check-the-environment.md +10 -0
  63. package/skills/elice-content-guide/topics/02-design-the-material.md +35 -0
  64. package/skills/elice-content-guide/topics/03-create-the-project.md +22 -0
  65. package/skills/elice-content-guide/topics/04-rules.md +14 -0
  66. package/skills/elice-content-guide/topics/05-screen-code.md +101 -0
  67. package/skills/elice-content-guide/topics/06-using-the-quiz-template.md +22 -0
  68. package/skills/elice-content-guide/topics/07-move-existing-html.md +10 -0
  69. package/skills/elice-content-guide/topics/08-fix-check-errors.md +27 -0
  70. package/skills/elice-content-guide/topics/09-check.md +11 -0
  71. package/skills/elice-content-guide/topics/10-build.md +8 -0
  72. package/skills/elice-content-guide/topics/11-more.md +4 -0
  73. package/skills/elice-content-guide/topics/12-upload-with-the-material-mcp.md +41 -0
  74. package/skills/elice-content-migrate/SKILL.md +10 -8
  75. package/skills/elice-content-publish/SKILL.md +8 -8
  76. package/templates/_shared/lib/cdk-mock.d.ts +5 -13
  77. package/templates/_shared/lib/cdk-mock.js +41 -136
  78. package/templates/_shared/lib/elice-content.css +81 -1
  79. package/templates/_shared/lib/elice-content.d.ts +6 -37
  80. package/templates/_shared/lib/elice-content.js +23 -236
  81. package/templates/blank/README.md +5 -6
  82. package/templates/blank/metadata.json +1 -3
  83. package/templates/blank/package.json +2 -2
  84. package/templates/blank/screens/edit.js +1 -1
  85. package/templates/blank/template.json +2 -2
  86. package/templates/quiz/README.md +4 -4
  87. package/templates/quiz/core/behaviors.js +4 -1
  88. package/templates/quiz/core/editor.d.ts +11 -9
  89. package/templates/quiz/core/editor.js +32 -32
  90. package/templates/quiz/core/model.js +3 -3
  91. package/templates/quiz/metadata.json +1 -3
  92. package/templates/quiz/package.json +2 -2
  93. package/templates/quiz/screens/edit.js +121 -29
  94. package/templates/quiz/screens/learn.js +5 -2
  95. package/templates/quiz/styles.css +96 -37
  96. package/templates/quiz/template.json +2 -2
  97. package/templates/quiz/ui/templates/edit.d.ts +4 -0
  98. package/templates/quiz/ui/templates/edit.js +69 -19
  99. package/templates/quiz/ui/templates/group.js +10 -2
  100. package/templates/quiz/ui/templates/page.js +1 -2
  101. package/templates/quiz/ui/templates/text.js +10 -7
  102. package/templates/quiz/ui/texts.js +14 -12
  103. package/es/commands/guide/index.d.ts +0 -29
  104. package/es/commands/guide/index.js +0 -120
  105. package/guides/content-development.md +0 -302
  106. package/templates/blank/completion.html +0 -15
  107. package/templates/blank/screens/completion.js +0 -7
@@ -4,7 +4,6 @@
4
4
  * 화면은 누가 보는지(학생 · 교육자 · 튜터)나 미리보기인지 몰라도 됩니다.
5
5
  * 학생 화면: app.useSubmit({ getAnswer, setAnswer, validate })
6
6
  * 편집 화면: app.useSave({ getContent, getGrading, validate }) · 채점 방식과 답: app.useGradingBlock() (퀴즈가 아닌 자료)
7
- * 완료 정책 화면: app.useCompletion() (metadata completionPolicies 안에서 고르고 SDK saveCompletionPolicy로 저장)
8
7
  * 여러 단계: app.usePaging({ count, onChange }) (옆 화살표 · n / N, 첫 · 마지막 단계에서 이전 · 다음 자료)
9
8
  * 읽기 전용 잠금, 답 복원, 결과·오류 안내, 저장 문구, 로컬 mock 표시는 키트가 합니다.
10
9
  *
@@ -12,7 +11,8 @@
12
11
  * 제출 · 저장 · 오류 안내를 처리합니다. SDK는 둘 중 하나를 자동으로 고릅니다.
13
12
  *
14
13
  * real lib/cdk.js (@eliceio/cdk 1.x) 플랫폼에서 열 때 (#token=, 편집기 #preview=1 · #edit=1)
15
- * 편집 화면은 edit 토큰으로 열려 '저장'이 서버에 바로 저장
14
+ * 편집 화면은 edit 토큰으로 열려 '저장'이 자료의 draft에 저장.
15
+ * 학생에게는 LXP 편집 페이지의 '저장'(새 버전)부터 보임
16
16
  * mock lib/cdk-mock.js (같은 인터페이스) 그 밖 (로컬): 로컬 채점, 화면 사이 저장 공유
17
17
  *
18
18
  * 바꾸기: 주소에 ?sdk=mock 또는 ?sdk=real, 또는 start({ screen, sdk: 'mock' })
@@ -27,9 +27,8 @@
27
27
  *
28
28
  * 정답은 콘텐츠(zip)에 넣지 않습니다. 채점은 서버가 채점 설정(settings.grading)으로 합니다 (ADR 0009).
29
29
  * 채점 설정 { type: pattern | rubric, answer_key | rubric }은 편집 화면이 edit 토큰으로 저장하고, 서버는 학생에게
30
- * settings.grading을 내려주지 않습니다. 완료 정책(on_access · on_submit · on_graded)은 settings가 아니라
31
- * material_version.completion_policy입니다: 자료가 지원하는 정책은 metadata completionPolicies(서버가 첫 값으로 정함)이고,
32
- * 완료 정책 화면이 그 안에서 SDK saveCompletionPolicy로 바꿉니다 (키트 app.completion.get() · set()).
30
+ * settings.grading을 내려주지 않습니다. 완료 정책(on_access · on_submit · on_graded)은 콘텐츠가 다루지 않습니다:
31
+ * LXP에 올린 뒤 설정 탭에서 교육자가 고릅니다 (ADR 0012).
33
32
  */
34
33
 
35
34
  /**
@@ -42,7 +41,6 @@ const SCREEN_ALLOWED = {
42
41
  instructor: sdk =>
43
42
  (sdk.screen === 'learn' || sdk.screen === 'instructor') && sdk.viewer === 'instructor',
44
43
  edit: sdk => sdk.screen === 'edit',
45
- completionPolicy: sdk => sdk.screen === 'completionPolicy',
46
44
  };
47
45
 
48
46
  const MESSAGES = {
@@ -62,8 +60,9 @@ const MESSAGES = {
62
60
  // 서버 코드: 채점 설정(settings.grading) 없이 채점해 완료(on_graded)를 고름
63
61
  material_grading_required:
64
62
  '채점 방식과 답이 아직 없어 채점해 통과하면 완료로 바꿀 수 없어요. 내용 편집에서 답을 먼저 저장해 주세요.',
65
- // 서버 코드 (SDK request_failed의 cause): 편집하는 사이 다른 곳에서 자료를 저장함
66
- material_changed: '그 사이 다른 곳에서 자료가 저장됐어요. 새로고침한 뒤 다시 편집해 주세요.',
63
+ // 서버 코드 (SDK content_not_ready의 cause): 업로드한 draft를 아직 처리 중이거나 처리에 실패함 (409)
64
+ material_draft_not_ready:
65
+ '업로드한 자료를 아직 처리하고 있거나 처리하지 못했어요. 잠시 뒤 다시 저장하고, 계속되면 자료를 다시 올려 주세요.',
67
66
  not_initialized: '아직 준비되지 않았습니다.',
68
67
  request_failed: '서버와 연결하지 못했습니다. 잠시 뒤 다시 시도해 주세요.',
69
68
  // 키트만의 코드: 자료 주소인데 접속 토큰이 없음 (새로고침 · 다른 HTML로 이동하면 SDK가 지운 토큰이 남지 않는다)
@@ -87,10 +86,10 @@ export class ContentError extends Error {
87
86
  /** SDK 오류를 화면이 그대로 보여 줄 수 있는 한국어 메시지로 */
88
87
  function toContentError(err) {
89
88
  if (err instanceof ContentError) return err;
90
- // 서버 오류 코드는 SDK 오류(request_failed)의 cause.cause.code에 있다 (예: 409 MATERIAL_CHANGED)
89
+ // 서버 오류 코드는 SDK 오류의 cause.cause.code에 있다 (예: 409 MATERIAL_DRAFT_NOT_READY → SDK content_not_ready)
91
90
  const serverCode = err?.cause?.cause?.code;
92
- if (serverCode === 'MATERIAL_CHANGED')
93
- return new ContentError('material_changed', MESSAGES.material_changed, err);
91
+ if (serverCode === 'MATERIAL_DRAFT_NOT_READY')
92
+ return new ContentError('material_draft_not_ready', MESSAGES.material_draft_not_ready, err);
94
93
  if (serverCode === 'MATERIAL_GRADING_REQUIRED')
95
94
  return new ContentError('material_grading_required', MESSAGES.material_grading_required, err);
96
95
  const code = typeof err?.code === 'string' ? err.code : 'request_failed';
@@ -115,54 +114,16 @@ export function normalizeGrading(grading) {
115
114
  return null;
116
115
  }
117
116
 
118
- /** 완료 정책 값 (서버 material_version.completion_policy) */
119
- const POLICY_VALUES = Object.freeze(['on_access', 'on_submit', 'on_graded']);
120
-
121
- /**
122
- * 완료 정책 읽기 · 바꾸기. 지금 값은 SDK material.completionPolicy, 지원하는 정책은 material.completionPolicies
123
- * (metadata completionPolicies. 서버가 아직 돌려주지 않으면 null, G132), 저장은 SDK saveCompletionPolicy
124
- * (PATCH completion_policy, 완료 정책 화면에서만). 값 이름은 서버와 같은 completion_policy
125
- * @returns {{ readonly policies: string[] | null, get(): Promise<{ completion_policy: string | null, policies: string[] | null }>, set(policy: string): Promise<void> }}
126
- */
127
- function completionApi(sdk) {
128
- const listed = () => {
129
- const policies = sdk.material?.completionPolicies;
130
- return Array.isArray(policies) && policies.length > 0 ? policies : null;
131
- };
132
- return {
133
- get policies() {
134
- return listed();
135
- },
136
- async get() {
137
- return { completion_policy: sdk.material?.completionPolicy ?? null, policies: listed() };
138
- },
139
- async set(policy) {
140
- const policies = listed() ?? POLICY_VALUES;
141
- if (!policies.includes(policy))
142
- throw new ContentError(
143
- 'invalid_input',
144
- `이 자료가 지원하지 않는 완료 정책입니다: ${policy} (가능: ${policies.join(', ')})`
145
- );
146
- try {
147
- await sdk.saveCompletionPolicy(policy);
148
- } catch (err) {
149
- throw toContentError(err);
150
- }
151
- },
152
- };
153
- }
154
-
155
117
  /** 로컬 mock에서 화면별 기본 fragment (보는 사람 · 설정 화면) */
156
118
  const LOCAL_MOCK_HASH = {
157
119
  learn: '',
158
120
  instructor: 'viewer=instructor',
159
121
  edit: 'scope=edit',
160
- completionPolicy: 'scope=edit&screen=completionPolicy',
161
122
  };
162
123
 
163
- /** 토큰 없는 draft: 편집기 미리보기 · 편집 화면 · 완료 정책 화면 */
164
- const DRAFT_HASH = /(?:^#|&)(?:preview|edit|completionPolicy)=1/;
165
- const LAUNCH_HASH = /(?:^#|&)(?:token|preview|edit|completionPolicy)=/;
124
+ /** 토큰 없는 draft: 편집기 미리보기 · 편집 화면 */
125
+ const DRAFT_HASH = /(?:^#|&)(?:preview|edit)=1/;
126
+ const LAUNCH_HASH = /(?:^#|&)(?:token|preview|edit)=/;
166
127
 
167
128
  const isLoopback = h => h === 'localhost' || h === '127.0.0.1' || h === '[::1]';
168
129
 
@@ -185,7 +146,7 @@ export function pickSdk({ hash, pathname, search, hostname = '' }) {
185
146
 
186
147
  /** mock: 주소에 보는 사람 · 미리보기 · 설정 화면이 없으면 화면에 맞게 */
187
148
  function mockLaunch(hash, screen) {
188
- if (/(?:^#|&)(?:viewer|preview|edit|completionPolicy|scope)=/.test(hash))
149
+ if (/(?:^#|&)(?:viewer|preview|edit|scope)=/.test(hash))
189
150
  return { hash, pathname: '/', local: true };
190
151
  const parts = [LOCAL_MOCK_HASH[screen], hash.replace(/^#/, '')].filter(Boolean);
191
152
  return { hash: parts.length ? `#${parts.join('&')}` : '', pathname: '/', local: true };
@@ -238,12 +199,7 @@ export function resolveLaunch(hash, pathname, screen) {
238
199
  return { hash, pathname: local ? LOCAL_MATERIAL_PATH : pathname, local };
239
200
  }
240
201
  return {
241
- hash:
242
- screen === 'edit'
243
- ? '#edit=1'
244
- : screen === 'completionPolicy'
245
- ? '#completionPolicy=1'
246
- : '#preview=1',
202
+ hash: screen === 'edit' ? '#edit=1' : '#preview=1',
247
203
  pathname: LOCAL_MATERIAL_PATH,
248
204
  local: true,
249
205
  };
@@ -251,7 +207,7 @@ export function resolveLaunch(hash, pathname, screen) {
251
207
 
252
208
  /**
253
209
  * @typedef {object} StartOptions
254
- * @property {'learn' | 'instructor' | 'edit' | 'completionPolicy'} screen 이 HTML이 어떤 화면인지
210
+ * @property {'learn' | 'instructor' | 'edit'} screen 이 HTML이 어떤 화면인지
255
211
  * @property {(error: ContentError) => void} [onError] 화면 밖 오류(세션 만료 등)를 받을 함수. 기본은 상단 알림
256
212
  * @property {'real' | 'mock' | object} [sdk] SDK 고르기 (기본: pickSdk). 객체면 그대로 씀 (테스트)
257
213
  * @property {object} [mock] mock 옵션 (scenario, grading, settings, delayMs)
@@ -346,7 +302,7 @@ export async function start(options) {
346
302
  viewer,
347
303
  /** 튜터가 학생 화면을 보는 중 */
348
304
  readOnly,
349
- /** 편집기가 토큰 없이 연 draft (#preview=1 · #edit=1). 서버에 아무것도 저장하지 않음 */
305
+ /** 편집기의 draft 미리보기 (#preview=1, edit 토큰이 있으면 draft의 내용을 읽음) · 저장 전 업로드의 편집 화면 (#edit=1). 제출을 기록하지 않음 */
350
306
  isDraft: Boolean(sdk.isDraft),
351
307
  /** 수업 페이지 이동 (previous · next · navigate · getHasPrevious · getHasNext) */
352
308
  navigation: sdk.navigation ?? null,
@@ -410,7 +366,8 @@ export async function start(options) {
410
366
  },
411
367
 
412
368
  /**
413
- * 내용 저장 (편집 화면): SDK saveSettings가 edit 토큰으로 서버에 바로 저장한다. 보통은 useSave를 쓴다.
369
+ * 내용 저장 (편집 화면): SDK saveSettings가 edit 토큰으로 자료의 draft에 저장한다. 학생에게는 LXP 편집 페이지에서
370
+ * 저장(새 버전)한 뒤 보인다. 보통은 useSave를 쓴다.
414
371
  * nextGrading(채점 설정 `{ type, answer_key | rubric }`)을 주면 settings.grading으로 같이 저장하고,
415
372
  * 주지 않으면 저장된 채점 설정을 그대로 둔다
416
373
  * @param {Record<string, unknown>} next
@@ -431,13 +388,6 @@ export async function start(options) {
431
388
  }
432
389
  },
433
390
 
434
- /**
435
- * 완료 정책 (on_access · on_submit · on_graded). settings가 아니라 material_version.completion_policy:
436
- * policies는 metadata completionPolicies, set은 SDK saveCompletionPolicy (완료 정책 화면에서만).
437
- * 보통은 완료 정책 화면에서 useCompletion을 쓴다
438
- */
439
- completion: completionApi(sdk),
440
-
441
391
  /**
442
392
  * 학생 화면의 제출 영역. 화면은 답을 모으고 채우는 방법만 알려 주면, 보는 사람별 처리는 키트가 한다.
443
393
  * - 튜터링: 화면을 읽기 전용으로 잠그고 학생 답을 채움, 제출 버튼 없음
@@ -467,16 +417,6 @@ export async function start(options) {
467
417
  return mountGradingBlock(app, opts ?? {});
468
418
  },
469
419
 
470
- /**
471
- * 완료 정책 화면 (LXP 설정 탭의 완료 정책 영역, ADR 0009). 정책 라디오 · 저장 버튼 · 변경 표시를 키트가 한다.
472
- * metadata completionPolicies 안의 정책만 보이고, 저장은 app.completion.set (SDK saveCompletionPolicy).
473
- * completionPolicies가 하나(고정)인 자료는 이 화면을 두지 않는다
474
- * @param {CompletionOptions} [opts]
475
- */
476
- useCompletion(opts) {
477
- return mountCompletion(app, opts ?? {});
478
- },
479
-
480
420
  /**
481
421
  * 자료 안 여러 단계 이동. 내용 양옆 동그란 화살표 + 안쪽 `n / N` 표시.
482
422
  * 첫 단계의 왼쪽 · 마지막 단계의 오른쪽은 LXP 이전 · 다음 수업 자료로 가는 버튼(모양이 다름)이 되고,
@@ -529,7 +469,6 @@ const appRoot = root => root ?? document.getElementById('app') ?? document.body;
529
469
  export function statusText(app) {
530
470
  if (app.sdkKind !== 'mock') return '';
531
471
  if (app.screen === 'edit') return 'mock SDK · 저장 내용은 이 브라우저에만';
532
- if (app.screen === 'completionPolicy') return 'mock SDK · 완료 정책은 이 브라우저에만';
533
472
  const parts = ['mock SDK · 로컬 채점, 서버에 저장되지 않음'];
534
473
  if (app.viewer === 'tutor')
535
474
  parts.push(`튜터링 · ${app.account?.fullname ?? '학생'}의 화면 (읽기 전용)`);
@@ -731,7 +670,8 @@ function mountSave(app, { getContent, getGrading, validate, root, label = '저
731
670
  let dirty = false;
732
671
  const markDirty = () => {
733
672
  dirty = true;
734
- // 이제 이 버튼이 실제 저장이라 (LXP 하단 저장은 settings를 저장하지 않음) 저장 전 상태는 이 문구가 유일한 안내
673
+ // settings는 이 버튼만 저장한다 (LXP 하단 저장은 draft를 새 버전으로 낼 뿐, 화면 안 내용을 가져가지 않음).
674
+ // 그래서 저장 전 상태는 이 문구가 유일한 안내
735
675
  status.textContent = '저장하지 않은 변경이 있어요.';
736
676
  };
737
677
  area.addEventListener('input', markDirty);
@@ -754,11 +694,11 @@ function mountSave(app, { getContent, getGrading, validate, root, label = '저
754
694
  if (dirty) e.preventDefault();
755
695
  });
756
696
 
757
- // 실제 SDK의 saveSettings는 edit 토큰으로 서버에 바로 저장한다 (새 버전, 학생 화면에 바로 반영)
697
+ // 실제 SDK의 saveSettings는 edit 토큰으로 자료의 draft에 저장한다. 학생에게는 LXP 편집 페이지의 저장(새 버전)부터 보인다
758
698
  const savedText = () =>
759
699
  app.sdkKind === 'mock'
760
700
  ? '저장했어요 (mock · 이 브라우저에만).'
761
- : '저장했어요. 학생 화면에 반영됩니다.';
701
+ : "저장했어요. 학생에게는 편집 페이지에서 '저장'을 누르면 반영됩니다.";
762
702
 
763
703
  button.addEventListener('click', async () => {
764
704
  const next = getContent();
@@ -803,31 +743,6 @@ function mountSave(app, { getContent, getGrading, validate, root, label = '저
803
743
  * @property {Element} [root] 블록을 넣을 곳 (기본: 화면 영역 #app 바로 뒤)
804
744
  */
805
745
 
806
- /**
807
- * @typedef {object} CompletionOptions
808
- * @property {Array<'on_access' | 'on_submit' | 'on_graded'>} [policies] 고를 수 있는 완료 정책
809
- * (기본 metadata completionPolicies, 서버가 주지 않으면 셋 다)
810
- * @property {Element} [root] 넣을 곳 (기본: 화면 영역 #app을 이 영역으로 채움)
811
- * @property {string} [label] 버튼 글자 (기본 '저장')
812
- */
813
-
814
- /** 완료 정책 문구 (ADR 0009). 열람 · 제출은 LXP 설정 탭 문구 그대로 (qa5 2026-11-10) */
815
- export const COMPLETION_POLICIES = Object.freeze({
816
- on_access: {
817
- label: '열람 시 학습 완료',
818
- description: "자료를 열면 학습 완료로 처리됩니다. 학생 화면에는 점수 대신 '완료'로 표시됩니다.",
819
- },
820
- on_submit: {
821
- label: '제출 시 학습 완료',
822
- description:
823
- "답과 관계없이 제출하면 학습 완료로 처리됩니다. 학생 화면에는 점수 대신 '완료'로 표시됩니다.",
824
- },
825
- on_graded: {
826
- label: '채점해 통과하면 학습 완료',
827
- description:
828
- '제출한 답을 편집 화면에서 정한 채점 방식으로 채점하고, 통과하면 학습 완료로 처리됩니다.',
829
- },
830
- });
831
746
 
832
747
  /** 채점 방식 문구 (settings.grading.type, LXP 설정 탭 문구 그대로) */
833
748
  export const GRADER_TYPES = Object.freeze({
@@ -862,14 +777,6 @@ const GRADING_TEXT = {
862
777
  emptyRubric: '평가 기준을 입력해 주세요.',
863
778
  };
864
779
 
865
- const COMPLETION_TEXT = {
866
- heading: '완료 정책',
867
- headingHelp: '학습 완료를 언제 기록할지 고릅니다: 열면, 제출하면, 채점해 통과하면.',
868
- grader: name => `채점 방식: ${name} (편집 화면에서 정함)`,
869
- noGrader: '채점 방식과 답이 아직 없습니다. 편집 화면에서 먼저 정해 주세요.',
870
- loading: '완료 정책을 불러오는 중…',
871
- };
872
-
873
780
  /** 정답 정규식 길이 상한 (서버에 보내는 값, 너무 긴 정규식은 막는다) */
874
781
  export const ANSWER_KEY_MAX = 5000;
875
782
  /** 정답 정규식 한 번 맞춰 보는 시간 상한(ms). 넘으면 ReDoS 위험으로 막는다 */
@@ -1014,126 +921,6 @@ function mountGradingBlock(app, { graders = ['pattern', 'rubric'], examples = GR
1014
921
  };
1015
922
  }
1016
923
 
1017
- function mountCompletion(app, { policies = app.completion.policies ?? POLICY_VALUES, root, label = '저장' }) {
1018
- if (app.screen !== 'completionPolicy')
1019
- throw new Error('useCompletion은 완료 정책 화면(screen: completionPolicy)에서만 씁니다.');
1020
- const t = COMPLETION_TEXT;
1021
- const area = appRoot(root);
1022
- const name = `ec-completion-${Math.random().toString(36).slice(2, 8)}`;
1023
- const section = h('section', { className: 'ec-grading' });
1024
- const head = h('div', { className: 'ec-grading-head' });
1025
- head.append(
1026
- h('h2', { textContent: t.heading }),
1027
- h('p', { className: 'ec-muted', textContent: t.headingHelp })
1028
- );
1029
- const group = h('div', { className: 'ec-grading-types', role: 'radiogroup' });
1030
- group.setAttribute('aria-label', t.heading);
1031
- section.append(head, group);
1032
- // 완료 정책 화면은 이 영역이 화면 전부라 기본 영역(#app)의 "불러오는 중"을 비운다. root를 주면 그 뒤에 더한다
1033
- if (root) area.append(section);
1034
- else area.replaceChildren(section);
1035
-
1036
- let current = policies[0];
1037
- const graderInfo = GRADER_TYPES[app.grading?.type];
1038
-
1039
- // 채점해 통과(on_graded): 편집 화면이 정한 채점 방식을 보여 준다
1040
- const gradedDetail = h('div', { className: 'ec-grading-detail' });
1041
- gradedDetail.append(
1042
- h('p', {
1043
- className: graderInfo ? 'ec-muted' : 'ec-error',
1044
- textContent: graderInfo ? t.grader(graderInfo.label) : t.noGrader,
1045
- })
1046
- );
1047
-
1048
- const cards = policies.map(policy => {
1049
- const { card, input } = radioCard(name, policy, COMPLETION_POLICIES[policy] ?? { label: policy, description: '' }, policy === current);
1050
- const wrap = h('div', { className: 'ec-grading-item' });
1051
- wrap.append(card);
1052
- if (policy === 'on_graded') wrap.append(gradedDetail);
1053
- input.addEventListener('change', () => select(policy));
1054
- group.append(wrap);
1055
- return { policy, card, input };
1056
- });
1057
- function select(policy) {
1058
- current = policy;
1059
- for (const c of cards) {
1060
- c.card.classList.toggle('selected', c.policy === policy);
1061
- c.input.checked = c.policy === policy;
1062
- }
1063
- gradedDetail.hidden = policy !== 'on_graded';
1064
- }
1065
- select(current);
1066
-
1067
- const status = h('p', { className: 'ec-muted', role: 'status', textContent: t.loading });
1068
- const error = h('p', { className: 'ec-error', role: 'alert' });
1069
- const button = h('button', { className: 'ec-primary', type: 'button', textContent: label, disabled: true });
1070
- const bar = h('div', { className: 'ec-submitbar' });
1071
- bar.append(status, error, button);
1072
- area.after(bar);
1073
-
1074
- let dirty = false;
1075
- const markDirty = () => {
1076
- dirty = true;
1077
- status.textContent = '저장하지 않은 변경이 있어요.';
1078
- };
1079
- area.addEventListener('input', markDirty);
1080
- area.addEventListener('change', markDirty);
1081
- globalThis.addEventListener?.('beforeunload', e => {
1082
- if (dirty) e.preventDefault();
1083
- });
1084
-
1085
- // 지금 완료 정책 (완료 정책 API · ecdk dev 흉내). 지원되지 않으면 저장을 막고 이유를 보여 준다
1086
- const ready = app.completion.get().then(
1087
- ({ completion_policy: policy }) => {
1088
- if (policies.includes(policy)) select(policy);
1089
- status.textContent = '';
1090
- button.disabled = false;
1091
- },
1092
- e => {
1093
- status.textContent = '';
1094
- error.textContent = e.message;
1095
- }
1096
- );
1097
-
1098
- const savedText = () =>
1099
- app.sdkKind === 'mock'
1100
- ? '저장했어요 (mock · 이 브라우저에만).'
1101
- : '저장했어요. 다음 제출부터 이 완료 정책을 씁니다.';
1102
-
1103
- button.addEventListener('click', async () => {
1104
- if (current === 'on_graded' && !graderInfo) {
1105
- error.textContent = t.noGrader;
1106
- return;
1107
- }
1108
- error.textContent = '';
1109
- button.disabled = true;
1110
- button.setAttribute('aria-busy', 'true');
1111
- try {
1112
- await app.completion.set(current);
1113
- dirty = false;
1114
- status.textContent = savedText();
1115
- } catch (e) {
1116
- status.textContent = '';
1117
- error.textContent = e.message;
1118
- } finally {
1119
- button.disabled = false;
1120
- button.removeAttribute('aria-busy');
1121
- }
1122
- });
1123
- return {
1124
- element: bar,
1125
- /** 지금 완료 정책을 불러온 뒤 끝나는 Promise */
1126
- ready,
1127
- get policy() {
1128
- return current;
1129
- },
1130
- markDirty,
1131
- get dirty() {
1132
- return dirty;
1133
- },
1134
- };
1135
- }
1136
-
1137
924
  function showBanner(error) {
1138
925
  if (typeof document === 'undefined') return;
1139
926
  let el = document.getElementById('elice-banner');
@@ -9,9 +9,8 @@ Elice Custom HTML 학습자료 프로젝트입니다.
9
9
  | `screens/learn.js` · `index.html` | 학생 화면 |
10
10
  | `screens/instructor.js` · `instructor.html` | 교육자 화면 |
11
11
  | `screens/edit.js` · `edit.html` | 내용 편집 화면 (CMS) |
12
- | `screens/completion.js` · `completion.html` | 완료 정책 화면 (교육자가 고름, 고칠 일 거의 없음) |
13
12
  | `styles.css` | 이 콘텐츠의 스타일 |
14
- | `metadata.json` | 화면 구성(`screens`) · 지원하는 완료 정책(`completionPolicies`) · 학습 참고 내용(`commentary`). `ecdk build`가 `build`만 채움 |
13
+ | `metadata.json` | 화면 구성(`screens`) · 학습 참고 내용(`commentary`). `ecdk build`가 `build`만 채움 |
15
14
  | `package.json` | SDK 버전(`@eliceio/cdk`) · 빌드 옵션 `"ecdk"` (`minify` 등). zip에 들어가지 않음 |
16
15
 
17
16
  이 프로젝트는 **템플릿(화면 · 코드)만** 만듭니다. 실제 내용과 정답은 LXP에 올린 뒤 편집 화면에서 입력합니다. `ecdk dev`의 내용 편집에서 넣은 것은 화면을 시험하는 견본이고 `.ecdk/settings.json`에만 남으며 올라가지 않습니다. 내용은 편집 화면이 저장한 것(`settings`)뿐입니다. 기본 내용 파일은 없어서, 편집 화면에서 저장하기 전에는 학생 · 교육자 화면이 "아직 내용이 없습니다" 안내를 보입니다 (`app.hasContent` · `app.emptyState()`).
@@ -52,7 +51,7 @@ app.useSave({ getContent, validate });
52
51
  | 언제 | SDK | 채점 · 저장 |
53
52
  | --------------------------------------------- | -------------------------------- | ----------------------------------------------------------------------------- |
54
53
  | 플랫폼에서 열 때 (`#token=`, 편집기 draft) | real (`lib/cdk.js`, build가 넣음) | 서버 |
55
- | 그 밖 (로컬) | mock (`lib/cdk-mock.js`) | 편집 화면이 저장한 정답 · 완료 정책으로 로컬 채점, 저장 내용·제출은 이 브라우저에 (프로젝트 폴더를 열면 `.ecdk/settings.json`으로 시작) |
54
+ | 그 밖 (로컬) | mock (`lib/cdk-mock.js`) | 편집 화면이 저장한 정답으로 로컬 채점 (정답이 없으면 제출만 받음), 저장 내용·제출은 이 브라우저에 (프로젝트 폴더를 열면 `.ecdk/settings.json`으로 시작) |
56
55
 
57
56
  - 강제로 바꾸기: 주소에 `?sdk=mock` 또는 `?sdk=real`
58
57
  - 보는 사람 바꾸기 (mock): `#viewer=tutor` (`student` · `instructor` · `tutor`), 편집기 draft 흉내: `#preview=1` · `#edit=1`
@@ -61,11 +60,11 @@ app.useSave({ getContent, validate });
61
60
 
62
61
  ## 정답
63
62
 
64
- 정답은 zip에 넣지 않습니다 (ADR 0009, `ecdk guide 2` · `5`).
63
+ 정답은 zip에 넣지 않습니다 (ADR 0009, 개발 가이드 스킬 `elice-content-guide`의 `topics/02-design-the-material.md` · `05-screen-code.md`).
65
64
 
66
65
  - **채점 방식 · 답**: 답을 채점하는 자료면 편집 화면에 키트의 채점 블록을 붙입니다: `const grading = app.useGradingBlock();` 후 `app.useSave({ …, getGrading: () => grading.getGrading() })`. LXP와 같은 문구로 기준 답안(정규표현식) · 평가 기준을 받아 `settings.grading`에 저장합니다 (학생에게는 내려가지 않음).
67
- - **완료 정책**: `metadata.json`의 `completionPolicies` (필수). 이 자료가 지원하는 정책이고, LXP에 올리면 서버가 **첫 값**으로 완료 정책을 정합니다. 기본은 `["on_submit", "on_access"]`(제출하면 완료, 교육자가 열면 완료로 바꿀 수 있음)이고, 교육자는 완료 정책 화면(`completion.html`, `screens.completionPolicy`)에서 이 안에서만 고릅니다. 하나로 고정하려면 `["on_submit"]`처럼 하나만 적고 완료 정책 화면 파일(`completion.html` · `screens/completion.js`)을 지운 뒤 `screens.completionPolicy`를 `{ "enabled": false }`로 바꿉니다.
68
- - 채점해 통과하면 완료(`on_graded`)를 넣으려면 편집 화면에 채점 블록이 있어야 합니다 (위). `ecdk dev`의 내용 편집에서 저장한 내용 · 채점 설정(`{ "type": "pattern", "answer_key": "^…$" }` · `{ "type": "rubric", "rubric": "…" }`)은 `.ecdk/settings.json`, 완료 정책 보기에서 고른 정책은 `.ecdk/completion.json`에 남고 로컬 채점에 쓰입니다. 둘 다 `ecdk build`가 zip에서 뺍니다. 정답 파일은 없습니다 (ADR 0011).
66
+ - **완료 정책**: 완료 정책은 LXP에 올린 뒤 설정 탭에서 교육자가 고릅니다 (열면 완료 · 제출하면 완료 · 채점해 통과하면 완료, ADR 0012). 프로젝트에는 적지 않습니다. 교육자가 '제출하면 완료' · '채점해 완료'를 고를 수 있게 하려면 학생 화면에 제출(`app.useSubmit`)을, '채점해 완료'까지 고를 수 있게 하려면 편집 화면에 채점 블록(위)을 둡니다.
67
+ - `ecdk dev`의 내용 편집에서 저장한 내용 · 채점 설정(`{ "type": "pattern", "answer_key": "^…$" }` · `{ "type": "rubric", "rubric": "…" }`)은 `.ecdk/settings.json`에 남고 로컬 채점에 쓰입니다 (채점 설정이 없으면 제출만 받음). `ecdk build`가 zip에서 뺍니다. 정답 파일은 없습니다 (ADR 0011).
69
68
 
70
69
  ## 명령
71
70
 
@@ -3,9 +3,7 @@
3
3
  "screens": {
4
4
  "learn": { "enabled": true, "entry": "index.html" },
5
5
  "instructor": { "enabled": true, "entry": "instructor.html" },
6
- "edit": { "enabled": true, "entry": "edit.html" },
7
- "completionPolicy": { "enabled": true, "entry": "completion.html" }
6
+ "edit": { "enabled": true, "entry": "edit.html" }
8
7
  },
9
- "completionPolicies": ["on_submit", "on_access"],
10
8
  "commentary": "commentary.txt"
11
9
  }
@@ -4,10 +4,10 @@
4
4
  "scripts": {
5
5
  "dev": "ecdk dev",
6
6
  "build": "ecdk build",
7
- "check": "ecdk check"
7
+ "validate": "ecdk validate"
8
8
  },
9
9
  "dependencies": {
10
- "@eliceio/cdk": "workspace:^1.0.0-alpha.3"
10
+ "@eliceio/cdk": "workspace:^1.0.0-alpha.4"
11
11
  },
12
12
  "ecdk": {}
13
13
  }
@@ -15,7 +15,7 @@ const message = Object.assign(document.createElement('textarea'), {
15
15
  });
16
16
  root.replaceChildren(title, message);
17
17
 
18
- // 답을 채점하는 자료면 채점 방식 · 답 블록을 붙이고 getGrading을 넘깁니다 (ADR 0009, ecdk guide 5):
18
+ // 답을 채점하는 자료면 채점 방식 · 답 블록을 붙이고 getGrading을 넘깁니다 (ADR 0009, 개발 가이드 스킬 elice-content-guide topics/05-screen-code.md):
19
19
  // const grading = app.useGradingBlock();
20
20
  // app.useSave({ getContent, validate, getGrading: () => grading.getGrading() });
21
21
  app.useSave({
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blank",
3
- "version": "1.0.0",
3
+ "version": "1.1.1",
4
4
  "title": "빈 자료",
5
- "description": "퀴즈가 아닌 모든 자료(시뮬레이션 · 시각화 · 활동 · 설명 · 플래시카드 · 설문)를 직접 만들 때. 학생 · 교육자 · 편집 · 완료 정책 화면 골격"
5
+ "description": "퀴즈가 아닌 모든 자료(시뮬레이션 · 시각화 · 활동 · 설명 · 플래시카드 · 설문)를 직접 만들 때. 학생 · 교육자 · 편집 화면 골격 (완료 정책은 LXP 설정 탭에서 교육자가 고름)"
6
6
  }
@@ -11,7 +11,7 @@ Elice Custom HTML 학습자료 프로젝트입니다.
11
11
  | `screens/edit.js` · `edit.html` | 내용 편집 화면 (CMS) |
12
12
  | `ui/` | 퀴즈의 모양: 색 · 간격 · 문구 · 마크업 (아래 표) |
13
13
  | `styles.css` | 이 콘텐츠의 스타일 (값은 `ui/theme.css`의 변수) |
14
- | `metadata.json` | 화면 구성(`screens`) · 완료 정책(`completionPolicies`) · 학습 참고 내용(`commentary`). `ecdk build`가 `build`만 채움 |
14
+ | `metadata.json` | 화면 구성(`screens`) · 학습 참고 내용(`commentary`). `ecdk build`가 `build`만 채움 |
15
15
  | `package.json` | SDK 버전(`@eliceio/cdk`) · 빌드 옵션 `"ecdk"` (`minify` 등). zip에 들어가지 않음 |
16
16
 
17
17
  ## 퀴즈 모양 바꾸기
@@ -28,7 +28,7 @@ core/ 동작 — 고치지 않습니다 (답 문자열 · 채점 약속,
28
28
  | 바꾸고 싶은 것 | 고치는 곳 |
29
29
  | -------------------------------------------- | ------------------------------------------------------------------------- |
30
30
  | 색 · 간격 · 모서리 | `ui/theme.css`의 `--qz-*` 변수 (예: `--qz-accent`, `--qz-option-padding`) |
31
- | 문구 ("확인 문제", "정답", 탭 제목 등) | `ui/texts.js` (HTML의 제목 · "불러오는 중"은 스크립트가 돌기 전 대비용) |
31
+ | 문구 ("정답", "편집 완료", 탭 제목 등) | `ui/texts.js` (HTML의 제목 · "불러오는 중"은 스크립트가 돌기 전 대비용) |
32
32
  | 보기 카드 마크업 | `ui/templates/choice.js` (모양은 `styles.css`의 `.qz-option`) |
33
33
  | 문항 겉모양 · 결과 · 해설 자리 | `ui/templates/question.js` |
34
34
  | 순서 맞추기 · 그룹 분류 배치 | `ui/templates/order.js` · `ui/templates/group.js` |
@@ -45,7 +45,7 @@ core/ 동작 — 고치지 않습니다 (답 문자열 · 채점 약속,
45
45
  | `input` | 주관식 입력란 (`text.js`) · 편집 칸 |
46
46
  | `pool` · `slots` | 순서 맞추기 (`order.js`) |
47
47
  | `pool` · `items`, 있으면 `pool-area` · `reset` · `remove` | 그룹 분류 (`group.js`) |
48
- | `preview-toggle` · `preview` · `count` · `handle` · `delete` · `type` · `up` · `down` | 편집 화면 (`edit.js`) |
48
+ | `count` · `handle` · `delete` · `type` · `up` · `down` · `answer` · `undo` · `type-warning` · `answer-error` | 편집 화면 (`edit.js`) |
49
49
 
50
50
  보기 · 칸 · 그룹 · 문항 요소의 `data-role` · `data-option` · `data-slot` · `data-group` · `data-id`, 상태 표시 `data-result`(`correct` · `wrong`) · `data-dragging` · `data-ghost`는 동작이 붙입니다. CSS에서 이 속성으로 상태를 꾸밀 수 있습니다.
51
51
 
@@ -96,7 +96,7 @@ app.useSave({ getContent, validate });
96
96
  - 퀴즈 하나에 문항은 **하나**입니다 (기존 LXP 퀴즈처럼). 문항이 있으면 "문항 추가" 대신 안내가 보이고, 여러 문항은 퀴즈 페이지를 여러 개 만듭니다. 이미 여러 문항으로 저장된 퀴즈도 그대로 보이고 저장됩니다.
97
97
  - 문항 유형: 단일 선택 · 복수 선택 · 순서 맞추기 · 주관식 · 그룹 분류
98
98
  - 학생 답은 문자열 하나로 제출합니다: 문항 순서대로 `문항id=답`을 `;`로 잇고 주관식은 URL 인코딩 (`q1=b;q2=a,d;q4=%EA%B0%80…`).
99
- - 퀴즈는 완료 정책 **채점해 통과하면 완료(on_graded)** · 채점 방식 **기준 답안(pattern)** 고정입니다 (`metadata.json` `"completionPolicies": ["on_graded"]`, ADR 0009). 하나뿐이라 완료 정책 화면이 없고, 모든 문항을 맞혀야 100점입니다 (문항별 점수 없음). 편집 화면은 답(`settings.grading`)만 저장하고 완료 정책은 보내지 않습니다.
99
+ - 퀴즈는 채점 방식 **기준 답안(pattern)** 고정이고, 모든 문항을 맞혀야 100점입니다 (문항별 점수 없음, ADR 0009). 편집 화면은 답(`settings.grading`)만 저장합니다. 완료 정책은 LXP에 올린 뒤 설정 탭에서 교육자가 고릅니다 (퀴즈는 보통 **채점해 통과하면 완료(on_graded)**, ADR 0012).
100
100
 
101
101
  ## 정답
102
102
 
@@ -195,7 +195,8 @@ function group({ q, options, byId, disabled, ui, made }) {
195
195
  const root = made(t.root({ q, boxes: boxes.map((b) => b.box) }));
196
196
  const pool = part(root, 'pool');
197
197
  const poolArea = part(root, 'pool-area') ?? pool;
198
- part(root, 'reset')?.addEventListener('click', () => {
198
+ const reset = part(root, 'reset');
199
+ reset?.addEventListener('click', () => {
199
200
  where = {};
200
201
  picked = null;
201
202
  draw();
@@ -235,6 +236,8 @@ function group({ q, options, byId, disabled, ui, made }) {
235
236
 
236
237
  function draw() {
237
238
  const left = options.filter((o) => !where[o.id]);
239
+ // 답안 초기화는 그룹에 놓은 보기가 있을 때만 (읽기 전용 화면에서는 늘 숨김)
240
+ if (reset) reset.hidden = disabled || left.length === options.length;
238
241
  pool.replaceChildren(
239
242
  ...present([...left.map(chip), left.length === 0 ? made(t.poolEmpty()) : null]),
240
243
  );
@@ -1,9 +1,7 @@
1
1
  // core/editor.js 타입 (편집기 자동완성 · 테스트용). templates는 ui/templates/edit.js와 같은 모양
2
2
  /* eslint-disable @typescript-eslint/no-explicit-any */
3
- /** 동작이 바꾸는 문구 (미리보기 버튼 · 글자 수 · 새 그룹 이름) */
3
+ /** 동작이 바꾸는 문구 (글자 수 · 새 그룹 이름) */
4
4
  export interface EditorLabels {
5
- preview: string;
6
- previewClose: string;
7
5
  count(length: number, max: number): string;
8
6
  group(letter: string): string;
9
7
  }
@@ -18,12 +16,14 @@ export declare function createEditor(opts: {
18
16
  label: string,
19
17
  value: string | undefined,
20
18
  onInput: (v: string) => void,
21
- opts?: { multiline?: boolean; required?: boolean; max?: number; hint?: string },
22
- ): HTMLElement;
23
- markdownField(
24
- label: string,
25
- value: string | undefined,
26
- onInput: (v: string) => void,
19
+ opts?: {
20
+ multiline?: boolean;
21
+ required?: boolean;
22
+ /** false면 "선택" 표시 없음 (기본 true) */
23
+ showOptional?: boolean;
24
+ max?: number;
25
+ hint?: string;
26
+ },
27
27
  ): HTMLElement;
28
28
  numberField(
29
29
  label: string,
@@ -38,6 +38,8 @@ export declare function createEditor(opts: {
38
38
  items: any[],
39
39
  key: string,
40
40
  opts?: {
41
+ /** 추가한 뒤 (예: 순서 맞추기 칸 수 늘리기) */
42
+ onAdd?: () => void;
41
43
  onDelete?: () => void;
42
44
  onInput?: (item: any) => void;
43
45
  /** 줄마다 정답 칸 (data-role="answer"): radio · checkbox · select(choices: [값, 이름]) */