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

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 (87) hide show
  1. package/README.md +110 -104
  2. package/es/cli.js +7 -22
  3. package/es/commands/build/index.d.ts +3 -21
  4. package/es/commands/build/index.js +17 -140
  5. package/es/commands/create/scaffold.d.ts +2 -0
  6. package/es/commands/create/scaffold.js +15 -1
  7. package/es/commands/doctor/index.d.ts +4 -3
  8. package/es/commands/doctor/index.js +14 -14
  9. package/es/commands/setup/index.d.ts +4 -7
  10. package/es/commands/setup/index.js +41 -70
  11. package/es/commands/uninstall/index.d.ts +9 -8
  12. package/es/commands/uninstall/index.js +41 -47
  13. package/es/commands/update/index.d.ts +4 -2
  14. package/es/commands/update/index.js +27 -18
  15. package/es/commands/validate/index.js +3 -1
  16. package/es/core/collect.d.ts +1 -1
  17. package/es/core/collect.js +3 -1
  18. package/es/core/config.d.ts +2 -2
  19. package/es/core/config.js +3 -3
  20. package/es/core/manifest.d.ts +3 -3
  21. package/es/core/manifest.js +4 -8
  22. package/es/{commands/mcp/index.d.ts → core/mcp.d.ts} +11 -18
  23. package/es/{commands/mcp/index.js → core/mcp.js} +29 -51
  24. package/es/core/prepare.d.ts +15 -10
  25. package/es/core/prepare.js +35 -35
  26. package/es/core/project-check.d.ts +6 -5
  27. package/es/core/project-check.js +9 -9
  28. package/es/core/sandbox.d.ts +6 -5
  29. package/es/core/sandbox.js +30 -8
  30. package/es/core/sdk.d.ts +7 -18
  31. package/es/core/sdk.js +8 -38
  32. package/es/{commands/skill/index.d.ts → core/skills.d.ts} +1 -17
  33. package/es/{commands/skill/index.js → core/skills.js} +6 -22
  34. package/es/dev/grading.d.ts +1 -1
  35. package/es/dev/grading.js +1 -1
  36. package/es/dev/host-page.js +2 -2
  37. package/es/dev/server.d.ts +6 -4
  38. package/es/dev/server.js +47 -77
  39. package/es/engines/vite/index.d.ts +2 -2
  40. package/es/engines/vite/index.js +2 -4
  41. package/es/engines/vite/plugin.d.ts +58 -0
  42. package/es/engines/vite/plugin.js +286 -0
  43. package/es/engines/vite/run.d.ts +15 -0
  44. package/es/engines/vite/run.js +92 -0
  45. package/es/rules/check.js +10 -12
  46. package/es/rules/csp.d.ts +1 -1
  47. package/es/rules/csp.js +1 -1
  48. package/es/rules/types.d.ts +8 -3
  49. package/es/rules.json.js +1 -1
  50. package/es/test-packages.d.ts +3 -1
  51. package/package.json +8 -3
  52. package/rules.json +9 -3
  53. package/skills/_shared/always.md +1 -1
  54. package/skills/elice-content-create/SKILL.md +2 -1
  55. package/skills/elice-content-guide/topics/01-check-the-environment.md +2 -2
  56. package/skills/elice-content-guide/topics/02-design-the-material.md +2 -0
  57. package/skills/elice-content-guide/topics/03-create-the-project.md +3 -3
  58. package/skills/elice-content-guide/topics/04-rules.md +1 -1
  59. package/skills/elice-content-guide/topics/05-screen-code.md +44 -13
  60. package/skills/elice-content-guide/topics/07-move-existing-html.md +2 -2
  61. package/skills/elice-content-guide/topics/08-fix-check-errors.md +21 -21
  62. package/skills/elice-content-guide/topics/10-build.md +1 -1
  63. package/skills/elice-content-guide/topics/12-upload-with-the-material-mcp.md +2 -2
  64. package/skills/elice-content-publish/SKILL.md +1 -1
  65. package/templates/_shared/lib/cdk-mock.js +2 -2
  66. package/templates/_shared/lib/elice-content-editor.d.ts +80 -0
  67. package/templates/_shared/lib/elice-content-editor.js +1062 -0
  68. package/templates/_shared/lib/elice-content.css +332 -0
  69. package/templates/_shared/lib/elice-content.js +18 -15
  70. package/templates/blank/README.md +29 -5
  71. package/templates/blank/commentary.txt +5 -0
  72. package/templates/blank/screens/edit.js +38 -17
  73. package/templates/blank/screens/instructor.js +20 -8
  74. package/templates/blank/screens/learn.js +151 -13
  75. package/templates/blank/styles.css +171 -0
  76. package/templates/blank/template.json +2 -2
  77. package/templates/quiz/README.md +2 -3
  78. package/templates/quiz/core/model.js +1 -1
  79. package/templates/quiz/screens/edit.js +14 -2
  80. package/templates/quiz/styles.css +11 -0
  81. package/templates/quiz/template.json +1 -1
  82. package/templates/quiz/ui/texts.js +1 -1
  83. package/es/core/minify.d.ts +0 -18
  84. package/es/core/minify.js +0 -93
  85. package/es/engines/static/index.d.ts +0 -3
  86. package/es/engines/static/index.js +0 -11
  87. package/es/engines/types.d.ts +0 -12
