@eliceio/cdk-cli 1.7.2-sharedqa.0 → 1.8.1-qa.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -15
- package/es/commands/create/index.js +6 -3
- package/es/commands/create/scaffold.d.ts +1 -1
- package/es/commands/create/scaffold.js +1 -1
- package/es/commands/doctor/index.js +34 -1
- package/es/core/lesson-check.d.ts +7 -0
- package/es/core/lesson-check.js +87 -0
- package/es/core/templates.d.ts +2 -0
- package/es/core/templates.js +4 -1
- package/es/dev/host-page.js +5 -2
- package/package.json +2 -2
- package/skills/_shared/always.md +1 -1
- package/skills/_shared/references/02-design-the-material.md +10 -9
- package/skills/_shared/references/03-create-the-project.md +12 -11
- package/skills/_shared/references/08-fix-check-errors.md +1 -0
- package/skills/_shared/references/12-upload-with-the-material-mcp.md +2 -2
- package/skills/_shared/references/17-using-the-entry-template.md +44 -5
- package/skills/_shared/references/18-using-the-lesson-template.md +207 -0
- package/skills/_shared/references/19-lesson-layouts.md +2132 -0
- package/skills/elice-content-create/SKILL.md +4 -3
- package/skills/elice-content-publish/SKILL.md +3 -3
- package/templates/blank/template.json +1 -1
- package/templates/board/package.json +1 -1
- package/templates/board/template.json +1 -1
- package/templates/board/ui/board.css +4 -1
- package/templates/board/ui/texts.js +3 -1
- package/templates/entry/screens/edit.js +8 -3
- package/templates/entry/template.json +1 -1
- package/templates/lesson/README.md +71 -0
- package/templates/lesson/commentary.txt +7 -0
- package/templates/lesson/core/dom.d.ts +4 -0
- package/templates/lesson/core/dom.js +22 -0
- package/templates/lesson/core/engine.d.ts +23 -0
- package/templates/lesson/core/engine.js +169 -0
- package/templates/lesson/core/interact.d.ts +2 -0
- package/templates/lesson/core/interact.js +429 -0
- package/templates/lesson/core/layout-files.d.ts +4 -0
- package/templates/lesson/core/layout-files.js +9 -0
- package/templates/lesson/core/lesson.d.ts +95 -0
- package/templates/lesson/core/lesson.js +609 -0
- package/templates/lesson/core/sample.d.ts +4 -0
- package/templates/lesson/core/sample.js +128 -0
- package/templates/lesson/edit.html +21 -0
- package/templates/lesson/gitignore +4 -0
- package/templates/lesson/index.html +22 -0
- package/templates/lesson/layouts/_actions.html +1 -0
- package/templates/lesson/layouts/_cmp.html +1 -0
- package/templates/lesson/layouts/_deco-corner.html +1 -0
- package/templates/lesson/layouts/_deco-cover.html +1 -0
- package/templates/lesson/layouts/_deco-section.html +1 -0
- package/templates/lesson/layouts/_foot.html +1 -0
- package/templates/lesson/layouts/_head.html +1 -0
- package/templates/lesson/layouts/_media.html +1 -0
- package/templates/lesson/layouts/agenda.html +13 -0
- package/templates/lesson/layouts/bar-chart.html +14 -0
- package/templates/lesson/layouts/cards.html +12 -0
- package/templates/lesson/layouts/checklist.html +12 -0
- package/templates/lesson/layouts/choice-list.html +13 -0
- package/templates/lesson/layouts/closing.html +13 -0
- package/templates/lesson/layouts/compare.html +12 -0
- package/templates/lesson/layouts/cover-dark.html +13 -0
- package/templates/lesson/layouts/cover.html +15 -0
- package/templates/lesson/layouts/figures.html +12 -0
- package/templates/lesson/layouts/flow.html +13 -0
- package/templates/lesson/layouts/how-to.html +15 -0
- package/templates/lesson/layouts/image-bg.html +12 -0
- package/templates/lesson/layouts/image-pair.html +15 -0
- package/templates/lesson/layouts/image-split.html +12 -0
- package/templates/lesson/layouts/layers.html +12 -0
- package/templates/lesson/layouts/objectives.html +12 -0
- package/templates/lesson/layouts/ox-card.html +24 -0
- package/templates/lesson/layouts/ox-list.html +21 -0
- package/templates/lesson/layouts/process.html +14 -0
- package/templates/lesson/layouts/profile.html +13 -0
- package/templates/lesson/layouts/prompt-builder.html +18 -0
- package/templates/lesson/layouts/quiz.html +14 -0
- package/templates/lesson/layouts/quote.html +12 -0
- package/templates/lesson/layouts/scenario-rows.html +12 -0
- package/templates/lesson/layouts/section.html +14 -0
- package/templates/lesson/layouts/simulation.html +18 -0
- package/templates/lesson/layouts/stat.html +14 -0
- package/templates/lesson/layouts/statement.html +13 -0
- package/templates/lesson/layouts/stats.html +12 -0
- package/templates/lesson/layouts/stepper.html +13 -0
- package/templates/lesson/layouts/table.html +12 -0
- package/templates/lesson/layouts/tabs.html +13 -0
- package/templates/lesson/layouts/text-visual.html +16 -0
- package/templates/lesson/layouts/timeline.html +12 -0
- package/templates/lesson/layouts/toggle.html +16 -0
- package/templates/lesson/layouts/variables.html +14 -0
- package/templates/lesson/layouts/venn.html +15 -0
- package/templates/lesson/layouts/versus.html +12 -0
- package/templates/lesson/metadata.json +9 -0
- package/templates/lesson/package.json +15 -0
- package/templates/lesson/public/img/sample-chat.svg +21 -0
- package/templates/lesson/screens/edit.js +79 -0
- package/templates/lesson/screens/learn.js +56 -0
- package/templates/lesson/styles.css +27 -0
- package/templates/lesson/template.json +7 -0
- package/templates/lesson/ui/design.css +1103 -0
- package/templates/lesson/ui/fonts/PretendardVariable.woff2 +0 -0
- package/templates/lesson/ui/learn.css +64 -0
- package/templates/lesson/ui/mobile.css +492 -0
- package/templates/lesson/ui/reset.css +6 -0
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
// 학습 자료 학생 화면의 실습 요소 동작 (디자이너 deck-kit deck.js를 옮긴 것): 복사 박스, 변수 입력, 프롬프트 빌더, 탭, 퀴즈(카드 · 목록),
|
|
2
|
+
// OX 퀴즈, 시뮬레이션, 큰 토글, 단계 칩, 체크리스트(브라우저 기본 체크박스).
|
|
3
|
+
// 쪽 넘기기 · 쪽 번호 · ← → 키는 키트 스테퍼(app.useStepper)가 하고, 전체 보기 · 강의 노트 패널 · 전체 화면 키는 두지 않는다.
|
|
4
|
+
// 퀴즈는 자가 확인이다: 화면 안에서 정오와 해설만 보이고 서버에 제출 · 채점하지 않는다.
|
|
5
|
+
// 입력한 변수 값은 이 화면에만 둔다 (브라우저 저장소 · 서버에 남기지 않음).
|
|
6
|
+
|
|
7
|
+
const CHECK_PATH = 'M5 12.5 10 17.5 19 7.5';
|
|
8
|
+
const SVG = 'http://www.w3.org/2000/svg';
|
|
9
|
+
|
|
10
|
+
function checkIcon() {
|
|
11
|
+
const svg = document.createElementNS(SVG, 'svg');
|
|
12
|
+
svg.setAttribute('viewBox', '0 0 24 24');
|
|
13
|
+
svg.setAttribute('aria-hidden', 'true');
|
|
14
|
+
const p = document.createElementNS(SVG, 'path');
|
|
15
|
+
for (const [k, v] of Object.entries({
|
|
16
|
+
d: CHECK_PATH,
|
|
17
|
+
fill: 'none',
|
|
18
|
+
stroke: 'currentColor',
|
|
19
|
+
'stroke-width': '2.6',
|
|
20
|
+
'stroke-linecap': 'round',
|
|
21
|
+
'stroke-linejoin': 'round',
|
|
22
|
+
}))
|
|
23
|
+
p.setAttribute(k, v);
|
|
24
|
+
svg.append(p);
|
|
25
|
+
return svg;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const el = (tag, className, text) => {
|
|
29
|
+
const n = document.createElement(tag);
|
|
30
|
+
if (className) n.className = className;
|
|
31
|
+
if (text !== undefined) n.textContent = text;
|
|
32
|
+
return n;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* 글 복사. 클립보드 API가 막히면(샌드박스 iframe 권한) 선택 + execCommand로, 그것도 안 되면 글을 선택해 두고 false
|
|
37
|
+
*/
|
|
38
|
+
function copyText(text, pre, done) {
|
|
39
|
+
const fallback = () => {
|
|
40
|
+
let ok = false;
|
|
41
|
+
try {
|
|
42
|
+
const r = document.createRange();
|
|
43
|
+
r.selectNodeContents(pre);
|
|
44
|
+
const s = window.getSelection();
|
|
45
|
+
s.removeAllRanges();
|
|
46
|
+
s.addRange(r);
|
|
47
|
+
ok = document.execCommand('copy');
|
|
48
|
+
} catch {
|
|
49
|
+
ok = false;
|
|
50
|
+
}
|
|
51
|
+
done(ok);
|
|
52
|
+
};
|
|
53
|
+
// 줄 끝 두 글자 묶기(WORD JOINER, core/engine.js fmt)는 보이지 않는 글자라 복사할 글에서 뺀다
|
|
54
|
+
text = text.replace(/\u2060/g, '');
|
|
55
|
+
if (navigator.clipboard?.writeText)
|
|
56
|
+
navigator.clipboard.writeText(text).then(
|
|
57
|
+
() => done(true),
|
|
58
|
+
fallback
|
|
59
|
+
);
|
|
60
|
+
else fallback();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** 복사 버튼: 체크 + "복사됨"으로 바뀌었다가 돌아온다 (실패면 "Ctrl+C로 복사", 글은 선택된 채) */
|
|
64
|
+
function flashCopied(btn, ok) {
|
|
65
|
+
btn._label ??= [...btn.childNodes].map(n => n.cloneNode(true));
|
|
66
|
+
btn.replaceChildren(...(ok ? [checkIcon(), '복사됨'] : ['Ctrl+C로 복사']));
|
|
67
|
+
btn.classList.toggle('is-copied', !!ok);
|
|
68
|
+
clearTimeout(btn._timer);
|
|
69
|
+
btn._timer = setTimeout(
|
|
70
|
+
() => {
|
|
71
|
+
btn.replaceChildren(...btn._label.map(n => n.cloneNode(true)));
|
|
72
|
+
btn.classList.remove('is-copied');
|
|
73
|
+
},
|
|
74
|
+
1800
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* 학습 자료의 실습 요소를 켠다. root: 슬라이드들을 담은 요소(#lesson), vars: 변수 key → 입력 전에 보일 값 (core/lesson.js buildLesson().vars)
|
|
80
|
+
*/
|
|
81
|
+
export function setupInteractions(root, vars = {}) {
|
|
82
|
+
/** 학생이 입력한 변수 값 (이 화면에만) */
|
|
83
|
+
const varVals = {};
|
|
84
|
+
const varText = k => (varVals[k] || '').trim() || vars[k] || k;
|
|
85
|
+
const all = sel => root.querySelectorAll(sel);
|
|
86
|
+
|
|
87
|
+
// ---- 프롬프트 빌더 ----
|
|
88
|
+
function renderBuilder(b) {
|
|
89
|
+
const tpl = b.getAttribute('data-template') || '';
|
|
90
|
+
const sel = (b._sel ??= {});
|
|
91
|
+
const groups = b.querySelectorAll('.bgroup');
|
|
92
|
+
let filled = 0;
|
|
93
|
+
for (const g of groups) if (sel[g.getAttribute('data-key')]) filled++;
|
|
94
|
+
const parts = [];
|
|
95
|
+
for (const m of tpl.matchAll(/\[\[([a-z0-9_-]+)\]\]|[^[]+|\[/g)) {
|
|
96
|
+
const k = m[1];
|
|
97
|
+
if (!k) {
|
|
98
|
+
parts.push(m[0]);
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
const g = [...groups].find(x => x.getAttribute('data-key') === k);
|
|
102
|
+
if (g) {
|
|
103
|
+
parts.push(
|
|
104
|
+
sel[k]
|
|
105
|
+
? el('mark', 'picked', sel[k])
|
|
106
|
+
: el('span', 'unfilled', `(${g.getAttribute('data-label')})`)
|
|
107
|
+
);
|
|
108
|
+
} else if (Object.hasOwn(vars, k)) {
|
|
109
|
+
const v = el('span', 'var', varText(k));
|
|
110
|
+
v.dataset.var = k;
|
|
111
|
+
v.dataset.default = vars[k];
|
|
112
|
+
parts.push(v);
|
|
113
|
+
} else parts.push(m[0]);
|
|
114
|
+
}
|
|
115
|
+
b.querySelector('.bout pre').replaceChildren(...parts);
|
|
116
|
+
b.querySelector('.bout-head b').textContent = `${filled} / ${groups.length}`;
|
|
117
|
+
b.querySelector('.bout').classList.toggle('is-done', filled === groups.length);
|
|
118
|
+
const submit = b.closest('section')?.querySelector('[data-act="submit"]');
|
|
119
|
+
if (submit) submit.disabled = filled !== groups.length;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function applyVar(k) {
|
|
123
|
+
for (const n of all('.var')) if (n.dataset.var === k) n.textContent = varText(k);
|
|
124
|
+
for (const i of all('[data-var-input]'))
|
|
125
|
+
if (i.getAttribute('data-var-input') === k && i.value !== (varVals[k] || ''))
|
|
126
|
+
i.value = varVals[k] || '';
|
|
127
|
+
all('.builder').forEach(renderBuilder);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
root.addEventListener('input', e => {
|
|
131
|
+
const t = e.target;
|
|
132
|
+
if (!(t instanceof Element)) return;
|
|
133
|
+
if (t.matches('[data-var-input]')) {
|
|
134
|
+
const k = t.getAttribute('data-var-input');
|
|
135
|
+
varVals[k] = t.value;
|
|
136
|
+
applyVar(k);
|
|
137
|
+
} else if (t.matches('.bcustom')) {
|
|
138
|
+
const b = t.closest('.builder');
|
|
139
|
+
const g = t.closest('.bgroup');
|
|
140
|
+
b._sel ??= {};
|
|
141
|
+
b._sel[g.getAttribute('data-key')] = t.value.trim();
|
|
142
|
+
renderBuilder(b);
|
|
143
|
+
} else if (t.closest('.sim-ctl input')) simUpdate(t.closest('[data-sim]'));
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
root.addEventListener('click', e => {
|
|
147
|
+
const target = e.target instanceof Element ? e.target : null;
|
|
148
|
+
if (!target) return;
|
|
149
|
+
|
|
150
|
+
// 복사 박스
|
|
151
|
+
const copy = target.closest('.copy');
|
|
152
|
+
if (copy) {
|
|
153
|
+
const pre = copy.parentNode.querySelector('pre');
|
|
154
|
+
copyText(pre ? pre.textContent : '', pre, ok => flashCopied(copy, ok));
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// 빌더 칩 · 탭 · 퀴즈 보기
|
|
159
|
+
const t = target.closest('.opt, .tab, .qopt');
|
|
160
|
+
if (t?.classList.contains('opt')) {
|
|
161
|
+
const b = t.closest('.builder');
|
|
162
|
+
const g = t.closest('.bgroup');
|
|
163
|
+
const key = g.getAttribute('data-key');
|
|
164
|
+
b._sel ??= {};
|
|
165
|
+
const input = g.querySelector('.bcustom');
|
|
166
|
+
const opts = g.querySelectorAll('.opt');
|
|
167
|
+
if (t.classList.contains('opt--custom')) {
|
|
168
|
+
const on = !t.classList.contains('is-on');
|
|
169
|
+
for (const o of opts) o.classList.remove('is-on');
|
|
170
|
+
t.classList.toggle('is-on', on);
|
|
171
|
+
if (input) {
|
|
172
|
+
input.classList.toggle('is-open', on);
|
|
173
|
+
if (on) input.focus();
|
|
174
|
+
}
|
|
175
|
+
b._sel[key] = on && input ? input.value.trim() : '';
|
|
176
|
+
} else {
|
|
177
|
+
const was = t.classList.contains('is-on');
|
|
178
|
+
for (const o of opts) o.classList.remove('is-on');
|
|
179
|
+
input?.classList.remove('is-open');
|
|
180
|
+
if (!was) t.classList.add('is-on');
|
|
181
|
+
b._sel[key] = was ? '' : t.getAttribute('data-text');
|
|
182
|
+
}
|
|
183
|
+
renderBuilder(b);
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
if (t?.classList.contains('tab')) {
|
|
187
|
+
const wrap = t.closest('[data-tabs]');
|
|
188
|
+
const i = t.getAttribute('data-i');
|
|
189
|
+
for (const x of wrap.querySelectorAll('.tab'))
|
|
190
|
+
x.setAttribute('aria-selected', x === t ? 'true' : 'false');
|
|
191
|
+
for (const p of wrap.querySelectorAll('.tabpanel'))
|
|
192
|
+
p.classList.toggle('is-on', p.getAttribute('data-i') === i);
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
if (t?.classList.contains('qopt')) {
|
|
196
|
+
const quiz = t.closest('.quiz');
|
|
197
|
+
if (quiz.classList.contains('quiz-done')) return;
|
|
198
|
+
for (const o of quiz.querySelectorAll('.qopt')) o.classList.remove('is-picked');
|
|
199
|
+
t.classList.add('is-picked');
|
|
200
|
+
const submit = t.closest('section').querySelector('[data-act="submit"]');
|
|
201
|
+
if (submit) submit.disabled = false;
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// OX 보기
|
|
206
|
+
const ox = target.closest('.oxb, .oxt');
|
|
207
|
+
if (ox) {
|
|
208
|
+
const r = ox.closest('[data-oxl], [data-oxc]');
|
|
209
|
+
if (!r || r.classList.contains('ox-done')) return;
|
|
210
|
+
const scope = ox.closest('.oxl-row') || r;
|
|
211
|
+
for (const x of scope.querySelectorAll('.oxb, .oxt')) x.classList.remove('is-picked');
|
|
212
|
+
ox.classList.add('is-picked');
|
|
213
|
+
const submit = r.closest('section').querySelector('[data-act="submit"]');
|
|
214
|
+
const done = r.hasAttribute('data-oxl')
|
|
215
|
+
? [...r.querySelectorAll('.oxl-row')].every(row => row.querySelector('.is-picked'))
|
|
216
|
+
: true;
|
|
217
|
+
if (submit) submit.disabled = !done;
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// 시뮬레이션 장면
|
|
222
|
+
const scene = target.closest('.sim-scene');
|
|
223
|
+
if (scene) {
|
|
224
|
+
const sim = scene.closest('[data-sim]');
|
|
225
|
+
if (sim.classList.contains('sim-done')) return;
|
|
226
|
+
for (const x of sim.querySelectorAll('.sim-scene')) x.classList.remove('is-on');
|
|
227
|
+
scene.classList.add('is-on');
|
|
228
|
+
simUpdate(sim);
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// 큰 토글
|
|
233
|
+
const tg = target.closest('.tg-btn');
|
|
234
|
+
if (tg) {
|
|
235
|
+
const box = tg.closest('[data-toggle]');
|
|
236
|
+
const i = tg.getAttribute('data-i');
|
|
237
|
+
for (const x of box.querySelectorAll('.tg-btn')) {
|
|
238
|
+
x.classList.toggle('is-on', x === tg);
|
|
239
|
+
x.setAttribute('aria-selected', x === tg ? 'true' : 'false');
|
|
240
|
+
}
|
|
241
|
+
for (const p of box.querySelectorAll('.tg-panel'))
|
|
242
|
+
p.classList.toggle('is-on', p.getAttribute('data-i') === i);
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// 단계 칩 (한 슬라이드 안 단계)
|
|
247
|
+
const stp = target.closest('.stp, .stp-prev, .stp-next');
|
|
248
|
+
if (stp) {
|
|
249
|
+
const box =
|
|
250
|
+
stp.closest('[data-stepper]') || stp.closest('section').querySelector('[data-stepper]');
|
|
251
|
+
const cur = box._step || 0;
|
|
252
|
+
if (stp.classList.contains('stp'))
|
|
253
|
+
setStep(box, Number.parseInt(stp.getAttribute('data-i'), 10) - 1);
|
|
254
|
+
else if (stp.classList.contains('stp-prev')) setStep(box, cur - 1);
|
|
255
|
+
else setStep(box, cur + 1);
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// 실행 버튼 (제출하기 · 다시 시도하기): 화면 안에서만, 서버 제출 없음
|
|
260
|
+
const act = target.closest('.act');
|
|
261
|
+
if (act && !act.disabled) runAction(act);
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
function runAction(btn) {
|
|
265
|
+
const sec = btn.closest('section.slide');
|
|
266
|
+
const kind = btn.getAttribute('data-act');
|
|
267
|
+
const submit = sec.querySelector('[data-act="submit"]');
|
|
268
|
+
const quiz = sec.querySelector('.quiz');
|
|
269
|
+
if (quiz) {
|
|
270
|
+
if (kind === 'submit') {
|
|
271
|
+
const pick = quiz.querySelector('.qopt.is-picked');
|
|
272
|
+
if (!pick) return;
|
|
273
|
+
const ans = quiz.getAttribute('data-answer');
|
|
274
|
+
quiz.classList.add('quiz-done');
|
|
275
|
+
for (const o of quiz.querySelectorAll('.qopt'))
|
|
276
|
+
if (o.getAttribute('data-n') === ans) o.classList.add('is-right');
|
|
277
|
+
if (pick.getAttribute('data-n') !== ans) pick.classList.add('is-wrong');
|
|
278
|
+
quiz.querySelector('.qexp')?.classList.add('is-open');
|
|
279
|
+
btn.disabled = true;
|
|
280
|
+
} else if (kind === 'retry') {
|
|
281
|
+
quiz.classList.remove('quiz-done');
|
|
282
|
+
for (const o of quiz.querySelectorAll('.qopt'))
|
|
283
|
+
o.classList.remove('is-picked', 'is-right', 'is-wrong');
|
|
284
|
+
quiz.querySelector('.qexp')?.classList.remove('is-open');
|
|
285
|
+
if (submit) submit.disabled = true;
|
|
286
|
+
}
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
const b = sec.querySelector('.builder');
|
|
290
|
+
if (b) {
|
|
291
|
+
if (kind === 'retry') {
|
|
292
|
+
b._sel = {};
|
|
293
|
+
for (const o of b.querySelectorAll('.opt')) o.classList.remove('is-on');
|
|
294
|
+
for (const i of b.querySelectorAll('.bcustom')) {
|
|
295
|
+
i.value = '';
|
|
296
|
+
i.classList.remove('is-open');
|
|
297
|
+
}
|
|
298
|
+
renderBuilder(b);
|
|
299
|
+
} else if (kind === 'submit') {
|
|
300
|
+
const pre = b.querySelector('.bout pre');
|
|
301
|
+
copyText(pre.textContent, pre, ok => flashCopied(btn, ok));
|
|
302
|
+
}
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
const oxRoot = sec.querySelector('[data-oxl], [data-oxc]');
|
|
306
|
+
if (oxRoot) {
|
|
307
|
+
const rows = oxRoot.hasAttribute('data-oxl')
|
|
308
|
+
? [...oxRoot.querySelectorAll('.oxl-row')]
|
|
309
|
+
: [oxRoot];
|
|
310
|
+
if (kind === 'submit') {
|
|
311
|
+
for (const r of rows) {
|
|
312
|
+
const ans = r.getAttribute('data-answer');
|
|
313
|
+
const pick = r.querySelector('.is-picked');
|
|
314
|
+
for (const x of r.querySelectorAll('.oxb, .oxt'))
|
|
315
|
+
if (x.getAttribute('data-v') === ans) x.classList.add('is-right');
|
|
316
|
+
if (pick && pick.getAttribute('data-v') !== ans) pick.classList.add('is-wrong');
|
|
317
|
+
r.classList.add('is-done');
|
|
318
|
+
}
|
|
319
|
+
oxRoot.classList.add('ox-done');
|
|
320
|
+
btn.disabled = true;
|
|
321
|
+
} else if (kind === 'retry') {
|
|
322
|
+
for (const r of rows) {
|
|
323
|
+
r.classList.remove('is-done');
|
|
324
|
+
for (const x of r.querySelectorAll('.oxb, .oxt'))
|
|
325
|
+
x.classList.remove('is-picked', 'is-right', 'is-wrong');
|
|
326
|
+
}
|
|
327
|
+
oxRoot.classList.remove('ox-done');
|
|
328
|
+
if (submit) submit.disabled = true;
|
|
329
|
+
}
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
const sim = sec.querySelector('[data-sim]');
|
|
333
|
+
if (sim) {
|
|
334
|
+
if (kind === 'submit') {
|
|
335
|
+
sim.classList.add('sim-done');
|
|
336
|
+
for (const i of sim.querySelectorAll('input')) i.disabled = true;
|
|
337
|
+
btn.disabled = true;
|
|
338
|
+
simUpdate(sim);
|
|
339
|
+
} else if (kind === 'retry') {
|
|
340
|
+
sim.classList.remove('sim-done');
|
|
341
|
+
for (const i of sim.querySelectorAll('input')) i.disabled = false;
|
|
342
|
+
sim.querySelectorAll('.sim-scene').forEach((x, i) => x.classList.toggle('is-on', i === 0));
|
|
343
|
+
for (const m of sim.querySelectorAll('.sim-m')) m.classList.remove('is-ok');
|
|
344
|
+
simInit(sim);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
// ---- 시뮬레이션 ----
|
|
350
|
+
function simInit(sim) {
|
|
351
|
+
for (const c of sim.querySelectorAll('.sim-ctl')) {
|
|
352
|
+
const vals = (c.getAttribute('data-values') || '').split('|').filter(Boolean);
|
|
353
|
+
const r = c.querySelector('input');
|
|
354
|
+
r.max = String(Math.max(0, vals.length - 1));
|
|
355
|
+
r.value = String(Math.floor(vals.length / 2));
|
|
356
|
+
c._vals = vals;
|
|
357
|
+
}
|
|
358
|
+
sim.style.setProperty('--m', String(sim.querySelectorAll('.sim-m').length));
|
|
359
|
+
simUpdate(sim);
|
|
360
|
+
}
|
|
361
|
+
function simState(sim) {
|
|
362
|
+
const st = {};
|
|
363
|
+
for (const c of sim.querySelectorAll('.sim-ctl'))
|
|
364
|
+
st[c.getAttribute('data-key')] = c._vals[Number(c.querySelector('input').value)];
|
|
365
|
+
const sc = sim.querySelector('.sim-scene.is-on');
|
|
366
|
+
st.__scene = sc ? sc.getAttribute('data-name') : '';
|
|
367
|
+
return st;
|
|
368
|
+
}
|
|
369
|
+
function simUpdate(sim) {
|
|
370
|
+
if (!sim) return;
|
|
371
|
+
const st = simState(sim);
|
|
372
|
+
const ctls = [...sim.querySelectorAll('.sim-ctl')];
|
|
373
|
+
for (const c of ctls)
|
|
374
|
+
c.querySelector('.sim-val').textContent = st[c.getAttribute('data-key')] ?? '';
|
|
375
|
+
const readout = sim.querySelector('.sim-readout');
|
|
376
|
+
if (readout) readout.textContent = ctls.map(c => st[c.getAttribute('data-key')]).join(' · ');
|
|
377
|
+
let ok = 0;
|
|
378
|
+
let total = 0;
|
|
379
|
+
for (const m of sim.querySelectorAll('.sim-m')) {
|
|
380
|
+
total++;
|
|
381
|
+
let pass = true;
|
|
382
|
+
const scn = m.getAttribute('data-scene');
|
|
383
|
+
if (scn && scn !== st.__scene) pass = false;
|
|
384
|
+
for (let p of (m.getAttribute('data-when') || '').split(';')) {
|
|
385
|
+
p = p.trim();
|
|
386
|
+
if (!p) continue;
|
|
387
|
+
const i = p.indexOf('=');
|
|
388
|
+
const allowed = p
|
|
389
|
+
.slice(i + 1)
|
|
390
|
+
.split('|')
|
|
391
|
+
.map(x => x.trim());
|
|
392
|
+
if (!allowed.includes(st[p.slice(0, i).trim()])) pass = false;
|
|
393
|
+
}
|
|
394
|
+
if (pass) m.classList.add('is-ok');
|
|
395
|
+
if (m.classList.contains('is-ok')) ok++;
|
|
396
|
+
}
|
|
397
|
+
const count = sim.querySelector('.sim-count');
|
|
398
|
+
if (count) count.textContent = `${ok} / ${total}`;
|
|
399
|
+
const submit = sim.closest('section')?.querySelector('[data-act="submit"]');
|
|
400
|
+
if (submit && !sim.classList.contains('sim-done')) submit.disabled = ok !== total;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
// ---- 단계 칩 ----
|
|
404
|
+
function setStep(box, i) {
|
|
405
|
+
const chips = [...box.querySelectorAll('.stp')];
|
|
406
|
+
i = Math.max(0, Math.min(chips.length - 1, i));
|
|
407
|
+
chips.forEach((c, k) => {
|
|
408
|
+
c.classList.toggle('is-on', k === i);
|
|
409
|
+
c.classList.toggle('is-done', k < i);
|
|
410
|
+
c.setAttribute('aria-selected', k === i ? 'true' : 'false');
|
|
411
|
+
});
|
|
412
|
+
box.querySelectorAll('.stp-panel').forEach((p, k) => p.classList.toggle('is-on', k === i));
|
|
413
|
+
const sec = box.closest('section');
|
|
414
|
+
const prev = sec.querySelector('.stp-prev');
|
|
415
|
+
const next = sec.querySelector('.stp-next');
|
|
416
|
+
if (prev) prev.hidden = i === 0;
|
|
417
|
+
if (next) {
|
|
418
|
+
next.hidden = i === chips.length - 1;
|
|
419
|
+
if (i < chips.length - 1)
|
|
420
|
+
next.textContent = `다음 단계: ${chips[i + 1].getAttribute('data-label')}`;
|
|
421
|
+
}
|
|
422
|
+
box._step = i;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
Object.keys(vars).forEach(applyVar);
|
|
426
|
+
all('.builder').forEach(renderBuilder);
|
|
427
|
+
all('[data-sim]').forEach(simInit);
|
|
428
|
+
all('[data-stepper]').forEach(box => setStep(box, 0));
|
|
429
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// 레이아웃 틀(layouts/*.html)을 빌드 때 글로 묶는다 (Vite import.meta.glob `?raw`, ecdk build · dev · vitest 모두).
|
|
2
|
+
// layouts/는 package.json ecdk.exclude로 zip · 화면 목록에서 빠지고, 이 파일을 거쳐 화면 코드에만 들어간다.
|
|
3
|
+
// Node에서 바로 부르는 곳(ecdk doctor project.lesson)은 파일을 직접 읽어 core/lesson.js parseLayouts로 넘긴다.
|
|
4
|
+
import { parseLayouts } from './lesson.js';
|
|
5
|
+
|
|
6
|
+
/** 학습 자료 레이아웃 묶음: { ids(순서), layouts: { id: { schema, template } }, partials } */
|
|
7
|
+
export const LAYOUTS = parseLayouts(
|
|
8
|
+
import.meta.glob('../layouts/*.html', { query: '?raw', import: 'default', eager: true })
|
|
9
|
+
);
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// core/lesson.js 타입 (편집기 자동완성 · 테스트용). lesson.js와 같이 고칩니다.
|
|
2
|
+
|
|
3
|
+
/** 슬롯 규칙 하나 (layouts/*.html 맨 위 <!--SCHEMA {...}-->) */
|
|
4
|
+
export interface SlotSpec {
|
|
5
|
+
req?: number | boolean;
|
|
6
|
+
max?: number;
|
|
7
|
+
/** 목록 항목 수 [최소, 최대] */
|
|
8
|
+
n?: [number, number];
|
|
9
|
+
t?: 'enum' | 'image' | 'bool' | 'row';
|
|
10
|
+
opts?: Array<string | number>;
|
|
11
|
+
default?: unknown;
|
|
12
|
+
style?: string;
|
|
13
|
+
hint?: string;
|
|
14
|
+
fields?: Record<string, SlotSpec>;
|
|
15
|
+
item?: SlotSpec;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface LayoutSchema {
|
|
19
|
+
id: string;
|
|
20
|
+
name: string;
|
|
21
|
+
use: string;
|
|
22
|
+
avoid: string;
|
|
23
|
+
slots: Record<string, SlotSpec>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** 레이아웃 묶음 (parseLayouts 결과) */
|
|
27
|
+
export interface LayoutSet {
|
|
28
|
+
/** 쓸 수 있는 레이아웃 (순서: 장표 → 실습 → 퀴즈) */
|
|
29
|
+
ids: string[];
|
|
30
|
+
layouts: Record<string, { schema: LayoutSchema; template: string }>;
|
|
31
|
+
/** 부분 틀 ({{>head}} 등, layouts/_*.html) */
|
|
32
|
+
partials: Record<string, string>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface LessonVariable {
|
|
36
|
+
key: string;
|
|
37
|
+
label?: string;
|
|
38
|
+
default?: string;
|
|
39
|
+
hint?: string;
|
|
40
|
+
placeholder?: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface LessonMeta {
|
|
44
|
+
title?: string;
|
|
45
|
+
brand?: string;
|
|
46
|
+
variables?: LessonVariable[];
|
|
47
|
+
style?: 'document' | 'slide';
|
|
48
|
+
title_mode?: 'fixed' | 'free';
|
|
49
|
+
header?: 'hide' | 'show';
|
|
50
|
+
background?: 'decor' | 'plain';
|
|
51
|
+
header_right?: 'none' | 'title';
|
|
52
|
+
title_label?: 'chapter' | 'title' | 'none';
|
|
53
|
+
key_color?: string;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface LessonSlide {
|
|
57
|
+
layout: string;
|
|
58
|
+
data?: Record<string, unknown>;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** 편집 화면이 저장하는 내용 (settings, grading 없음) */
|
|
62
|
+
export interface Lesson {
|
|
63
|
+
meta?: LessonMeta;
|
|
64
|
+
slides: LessonSlide[];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface LessonFinding {
|
|
68
|
+
level: 'error' | 'warn';
|
|
69
|
+
message: string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface BuiltLesson {
|
|
73
|
+
slides: { html: string; layout: string; title: string; notes: string }[];
|
|
74
|
+
report: LessonFinding[];
|
|
75
|
+
attrs: { title: string; header: string; hright: string; bg: string; key: string; single: boolean };
|
|
76
|
+
vars: Record<string, string>;
|
|
77
|
+
title: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface BuildOptions {
|
|
81
|
+
/** 레이아웃 묶음 (parseLayouts 결과, 화면은 core/layout-files.js의 LAYOUTS) */
|
|
82
|
+
layouts: LayoutSet;
|
|
83
|
+
/** 이미지 파일이 있는지 (Node 검사). 없으면 파일 검사를 하지 않는다 */
|
|
84
|
+
imageExists?: (path: string) => boolean;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export declare const UNIVERSAL: Record<string, SlotSpec>;
|
|
88
|
+
/** 레이아웃 순서 (원본 build.py ORDER) */
|
|
89
|
+
export declare const ORDER: string[];
|
|
90
|
+
/** 레이아웃 틀 파일 { 경로: 내용 } → 레이아웃 묶음. SCHEMA 주석이 없거나 id가 파일 이름과 다르면 던진다 */
|
|
91
|
+
export declare function parseLayouts(files: Record<string, string>): LayoutSet;
|
|
92
|
+
export declare function visibleLength(s: unknown): number;
|
|
93
|
+
export declare function buildLesson(content: unknown, options: BuildOptions): BuiltLesson;
|
|
94
|
+
export declare function validateLesson(content: unknown, options: BuildOptions): LessonFinding[];
|
|
95
|
+
export declare function cleanLesson<T>(content: T, options: { layouts: LayoutSet }): T;
|