@eliceio/cdk-cli 0.0.0-stage → 0.1.0-alpha.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.
- package/README.md +511 -2
- package/es/bin/index.d.ts +2 -0
- package/es/bin/index.js +10 -0
- package/es/cli.d.ts +5 -0
- package/es/cli.js +171 -0
- package/es/commands/build/index.d.ts +27 -0
- package/es/commands/build/index.js +154 -0
- package/es/commands/check/index.d.ts +9 -0
- package/es/commands/check/index.js +31 -0
- package/es/commands/create/index.d.ts +8 -0
- package/es/commands/create/index.js +22 -0
- package/es/commands/create/scaffold.d.ts +24 -0
- package/es/commands/create/scaffold.js +82 -0
- package/es/commands/dev/index.d.ts +6 -0
- package/es/commands/dev/index.js +40 -0
- package/es/commands/doctor/index.d.ts +33 -0
- package/es/commands/doctor/index.js +230 -0
- package/es/core/collect.d.ts +21 -0
- package/es/core/collect.js +89 -0
- package/es/core/config.d.ts +55 -0
- package/es/core/config.js +109 -0
- package/es/core/manifest.d.ts +15 -0
- package/es/core/manifest.js +43 -0
- package/es/core/minify.d.ts +18 -0
- package/es/core/minify.js +93 -0
- package/es/core/prepare.d.ts +12 -0
- package/es/core/prepare.js +86 -0
- package/es/core/protocol.d.ts +2 -0
- package/es/core/protocol.js +4 -0
- package/es/core/zip.d.ts +4 -0
- package/es/core/zip.js +17 -0
- package/es/dev/grading.d.ts +15 -0
- package/es/dev/grading.js +37 -0
- package/es/dev/host-page.d.ts +7 -0
- package/es/dev/host-page.js +240 -0
- package/es/dev/inject.d.ts +8 -0
- package/es/dev/inject.js +38 -0
- package/es/dev/mock-api.d.ts +65 -0
- package/es/dev/mock-api.js +269 -0
- package/es/dev/server.d.ts +24 -0
- package/es/dev/server.js +294 -0
- package/es/engines/static/index.d.ts +3 -0
- package/es/engines/static/index.js +11 -0
- package/es/engines/types.d.ts +12 -0
- package/es/engines/vite/index.d.ts +2 -0
- package/es/engines/vite/index.js +4 -0
- package/es/index.d.ts +2 -0
- package/es/index.js +2 -0
- package/es/rules/check.d.ts +2 -0
- package/es/rules/check.js +209 -0
- package/es/rules/index.d.ts +8 -0
- package/es/rules/index.js +7 -0
- package/es/rules/manifest.d.ts +39 -0
- package/es/rules/manifest.js +168 -0
- package/es/rules/node.d.ts +11 -0
- package/es/rules/node.js +87 -0
- package/es/rules/path.d.ts +7 -0
- package/es/rules/path.js +35 -0
- package/es/rules/refs.d.ts +19 -0
- package/es/rules/refs.js +111 -0
- package/es/rules/skip.d.ts +12 -0
- package/es/rules/skip.js +55 -0
- package/es/rules/spec.d.ts +3 -0
- package/es/rules/spec.js +6 -0
- package/es/rules/types.d.ts +138 -0
- package/es/rules/unused.d.ts +7 -0
- package/es/rules/unused.js +21 -0
- package/es/rules/zip.d.ts +13 -0
- package/es/rules/zip.js +45 -0
- package/es/rules.json.js +3 -0
- package/es/types.d.ts +4 -0
- package/es/version.d.ts +1 -0
- package/es/version.js +3 -0
- package/package.json +48 -3
- package/rules.json +555 -0
- package/templates/_shared/lib/cdk-mock.d.ts +94 -0
- package/templates/_shared/lib/cdk-mock.js +429 -0
- package/templates/_shared/lib/cdk.js +3 -0
- package/templates/_shared/lib/elice-content.css +252 -0
- package/templates/_shared/lib/elice-content.d.ts +121 -0
- package/templates/_shared/lib/elice-content.js +541 -0
- package/templates/_shared/lib/elice-tokens.css +446 -0
- package/templates/blank/README.md +64 -0
- package/templates/blank/content.json +4 -0
- package/templates/blank/edit.html +15 -0
- package/templates/blank/elice.config.json +12 -0
- package/templates/blank/gitignore +3 -0
- package/templates/blank/index.html +15 -0
- package/templates/blank/instructor.html +15 -0
- package/templates/blank/screens/edit.js +21 -0
- package/templates/blank/screens/instructor.js +9 -0
- package/templates/blank/screens/learn.js +19 -0
- package/templates/blank/styles.css +1 -0
- package/templates/quiz/README.md +108 -0
- package/templates/quiz/content.json +81 -0
- package/templates/quiz/core/behaviors.d.ts +59 -0
- package/templates/quiz/core/behaviors.js +309 -0
- package/templates/quiz/core/dom.d.ts +13 -0
- package/templates/quiz/core/dom.js +83 -0
- package/templates/quiz/core/editor.d.ts +48 -0
- package/templates/quiz/core/editor.js +206 -0
- package/templates/quiz/core/markdown.d.ts +2 -0
- package/templates/quiz/core/markdown.js +84 -0
- package/templates/quiz/core/model.d.ts +20 -0
- package/templates/quiz/core/model.js +203 -0
- package/templates/quiz/edit.html +17 -0
- package/templates/quiz/elice.config.json +14 -0
- package/templates/quiz/gitignore +3 -0
- package/templates/quiz/grading.json +13 -0
- package/templates/quiz/index.html +17 -0
- package/templates/quiz/instructor.html +17 -0
- package/templates/quiz/screens/edit.js +139 -0
- package/templates/quiz/screens/instructor.js +27 -0
- package/templates/quiz/screens/learn.js +50 -0
- package/templates/quiz/styles.css +510 -0
- package/templates/quiz/ui/templates/choice.js +22 -0
- package/templates/quiz/ui/templates/edit.d.ts +14 -0
- package/templates/quiz/ui/templates/edit.js +187 -0
- package/templates/quiz/ui/templates/group.js +47 -0
- package/templates/quiz/ui/templates/index.d.ts +5 -0
- package/templates/quiz/ui/templates/index.js +17 -0
- package/templates/quiz/ui/templates/order.js +35 -0
- package/templates/quiz/ui/templates/page.js +29 -0
- package/templates/quiz/ui/templates/question.js +28 -0
- package/templates/quiz/ui/templates/text.js +16 -0
- package/templates/quiz/ui/texts.d.ts +3 -0
- package/templates/quiz/ui/texts.js +128 -0
- package/templates/quiz/ui/theme.css +50 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
// 내용 편집 화면(CMS). 기존 퀴즈 편집 폼을 옮김 (docs/quiz-spec.md §3). 저장 버튼 · 변경 표시는 키트(useSave)가 합니다.
|
|
2
|
+
// 정답은 여기서 다루지 않습니다: LXP 편집 화면의 채점 설정에서 정답(문항 id별 답 묶음)을 지정합니다.
|
|
3
|
+
// 저장한 내용은 학생에게도 내려가므로 정답을 넣지 않습니다.
|
|
4
|
+
// 여기서는 어떤 칸을 어떤 순서로 놓을지만 정합니다. 모양은 ui/(templates/edit.js · texts · theme.css), 동작은 core/editor.js.
|
|
5
|
+
import { start } from '../lib/elice-content.js';
|
|
6
|
+
import { createEditor } from '../core/editor.js';
|
|
7
|
+
import { convertType, LIMITS, newQuestion, validateQuiz } from '../core/model.js';
|
|
8
|
+
import * as templates from '../ui/templates/edit.js';
|
|
9
|
+
import { loading } from '../ui/templates/page.js';
|
|
10
|
+
import { texts } from '../ui/texts.js';
|
|
11
|
+
|
|
12
|
+
const t = texts.edit;
|
|
13
|
+
const root = document.getElementById('app');
|
|
14
|
+
document.title = texts.page.edit;
|
|
15
|
+
root.replaceChildren(loading());
|
|
16
|
+
const app = await start({ screen: 'edit' });
|
|
17
|
+
const draft = structuredClone(app.content);
|
|
18
|
+
draft.questions ??= [];
|
|
19
|
+
const form = createEditor({
|
|
20
|
+
rerender: render,
|
|
21
|
+
root,
|
|
22
|
+
templates,
|
|
23
|
+
labels: {
|
|
24
|
+
preview: t.preview,
|
|
25
|
+
previewClose: t.previewClose,
|
|
26
|
+
count: t.count,
|
|
27
|
+
group: texts.defaults.group,
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
let save = null;
|
|
31
|
+
|
|
32
|
+
const swap = (list, i, j) => {
|
|
33
|
+
if (j < 0 || j >= list.length) return;
|
|
34
|
+
[list[i], list[j]] = [list[j], list[i]];
|
|
35
|
+
render();
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/** 문항 카드 안의 칸들. 유형마다 보이는 칸이 다르다 */
|
|
39
|
+
function questionFields(q, i) {
|
|
40
|
+
const body = [
|
|
41
|
+
form.field(t.title, q.title, (v) => (q.title = v), { required: true, max: LIMITS.titleMax }),
|
|
42
|
+
form.markdownField(t.description, q.description, (v) => (q.description = v)),
|
|
43
|
+
];
|
|
44
|
+
if (q.type === 'select_one' || q.type === 'select_multiple' || q.type === 'order') {
|
|
45
|
+
const options = form.itemList('option', q.options, `${i}o`, {
|
|
46
|
+
onDelete: () => {
|
|
47
|
+
if (q.type === 'order') q.slots = Math.min(q.slots, q.options.length);
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
body.push(form.ui.section({ label: t.options, body: options }));
|
|
51
|
+
}
|
|
52
|
+
if (q.type === 'order')
|
|
53
|
+
body.push(
|
|
54
|
+
form.numberField(t.slots, t.slotsHint, q.slots, q.options.length, (v) => (q.slots = v)),
|
|
55
|
+
);
|
|
56
|
+
if (q.type === 'group')
|
|
57
|
+
body.push(
|
|
58
|
+
form.ui.section({ label: t.groups, body: form.itemList('group', q.groups, `${i}g`) }),
|
|
59
|
+
form.ui.section({
|
|
60
|
+
label: t.options,
|
|
61
|
+
hint: t.groupOptionsHint,
|
|
62
|
+
body: form.itemList('option', q.options, `${i}o`),
|
|
63
|
+
}),
|
|
64
|
+
);
|
|
65
|
+
if (q.type === 'text')
|
|
66
|
+
body.push(
|
|
67
|
+
form.field(t.placeholder, q.placeholder, (v) => (q.placeholder = v), {
|
|
68
|
+
max: LIMITS.placeholderMax,
|
|
69
|
+
hint: t.placeholderHint,
|
|
70
|
+
}),
|
|
71
|
+
);
|
|
72
|
+
if (q.type !== 'text') body.push(form.toggle(t.shuffle, q.shuffle, (v) => (q.shuffle = v)));
|
|
73
|
+
body.push(
|
|
74
|
+
form.toggle(t.explanationOn, q.explanation?.enabled, (v) => {
|
|
75
|
+
q.explanation = { ...(q.explanation ?? { text: '' }), enabled: v };
|
|
76
|
+
render();
|
|
77
|
+
}),
|
|
78
|
+
);
|
|
79
|
+
if (q.explanation?.enabled)
|
|
80
|
+
body.push(
|
|
81
|
+
form.markdownField(t.explanation, q.explanation.text, (v) => (q.explanation.text = v)),
|
|
82
|
+
);
|
|
83
|
+
return body;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function questionCard(q, i) {
|
|
87
|
+
return form.card(
|
|
88
|
+
{
|
|
89
|
+
q,
|
|
90
|
+
index: i,
|
|
91
|
+
count: draft.questions.length,
|
|
92
|
+
types: Object.entries(texts.types),
|
|
93
|
+
body: questionFields(q, i),
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
type: (type) => {
|
|
97
|
+
draft.questions[i] = convertType(q, type, texts.defaults);
|
|
98
|
+
render();
|
|
99
|
+
},
|
|
100
|
+
up: () => swap(draft.questions, i, i - 1),
|
|
101
|
+
down: () => swap(draft.questions, i, i + 1),
|
|
102
|
+
remove: () => {
|
|
103
|
+
draft.questions.splice(i, 1);
|
|
104
|
+
render();
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function render() {
|
|
111
|
+
root.replaceChildren(
|
|
112
|
+
form.ui.info(),
|
|
113
|
+
form.field(t.quizTitle, draft.title, (v) => (draft.title = v), { required: true }),
|
|
114
|
+
form.markdownField(t.quizDescription, draft.description, (v) => (draft.description = v)),
|
|
115
|
+
...draft.questions.map(questionCard),
|
|
116
|
+
form.addQuestion(() => {
|
|
117
|
+
draft.questions.push(
|
|
118
|
+
newQuestion(
|
|
119
|
+
'select_one',
|
|
120
|
+
draft.questions.map((q) => q.id),
|
|
121
|
+
texts.defaults,
|
|
122
|
+
),
|
|
123
|
+
);
|
|
124
|
+
render();
|
|
125
|
+
}),
|
|
126
|
+
);
|
|
127
|
+
save?.markDirty();
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
render();
|
|
131
|
+
save = app.useSave({
|
|
132
|
+
getContent: () => structuredClone(draft),
|
|
133
|
+
validate: (content) => {
|
|
134
|
+
const problem = validateQuiz(content, texts.validation);
|
|
135
|
+
if (!problem) return true;
|
|
136
|
+
form.cardAt(problem.questionIndex)?.scrollIntoView({ block: 'center' });
|
|
137
|
+
return problem.message;
|
|
138
|
+
},
|
|
139
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// 교육자 화면. 문항 구성과 해설을 한눈에 봅니다.
|
|
2
|
+
// 정답과 반 전체 결과는 서버가 교육자 모드에 내려주면 표시합니다 (서버 요청 중).
|
|
3
|
+
// 모양은 ui/(templates · texts · theme.css), 동작은 core/에 있습니다.
|
|
4
|
+
import { start } from '../lib/elice-content.js';
|
|
5
|
+
import { renderQuestion } from '../core/behaviors.js';
|
|
6
|
+
import { labels, templates } from '../ui/templates/index.js';
|
|
7
|
+
import { instructorHeader, loading } from '../ui/templates/page.js';
|
|
8
|
+
import { texts } from '../ui/texts.js';
|
|
9
|
+
|
|
10
|
+
const root = document.getElementById('app');
|
|
11
|
+
document.title = texts.page.instructor;
|
|
12
|
+
root.replaceChildren(loading());
|
|
13
|
+
const app = await start({ screen: 'instructor' });
|
|
14
|
+
const { title, questions = [] } = app.content;
|
|
15
|
+
const counts = questions.reduce((m, q) => ({ ...m, [q.type]: (m[q.type] ?? 0) + 1 }), {});
|
|
16
|
+
|
|
17
|
+
const views = questions.map((q, i) => renderQuestion(q, i, { templates, labels, disabled: true }));
|
|
18
|
+
views.forEach((v) => v.showExplanation());
|
|
19
|
+
|
|
20
|
+
root.replaceChildren(
|
|
21
|
+
instructorHeader({
|
|
22
|
+
title: title ?? '',
|
|
23
|
+
count: questions.length,
|
|
24
|
+
byType: Object.entries(counts).map(([t, n]) => [texts.types[t] ?? t, n]),
|
|
25
|
+
}),
|
|
26
|
+
...views.map((v) => v.el),
|
|
27
|
+
);
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// 학생 화면. 화면 머리와 문항을 놓고, 답을 모으고 채우는 방법만 키트에 알려 줍니다.
|
|
2
|
+
// 튜터링 잠금 · 미리보기 안내 · 답 복원 · 점수와 오류 표시는 키트(useSubmit)가 합니다.
|
|
3
|
+
// 모양은 ui/(templates · texts · theme.css), 동작은 core/에 있습니다.
|
|
4
|
+
import { start } from '../lib/elice-content.js';
|
|
5
|
+
import { renderQuestion } from '../core/behaviors.js';
|
|
6
|
+
import { decodeAnswer, encodeAnswer, isAnswered } from '../core/model.js';
|
|
7
|
+
import { labels, templates } from '../ui/templates/index.js';
|
|
8
|
+
import { learnHeader, loading } from '../ui/templates/page.js';
|
|
9
|
+
import { texts } from '../ui/texts.js';
|
|
10
|
+
|
|
11
|
+
const root = document.getElementById('app');
|
|
12
|
+
document.title = texts.page.learn;
|
|
13
|
+
root.replaceChildren(loading());
|
|
14
|
+
const app = await start({ screen: 'learn' });
|
|
15
|
+
const { title, description, questions = [] } = app.content;
|
|
16
|
+
const views = questions.map((q, i) =>
|
|
17
|
+
renderQuestion(q, i, { templates, labels, seed: app.account?.anonymousId ?? '' }),
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
root.replaceChildren(learnHeader({ title: title ?? '', description }), ...views.map((v) => v.el));
|
|
21
|
+
|
|
22
|
+
app.useSubmit({
|
|
23
|
+
getAnswer: () => ({
|
|
24
|
+
answers: Object.fromEntries(
|
|
25
|
+
questions.map((q, i) => [q.id, encodeAnswer(q, views[i].getValue())]),
|
|
26
|
+
),
|
|
27
|
+
}),
|
|
28
|
+
setAnswer: (answer) =>
|
|
29
|
+
questions.forEach((q, i) => views[i].setValue(decodeAnswer(q, answer?.answers?.[q.id]))),
|
|
30
|
+
validate: () => {
|
|
31
|
+
const left = questions.findIndex((q, i) => !isAnswered(q, views[i].getValue()));
|
|
32
|
+
return left < 0 || texts.learn.unanswered(left + 1);
|
|
33
|
+
},
|
|
34
|
+
// 서버 채점 결과는 전체 { isCorrect, score }뿐이라 모두 맞았을 때만 문항마다 정답 표시. 해설은 한 번이라도 제출하면
|
|
35
|
+
onResult: (res) => {
|
|
36
|
+
views.forEach((v) => {
|
|
37
|
+
v.setResult(res.isCorrect === true ? true : null);
|
|
38
|
+
v.showExplanation();
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// 다시 고치면 그 문항의 결과 색을 지운다 (기존 동작)
|
|
44
|
+
root.addEventListener('input', (e) => clearResult(e.target));
|
|
45
|
+
root.addEventListener('click', (e) => clearResult(e.target));
|
|
46
|
+
function clearResult(target) {
|
|
47
|
+
const card = target instanceof Element ? target.closest('[data-role="question"]') : null;
|
|
48
|
+
const i = card ? questions.findIndex((q) => q.id === card.dataset.id) : -1;
|
|
49
|
+
if (i >= 0 && !app.readOnly) views[i].setResult(null);
|
|
50
|
+
}
|