@@ -1,24 +1,162 @@
1
- // 학생 화면. 내용을 그리고, 답을 모으고 채우는 방법만 키트에 알려 줍니다.
2
- // 튜터링 잠금 · 미리보기 안내 · 답 복원 · 결과와 오류 표시는 키트(useSubmit)가 합니다.
1
+ // 학생 화면 예제 "예측하고 확인하기": 항목마다 값을 막대로 예측하고, 정답 보기로 실제 값과 비교합니다.
2
+ // 내용(app.content)은 편집 화면이 저장한 { title, intro, unit, items: [{ name, value, note }] }입니다 (screens/edit.js).
3
+ // 이 자료에 맞게 바꿀 곳: show() 안의 화면. 내용 모양을 바꾸면 screens/edit.js의 schema · sample도 같이 바꿉니다.
3
4
  import { start } from '../lib/elice-content.js';
4
5
 
5
6
  const app = await start({ screen: 'learn' });
6
7
  const root = document.getElementById('app');
7
8
  // 편집 화면에서 아직 내용을 저장하지 않았으면 안내만 보인다 (기본 내용은 없음)
8
- if (app.hasContent) show();
9
+ if (app.hasContent) show(app.content);
9
10
  else root.replaceChildren(app.emptyState());
10
11
 
11
- function show() {
12
- const title = Object.assign(document.createElement('h1'), { textContent: app.content.title ?? '' });
13
- const message = Object.assign(document.createElement('p'), {
14
- textContent: app.content.message ?? '',
12
+ function h(tag, props = {}, ...children) {
13
+ const el = Object.assign(document.createElement(tag), props);
14
+ el.append(...children);
15
+ return el;
16
+ }
17
+ function fmt(n) {
18
+ return n.toLocaleString('ko-KR', { maximumFractionDigits: 1 });
19
+ }
20
+
21
+ /** 축 끝: 가장 큰 값의 1.5배를 보기 좋은 수(1 · 2 · 2.5 · 5 × 10ⁿ)로 올림 */
22
+ function axisMax(values) {
23
+ const raw = Math.max(...values, 0) * 1.5;
24
+ if (!(raw > 0)) return 10;
25
+ const p = 10 ** Math.floor(Math.log10(raw));
26
+ return [1, 2, 2.5, 5, 10].map(m => m * p).find(x => x >= raw);
27
+ }
28
+
29
+ function show({ title = '', intro = '', unit = '', items = [] }) {
30
+ const list = items.filter(it => it && Number.isFinite(it.value));
31
+ const max = axisMax(list.map(it => it.value));
32
+ const step = max / 100;
33
+ const start = Math.round(max / 2 / step) * step;
34
+ const withUnit = n => `${fmt(n)}${unit ? ` ${unit}` : ''}`;
35
+ let predictions = list.map(() => start);
36
+ let revealed = false;
37
+
38
+ // 항목 한 줄: 이름 · 막대(끌거나 ← → 키) · 숫자 칸. 정답 보기 뒤에는 실제 값 표시와 차이
39
+ const rows = list.map((it, i) => {
40
+ const id = `predict-${i}`;
41
+ const range = h('input', { type: 'range', id, min: 0, max, step, className: 'predict-range' });
42
+ const number = h('input', { type: 'number', min: 0, step: 'any', className: 'predict-number' });
43
+ number.setAttribute('aria-label', `${it.name} 예측 값${unit ? ` (${unit})` : ''}`);
44
+ const real = h('span', { className: 'predict-real', hidden: true });
45
+ real.append(
46
+ h('span', { className: 'predict-real-label', textContent: `실제 ${withUnit(it.value)}` })
47
+ );
48
+ const diff = h('p', { className: 'predict-diff', hidden: true });
49
+ range.addEventListener('input', () => set(i, Number(range.value)));
50
+ number.addEventListener('input', () => {
51
+ if (number.value.trim() !== '') set(i, Number(number.value), { fromNumber: true });
52
+ });
53
+ number.addEventListener('change', () => paint());
54
+ const row = h(
55
+ 'div',
56
+ { className: 'predict-row' },
57
+ h('label', { htmlFor: id, className: 'predict-name', textContent: it.name }),
58
+ h('div', { className: 'predict-track' }, range, real),
59
+ number,
60
+ diff
61
+ );
62
+ return { row, range, number, real, diff };
15
63
  });
16
- const answer = Object.assign(document.createElement('textarea'), { ariaLabel: '답' });
17
- root.replaceChildren(title, message, answer);
18
64
 
19
- app.useSubmit({
20
- getAnswer: () => ({ text: answer.value }),
21
- setAnswer: (a) => (answer.value = a?.text ?? ''),
22
- validate: (a) => a.text.trim() !== '' || '답을 입력해 주세요.',
65
+ const total = h('p', { className: 'predict-total' });
66
+ const ranking = h('p', { className: 'predict-ranking' });
67
+ const summary = h('div', { className: 'predict-summary' }, total, ranking);
68
+ summary.setAttribute('aria-live', 'polite');
69
+ const reveal = h('button', { type: 'button', className: 'ec-primary', textContent: '정답 보기' });
70
+ const again = h('button', { type: 'button', textContent: '다시 예측', hidden: true });
71
+ reveal.addEventListener('click', () => {
72
+ revealed = true;
73
+ paint();
74
+ again.focus();
23
75
  });
76
+ again.addEventListener('click', () => {
77
+ revealed = false;
78
+ predictions = list.map(() => start);
79
+ paint();
80
+ rows[0]?.range.focus();
81
+ });
82
+
83
+ root.replaceChildren(
84
+ h('h1', { textContent: title }),
85
+ h('p', { className: 'predict-intro', textContent: intro }),
86
+ h('div', { className: 'predict-chart' }, ...rows.map(r => r.row)),
87
+ summary,
88
+ h('div', { className: 'predict-actions' }, again, reveal)
89
+ );
90
+
91
+ function set(i, v, { fromNumber = false } = {}) {
92
+ if (revealed || !Number.isFinite(v)) return;
93
+ predictions[i] = Math.min(Math.max(0, v), max);
94
+ paint({ keepNumber: fromNumber ? i : -1 });
95
+ }
96
+
97
+ /** 큰 순서 이름 (같으면 원래 순서) */
98
+ const order = values =>
99
+ values
100
+ .map((v, i) => [v, i])
101
+ .sort((a, b) => b[0] - a[0] || a[1] - b[1])
102
+ .map(([, i]) => i);
103
+
104
+ function paint({ keepNumber = -1 } = {}) {
105
+ rows.forEach((r, i) => {
106
+ const p = predictions[i];
107
+ const it = list[i];
108
+ r.range.value = String(p);
109
+ r.range.style.setProperty('--fill', `${(p / max) * 100}%`);
110
+ r.range.setAttribute('aria-valuetext', withUnit(p));
111
+ // 숫자 칸에 입력 중이면 고쳐 쓰지 않는다 (지우고 다시 쓰는 중일 수 있음)
112
+ if (i !== keepNumber) r.number.value = String(Math.round(p * 10) / 10);
113
+ r.range.disabled = r.number.disabled = revealed;
114
+ r.real.hidden = r.diff.hidden = !revealed;
115
+ r.real.style.setProperty('--at', `${(Math.min(it.value, max) / max) * 100}%`);
116
+ if (revealed) {
117
+ const d = p - it.value;
118
+ const pct = it.value ? Math.round((Math.abs(d) / it.value) * 100) : 0;
119
+ const close = pct <= 5;
120
+ r.diff.className = `predict-diff ${close ? 'ok' : 'no'}`;
121
+ r.diff.textContent = close
122
+ ? `거의 맞았어요 (차이 ${withUnit(Math.abs(d))})`
123
+ : `${d > 0 ? '+' : '−'}${withUnit(Math.abs(d))} · ${pct}% ${d > 0 ? '크게' : '작게'} 예측`;
124
+ if (it.note)
125
+ r.diff.append(h('span', { className: 'predict-note', textContent: ` · ${it.note}` }));
126
+ }
127
+ });
128
+ const sum = predictions.reduce(
129
+ (a, b) => a + b,
130
+ 0
131
+ );
132
+ const mine = order(predictions);
133
+ const names = idx => idx.map(i => list[i].name).join(' › ');
134
+ if (!revealed) {
135
+ total.textContent = `예측 합계 ${withUnit(sum)}`;
136
+ ranking.textContent = `예측한 큰 순서: ${names(mine)}`;
137
+ } else {
138
+ const truth = order(list.map(it => it.value));
139
+ const hit = truth.filter((i, k) => mine[k] === i).length;
140
+ total.textContent = `예측 합계 ${withUnit(sum)} · 실제 합계 ${withUnit(
141
+ list.reduce(
142
+ (a, it) => a + it.value,
143
+ 0
144
+ )
145
+ )}`;
146
+ ranking.textContent = `실제 큰 순서: ${names(truth)} (순서 ${hit} / ${list.length}자리 맞음)`;
147
+ }
148
+ reveal.hidden = revealed;
149
+ again.hidden = !revealed;
150
+ }
151
+ paint();
152
+
153
+ // 제출을 받으려면 (교육자가 LXP 설정에서 '제출하면 완료'를 고를 수 있게) 주석을 풉니다. 기본은 제출 없음(열면 완료).
154
+ // 답은 작은 JSON으로 냅니다. 다시 열면 키트가 setAnswer로 채워 줍니다.
155
+ // app.useSubmit({
156
+ // getAnswer: () => ({ predictions: list.map((it, i) => ({ name: it.name, value: predictions[i] })) }),
157
+ // setAnswer: a => {
158
+ // a?.predictions?.forEach((p, i) => (predictions[i] = p.value));
159
+ // paint();
160
+ // },
161
+ // });
24
162
  }
@@ -1 +1,172 @@
1
1
  /* 이 콘텐츠만의 스타일. lib/elice-content.css의 --ec-* 변수를 덮어써도 됩니다 */
2
+
3
+ /* 예제 "예측하고 확인하기" (screens/learn.js · instructor.js). 이 자료에 맞게 바꿀 곳 */
4
+ .predict-intro {
5
+ color: var(--ec-muted);
6
+ word-break: keep-all;
7
+ }
8
+ .predict-chart {
9
+ display: flex;
10
+ flex-direction: column;
11
+ /* 정답 보기의 실제 값 이름표가 위 줄에 겹치지 않게 */
12
+ gap: 28px;
13
+ }
14
+ /* 데스크톱: 이름 | 막대 | 숫자 한 줄, 차이는 막대 아래 */
15
+ .predict-row {
16
+ display: grid;
17
+ grid-template-columns: 6em 1fr 8em;
18
+ grid-template-areas:
19
+ 'name track number'
20
+ '. diff diff';
21
+ align-items: center;
22
+ gap: 4px 12px;
23
+ }
24
+ .predict-name {
25
+ grid-area: name;
26
+ font-weight: var(--eds-fw-semibold);
27
+ word-break: keep-all;
28
+ }
29
+ .predict-track {
30
+ grid-area: track;
31
+ position: relative;
32
+ }
33
+ .predict-number {
34
+ grid-area: number;
35
+ text-align: right;
36
+ }
37
+ .predict-diff {
38
+ grid-area: diff;
39
+ font-size: var(--eds-fs-body2);
40
+ }
41
+ .predict-diff.ok {
42
+ color: var(--ec-ok);
43
+ }
44
+ .predict-diff.no {
45
+ color: var(--ec-no);
46
+ }
47
+ .predict-note {
48
+ color: var(--ec-muted);
49
+ }
50
+ /* 막대 = 가로 range. 채운 부분이 예측 값(--fill), 손잡이는 막대 끝의 세로 손잡이. 끌거나 ← → 키 */
51
+ .predict-range {
52
+ display: block;
53
+ width: 100%;
54
+ height: 36px;
55
+ margin: 0;
56
+ padding: 0;
57
+ border: 0;
58
+ border-radius: 6px;
59
+ appearance: none;
60
+ background: linear-gradient(
61
+ to right,
62
+ var(--ec-accent) var(--fill, 50%),
63
+ var(--ec-surface) var(--fill, 50%)
64
+ );
65
+ cursor: pointer;
66
+ touch-action: pan-y;
67
+ }
68
+ .predict-range::-webkit-slider-thumb {
69
+ appearance: none;
70
+ width: 12px;
71
+ height: 44px;
72
+ border-radius: 6px;
73
+ border: 2px solid var(--ec-bg);
74
+ background: var(--ec-accent-dark);
75
+ box-shadow: var(--ec-shadow);
76
+ }
77
+ .predict-range::-moz-range-thumb {
78
+ width: 12px;
79
+ height: 44px;
80
+ border-radius: 6px;
81
+ border: 2px solid var(--ec-bg);
82
+ background: var(--ec-accent-dark);
83
+ }
84
+ .predict-range:focus-visible {
85
+ outline: 2px solid var(--ec-accent);
86
+ outline-offset: 3px;
87
+ }
88
+ .predict-range:disabled {
89
+ cursor: default;
90
+ opacity: 0.7;
91
+ }
92
+ /* 정답 보기 뒤 실제 값: 막대 위 세로선 + 이름표 */
93
+ .predict-real {
94
+ position: absolute;
95
+ top: -6px;
96
+ bottom: -6px;
97
+ left: var(--at);
98
+ width: 0;
99
+ border-left: 3px solid var(--ec-fg);
100
+ pointer-events: none;
101
+ }
102
+ .predict-real-label {
103
+ position: absolute;
104
+ bottom: 100%;
105
+ left: 0;
106
+ translate: -50% 0;
107
+ padding: 0 4px;
108
+ border-radius: 4px;
109
+ background: var(--ec-fg);
110
+ color: var(--ec-bg);
111
+ font-size: var(--eds-fs-caption);
112
+ font-weight: var(--eds-fw-semibold);
113
+ white-space: nowrap;
114
+ }
115
+ .predict-summary {
116
+ display: flex;
117
+ flex-direction: column;
118
+ gap: 4px;
119
+ padding: 12px 16px;
120
+ border-radius: var(--ec-radius);
121
+ background: var(--ec-surface);
122
+ }
123
+ .predict-total {
124
+ font-weight: var(--eds-fw-bold);
125
+ }
126
+ .predict-ranking {
127
+ color: var(--ec-muted);
128
+ word-break: keep-all;
129
+ }
130
+ .predict-actions {
131
+ display: flex;
132
+ justify-content: flex-end;
133
+ gap: 8px;
134
+ }
135
+ /* 모바일: 이름 · 숫자 한 줄, 막대는 그 아래 전체 폭 */
136
+ @media (max-width: 511.98px) {
137
+ .predict-row {
138
+ grid-template-columns: 1fr 7em;
139
+ grid-template-areas:
140
+ 'name number'
141
+ 'track track'
142
+ 'diff diff';
143
+ gap: 8px;
144
+ }
145
+ .predict-row .predict-track {
146
+ margin-top: 14px;
147
+ }
148
+ .predict-actions button {
149
+ flex: 1;
150
+ }
151
+ }
152
+
153
+ /* 교육자 화면 표 */
154
+ .predict-table {
155
+ width: 100%;
156
+ border-collapse: collapse;
157
+ font-size: var(--eds-fs-body2);
158
+ }
159
+ .predict-table th,
160
+ .predict-table td {
161
+ padding: 8px 10px;
162
+ border-bottom: 1px solid var(--ec-line);
163
+ text-align: left;
164
+ }
165
+ .predict-table th {
166
+ color: var(--ec-muted);
167
+ font-weight: var(--eds-fw-semibold);
168
+ }
169
+ .predict-table td:nth-child(2) {
170
+ text-align: right;
171
+ font-variant-numeric: tabular-nums;
172
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blank",
3
- "version": "1.1.1",
3
+ "version": "1.2.0",
4
4
  "title": "빈 자료",
5
- "description": "퀴즈가 아닌 모든 자료(시뮬레이션 · 시각화 · 활동 · 설명 · 플래시카드 · 설문)를 직접 만들 때. 학생 · 교육자 · 편집 화면 골격 (완료 정책은 LXP 설정 탭에서 교육자가 고름)"
5
+ "description": "퀴즈가 아닌 모든 자료(시뮬레이션 · 시각화 · 활동 · 설명 · 플래시카드 · 설문)를 직접 만들 때. 예제 \"예측하고 확인하기\"(막대 예측 · 정답 보기)와 내용 JSON 편집기(폼 보기 · 코드 보기)로 시작 (완료 정책은 LXP 설정 탭에서 교육자가 고름)"
6
6
  }
@@ -13,7 +13,6 @@ Elice Custom HTML 학습자료 프로젝트입니다.
13
13
  | `styles.css` | 이 콘텐츠의 스타일 (값은 `ui/theme.css`의 변수) |
14
14
  | `metadata.json` | 화면 구성(`screens`) · 학습 참고 내용(`commentary`). `ecdk build`가 `build`만 채움 |
15
15
  | `package.json` | SDK 버전(`@eliceio/cdk`) · 빌드 옵션 `"ecdk"` (`minify` 등). zip에 들어가지 않음 |
16
-
17
16
  ## 퀴즈 모양 바꾸기
18
17
 
19
18
  ```
@@ -51,7 +50,7 @@ core/ 동작 — 고치지 않습니다 (답 문자열 · 채점 약속,
51
50
 
52
51
  이 프로젝트는 **템플릿(화면 · 코드)만** 만듭니다. 실제 내용과 정답은 LXP에 올린 뒤 편집 화면에서 입력합니다. `ecdk dev`의 내용 편집에서 넣은 것은 화면을 시험하는 견본이고 `.ecdk/settings.json`에만 남으며 올라가지 않습니다. 내용은 편집 화면이 저장한 것(`settings`)뿐입니다. 기본 문항은 없어서, 편집 화면에서 저장하기 전에는 학생 · 교육자 화면이 "아직 내용이 없습니다" 안내를 보입니다 (`app.hasContent` · `app.emptyState()`).
53
52
 
54
- `lib/`(화면 키트)는 플랫폼 연결 로직이라 고치지 않습니다. SDK(`lib/cdk.js`)는 프로젝트에 없고 `ecdk build` · `ecdk dev`가 `node_modules/@eliceio/cdk`에서 넣습니다 (처음 한 번 `npm install`, 올리기 `npm update @eliceio/cdk`). 화면은 **누가 보는지(학생 · 교육자 · 튜터)나 미리보기인지 몰라도 됩니다.**
53
+ `lib/`(화면 키트)는 플랫폼 연결 로직이라 고치지 않습니다. SDK는 `package.json` 의존성(`@eliceio/cdk`)이고 키트가 import하며, `ecdk build`(Vite)가 화면 코드와 함께 번들로 묶습니다 (처음 한 번 `npm install`, 올리기 `npm update @eliceio/cdk`). 화면은 **누가 보는지(학생 · 교육자 · 튜터)나 미리보기인지 몰라도 됩니다.**
55
54
 
56
55
  ```js
57
56
  // 학생 화면: 문항을 그리고 답을 모으고 채우는 방법만 알려 준다
@@ -82,7 +81,7 @@ app.useSave({ getContent, validate });
82
81
 
83
82
  | 언제 | SDK | 채점 · 저장 |
84
83
  | ------------------------------------------ | ------------------------ | ------------------------------------------------------------------------------ |
85
- | 플랫폼에서 열 때 (`#token=`, 편집기 draft) | real (`lib/cdk.js`, build가 넣음) | 서버 |
84
+ | 플랫폼에서 열 때 (`#token=`, 편집기 draft) | real (`@eliceio/cdk`, 번들에 들어감) | 서버 |
86
85
  | 그 밖 (로컬) | mock (`lib/cdk-mock.js`) | 편집 화면이 저장한 정답 · 완료 정책으로 로컬 채점, 저장 내용·제출은 이 브라우저에 (프로젝트 폴더를 열면 `.ecdk/settings.json`으로 시작) |
87
86
 
88
87
  - 강제로 바꾸기: 주소에 `?sdk=mock` 또는 `?sdk=real`
@@ -260,7 +260,7 @@ export function parseAnswerKey(questions, regex) {
260
260
  }
261
261
 
262
262
  /**
263
- * 정답 검증 1: 모든 문항에 정답이 있고, 정답이 지금 있는 보기 · 그룹을 가리키는지 (G63).
263
+ * 정답 검증 1: 모든 문항에 정답이 있고, 정답이 지금 있는 보기 · 그룹을 가리키는지.
264
264
  * 문제가 없으면 null, 있으면 { questionIndex, message }
265
265
  * @param {object} v 검증 문구 (ui/texts.js의 answers.validation)
266
266
  */
@@ -12,6 +12,7 @@ import {
12
12
  checkAnswerKey,
13
13
  convertType,
14
14
  INLINE_ANSWER_TYPES,
15
+ isAnswered,
15
16
  joinAnswers,
16
17
  LIMITS,
17
18
  newQuestion,
@@ -120,6 +121,15 @@ function optionsOpts(q) {
120
121
  // 다시 그릴 때 지우기 전 칸 값으로 덮지 않게
121
122
  answerViews.delete(q.id);
122
123
  },
124
+ // 순서 맞추기: 보기 글을 고치면 정답 칸의 보기 이름도 바로 바꾼다 (다시 그리면 입력 중 초점을 잃음)
125
+ onInput:
126
+ q.type === 'order'
127
+ ? o => {
128
+ const view = answerViews.get(q.id);
129
+ for (const chip of view?.el.querySelectorAll(`[data-role="chip"][data-option="${o.id}"]`) ?? [])
130
+ chip.textContent = o.text;
131
+ }
132
+ : undefined,
123
133
  answer: inline ? inlineAnswer(q) : undefined,
124
134
  };
125
135
  }
@@ -224,11 +234,13 @@ function questionCard(q, i) {
224
234
  },
225
235
  {
226
236
  type: type => {
237
+ readAnswerViews();
238
+ // 고른 정답이 있었을 때만 알림 (유형이 바뀌면 답 모양이 달라지므로 정답을 다시 고른다)
239
+ const hadAnswer = isAnswered(q, answers[q.id]);
227
240
  draft.questions[i] = convertType(q, type, texts.defaults);
228
- // 유형이 바뀌면 답 모양이 달라지므로 정답을 다시 고른다 (카드 위에 알림)
229
241
  delete answers[q.id];
230
242
  answerViews.delete(q.id);
231
- retyped.add(q.id);
243
+ if (hadAnswer) retyped.add(q.id);
232
244
  render();
233
245
  },
234
246
  up: () => swap(draft.questions, i, i - 1),
@@ -406,6 +406,17 @@
406
406
  .qz-group:hover .ec-dropzone {
407
407
  border-color: var(--qz-accent);
408
408
  }
409
+ /* 읽기 전용(교육자 화면 · 튜터링): 놓으라는 안내 · 누르는 손 모양을 감춘다 (빈 칸 자리는 그대로) */
410
+ .qz-question:disabled .qz-group {
411
+ cursor: default;
412
+ }
413
+ .qz-question:disabled .qz-group:hover .ec-dropzone {
414
+ border-color: var(--ec-border);
415
+ }
416
+ .qz-question:disabled .ec-dropzone > *,
417
+ .qz-question:disabled .qz-empty {
418
+ visibility: hidden;
419
+ }
409
420
  .qz-pool-head {
410
421
  /* 답안 초기화가 숨었다 나타나도 높이가 그대로 (버튼 높이 30px) */
411
422
  min-height: 30px;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quiz",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "title": "퀴즈",
5
5
  "description": "한 문항 퀴즈 (여러 문항은 페이지를 여러 개로). 문항 없이 시작해 편집 화면 \"문항 추가\"로 선택 · 순서 · 주관식 · 그룹 분류 문항 하나를 만듦. 정답은 편집 화면에서 정하고 기준 답안(pattern)으로 채점 (완료 정책은 LXP 설정 탭에서 교육자가 고름)"
6
6
  }
@@ -55,7 +55,7 @@ export const texts = {
55
55
  badge: '교육자 화면',
56
56
  summary: (count, byType) => `문항 ${count}개 · ${byType.join(' · ')}`,
57
57
  summaryType: (type, n) => `${type} ${n}`,
58
- note: '정답은 내용 편집 화면에서 문항마다 정합니다. 모든 문항을 맞혀야 완료(100점)됩니다.',
58
+ note: '정답은 내용 편집 화면에서 문항마다 정합니다. 모든 문항을 맞혀야 100점입니다.',
59
59
  },
60
60
 
61
61
  /** 문항 (학생 · 교육자 공통) */
@@ -1,18 +0,0 @@
1
- import type { SourceFile } from './collect.js';
2
- export interface MinifyReport {
3
- /** 줄인 파일 수 */
4
- files: number;
5
- before: number;
6
- after: number;
7
- /** 만든 .map 수와 크기 (sourcemap일 때) */
8
- maps?: {
9
- files: number;
10
- bytes: number;
11
- } | undefined;
12
- }
13
- export declare function minifyFiles(files: SourceFile[], { sourcemap }?: {
14
- sourcemap?: boolean | undefined;
15
- }): Promise<{
16
- files: SourceFile[];
17
- report: MinifyReport;
18
- }>;
package/es/core/minify.js DELETED
@@ -1,93 +0,0 @@
1
- import { transform } from 'esbuild';
2
-
3
- /**
4
- * package.json `"ecdk"`의 `"minify": true`일 때 zip에 넣기 전에 줄인다 (용량 줄이기).
5
- * 파일 단위 변환(번들 아님)이라 경로 · import · 파일 구성은 그대로다.
6
- *
7
- * - JS(.js · .mjs): 공백 · 주석 제거, 이름 줄이기. ES 모듈의 import/export와 top-level await는 그대로.
8
- * - CSS: 공백 · 주석 제거.
9
- * - JSON: 공백 제거 (형식이 틀리면 그대로 둠, 검사가 알려 줌). metadata.json은 사람이 보도록 그대로.
10
- * - HTML · 이미지 등은 그대로.
11
- * - sourcemap: 줄인 JS · CSS 옆에 `<파일>.map`을 두고 끝에 sourceMappingURL을 단다 (원본 내용 포함).
12
- * 이미 줄여 둔 파일(minify로 10%도 안 줄어듦, 예: lib/cdk.js)은 .map을 만들지 않는다.
13
- *
14
- * 검사는 minify 전 원본으로 한다 (`ecdk-ignore` 주석 · 원본 줄 번호). build 참고.
15
- */
16
- const encoder = new TextEncoder();
17
- const decoder = new TextDecoder();
18
- const KEEP = new Set(['metadata.json']);
19
- async function minifyFiles(files, {
20
- sourcemap = false
21
- } = {}) {
22
- let count = 0;
23
- let before = 0;
24
- let after = 0;
25
- const maps = [];
26
- const out = await Promise.all(files.map(async f => {
27
- if (KEEP.has(f.path)) return f;
28
- const loader = /\.m?js$/i.test(f.path) ? 'js' : /\.css$/i.test(f.path) ? 'css' : null;
29
- const isJson = /\.json$/i.test(f.path);
30
- if (!loader && !isJson) return f;
31
- const text = decoder.decode(f.data);
32
- let next;
33
- if (isJson) {
34
- try {
35
- next = JSON.stringify(JSON.parse(text));
36
- } catch {
37
- return f;
38
- }
39
- } else if (loader) {
40
- const name = f.path.split('/').pop() ?? f.path;
41
- try {
42
- const r = await transform(text, {
43
- loader,
44
- minify: true,
45
- target: 'es2022',
46
- ...(sourcemap ? {
47
- sourcemap: 'external',
48
- sourcefile: name
49
- } : {})
50
- });
51
- next = r.code;
52
- // 이미 줄여 둔 파일(묶어 넣은 SDK 등)은 .map이 줄인 코드를 다시 가리킬 뿐이라 용량만 늘린다
53
- const alreadyMin = encoder.encode(next).byteLength > f.data.byteLength * 0.9;
54
- if (sourcemap && r.map && !alreadyMin) {
55
- next += loader === 'css' ? `\n/*# sourceMappingURL=${name}.map */\n` : `\n//# sourceMappingURL=${name}.map\n`;
56
- maps.push({
57
- path: `${f.path}.map`,
58
- data: encoder.encode(r.map)
59
- });
60
- }
61
- } catch (e) {
62
- const detail = e.errors?.[0];
63
- throw new Error(`minify 실패: ${f.path}${detail?.location ? `:${detail.location.line}` : ''} ${detail?.text ?? e.message}. 문법을 확인하거나 package.json "ecdk"의 minify를 끄세요.`);
64
- }
65
- } else return f;
66
- const data = encoder.encode(next);
67
- if (data.byteLength >= f.data.byteLength && !sourcemap) return f;
68
- count += 1;
69
- before += f.data.byteLength;
70
- after += data.byteLength;
71
- return {
72
- path: f.path,
73
- data
74
- };
75
- }));
76
- const mapBytes = maps.reduce((s, m) => s + m.data.byteLength, 0);
77
- return {
78
- files: [...out, ...maps],
79
- report: {
80
- files: count,
81
- before,
82
- after,
83
- ...(sourcemap ? {
84
- maps: {
85
- files: maps.length,
86
- bytes: mapBytes
87
- }
88
- } : {})
89
- }
90
- };
91
- }
92
-
93
- export { minifyFiles };
@@ -1,3 +0,0 @@
1
- import type { ContentEngine } from '../types.js';
2
- /** 번들 없이 원본을 그대로 쓴다. 기본 엔진, 의존성 없음. */
3
- export declare const staticEngine: ContentEngine;
@@ -1,11 +0,0 @@
1
- /** 번들 없이 원본을 그대로 쓴다. 기본 엔진, 의존성 없음. */
2
- const staticEngine = {
3
- name: 'static',
4
- async build({
5
- files
6
- }) {
7
- return files;
8
- }
9
- };
10
-
11
- export { staticEngine };
@@ -1,12 +0,0 @@
1
- import type { SourceFile } from '../core/collect.js';
2
- export interface EngineBuildContext {
3
- /** 콘텐츠 원본 폴더 (절대경로) */
4
- srcDir: string;
5
- /** core가 정답·비밀·프로젝트 파일을 뺀 뒤의 원본 */
6
- files: SourceFile[];
7
- }
8
- /** 2단계에서 dev()를 더한다 (CLI 구조 문서의 ContentEngine). */
9
- export interface ContentEngine {
10
- name: string;
11
- build(ctx: EngineBuildContext): Promise<SourceFile[]>;
12
- }